#include <RTPAVProfilePayload32Sender.h>
Inheritance diagram for RTPAVProfilePayload32Sender:

Protected Member Functions | |
| virtual void | initialize () |
| virtual void | initializeSenderModule (RTPInnerPacket *rinpIn) |
| virtual bool | sendPacket () |
Protected Attributes | |
| double | _initialDelay |
| double | _framesPerSecond |
| double | _frameNumber |
|
|
Initializes the module. It sets the values for clock rate and payload type. Reimplemented from RTPPayloadSender. 00037 {
00038
00039 RTPPayloadSender::initialize();
00040
00041 _clockRate = 90000;
00042 _payloadType = 32;
00043 };
|
|
|
This method reads the gdf file header. Reimplemented from RTPPayloadSender. 00121 {
00122
00123 char line[100];
00124 char unit[100];
00125 char description[100];
00126
00127 RTPPayloadSender::initializeSenderModule(rinpIn);
00128
00129 // first line: fps unit description
00130 _inputFileStream.get(line, 100, '\n');
00131
00132 float fps;
00133 sscanf(line, "%f %s %s", &fps, unit, description);
00134 _framesPerSecond = fps;
00135
00136 _frameNumber = 0;
00137
00138 // get new line character
00139 char c;
00140 _inputFileStream.get(c);
00141
00142 // second line: initial delay unit description
00143 _inputFileStream.get(line, 100, '\n');
00144
00145 float delay;
00146 sscanf(line, "%f %s %s", &delay, unit, description);
00147
00148 _initialDelay = delay;
00149
00150 // wait initial delay
00151 // cMessage *reminderMessage = new cMessage("next frame");
00152 // scheduleAt(simTime() + _initialDelay, reminderMessage);
00153
00154 };
|
|
|
This method sends one mpeg frame. It sends one or more rtp data packet. Returns false if there were no more frames. Reimplemented from RTPPayloadSender. 00157 {
00158
00159 // read next frame line
00160 int bits;
00161 char unit[100];
00162 char description[100];
00163
00164 _inputFileStream >> bits;
00165 _inputFileStream >> unit;
00166 _inputFileStream.get(description, 100, '\n');
00167
00168 int pictureType = 0;
00169
00170 if (strchr(description, 'I')) {
00171 pictureType = 1;
00172 }
00173 else if (strchr(description, 'P')) {
00174 pictureType = 2;
00175 }
00176 else if (strchr(description, 'B')) {
00177 pictureType = 3;
00178 }
00179 else if (strchr(description, 'D')) {
00180 pictureType = 4;
00181 };
00182
00183 int bytesRemaining = bits / 8;
00184
00185 if (!_inputFileStream.eof()) {
00186 while (bytesRemaining > 0) {
00187 RTPPacket *rtpPacket = new RTPPacket("RTPPacket");
00188 RTPMpegPacket *mpegPacket = new RTPMpegPacket("MpegPacket");
00189
00190 // the only mpeg information we know is the picture type
00191 mpegPacket->setPictureType(pictureType);
00192
00193 // the maximum number of real data bytes
00194 int maxDataSize = _mtu - rtpPacket->length() - mpegPacket->length();
00195
00196 if (bytesRemaining > maxDataSize) {
00197
00198 // we do not know where slices in the
00199 // mpeg picture begin
00200 // so we simulate by assuming a slice
00201 // has a length of 64 bytes
00202 int slicedDataSize = (maxDataSize / 64) * 64;
00203
00204 mpegPacket->addLength(slicedDataSize);
00205
00206
00207 rtpPacket->encapsulate(mpegPacket);
00208
00209 bytesRemaining = bytesRemaining - slicedDataSize;
00210 }
00211 else {
00212 mpegPacket->addLength(bytesRemaining);
00213 rtpPacket->encapsulate(mpegPacket);
00214 // set marker because this is
00215 // the last packet of the frame
00216 rtpPacket->setMarker(1);
00217 bytesRemaining = 0;
00218 }
00219
00220 rtpPacket->setPayloadType(_payloadType);
00221 rtpPacket->setSequenceNumber(_sequenceNumber);
00222 _sequenceNumber++;
00223
00224
00225 rtpPacket->setTimeStamp(_timeStampBase + (_initialDelay + (1 / _framesPerSecond) * (double)_frameNumber) * _clockRate);
00226 rtpPacket->setSSRC(_ssrc);
00227
00228
00229 RTPInnerPacket *rinpOut = new RTPInnerPacket("dataOut()");
00230
00231
00232 rinpOut->dataOut(rtpPacket);
00233
00234 send(rinpOut, "toProfile");
00235
00236 };
00237 _frameNumber++;
00238
00239 _reminderMessage = new cMessage("nextFrame");
00240 scheduleAt(simTime() + 1.0 / _framesPerSecond, _reminderMessage);
00241 return true;
00242 }
00243 else {
00244 return false;
00245 }
00246 }
|
|
|
The number of the current mpeg frame. Needed for calculating the rtp time stamp in the rtp data packets. |
|
|
The number of frames per second of the mpeg video. |
|
|
The initial delay of the mpeg video. |
1.4.1