OPAL  Version 3.18.8
OpalTranscoder Class Referenceabstract

#include <transcoders.h>

Inheritance diagram for OpalTranscoder:
Collaboration diagram for OpalTranscoder:

Public Member Functions

Construction
 OpalTranscoder (const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
 
- Public Member Functions inherited from OpalMediaFormatPair
 OpalMediaFormatPair (const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
 
void PrintOn (ostream &strm) const
 
virtual Comparison Compare (const PObject &obj) const
 
const OpalMediaFormatGetInputFormat () const
 
const OpalMediaFormatGetOutputFormat () const
 

Protected Member Functions

virtual bool OnCreated (const OpalMediaFormat &srcFormat, const OpalMediaFormat &destFormat, const BYTE *instance, unsigned instanceLen)
 
 PDECLARE_MUTEX (updateMutex)
 

Protected Attributes

PINDEX maxOutputSize
 
PNotifier commandNotifier
 
unsigned m_sessionID
 
bool outputIsRTP
 
bool inputIsRTP
 
bool acceptEmptyPayload
 
bool acceptOtherPayloads
 
unsigned m_inClockRate
 
unsigned m_outClockRate
 
RTP_DataFrame::PayloadTypes m_lastPayloadType
 
unsigned m_consecutivePayloadTypeMismatches
 
- Protected Attributes inherited from OpalMediaFormatPair
OpalMediaFormat inputMediaFormat
 
OpalMediaFormat outputMediaFormat
 

Operations

virtual bool UpdateMediaFormats (const OpalMediaFormat &inputMediaFormat, const OpalMediaFormat &outputMediaFormat)
 
virtual PBoolean ExecuteCommand (const OpalMediaCommand &command)
 
virtual PINDEX GetOptimalDataFrameSize (PBoolean input) const =0
 
virtual PBoolean ConvertFrames (const RTP_DataFrame &input, RTP_DataFrameList &output)
 
virtual PBoolean Convert (const RTP_DataFrame &input, RTP_DataFrame &output)=0
 
PINDEX GetMaxOutputSize () const
 
void SetMaxOutputSize (PINDEX size)
 
void SetCommandNotifier (const PNotifier &notifier)
 
const PNotifier & GetCommandNotifier () const
 
void NotifyCommand (const OpalMediaCommand &command) const
 Notify command notifier of command. More...
 
unsigned GetSessionID () const
 Get session ID for the transcoder (from OpalMediaStream) More...
 
void SetSessionID (unsigned id)
 Set session ID for the transcoder (from OpalMediaStream) More...
 
RTP_DataFrame::PayloadTypes GetPayloadType (PBoolean input) const
 
virtual bool AcceptComfortNoise () const
 
virtual bool AcceptEmptyPayload () const
 
virtual bool AcceptOtherPayloads () const
 
virtual void GetStatistics (OpalMediaStatistics &statistics) const
 
void CopyTimestamp (RTP_DataFrame &dst, const RTP_DataFrame &src, bool inToOut) const
 
static OpalTranscoderCreate (const OpalMediaFormat &srcFormat, const OpalMediaFormat &dstFormat, const BYTE *instance=NULL, unsigned instanceLen=0)
 
static bool SelectFormats (const OpalMediaType &mediaType, const OpalMediaFormatList &srcFormats, const OpalMediaFormatList &dstFormats, const OpalMediaFormatList &masterFormats, OpalMediaFormat &srcFormat, OpalMediaFormat &dstFormat)
 
static bool FindIntermediateFormat (const OpalMediaFormat &srcFormat, const OpalMediaFormat &dstFormat, OpalMediaFormat &intermediateFormat)
 
static OpalMediaFormatList GetDestinationFormats (const OpalMediaFormat &srcFormat)
 
static OpalMediaFormatList GetSourceFormats (const OpalMediaFormat &dstFormat)
 
static OpalMediaFormatList GetPossibleFormats (const OpalMediaFormatList &formats)
 

Detailed Description

This class embodies the implementation of a specific transcoder instance used to convert data from one format to another.

An application may create a descendent off this class and override functions as required for implementing a transcoder.

Constructor & Destructor Documentation

OpalTranscoder::OpalTranscoder ( const OpalMediaFormat inputMediaFormat,
const OpalMediaFormat outputMediaFormat 
)

Create a new transcoder implementation.

Parameters
inputMediaFormatInput media format
outputMediaFormatOutput media format

Member Function Documentation

virtual bool OpalTranscoder::AcceptComfortNoise ( ) const
inlinevirtual
virtual bool OpalTranscoder::AcceptEmptyPayload ( ) const
inlinevirtual

References acceptEmptyPayload.

virtual bool OpalTranscoder::AcceptOtherPayloads ( ) const
inlinevirtual

References acceptOtherPayloads.

virtual PBoolean OpalTranscoder::Convert ( const RTP_DataFrame input,
RTP_DataFrame output 
)
pure virtual

Convert the data from one format to another. This function takes the input data as a RTP_DataFrame and converts it to its output format, placing it into the RTP_DataFrame provided.

Returns false if the conversion fails.

Parameters
inputInput data
outputOutput data

Implemented in OpalStreamedTranscoder, OpalFramedTranscoder, OpalVideoTranscoder, and Opal_G711_PCM.

virtual PBoolean OpalTranscoder::ConvertFrames ( const RTP_DataFrame input,
RTP_DataFrameList &  output 
)
virtual

Convert the data from one format to another. This function takes the input data as a RTP_DataFrame and converts it to its output format, placing it (possibly) into multiple RTP_DataFrame objects.

The default behaviour makes sure the output list has only one element in it and calls the Convert() function.

Returns false if the conversion fails.

Parameters
inputInput data
outputOutput data

Reimplemented in OpalPluginVideoTranscoder, OpalRFC4175Decoder, and OpalRFC4175Encoder.

void OpalTranscoder::CopyTimestamp ( RTP_DataFrame dst,
const RTP_DataFrame src,
bool  inToOut 
) const
static OpalTranscoder* OpalTranscoder::Create ( const OpalMediaFormat srcFormat,
const OpalMediaFormat dstFormat,
const BYTE *  instance = NULL,
unsigned  instanceLen = 0 
)
static

Create an instance of a media conversion function. Returns NULL if there is no registered media transcoder between the two named formats.

Parameters
srcFormatName of source format
dstFormatName of destination format
instanceUnique instance identifier for transcoder
instanceLenLength of instance identifier
virtual PBoolean OpalTranscoder::ExecuteCommand ( const OpalMediaCommand command)
virtual

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 simply returns false.

Returns
true if command is handled.
Parameters
commandCommand to execute.

Reimplemented in OpalPluginVideoTranscoder, OpalPluginStreamedAudioTranscoder, OpalPluginFramedAudioTranscoder, and OpalVideoTranscoder.

static bool OpalTranscoder::FindIntermediateFormat ( const OpalMediaFormat srcFormat,
const OpalMediaFormat dstFormat,
OpalMediaFormat intermediateFormat 
)
static

Find media intermediate format for transcoders. This function attempts to find the intermediate media format that will allow two transcoders to be used to get data from the source format to the destination format.

If there is a transcoder that can go directly from the source format to the destination format then the function returns true but the intermediateFormat parmaeter will be an invlid format.

Returns false if there is no registered media transcoder that can be used between the two named formats.

Parameters
srcFormatSelected destination format to be used
dstFormatSelected destination format to be used
intermediateFormatIntermediate format that can be used
const PNotifier& OpalTranscoder::GetCommandNotifier ( ) const
inline

Get the notifier to receive commands generated by the transcoder. The commands are highly context sensitive, for example OpalVideoUpdatePicture would only apply to a video transcoder.

References commandNotifier.

static OpalMediaFormatList OpalTranscoder::GetDestinationFormats ( const OpalMediaFormat srcFormat)
static

Get a list of possible destination media formats for the destination.

Parameters
srcFormatSelected source format
PINDEX OpalTranscoder::GetMaxOutputSize ( ) const
inline

Get maximum output size.

References maxOutputSize.

virtual PINDEX OpalTranscoder::GetOptimalDataFrameSize ( PBoolean  input) const
pure virtual

Get the optimal size for data frames to be converted. This function returns the size of frames that will be most efficient in conversion. A RTP_DataFrame will attempt to provide or use data in multiples of this size. Note that it may not do so, so the transcoder must be able to handle any sized packets.

Parameters
inputFlag for input or output data size

Implemented in OpalStreamedTranscoder, OpalFramedTranscoder, and OpalVideoTranscoder.

RTP_DataFrame::PayloadTypes OpalTranscoder::GetPayloadType ( PBoolean  input) const
Parameters
inputFlag for input or output data size
static OpalMediaFormatList OpalTranscoder::GetPossibleFormats ( const OpalMediaFormatList formats)
static

Get a list of possible media formats that can do bi-directional media.

Parameters
formatsDestination format list
unsigned OpalTranscoder::GetSessionID ( ) const
inline

Get session ID for the transcoder (from OpalMediaStream)

References m_sessionID.

static OpalMediaFormatList OpalTranscoder::GetSourceFormats ( const OpalMediaFormat dstFormat)
static

Get a list of possible source media formats for the destination.

Parameters
dstFormatSelected destination format
virtual void OpalTranscoder::GetStatistics ( OpalMediaStatistics statistics) const
virtual
void OpalTranscoder::NotifyCommand ( const OpalMediaCommand command) const

Notify command notifier of command.

virtual bool OpalTranscoder::OnCreated ( const OpalMediaFormat srcFormat,
const OpalMediaFormat destFormat,
const BYTE *  instance,
unsigned  instanceLen 
)
protectedvirtual

Initialise the just created transcoder

Parameters
srcFormatSource media format
destFormatDestination media format
instanceUnique instance identifier for transcoder
instanceLenLength of instance identifier

Reimplemented in OpalPluginVideoTranscoder, OpalPluginStreamedAudioTranscoder, and OpalPluginFramedAudioTranscoder.

OpalTranscoder::PDECLARE_MUTEX ( updateMutex  )
protected
static bool OpalTranscoder::SelectFormats ( const OpalMediaType mediaType,
const OpalMediaFormatList srcFormats,
const OpalMediaFormatList dstFormats,
const OpalMediaFormatList masterFormats,
OpalMediaFormat srcFormat,
OpalMediaFormat dstFormat 
)
static

Find media format(s) for transcoders. This function attempts to find and intermediate media format that will allow two transcoders to be used to get data from the source format to the destination format.

There could be many possible matches between the two lists, so preference is given to the order of the destination formats.

At least one of the two selected medai formats (source or destination) must also be of the specified media type ("audio", "video" etc).

Returns false if there is no registered media transcoder that can be used to get from src to dst for the media type.

Parameters
mediaTypeMedia type for selection.
srcFormatsNames of possible source formats
dstFormatsNames of possible destination formats
masterFormatsMaster list of formats for merging options
srcFormatSelected source format to be used
dstFormatSelected destination format to be used
void OpalTranscoder::SetCommandNotifier ( const PNotifier &  notifier)
inline

Set a notifier to receive commands generated by the transcoder. The commands are highly context sensitive, for example OpalVideoUpdatePicture would only apply to a video transcoder.

Parameters
notifierCommand to execute.

References commandNotifier.

void OpalTranscoder::SetMaxOutputSize ( PINDEX  size)

Set the maximum output size.

void OpalTranscoder::SetSessionID ( unsigned  id)
inline

Set session ID for the transcoder (from OpalMediaStream)

References m_sessionID.

virtual bool OpalTranscoder::UpdateMediaFormats ( const OpalMediaFormat inputMediaFormat,
const OpalMediaFormat outputMediaFormat 
)
virtual

Update the input and output media formats. 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.

If a format is empty (invalid) it is ignored and does not update the internal variable. In this way only the input or output side can be updated.

The default behaviour updates the inputMediaFormat and outputMediaFormat member variables.

Parameters
inputMediaFormatInput media format
outputMediaFormatOutput media format

Reimplemented in OpalFramedTranscoder, OpalPluginVideoTranscoder, OpalPluginStreamedAudioTranscoder, OpalPluginFramedAudioTranscoder, and OpalVideoTranscoder.

Field Documentation

bool OpalTranscoder::acceptEmptyPayload
protected

Referenced by AcceptEmptyPayload().

bool OpalTranscoder::acceptOtherPayloads
protected

Referenced by AcceptOtherPayloads().

PNotifier OpalTranscoder::commandNotifier
protected
bool OpalTranscoder::inputIsRTP
protected
unsigned OpalTranscoder::m_consecutivePayloadTypeMismatches
protected
unsigned OpalTranscoder::m_inClockRate
protected
RTP_DataFrame::PayloadTypes OpalTranscoder::m_lastPayloadType
protected
unsigned OpalTranscoder::m_outClockRate
protected
unsigned OpalTranscoder::m_sessionID
protected

Referenced by GetSessionID(), and SetSessionID().

PINDEX OpalTranscoder::maxOutputSize
protected

Referenced by GetMaxOutputSize().

bool OpalTranscoder::outputIsRTP
protected

The documentation for this class was generated from the following file: