Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

H323Codec Class Reference

#include <codecs.h>

Inheritance diagram for H323Codec:

H323AudioCodec H323VideoCodec G7231_File_Codec H323_LIDCodec H323FramedAudioCodec H323_Cu30Codec H323_H261Codec OpalDynaVideoCodec H323StreamedAudioCodec OpalDynaAudioCodec H323_ALawCodec H323_muLawCodec OpalDynaNonStandardAudioCodec List of all members.

Public Types

enum  Direction { Encoder, Decoder }

Public Member Functions

 H323Codec (const char *mediaFormat, Direction direction)
virtual BOOL Open (H323Connection &connection)
virtual void Close ()=0
virtual BOOL Read (BYTE *buffer, unsigned &length, RTP_DataFrame &rtpFrame)=0
virtual BOOL Write (const BYTE *buffer, unsigned length, const RTP_DataFrame &frame, unsigned &written)=0
virtual unsigned GetFrameRate () const
virtual void OnFlowControl (long bitRateRestriction)
virtual void OnMiscellaneousCommand (const H245_MiscellaneousCommand_type &type)
virtual void OnMiscellaneousIndication (const H245_MiscellaneousIndication_type &type)
Direction GetDirection () const
const OpalMediaFormatGetMediaFormat () const
virtual BOOL AttachChannel (PChannel *channel, BOOL autoDelete=TRUE)
virtual PChannel * SwapChannel (PChannel *newChannel, BOOL autoDelete=TRUE)
virtual BOOL CloseRawDataChannel ()
PChannel * GetRawDataChannel ()
virtual BOOL IsRawDataChannelNative () const
BOOL ReadRaw (void *data, PINDEX size, PINDEX &length)
BOOL WriteRaw (void *data, PINDEX length)
BOOL AttachLogicalChannel (H323Channel *channel)
void AddFilter (const PNotifier &notifier)

Protected Member Functions

 PLIST (FilterList, PNotifier)

Protected Attributes

Direction direction
OpalMediaFormat mediaFormat
H323ChannellogicalChannel
PChannel * rawDataChannel
BOOL deleteChannel
PMutex rawChannelMutex
PINDEX lastSequenceNumber
FilterList filters

Classes

class  FilterInfo

Detailed Description

This class embodies the implementation of a specific codec instance used to transfer data via the logical channels opened and managed by the H323 control channel.

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


Member Enumeration Documentation

enum H323Codec::Direction
 

Enumerator:
Encoder 
Decoder 


Constructor & Destructor Documentation

H323Codec::H323Codec const char *  mediaFormat,
Direction  direction
 

Parameters:
direction  Media format for codec Direction in which this instance runs


Member Function Documentation

void H323Codec::AddFilter const PNotifier &  notifier  ) 
 

Add a filter to the codec. The call back function is executed just after reading from, or just before writing to, the raw data channel. The callback is passed the H323Codec::FilterInfo structure containing the data that is being read or written.

To use define: PDECLARE_NOTIFIER(H323Codec::FilterInfo, YourClass, YourFunction); and void YourClass::YourFunction(H323Codec::FilterInfo & info, INT) { DO something with data } and to connect to a codec: BOOL YourClass::OnStartLogicalChannel(H323Channel & channel) { H323Codec * codec = channel.GetCodec(); codec->AddFilter(PCREATE_NOTIFIER(YourFunction)); } for example. Other places can be used to set the filter.

virtual BOOL H323Codec::AttachChannel PChannel *  channel,
BOOL  autoDelete = TRUE
[virtual]
 

Attach the raw data channel for use by codec. Note the channel provided will be deleted on destruction of the codec.

The channel connects the codec (audio or video) with hardware to read/write data. Thus, the video codec provides a pointer to the data, which the renderer/grabber then accesses to display/grab the image from/to.

Parameters:
autoDelete  Channel to read/write raw codec data Channel is to be automatically deleted

BOOL H323Codec::AttachLogicalChannel H323Channel channel  ) 
 

Attach the logical channel, for use by the codec. The channel provided is not deleted on destruction, it is just used.

The logical channel provides a means for the codec to send control messages. E.G. the receive video codec wants to receive a frame update.

virtual void H323Codec::Close  )  [pure virtual]
 

Close the codec.

Implemented in H323AudioCodec, and H323VideoCodec.

virtual BOOL H323Codec::CloseRawDataChannel  )  [virtual]
 

Close the raw data channel, described in H323Codec::AttachChannel

Direction H323Codec::GetDirection  )  const [inline]
 

virtual unsigned H323Codec::GetFrameRate  )  const [virtual]
 

Get the frame rate in RTP timestamp units.

Reimplemented in H323AudioCodec, and H323_H261Codec.

const OpalMediaFormat& H323Codec::GetMediaFormat  )  const [inline]
 

PChannel* H323Codec::GetRawDataChannel  )  [inline]
 

Return a pointer to the raw data channel, which can then be used to access the recording/playing device. (or testing if channel is attached).

