00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
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