RTPAVProfileSampleBasedAudioReceiver Class Reference

#include <RTPAVProfileSampleBasedAudioReceiver.h>

Inheritance diagram for RTPAVProfileSampleBasedAudioReceiver:

RTPPayloadReceiver RTPAVProfilePayload10Receiver List of all members.

Protected Member Functions

virtual void processPacket (RTPPacket *packet)
virtual void openOutputFile (const char *fileName)
virtual void closeOutputFile ()
virtual void insertSilence (simtime_t duration)

Protected Attributes

AFfilehandle _audioFile
AFfilesetup _fileSetup
int _samplingRate
int _sampleWidth
int _numberOfChannels

Private Member Functions

 Module_Class_Members (RTPAVProfileSampleBasedAudioReceiver, RTPPayloadReceiver, 0) virtual ~RTPAVProfileSampleBasedAudioReceiver()

Member Function Documentation

void RTPAVProfileSampleBasedAudioReceiver::closeOutputFile (  )  [protected, virtual]

Closes the output file stream.

Reimplemented from RTPPayloadReceiver.

00092                                                            {
00093     if (afCloseFile(_audioFile)) {
00094         opp_error("payload receiver: error closing output file");
00095     };
00096 };

void RTPAVProfileSampleBasedAudioReceiver::insertSilence ( simtime_t  duration  )  [protected, virtual]

When packets arrival late or have been lost, this method can be called to insert a silence period. It must be overwritten because in different audio formats different values for silence exist.

Reimplemented in RTPAVProfilePayload10Receiver.

00099                                                                            {
00100     // depends at least on sampling rate and sample width
00101 }

RTPAVProfileSampleBasedAudioReceiver::Module_Class_Members ( RTPAVProfileSampleBasedAudioReceiver  ,
RTPPayloadReceiver  ,
 
) [private]

void RTPAVProfileSampleBasedAudioReceiver::openOutputFile ( const char *  fileName  )  [protected, virtual]

This method is called by initialize and opens the output file stream. For most payload receivers this method works well, only when using a library for a payload type which provides an own open method it must

Reimplemented from RTPPayloadReceiver.

00079                                                                               {
00080     _fileSetup = afNewFileSetup();
00081     afInitByteOrder(_fileSetup, AF_DEFAULT_TRACK, AF_BYTEORDER_LITTLEENDIAN);
00082     afInitChannels(_fileSetup, AF_DEFAULT_TRACK, _numberOfChannels);
00083     afInitSampleFormat(_fileSetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, _sampleWidth);
00084     afInitRate(_fileSetup, AF_DEFAULT_TRACK, (double)_samplingRate);
00085     _audioFile = afOpenFile(fileName, "w", _fileSetup);
00086     if (_audioFile == AF_NULL_FILEHANDLE) {
00087         opp_error("payload receiver: error creating output file");
00088     };
00089 };

void RTPAVProfileSampleBasedAudioReceiver::processPacket ( RTPPacket packet  )  [protected, virtual]

Writes contents of this RTPPacket into the output file. Must be overwritten by subclasses.

Reimplemented from RTPPayloadReceiver.

00070                                                                           {
00071     //RTPPayloadReceiver::processPacket(packet);
00072     void *data = packet->par("data");
00073     int dataSize = packet->payloadLength();
00074     int numberOfFrames = dataSize  / ((_sampleWidth / 8) * _numberOfChannels);
00075     afWriteFrames(_audioFile, AF_DEFAULT_TRACK, data, numberOfFrames);
00076 };


Member Data Documentation

AFfilehandle RTPAVProfileSampleBasedAudioReceiver::_audioFile [protected]

AFfilesetup RTPAVProfileSampleBasedAudioReceiver::_fileSetup [protected]

int RTPAVProfileSampleBasedAudioReceiver::_numberOfChannels [protected]

int RTPAVProfileSampleBasedAudioReceiver::_sampleWidth [protected]

int RTPAVProfileSampleBasedAudioReceiver::_samplingRate [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:23 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7