virtual BOOL H323Codec::IsRawDataChannelNative  )  const [virtual]
 

Return flag indicating raw channel is native. For audio codecs, FALSE typically means that the format is PCM-16. For video codecs, FALSE typically means that the format is YUV411P.

The default behaviour returns FALSE.

Reimplemented in H323_LIDCodec, and G7231_File_Codec.

virtual void H323Codec::OnFlowControl long  bitRateRestriction  )  [virtual]
 

Limit bit flow for the logical channel. The default behaviour does nothing.

Parameters:
bitRateRestriction  Bit rate limitation

virtual void H323Codec::OnMiscellaneousCommand const H245_MiscellaneousCommand_type type  )  [virtual]
 

Process a miscellaneous command on the logical channel. The default behaviour does nothing.

Parameters:
type  Command to process

Reimplemented in H323VideoCodec.

virtual void H323Codec::OnMiscellaneousIndication const H245_MiscellaneousIndication_type type  )  [virtual]
 

Process a miscellaneous indication on the logical channel. The default behaviour does nothing.

Parameters:
type  Indication to process

Reimplemented in H323VideoCodec.

virtual BOOL H323Codec::Open H323Connection connection  )  [virtual]
 

Open the codec. This will open the codec for encoding or decoding, it is called after the logical channel have been established and the background threads to drive them have been started. This is primarily used to delay allocation of resources until the last millisecond.

A descendent class may be created by the application and it may cast the connection parameter to the application defined descendent of H323Connection to obtain information needed to open the codec.

The default behaviour does nothing.

Parameters:
connection  Connection between the endpoints

Reimplemented in H323AudioCodec, and H323VideoCodec.

H323Codec::PLIST FilterList  ,
PNotifier 
[protected]
 

virtual BOOL H323Codec::Read BYTE *  buffer,
unsigned &  length,
RTP_DataFrame rtpFrame
[pure virtual]
 

Encode the data from the appropriate device. This will encode data for transmission. The exact size and description of the data placed in the buffer is codec dependent but should be less than OpalMediaFormat::GetFrameSize() in length.

The length parameter is filled with the actual length of the encoded data, often this will be the same as OpalMediaFormat::GetFrameSize().

This function is called every GetFrameRate() timestamp units, so MUST take less than (or equal to) that amount of time to complete. It should always return the amount of data that corresponds to the GetFrameRate() timestamp units as well.

A returned length of zero indicates that time has passed but there is no data encoded. This is typically used for silence detection in an audio codec.

Parameters:
length  Buffer of encoded data
rtpFrame  Actual length of encoded data buffer RTP data frame

Implemented in H323FramedAudioCodec, H323_Cu30Codec, OpalDynaVideoCodec, H323_H261Codec, H323_LIDCodec, and G7231_File_Codec.

BOOL H323Codec::ReadRaw void *  data,
PINDEX  size,
PINDEX &  length
 

Read from the raw data channel.

virtual PChannel* H323Codec::SwapChannel PChannel *  newChannel,
BOOL  autoDelete = TRUE
[virtual]
 

Attach a new channel and returns the previous one, without neither deleting it nor closing it. This method is used to, for example, when swapping to or from a hold media channel

Parameters:
autoDelete  Channel to read/write raw codec data Channel is to be automatically deleted

virtual BOOL H323Codec::Write const BYTE *  buffer,
unsigned  length,
const RTP_DataFrame frame,
unsigned &  written
[pure virtual]
 

Decode the data and output it to appropriate device. This will decode a single frame of received data. The exact size and description of the data required in the buffer is codec dependent but should be at least than OpalMediaFormat::GetFrameSize() in length.

It is expected this function anunciates the data. That is, for example with audio data, the sound is output on a speaker.

This function is called every GetFrameRate() timestamp units, so MUST take less than that amount of time to complete!

Parameters:
length  Buffer of encoded data
frame  Length of encoded data buffer
written  Entire RTP frame Number of bytes used from data buffer

Implemented in H323FramedAudioCodec, H323_Cu30Codec, OpalDynaVideoCodec, H323_H261Codec, H323_LIDCodec, and G7231_File_Codec.

BOOL H323Codec::WriteRaw void *  data,
PINDEX  length
 

Write from the raw data channel.


Member Data Documentation

BOOL H323Codec::deleteChannel [protected]
 

Direction H323Codec::direction [protected]
 

FilterList H323Codec::filters [protected]
 

PINDEX H323Codec::lastSequenceNumber [protected]
 

H323Channel* H323Codec::logicalChannel [protected]
 

OpalMediaFormat H323Codec::mediaFormat [protected]
 

PMutex H323Codec::rawChannelMutex [protected]
 

PChannel* H323Codec::rawDataChannel [protected]
 


The documentation for this class was generated from the following file:
Generated on Mon Sep 26 15:45:21 2005 for OpenH323 by  doxygen 1.4.4