patch.h

Go to the documentation of this file.
00001 /*
00002  * patch.h
00003  *
00004  * Media stream patch thread.
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2001 Equivalence Pty. Ltd.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Log: patch.h,v $
00028  * Revision 2.10.2.1  2006/02/06 04:38:37  csoutheren
00029  * Backported RTP payload mapping fixes from CVS head
00030  *
00031  * Revision 2.11  2006/02/02 07:02:57  csoutheren
00032  * Added RTP payload map to transcoders and connections to allow remote SIP endpoints
00033  * to change the payload type used for outgoing RTP.
00034  *
00035  * Revision 2.10  2005/11/30 13:35:26  csoutheren
00036  * Changed tags for Doxygen
00037  *
00038  * Revision 2.9  2005/11/07 06:34:52  csoutheren
00039  * Changed PMutex to PTimedMutex
00040  *
00041  * Revision 2.8  2005/09/04 06:23:38  rjongbloed
00042  * Added OpalMediaCommand mechanism (via PNotifier) for media streams
00043  *   and media transcoders to send commands back to remote.
00044  *
00045  * Revision 2.7  2005/08/31 13:19:25  rjongbloed
00046  * Added mechanism for controlling media (especially codecs) including
00047  *   changing the OpalMediaFormat option list (eg bit rate) and a completely
00048  *   new OpalMediaCommand abstraction for things like video fast update.
00049  *
00050  * Revision 2.6  2004/08/15 10:10:27  rjongbloed
00051  * Fixed possible deadlock when closing media patch
00052  *
00053  * Revision 2.5  2004/08/14 07:56:29  rjongbloed
00054  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00055  *
00056  * Revision 2.4  2004/03/11 06:54:27  csoutheren
00057  * Added ability to disable SIP or H.323 stacks
00058  *
00059  * Revision 2.3  2003/03/17 10:26:59  robertj
00060  * Added video support.
00061  *
00062  * Revision 2.2  2002/09/16 02:52:35  robertj
00063  * Added #define so can select if #pragma interface/implementation is used on
00064  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00065  *
00066  * Revision 2.1  2002/01/22 05:07:49  robertj
00067  * Added filter functions to media patch.
00068  *
00069  * Revision 2.0  2001/07/27 15:48:24  robertj
00070  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00071  *
00072  */
00073 
00074 #ifndef __OPAL_PATCH_H
00075 #define __OPAL_PATCH_H
00076 
00077 #ifdef P_USE_PRAGMA
00078 #pragma interface
00079 #endif
00080 
00081 #include <opal/buildopts.h>
00082 
00083 #include <opal/mediafmt.h>
00084 #include <opal/mediacmd.h>
00085 
00086 
00087 class OpalMediaStream;
00088 class OpalTranscoder;
00089 
00090 
00102 class OpalMediaPatch : public PThread
00103 {
00104     PCLASSINFO(OpalMediaPatch, PThread);
00105   public:
00111     OpalMediaPatch(
00112       OpalMediaStream & source       
00113     );
00114 
00117     ~OpalMediaPatch();
00119 
00126     void PrintOn(
00127       ostream & strm    
00128     ) const;
00130 
00135     virtual void Main();
00136 
00142     void Close();
00143 
00148     BOOL AddSink(
00149       OpalMediaStream * stream,                     
00150       const RTP_DataFrame::PayloadMapType & rtpMap  
00151     );
00152 
00157     void RemoveSink(
00158       OpalMediaStream * stream  
00159     );
00160 
00163     OpalMediaStream & GetSource() const { return source; }
00164 
00169     void AddFilter(
00170       const PNotifier & filter,
00171       const OpalMediaFormat & stage = OpalMediaFormat()
00172     );
00173 
00176     BOOL RemoveFilter(
00177       const PNotifier & filter,
00178       const OpalMediaFormat & stage = OpalMediaFormat()
00179     );
00180 
00183     virtual void FilterFrame(
00184       RTP_DataFrame & frame,
00185       const OpalMediaFormat & mediaFormat
00186     );
00187 
00196     virtual BOOL UpdateMediaFormat(
00197       const OpalMediaFormat & mediaFormat,  
00198       BOOL fromSink                         
00199     );
00200 
00208     virtual BOOL ExecuteCommand(
00209       const OpalMediaCommand & command,   
00210       BOOL fromSink                       
00211     );
00212 
00220     virtual void SetCommandNotifier(
00221       const PNotifier & notifier,   
00222       BOOL fromSink                 
00223     );
00225 
00226   protected:
00227     OpalMediaStream & source;
00228 
00229     class Sink : public PObject {
00230         PCLASSINFO(Sink, PObject);
00231       public:
00232         Sink(OpalMediaPatch & p, OpalMediaStream * s);
00233         ~Sink();
00234         bool UpdateMediaFormat(const OpalMediaFormat & mediaFormat);
00235         bool ExecuteCommand(const OpalMediaCommand & command);
00236         void SetCommandNotifier(const PNotifier & notifier);
00237         bool WriteFrame(RTP_DataFrame & sourceFrame);
00238 
00239         OpalMediaPatch  & patch;
00240         OpalMediaStream * stream;
00241         OpalTranscoder  * primaryCodec;
00242         OpalTranscoder  * secondaryCodec;
00243         RTP_DataFrameList intermediateFrames;
00244         RTP_DataFrameList finalFrames;
00245         bool              writeSuccessful;
00246     };
00247     PList<Sink> sinks;
00248 
00249     class Filter : public PObject {
00250         PCLASSINFO(Filter, PObject);
00251       public:
00252         Filter(const PNotifier & n, const OpalMediaFormat & s) : notifier(n), stage(s) { }
00253         PNotifier notifier;
00254         OpalMediaFormat stage;
00255     };
00256     PList<Filter> filters;
00257 
00258     mutable PTimedMutex inUse;
00259 };
00260 
00261 
00262 #endif // __OPAL_PATCH_H
00263 
00264 
00265 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Sep 25 16:20:10 2006 for OPAL by  doxygen 1.4.7