#include <patch.h>
Inheritance diagram for OpalMediaPatch:
Public Member Functions | |
Overrides from PObject | |
void | PrintOn (ostream &strm) const |
Operations | |
virtual void | Start () |
virtual bool | OnPatchStart () |
virtual void | Close () |
PBoolean | AddSink (const OpalMediaStreamPtr &stream) |
void | RemoveSink (const OpalMediaStreamPtr &stream) |
OpalMediaStream & | GetSource () const |
OpalMediaStreamPtr | GetSink (PINDEX i=0) const |
OpalMediaFormat | GetSinkFormat (PINDEX i=0) const |
void | AddFilter (const PNotifier &filter, const OpalMediaFormat &stage=OpalMediaFormat()) |
PBoolean | RemoveFilter (const PNotifier &filter, const OpalMediaFormat &stage=OpalMediaFormat()) |
virtual void | FilterFrame (RTP_DataFrame &frame, const OpalMediaFormat &mediaFormat) |
virtual bool | UpdateMediaFormat (const OpalMediaFormat &mediaFormat) |
virtual PBoolean | ExecuteCommand (const OpalMediaCommand &command, PBoolean fromSink) |
virtual void | SetCommandNotifier (const PNotifier ¬ifier, PBoolean fromSink) |
virtual PBoolean | PushFrame (RTP_DataFrame &) |
virtual OpalTranscoder * | GetAndLockSinkTranscoder (PINDEX i=0) const |
virtual void | UnLockSinkTranscoder () const |
Protected Member Functions | |
virtual void | Main () |
bool | DispatchFrame (RTP_DataFrame &frame) |
Protected Attributes | |
OpalMediaStream & | source |
PList< Sink > | sinks |
PList< Filter > | filters |
Thread * | patchThread |
PMutex | patchThreadMutex |
PReadWriteMutex | inUse |
Classes | |
class | Filter |
class | Sink |
class | Thread |
Note the thread is not actually started straight away. It is expected that the Start() function is called on the patch when the creator code is ready for it to begin. For example all sink streams have been added.
OpalMediaPatch::OpalMediaPatch | ( | OpalMediaStream & | source | ) |
Create a new patch. Note the thread is not started here.
source | Source media stream |
OpalMediaPatch::~OpalMediaPatch | ( | ) |
Destroy patch.
OpalMediaPatch::OpalMediaPatch | ( | OpalMediaStream & | source | ) |
Create a new patch. Note the thread is not started here.
source | Source media stream |
OpalMediaPatch::~OpalMediaPatch | ( | ) |
Destroy patch.
void OpalMediaPatch::PrintOn | ( | ostream & | strm | ) | const |
Standard stream print function. The PObject class has a << operator defined that calls this function polymorphically.
strm | Stream to output text representation |
virtual void OpalMediaPatch::Start | ( | ) | [virtual] |
Start the patch. The default implementation simply starts the patch thread, which in turn calls Main()
Reimplemented in OpalPassiveMediaPatch.
virtual bool OpalMediaPatch::OnPatchStart | ( | ) | [virtual] |
Indicate the patch has started. Typically called from the beginning of the patch thread.
Default behaviour make sure jitter buffer is created.
Returns bool indicating all media streams are asynchronous so the patch should assure no thread startvation
virtual void OpalMediaPatch::Close | ( | ) | [virtual] |
Close the patch. This is an internal function that closes all of the sink streams and waits for the the thread to terminate. It is called when the source stream is called.
PBoolean OpalMediaPatch::AddSink | ( | const OpalMediaStreamPtr & | stream | ) |
Add another "sink" OpalMediaStream to patch. The stream must not be a ReadOnly media stream for the patch to be able to write to it.
stream | Media stream to add. |
void OpalMediaPatch::RemoveSink | ( | const OpalMediaStreamPtr & | stream | ) |
Add existing "sink" OpalMediaStream to patch. If the stream is not a sink of this patch then this function does nothing.
stream | Media stream to remove |
OpalMediaStream& OpalMediaPatch::GetSource | ( | ) | const [inline] |
Get the current source stream for patch.
OpalMediaStreamPtr OpalMediaPatch::GetSink | ( | PINDEX | i = 0 |
) | const |
Get the media stream for a sink stream
OpalMediaFormat OpalMediaPatch::GetSinkFormat | ( | PINDEX | i = 0 |
) | const |
Get the media format for a sink stream
void OpalMediaPatch::AddFilter | ( | const PNotifier & | filter, | |
const OpalMediaFormat & | stage = OpalMediaFormat() | |||
) |
Add a filter to the media pipeline. Use PDECLARE_NOTIFIER(RTP_DataFrame, YourClass, YourFunction) for the filter function notifier.
PBoolean OpalMediaPatch::RemoveFilter | ( | const PNotifier & | filter, | |
const OpalMediaFormat & | stage = OpalMediaFormat() | |||
) |
Remove a filter from the media pipeline.
virtual void OpalMediaPatch::FilterFrame | ( | RTP_DataFrame & | frame, | |
const OpalMediaFormat & | mediaFormat | |||
) | [virtual] |
Filter a frame. Calls all filter functions.
virtual bool OpalMediaPatch::UpdateMediaFormat | ( | const OpalMediaFormat & | mediaFormat | ) | [virtual] |
Update the source/sink media format. This can be used to adjust the parameters of a codec at run time. Note you cannot change the basic media format, eg change GSM0610 to G.711, only options for that format, eg 6k3 mode to 5k3 mode in G.723.1. If the formats are different then a OpalMediaFormat::Merge() is performed.
The default behaviour updates the source/sink media stream and the output side of any relevant transcoders.
mediaFormat | New media format |
virtual PBoolean OpalMediaPatch::ExecuteCommand | ( | const OpalMediaCommand & | command, | |
PBoolean | fromSink | |||
) | [virtual] |
Execute the command specified to the transcoder. The commands are highly context sensitive, for example VideoFastUpdate would only apply to a video transcoder.
The default behaviour passes the command on to the source or sinks and the sinks transcoders.
command | Command to execute. |
fromSink | Flag for source or sink |
virtual void OpalMediaPatch::SetCommandNotifier | ( | const PNotifier & | notifier, | |
PBoolean | fromSink | |||
) | [virtual] |
Set a notifier to receive commands generated by the transcoder. The commands are highly context sensitive, for example VideoFastUpdate would only apply to a video transcoder.
The default behaviour passes the command on to the source or sinks and the sinks transcoders.
notifier | Command to execute. |
fromSink | Flag for source or sink |
virtual PBoolean OpalMediaPatch::PushFrame | ( | RTP_DataFrame & | ) | [inline, virtual] |
Reimplemented in OpalPassiveMediaPatch.
virtual OpalTranscoder* OpalMediaPatch::GetAndLockSinkTranscoder | ( | PINDEX | i = 0 |
) | const [virtual] |
Get the transcoder used within a sink stream
virtual void OpalMediaPatch::UnLockSinkTranscoder | ( | ) | const [virtual] |
virtual void OpalMediaPatch::Main | ( | ) | [protected, virtual] |
Called from the associated patch thread
bool OpalMediaPatch::DispatchFrame | ( | RTP_DataFrame & | frame | ) | [protected] |
OpalMediaStream& OpalMediaPatch::source [protected] |
PList<Sink> OpalMediaPatch::sinks [protected] |
PList<Filter> OpalMediaPatch::filters [protected] |
Thread* OpalMediaPatch::patchThread [protected] |
PMutex OpalMediaPatch::patchThreadMutex [protected] |
PReadWriteMutex OpalMediaPatch::inUse [mutable, protected] |