OPAL
Version 3.18.8
|
#include <mediastrm.h>
Public Member Functions | |
virtual PString | GetPatchThreadName () const |
virtual bool | InternalUpdateMediaFormat (const OpalMediaFormat &mediaFormat) |
virtual bool | InternalSetPaused (bool pause, bool fromUser, bool fromPatch) |
virtual bool | InternalExecuteCommand (const OpalMediaCommand &command) |
Overrides from PObject | |
void | PrintOn (ostream &strm) const |
Operations | |
virtual OpalMediaFormat | GetMediaFormat () const |
virtual bool | SetMediaFormat (const OpalMediaFormat &mediaFormat) |
bool | UpdateMediaFormat (const OpalMediaFormat &mediaFormat, bool mergeOnly=false) |
bool | ExecuteCommand (const OpalMediaCommand &command) const |
virtual PBoolean | Open () |
virtual bool | IsOpen () const |
virtual bool | IsEstablished () const |
virtual PBoolean | Start () |
virtual PBoolean | Close () |
virtual void | OnStartMediaPatch () |
virtual void | OnStopMediaPatch (OpalMediaPatch &patch) |
virtual bool | SetMediaPassThrough (OpalMediaStream &otherStream, bool bypass) |
virtual PBoolean | WritePackets (RTP_DataFrameList &packets) |
virtual PBoolean | ReadPacket (RTP_DataFrame &packet) |
virtual PBoolean | WritePacket (RTP_DataFrame &packet) |
virtual PBoolean | ReadData (BYTE *data, PINDEX size, PINDEX &length) |
virtual PBoolean | WriteData (const BYTE *data, PINDEX length, PINDEX &written) |
virtual bool | PushPacket (RTP_DataFrame &packet) |
virtual PBoolean | SetDataSize (PINDEX dataSize, PINDEX frameTime) |
PINDEX | GetDataSize () const |
virtual PBoolean | IsSynchronous () const =0 |
virtual PBoolean | RequiresPatchThread (OpalMediaStream *stream) const |
virtual PBoolean | RequiresPatchThread () const |
virtual bool | RequireMediaTransportThread (OpalMediaStream &stream) const |
virtual bool | EnableJitterBuffer (bool enab=true) |
Member variable access | |
OpalConnection & | GetConnection () const |
bool | IsSource () const |
bool | IsSink () const |
unsigned | GetSessionID () const |
void | SetSessionID (unsigned id) |
PString | GetID () const |
unsigned | GetTimestamp () const |
void | SetTimestamp (unsigned ts) |
bool | GetMarker () const |
void | SetMarker (bool m) |
bool | IsPaused () const |
bool | SetPaused (bool pause) |
virtual PBoolean | SetPatch (OpalMediaPatch *patch) |
OpalMediaPatchPtr | GetPatch () const |
void | AddFilter (const PNotifier &filter, const OpalMediaFormat &stage=OpalMediaFormat()) const |
bool | RemoveFilter (const PNotifier &filter, const OpalMediaFormat &stage=OpalMediaFormat()) const |
virtual void | GetStatistics (OpalMediaStatistics &statistics, bool fromPatch=false) const |
P_DECLARE_BITWISE_ENUM (Details, 6,(DetailMinimum, DetailEOL, DetailNAT, DetailSecured, DetailFEC, DetailAudio, DetailAddresses)) | |
virtual void | PrintDetail (ostream &strm, const char *prefix=NULL, Details details=Details::All()) const |
Protected Types | |
typedef OpalMediaPatchPtr | PatchPtr |
Protected Member Functions | |
OpalMediaPatchPtr | InternalSetPatchPart1 (OpalMediaPatch *newPatch) |
void | InternalSetPatchPart2 (const OpalMediaPatchPtr &oldPatch) |
virtual bool | InternalSetJitterBuffer (const OpalJitterBuffer::Init &init) |
virtual void | InternalClose ()=0 |
Protected Attributes | |
OpalConnection & | m_connection |
unsigned | m_sessionID |
WORD | m_sequenceNumber |
RTP_SyncSourceId | m_syncSourceId |
PString | m_identifier |
OpalMediaFormat | m_mediaFormat |
atomic< bool > | m_paused |
bool | m_isSource |
atomic< bool > | m_isOpen |
PINDEX | m_defaultDataSize |
unsigned | m_timestamp |
bool | m_marker |
OpalMediaPatchPtr | m_mediaPatch |
RTP_DataFrame::PayloadTypes | m_payloadType |
unsigned | m_frameTime |
PINDEX | m_frameSize |
Friends | |
class | OpalMediaPatch |
Construction | |
OpalMediaStream (OpalConnection &conn, const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource) | |
~OpalMediaStream () | |
This class describes a media stream as used in the OPAL system. A media stream is the channel through which media data is trasferred between OPAL entities. For example, data being sent to an RTP session over a network would be through a media stream.
|
protected |
|
protected |
Construct a new media stream.
conn | Connection that owns the stream |
mediaFormat | Media format for stream |
sessionID | Session number for stream |
isSource | Is a source stream |
OpalMediaStream::~OpalMediaStream | ( | ) |
Destroy the media stream. Make sure the patch, if present, has been stopped and deleted.
void OpalMediaStream::AddFilter | ( | const PNotifier & | filter, |
const OpalMediaFormat & | stage = OpalMediaFormat() |
||
) | const |
Add a filter to the owning patch safely.
filter | Filter notifier to be called. |
stage | Stage in codec pipeline to call filter |
|
virtual |
Close the media stream.
The default marks the stream as closed and calls OpalConnection::OnClosedMediaStream().
|
virtual |
Enable jitter buffer for the media stream. Returns true if a jitter buffer is enabled. Returns false if the jitter buffer is disabled or no jitter buffer can be used on the media stream.
The default behaviour does nothing and returns false.
bool OpalMediaStream::ExecuteCommand | ( | const OpalMediaCommand & | command | ) | const |
Execute the command specified to the transcoder. The commands are highly context sensitive, for example OpalVideoUpdatePicture would only apply to a video transcoder.
The default behaviour passes the command on to the OpalMediaPatch.
command | Command to execute. |
|
inline |
Get the owner connection.
References m_connection.
|
inline |
Get the data size in bytes that is expected to be used. Some media streams can make use of this information to perform optimisations.
References m_defaultDataSize.
|
inline |
Get the ID associated with this stream. Used for detecting two the streams associated with a bidirectional media channel
References m_identifier.
|
inline |
Get the marker bit of last read.
References m_marker.
|
virtual |
Get the currently selected media format. The media data format is a string representation of the format being transferred by the media channel. It is typically a value as provided by the RTP_PayloadType class.
The default behaviour simply returns the member variable "mediaFormat".
|
inline |
Get the patch thread that is using the stream.
References m_mediaPatch.
|
virtual |
Reimplemented in OpalRTPMediaStream.
|
inline |
Get the session number of the stream.
References m_sessionID.
|
virtual |
Reimplemented in OpalRTPMediaStream.
|
inline |
Get the timestamp of last read.
References m_timestamp.
|
protectedpure virtual |
Close any internal components of the stream. This should be used in preference to overriding the Close() function as it is guaranteed to be called exactly once and avoids race conditions in the shut down sequence of a media stream.
Implemented in OpalMixerMediaStream, OpalVideoMediaStream, OpalLocalMediaStream, OpalRawMediaStream, OpalLineMediaStream, OpalNullMediaStream, OpalIVRMediaStream, OpalMSRPMediaStream, OpalRTPMediaStream, OpalIAX2MediaStream, and OpalT140MediaStream.
|
virtual |
Reimplemented in OpalVideoMediaStream, and OpalRTPMediaStream.
|
protectedvirtual |
Reimplemented in OpalMixerMediaStream, and OpalRTPMediaStream.
|
protected |
|
protected |
|
virtual |
Reimplemented in OpalNullMediaStream, and OpalRTPMediaStream.
Referenced by SetPaused().
|
virtual |
Reimplemented in OpalVideoMediaStream, OpalNullMediaStream, and OpalRTPMediaStream.
|
virtual |
Returns true if the media stream is established.
Reimplemented in OpalRTPMediaStream.
|
virtual |
Returns true if the media stream is open.
Reimplemented in OpalRTPMediaStream.
|
inline |
Get the paused state for stream.
References m_paused.
|
inline |
Determine of media stream is a source or a sink.
References m_isSource.
Referenced by OpalH224MediaStream::RequiresPatchThread(), and OpalMSRPMediaStream::RequiresPatchThread().
|
inline |
Determine of media stream is a source or a sink.
References m_isSource.
|
pure virtual |
Indicate if the media stream is synchronous. If this returns true then the media stream will block of the amount of time it takes to annunciate the data. For example if the media stream is over a sound card, and 480 bytes of data are to be written it will take 30 milliseconds to complete.
Implemented in OpalMixerMediaStream, OpalUDPMediaStream, OpalLocalMediaStream, OpalVideoMediaStream, OpalFileMediaStream, OpalLineMediaStream, OpalNullMediaStream, OpalIVRMediaStream, OpalMSRPMediaStream, OpalH224MediaStream, OpalRTPMediaStream, OpalIAX2MediaStream, and OpalT140MediaStream.
|
virtual |
Callback that is called on the source stream once the media patch has started. The default behaviour calls OpalConnection::OnMediaPatchStart()
Reimplemented in OpalH224MediaStream, and OpalRTPMediaStream.
|
virtual |
Callback that is called on the source stream once the media patch has started. The default behaviour calls OpalConnection::OnMediaPatchStop()
patch | Media patch that is stopping |
|
virtual |
Open the media stream using the media format.
The default behaviour simply sets the isOpen variable to true.
Reimplemented in OpalMixerMediaStream, OpalVideoMediaStream, OpalLineMediaStream, OpalIVRMediaStream, OpalMSRPMediaStream, and OpalRTPMediaStream.
OpalMediaStream::P_DECLARE_BITWISE_ENUM | ( | Details | , |
6 | , | ||
(DetailMinimum, DetailEOL, DetailNAT, DetailSecured, DetailFEC, DetailAudio, DetailAddresses) | |||
) |
|
virtual |
Reimplemented in OpalRTPMediaStream.
void OpalMediaStream::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 |
Pushes a frame to the patch
|
virtual |
Read raw media data from the source media stream. The default behaviour simply calls ReadPacket() on the data portion of the RTP_DataFrame and sets the frames timestamp and marker from the internal member variables of the media stream class.
data | Data buffer to read to |
size | Size of buffer |
length | Length of data actually read |
Reimplemented in OpalLocalMediaStream, OpalVideoMediaStream, OpalFileMediaStream, OpalRawMediaStream, OpalLineMediaStream, and OpalNullMediaStream.
|
virtual |
Read an RTP frame of data from the source media stream. The default behaviour simply calls ReadData() on the data portion of the RTP_DataFrame and sets the frames timestamp and marker from the internal member variables of the media stream class.
Reimplemented in OpalUDPMediaStream, OpalLocalMediaStream, OpalLineMediaStream, OpalMSRPMediaStream, OpalH224MediaStream, OpalRTPMediaStream, OpalIAX2MediaStream, and OpalT140MediaStream.
bool OpalMediaStream::RemoveFilter | ( | const PNotifier & | filter, |
const OpalMediaFormat & | stage = OpalMediaFormat() |
||
) | const |
Remove a filter from the owning patch safely.
filter | Filter notifier to be called. |
stage | Stage in codec pipeline to call filter |
|
virtual |
Indicate media transport is required. One of the two streams in the patch can indicate that media transport is not required as it is somehow being bypassed.
stream | Other stream in patch |
|
virtual |
Indicate if the media stream requires a OpalMediaPatch thread (active patch). This is called on the source/sink stream and is passed the sink/source stream that the patch will initially be using. The function could conditionally require the patch thread to execute a thread reading and writing data, or prevent it from doing so as it can do so in hardware in some way, e.g. both streams are on the same OpalLineInterfaceDevice.
The default behaviour simply returns true.
stream | Other stream in patch |
Reimplemented in OpalLineMediaStream.
|
virtual |
Reimplemented in OpalMixerMediaStream, OpalNullMediaStream, OpalMSRPMediaStream, OpalH224MediaStream, OpalRTPMediaStream, and OpalT140MediaStream.
|
virtual |
Set the data size in bytes that is expected to be used. Some media streams can make use of this information to perform optimisations.
The default behaviour does nothing.
dataSize | New data size (in total) |
frameTime | Individual frame time (if applicable) |
Reimplemented in OpalVideoMediaStream, OpalLineMediaStream, and OpalRTPMediaStream.
|
inline |
Set marker bit for next write.
References m_marker.
|
virtual |
Set a new media format for the stream. Unlike UpdateMediaFormat() this will shut down the patch and attempt to create new transcoders to meet the requirement.
mediaFormat | New media format |
|
virtual |
Bypass media patch. Send media directly to/from the media streams.
otherStream | Stream to bypass media data to/from |
bypass | Turn bypass on or off |
Reimplemented in OpalRTPMediaStream.
|
virtual |
Set the patch thread that is using this stream.
patch | Media patch thread |
Reimplemented in OpalRTPMediaStream.
|
inline |
Set the paused state for stream. This will stop reading/writing data from the stream. Returns true if the pause state was changed
pause | Indicate that the stream should be paused |
References InternalSetPaused().
|
inline |
Get the session number of the stream.
References m_sessionID.
|
inline |
Set timestamp for next write.
References m_timestamp.
|
virtual |
Start the media stream.
The default behaviour calls Resume() on the associated OpalMediaPatch thread if it was suspended.
Reimplemented in OpalRTPMediaStream.
bool OpalMediaStream::UpdateMediaFormat | ( | const OpalMediaFormat & | mediaFormat, |
bool | mergeOnly = false |
||
) |
Update the 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, or the mergeOnly
parameter is true, then a OpalMediaFormat::Merge() rather than OpalMediaFormat::Update() is performed.
mediaFormat | New media format |
mergeOnly | Indicate merge parameters |
|
virtual |
Write raw media data to the sink media stream. The default behaviour calls WritePacket() on the data portion of the RTP_DataFrame and and sets the internal timestamp and marker from the member variables of the media stream class.
data | Data to write |
length | Length of data to read. |
written | Length of data actually written |
Reimplemented in OpalLocalMediaStream, OpalVideoMediaStream, OpalFileMediaStream, OpalRawMediaStream, OpalLineMediaStream, OpalNullMediaStream, and OpalIAX2MediaStream.
|
virtual |
Write an RTP frame of data to the sink media stream. The default behaviour simply calls WriteData() on the data portion of the RTP_DataFrame and and sets the internal timestamp and marker from the member variables of the media stream class.
Reimplemented in OpalMixerMediaStream, OpalUDPMediaStream, OpalLocalMediaStream, OpalLineMediaStream, OpalMSRPMediaStream, OpalH224MediaStream, OpalRTPMediaStream, and OpalT140MediaStream.
|
virtual |
Write a list of RTP frames of data to the sink media stream. The default behaviour simply calls WritePacket() on each of the elements in the list.
|
friend |
|
protected |
Referenced by GetConnection().
|
protected |
Referenced by GetDataSize().
|
protected |
|
protected |
|
protected |
Referenced by GetID().
|
protected |
|
protected |
Referenced by IsSink(), and IsSource().
|
protected |
Referenced by GetMarker(), and SetMarker().
|
protected |
|
protected |
Referenced by GetPatch().
|
protected |
Referenced by IsPaused().
|
protected |
|
protected |
|
protected |
Referenced by GetSessionID(), and SetSessionID().
|
protected |
|
protected |
Referenced by GetTimestamp(), and SetTimestamp().