#include <MPEG2TransportStreamMultiplexor.hh>
Inheritance diagram for MPEG2TransportStreamMultiplexor:


Public Types | |
| typedef void( | afterGettingFunc )(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) |
| typedef void( | onCloseFunc )(void *clientData) |
Public Member Functions | |
| void | getNextFrame (unsigned char *to, unsigned maxSize, afterGettingFunc *afterGettingFunc, void *afterGettingClientData, onCloseFunc *onCloseFunc, void *onCloseClientData) |
| void | stopGettingFrames () |
| virtual unsigned | maxFrameSize () const |
| Boolean | isCurrentlyAwaitingData () const |
| virtual void | getAttributes () const |
| virtual char const * | MIMEtype () const |
| virtual Boolean | isRTPSource () const |
| virtual Boolean | isMPEG1or2VideoStreamFramer () const |
| virtual Boolean | isMPEG4VideoStreamFramer () const |
| virtual Boolean | isH264VideoStreamFramer () const |
| virtual Boolean | isJPEGVideoSource () const |
| virtual Boolean | isAMRAudioSource () const |
| UsageEnvironment & | envir () const |
| char const * | name () const |
| virtual Boolean | isSink () const |
| virtual Boolean | isRTCPInstance () const |
| virtual Boolean | isRTSPClient () const |
| virtual Boolean | isRTSPServer () const |
| virtual Boolean | isMediaSession () const |
| virtual Boolean | isServerMediaSession () const |
| virtual Boolean | isDarwinInjector () const |
Static Public Member Functions | |
| static Boolean | lookupByName (UsageEnvironment &env, char const *sourceName, FramedSource *&resultSource) |
| static Boolean | lookupByName (UsageEnvironment &env, char const *sourceName, MediaSource *&resultSource) |
| static Boolean | lookupByName (UsageEnvironment &env, char const *mediumName, Medium *&resultMedium) |
| static void | handleClosure (void *clientData) |
| static void | close (UsageEnvironment &env, char const *mediumName) |
| static void | close (Medium *medium) |
Protected Member Functions | |
| MPEG2TransportStreamMultiplexor (UsageEnvironment &env) | |
| virtual | ~MPEG2TransportStreamMultiplexor () |
| virtual void | awaitNewBuffer (unsigned char *oldBuffer)=0 |
| void | handleNewBuffer (unsigned char *buffer, unsigned bufferSize, int mpegVersion, MPEG1or2Demux::SCR scr) |
| virtual void | doStopGettingFrames () |
| TaskToken & | nextTask () |
Static Protected Member Functions | |
| static void | afterGetting (FramedSource *source) |
Protected Attributes | |
| Boolean | fHaveVideoStreams |
| unsigned char * | fTo |
| unsigned | fMaxSize |
| unsigned | fFrameSize |
| unsigned | fNumTruncatedBytes |
| timeval | fPresentationTime |
| unsigned | fDurationInMicroseconds |
Private Member Functions | |
| virtual void | doGetNextFrame () |
| void | deliverDataToClient (u_int8_t pid, unsigned char *buffer, unsigned bufferSize, unsigned &startPositionInBuffer) |
| void | deliverPATPacket () |
| void | deliverPMTPacket (Boolean hasChanged) |
| void | setProgramStreamMap (unsigned frameSize) |
Private Attributes | |
| unsigned | fOutgoingPacketCounter |
| unsigned | fProgramMapVersion |
| u_int8_t | fPreviousInputProgramMapVersion |
| u_int8_t | fCurrentInputProgramMapVersion |
| struct { | |
| unsigned counter | |
| u_int8_t streamType | |
| } | fPIDState [PID_TABLE_SIZE] |
| u_int8_t | fPCR_PID |
| u_int8_t | fCurrentPID |
| MPEG1or2Demux::SCR | fPCR |
| unsigned char * | fInputBuffer |
| unsigned | fInputBufferSize |
| unsigned | fInputBufferBytesUsed |
| Boolean | fIsFirstAdaptationField |
Definition at line 34 of file MPEG2TransportStreamMultiplexor.hh.
typedef void( FramedSource::afterGettingFunc)(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) [inherited] |
Definition at line 36 of file FramedSource.hh.
typedef void( FramedSource::onCloseFunc)(void *clientData) [inherited] |
Definition at line 40 of file FramedSource.hh.
| MPEG2TransportStreamMultiplexor::MPEG2TransportStreamMultiplexor | ( | UsageEnvironment & | env | ) | [protected] |
Definition at line 32 of file MPEG2TransportStreamMultiplexor.cpp.
References PID_TABLE_SIZE.
00033 : FramedSource(env), 00034 fHaveVideoStreams(True/*by default*/), 00035 fOutgoingPacketCounter(0), fProgramMapVersion(0), 00036 fPreviousInputProgramMapVersion(0xFF), fCurrentInputProgramMapVersion(0xFF), 00037 fPCR_PID(0), fCurrentPID(0), 00038 fInputBuffer(NULL), fInputBufferSize(0), fInputBufferBytesUsed(0), 00039 fIsFirstAdaptationField(True) { 00040 for (unsigned i = 0; i < PID_TABLE_SIZE; ++i) { 00041 fPIDState[i].counter = 0; 00042 fPIDState[i].streamType = 0; 00043 } 00044 }
| MPEG2TransportStreamMultiplexor::~MPEG2TransportStreamMultiplexor | ( | ) | [protected, virtual] |
| virtual void MPEG2TransportStreamMultiplexor::awaitNewBuffer | ( | unsigned char * | oldBuffer | ) | [protected, pure virtual] |
Implemented in MPEG2TransportStreamFromESSource, and MPEG2TransportStreamFromPESSource.
Referenced by doGetNextFrame().
| void MPEG2TransportStreamMultiplexor::handleNewBuffer | ( | unsigned char * | buffer, | |
| unsigned | bufferSize, | |||
| int | mpegVersion, | |||
| MPEG1or2Demux::SCR | scr | |||
| ) | [protected] |
Definition at line 87 of file MPEG2TransportStreamMultiplexor.cpp.
References doGetNextFrame(), fCurrentPID, fHaveVideoStreams, fInputBuffer, fInputBufferBytesUsed, fInputBufferSize, fPCR, fPCR_PID, fPIDState, setProgramStreamMap(), and streamType.
Referenced by MPEG2TransportStreamFromPESSource::afterGettingFrame1(), and InputESSourceRecord::deliverBufferToClient().
00088 { 00089 if (bufferSize < 4) return; 00090 fInputBuffer = buffer; 00091 fInputBufferSize = bufferSize; 00092 fInputBufferBytesUsed = 0; 00093 00094 u_int8_t stream_id = fInputBuffer[3]; 00095 // Use "stream_id" directly as our PID. 00096 // Also, figure out the Program Map 'stream type' from this. 00097 if (stream_id == 0xBE) { // padding_stream; ignore 00098 fInputBufferSize = 0; 00099 } else if (stream_id == 0xBC) { // program_stream_map 00100 setProgramStreamMap(fInputBufferSize); 00101 fInputBufferSize = 0; // then, ignore the buffer 00102 } else { 00103 fCurrentPID = stream_id; 00104 00105 // Set the stream's type: 00106 u_int8_t& streamType = fPIDState[fCurrentPID].streamType; // alias 00107 00108 if (streamType == 0) { 00109 // Instead, set the stream's type to default values, based on whether 00110 // the stream is audio or video, and whether it's MPEG-1 or MPEG-2: 00111 if ((stream_id&0xF0) == 0xE0) { // video 00112 streamType = mpegVersion == 1 ? 1 : mpegVersion == 2 ? 2 : 0x10; 00113 } else if ((stream_id&0xE0) == 0xC0) { // audio 00114 streamType = mpegVersion == 1 ? 3 : mpegVersion == 2 ? 4 : 0xF; 00115 } else if (stream_id == 0xBD) { // private_stream1 (usually AC-3) 00116 streamType = 0x06; // for DVB; for ATSC, use 0x81 00117 } else { // something else, e.g., AC-3 uses private_stream1 (0xBD) 00118 streamType = 0x81; // private 00119 } 00120 } 00121 00122 if (fPCR_PID == 0) { // set it to this stream, if it's appropriate: 00123 if ((!fHaveVideoStreams && (streamType == 3 || streamType == 4 || streamType == 0xF))/* audio stream */ || 00124 (streamType == 1 || streamType == 2 || streamType == 0x10)/* video stream */) { 00125 fPCR_PID = fCurrentPID; // use this stream's SCR for PCR 00126 } 00127 } 00128 if (fCurrentPID == fPCR_PID) { 00129 // Record the input's current SCR timestamp, for use as our PCR: 00130 fPCR = scr; 00131 } 00132 } 00133 00134 // Now that we have new input data, retry the last delivery to the client: 00135 doGetNextFrame(); 00136 }
| void MPEG2TransportStreamMultiplexor::doGetNextFrame | ( | ) | [private, virtual] |
Implements FramedSource.
Definition at line 49 of file MPEG2TransportStreamMultiplexor.cpp.
References FramedSource::afterGetting(), awaitNewBuffer(), deliverDataToClient(), deliverPATPacket(), deliverPMTPacket(), fCurrentInputProgramMapVersion, fCurrentPID, fInputBuffer, fInputBufferBytesUsed, fInputBufferSize, fOutgoingPacketCounter, fPIDState, fPreviousInputProgramMapVersion, PAT_FREQUENCY, and PMT_FREQUENCY.
Referenced by handleNewBuffer().
00049 { 00050 if (fInputBufferBytesUsed >= fInputBufferSize) { 00051 // No more bytes are available from the current buffer. 00052 // Arrange to read a new one. 00053 awaitNewBuffer(fInputBuffer); 00054 return; 00055 } 00056 00057 do { 00058 // Periodically return a Program Association Table packet instead: 00059 if (fOutgoingPacketCounter++ % PAT_FREQUENCY == 0) { 00060 deliverPATPacket(); 00061 break; 00062 } 00063 00064 // Periodically (or when we see a new PID) return a Program Map Table instead: 00065 Boolean programMapHasChanged = fPIDState[fCurrentPID].counter == 0 00066 || fCurrentInputProgramMapVersion != fPreviousInputProgramMapVersion; 00067 if (fOutgoingPacketCounter % PMT_FREQUENCY == 0 || programMapHasChanged) { 00068 if (programMapHasChanged) { // reset values for next time: 00069 fPIDState[fCurrentPID].counter = 1; 00070 fPreviousInputProgramMapVersion = fCurrentInputProgramMapVersion; 00071 } 00072 deliverPMTPacket(programMapHasChanged); 00073 break; 00074 } 00075 00076 // Normal case: Deliver (or continue delivering) the recently-read data: 00077 deliverDataToClient(fCurrentPID, fInputBuffer, fInputBufferSize, 00078 fInputBufferBytesUsed); 00079 } while (0); 00080 00081 // NEED TO SET fPresentationTime, durationInMicroseconds ##### 00082 // Complete the delivery to the client: 00083 afterGetting(this); 00084 }
| void MPEG2TransportStreamMultiplexor::deliverDataToClient | ( | u_int8_t | pid, | |
| unsigned char * | buffer, | |||
| unsigned | bufferSize, | |||
| unsigned & | startPositionInBuffer | |||
| ) | [private] |
Definition at line 139 of file MPEG2TransportStreamMultiplexor.cpp.
References MPEG1or2Demux::SCR::extension, False, FramedSource::fFrameSize, fIsFirstAdaptationField, FramedSource::fMaxSize, FramedSource::fNumTruncatedBytes, fPCR, fPCR_PID, fPIDState, FramedSource::fTo, MPEG1or2Demux::SCR::highBit, MPEG1or2Demux::SCR::remainingBits, and TRANSPORT_PACKET_SIZE.
Referenced by deliverPATPacket(), deliverPMTPacket(), and doGetNextFrame().
00140 { 00141 // Construct a new Transport packet, and deliver it to the client: 00142 if (fMaxSize < TRANSPORT_PACKET_SIZE) { 00143 fFrameSize = 0; // the client hasn't given us enough space; deliver nothing 00144 fNumTruncatedBytes = TRANSPORT_PACKET_SIZE; 00145 } else { 00146 fFrameSize = TRANSPORT_PACKET_SIZE; 00147 Boolean willAddPCR = pid == fPCR_PID && startPositionInBuffer == 0 00148 && !(fPCR.highBit == 0 && fPCR.remainingBits == 0 && fPCR.extension == 0); 00149 unsigned const numBytesAvailable = bufferSize - startPositionInBuffer; 00150 unsigned numHeaderBytes = 4; // by default 00151 unsigned numPCRBytes = 0; // by default 00152 unsigned numPaddingBytes = 0; // by default 00153 unsigned numDataBytes; 00154 u_int8_t adaptation_field_control; 00155 if (willAddPCR) { 00156 adaptation_field_control = 0x30; 00157 numHeaderBytes += 2; // for the "adaptation_field_length" and flags 00158 numPCRBytes = 6; 00159 if (numBytesAvailable >= TRANSPORT_PACKET_SIZE - numHeaderBytes - numPCRBytes) { 00160 numDataBytes = TRANSPORT_PACKET_SIZE - numHeaderBytes - numPCRBytes; 00161 } else { 00162 numDataBytes = numBytesAvailable; 00163 numPaddingBytes 00164 = TRANSPORT_PACKET_SIZE - numHeaderBytes - numPCRBytes - numDataBytes; 00165 } 00166 } else if (numBytesAvailable >= TRANSPORT_PACKET_SIZE - numHeaderBytes) { 00167 // This is the common case 00168 adaptation_field_control = 0x10; 00169 numDataBytes = TRANSPORT_PACKET_SIZE - numHeaderBytes; 00170 } else { 00171 adaptation_field_control = 0x30; 00172 ++numHeaderBytes; // for the "adaptation_field_length" 00173 // ASSERT: numBytesAvailable <= TRANSPORT_PACKET_SIZE - numHeaderBytes 00174 numDataBytes = numBytesAvailable; 00175 if (numDataBytes < TRANSPORT_PACKET_SIZE - numHeaderBytes) { 00176 ++numHeaderBytes; // for the adaptation field flags 00177 numPaddingBytes = TRANSPORT_PACKET_SIZE - numHeaderBytes - numDataBytes; 00178 } 00179 } 00180 // ASSERT: numHeaderBytes+numPCRBytes+numPaddingBytes+numDataBytes 00181 // == TRANSPORT_PACKET_SIZE 00182 00183 // Fill in the header of the Transport Stream packet: 00184 unsigned char* header = fTo; 00185 *header++ = 0x47; // sync_byte 00186 *header++ = (startPositionInBuffer == 0) ? 0x40 : 0x00; 00187 // transport_error_indicator, payload_unit_start_indicator, transport_priority, 00188 // first 5 bits of PID 00189 *header++ = pid; 00190 // last 8 bits of PID 00191 unsigned& continuity_counter = fPIDState[pid].counter; // alias 00192 *header++ = adaptation_field_control|(continuity_counter&0x0F); 00193 // transport_scrambling_control, adaptation_field_control, continuity_counter 00194 ++continuity_counter; 00195 if (adaptation_field_control == 0x30) { 00196 // Add an adaptation field: 00197 u_int8_t adaptation_field_length 00198 = (numHeaderBytes == 5) ? 0 : 1 + numPCRBytes + numPaddingBytes; 00199 *header++ = adaptation_field_length; 00200 if (numHeaderBytes > 5) { 00201 u_int8_t flags = willAddPCR ? 0x10 : 0x00; 00202 if (fIsFirstAdaptationField) { 00203 flags |= 0x80; // discontinuity_indicator 00204 fIsFirstAdaptationField = False; 00205 } 00206 *header++ = flags; 00207 if (willAddPCR) { 00208 u_int32_t pcrHigh32Bits = (fPCR.highBit<<31) | (fPCR.remainingBits>>1); 00209 u_int8_t pcrLowBit = fPCR.remainingBits&1; 00210 u_int8_t extHighBit = (fPCR.extension&0x100)>>8; 00211 *header++ = pcrHigh32Bits>>24; 00212 *header++ = pcrHigh32Bits>>16; 00213 *header++ = pcrHigh32Bits>>8; 00214 *header++ = pcrHigh32Bits; 00215 *header++ = (pcrLowBit<<7)|0x7E|extHighBit; 00216 *header++ = (u_int8_t)fPCR.extension; // low 8 bits of extension 00217 } 00218 } 00219 } 00220 00221 // Add any padding bytes: 00222 for (unsigned i = 0; i < numPaddingBytes; ++i) *header++ = 0xFF; 00223 00224 // Finally, add the data bytes: 00225 memmove(header, &buffer[startPositionInBuffer], numDataBytes); 00226 startPositionInBuffer += numDataBytes; 00227 } 00228 }
| void MPEG2TransportStreamMultiplexor::deliverPATPacket | ( | ) | [private] |
Definition at line 236 of file MPEG2TransportStreamMultiplexor.cpp.
References calculateCRC(), deliverDataToClient(), OUR_PROGRAM_MAP_PID, OUR_PROGRAM_NUMBER, PAT_PID, and TRANSPORT_PACKET_SIZE.
Referenced by doGetNextFrame().
00236 { 00237 // First, create a new buffer for the PAT packet: 00238 unsigned const patSize = TRANSPORT_PACKET_SIZE - 4; // allow for the 4-byte header 00239 unsigned char* patBuffer = new unsigned char[patSize]; 00240 00241 // and fill it in: 00242 unsigned char* pat = patBuffer; 00243 *pat++ = 0; // pointer_field 00244 *pat++ = 0; // table_id 00245 *pat++ = 0xB0; // section_syntax_indicator; 0; reserved, section_length (high) 00246 *pat++ = 13; // section_length (low) 00247 *pat++ = 0; *pat++ = 1; // transport_stream_id 00248 *pat++ = 0xC3; // reserved; version_number; current_next_indicator 00249 *pat++ = 0; // section_number 00250 *pat++ = 0; // last_section_number 00251 *pat++ = OUR_PROGRAM_NUMBER>>8; *pat++ = OUR_PROGRAM_NUMBER; // program_number 00252 *pat++ = 0xE0|(OUR_PROGRAM_MAP_PID>>8); // reserved; program_map_PID (high) 00253 *pat++ = OUR_PROGRAM_MAP_PID; // program_map_PID (low) 00254 00255 // Compute the CRC from the bytes we currently have (not including "pointer_field"): 00256 u_int32_t crc = calculateCRC(patBuffer+1, pat - (patBuffer+1)); 00257 *pat++ = crc>>24; *pat++ = crc>>16; *pat++ = crc>>8; *pat++ = crc; 00258 00259 // Fill in the rest of the packet with padding bytes: 00260 while (pat < &patBuffer[patSize]) *pat++ = 0xFF; 00261 00262 // Deliver the packet: 00263 unsigned startPosition = 0; 00264 deliverDataToClient(PAT_PID, patBuffer, patSize, startPosition); 00265 00266 // Finally, remove the new buffer: 00267 delete[] patBuffer; 00268 }
| void MPEG2TransportStreamMultiplexor::deliverPMTPacket | ( | Boolean | hasChanged | ) | [private] |
Definition at line 270 of file MPEG2TransportStreamMultiplexor.cpp.
References calculateCRC(), deliverDataToClient(), fPCR_PID, fPIDState, fProgramMapVersion, OUR_PROGRAM_MAP_PID, OUR_PROGRAM_NUMBER, PID_TABLE_SIZE, streamType, and TRANSPORT_PACKET_SIZE.
Referenced by doGetNextFrame().
00270 { 00271 if (hasChanged) ++fProgramMapVersion; 00272 00273 // First, create a new buffer for the PMT packet: 00274 unsigned const pmtSize = TRANSPORT_PACKET_SIZE - 4; // allow for the 4-byte header 00275 unsigned char* pmtBuffer = new unsigned char[pmtSize]; 00276 00277 // and fill it in: 00278 unsigned char* pmt = pmtBuffer; 00279 *pmt++ = 0; // pointer_field 00280 *pmt++ = 2; // table_id 00281 *pmt++ = 0xB0; // section_syntax_indicator; 0; reserved, section_length (high) 00282 unsigned char* section_lengthPtr = pmt; // save for later 00283 *pmt++ = 0; // section_length (low) (fill in later) 00284 *pmt++ = OUR_PROGRAM_NUMBER>>8; *pmt++ = OUR_PROGRAM_NUMBER; // program_number 00285 *pmt++ = 0xC1|((fProgramMapVersion&0x1F)<<1); // reserved; version_number; current_next_indicator 00286 *pmt++ = 0; // section_number 00287 *pmt++ = 0; // last_section_number 00288 *pmt++ = 0xE0; // reserved; PCR_PID (high) 00289 *pmt++ = fPCR_PID; // PCR_PID (low) 00290 *pmt++ = 0xF0; // reserved; program_info_length (high) 00291 *pmt++ = 0; // program_info_length (low) 00292 for (int pid = 0; pid < PID_TABLE_SIZE; ++pid) { 00293 if (fPIDState[pid].streamType != 0) { 00294 // This PID gets recorded in the table 00295 *pmt++ = fPIDState[pid].streamType; 00296 *pmt++ = 0xE0; // reserved; elementary_pid (high) 00297 *pmt++ = pid; // elementary_pid (low) 00298 *pmt++ = 0xF0; // reserved; ES_info_length (high) 00299 *pmt++ = 0; // ES_info_length (low) 00300 } 00301 } 00302 unsigned section_length = pmt - (section_lengthPtr+1) + 4 /*for CRC*/; 00303 *section_lengthPtr = section_length; 00304 00305 // Compute the CRC from the bytes we currently have (not including "pointer_field"): 00306 u_int32_t crc = calculateCRC(pmtBuffer+1, pmt - (pmtBuffer+1)); 00307 *pmt++ = crc>>24; *pmt++ = crc>>16; *pmt++ = crc>>8; *pmt++ = crc; 00308 00309 // Fill in the rest of the packet with padding bytes: 00310 while (pmt < &pmtBuffer[pmtSize]) *pmt++ = 0xFF; 00311 00312 // Deliver the packet: 00313 unsigned startPosition = 0; 00314 deliverDataToClient(OUR_PROGRAM_MAP_PID, pmtBuffer, pmtSize, startPosition); 00315 00316 // Finally, remove the new buffer: 00317 delete[] pmtBuffer; 00318 }
| void MPEG2TransportStreamMultiplexor::setProgramStreamMap | ( | unsigned | frameSize | ) | [private] |
Definition at line 320 of file MPEG2TransportStreamMultiplexor.cpp.
References fCurrentInputProgramMapVersion, fInputBuffer, and fPIDState.
Referenced by handleNewBuffer().
00320 { 00321 if (frameSize <= 16) return; // program_stream_map is too small to be useful 00322 if (frameSize > 0xFF) return; // program_stream_map is too large 00323 00324 u_int16_t program_stream_map_length = (fInputBuffer[4]<<8) | fInputBuffer[5]; 00325 if ((u_int16_t)frameSize > 6+program_stream_map_length) { 00326 frameSize = 6+program_stream_map_length; 00327 } 00328 00329 u_int8_t versionByte = fInputBuffer[6]; 00330 if ((versionByte&0x80) == 0) return; // "current_next_indicator" is not set 00331 fCurrentInputProgramMapVersion = versionByte&0x1F; 00332 00333 u_int16_t program_stream_info_length = (fInputBuffer[8]<<8) | fInputBuffer[9]; 00334 unsigned offset = 10 + program_stream_info_length; // skip over 'descriptors' 00335 00336 u_int16_t elementary_stream_map_length 00337 = (fInputBuffer[offset]<<8) | fInputBuffer[offset+1]; 00338 offset += 2; 00339 frameSize -= 4; // sizeof CRC_32 00340 if (frameSize > offset + elementary_stream_map_length) { 00341 frameSize = offset + elementary_stream_map_length; 00342 } 00343 00344 while (offset + 4 <= frameSize) { 00345 u_int8_t stream_type = fInputBuffer[offset]; 00346 u_int8_t elementary_stream_id = fInputBuffer[offset+1]; 00347 00348 fPIDState[elementary_stream_id].streamType = stream_type; 00349 00350 u_int16_t elementary_stream_info_length 00351 = (fInputBuffer[offset+2]<<8) | fInputBuffer[offset+3]; 00352 offset += 4 + elementary_stream_info_length; 00353 } 00354 }
| Boolean FramedSource::lookupByName | ( | UsageEnvironment & | env, | |
| char const * | sourceName, | |||
| FramedSource *& | resultSource | |||
| ) | [static, inherited] |
Definition at line 41 of file FramedSource.cpp.
References env, False, MediaSource::isFramedSource(), MediaSource::lookupByName(), NULL, and True.
Referenced by MP3ADUinterleaverBase::getInputSource().
00042 { 00043 resultSource = NULL; // unless we succeed 00044 00045 MediaSource* source; 00046 if (!MediaSource::lookupByName(env, sourceName, source)) return False; 00047 00048 if (!source->isFramedSource()) { 00049 env.setResultMsg(sourceName, " is not a framed source"); 00050 return False; 00051 } 00052 00053 resultSource = (FramedSource*)source; 00054 return True; 00055 }
| Boolean MediaSource::lookupByName | ( | UsageEnvironment & | env, | |
| char const * | sourceName, | |||
| MediaSource *& | resultSource | |||
| ) | [static, inherited] |
Definition at line 62 of file MediaSource.cpp.
References env, False, Medium::isSource(), Medium::lookupByName(), NULL, and True.
Referenced by RTPSource::lookupByName(), and FramedSource::lookupByName().
00064 { 00065 resultSource = NULL; // unless we succeed 00066 00067 Medium* medium; 00068 if (!Medium::lookupByName(env, sourceName, medium)) return False; 00069 00070 if (!medium->isSource()) { 00071 env.setResultMsg(sourceName, " is not a media source"); 00072 return False; 00073 } 00074 00075 resultSource = (MediaSource*)medium; 00076 return True; 00077 }
| Boolean Medium::lookupByName | ( | UsageEnvironment & | env, | |
| char const * | mediumName, | |||
| Medium *& | resultMedium | |||
| ) | [static, inherited] |
Definition at line 65 of file Media.cpp.
References env, False, MediaLookupTable::lookup(), NULL, MediaLookupTable::ourMedia(), UsageEnvironment::setResultMsg(), and True.
Referenced by ServerMediaSession::lookupByName(), RTSPServer::lookupByName(), RTSPClient::lookupByName(), RTCPInstance::lookupByName(), MediaSource::lookupByName(), MediaSink::lookupByName(), MediaSession::lookupByName(), and DarwinInjector::lookupByName().
00066 { 00067 resultMedium = MediaLookupTable::ourMedia(env)->lookup(mediumName); 00068 if (resultMedium == NULL) { 00069 env.setResultMsg("Medium ", mediumName, " does not exist"); 00070 return False; 00071 } 00072 00073 return True; 00074 }
| void FramedSource::getNextFrame | ( | unsigned char * | to, | |
| unsigned | maxSize, | |||
| afterGettingFunc * | afterGettingFunc, | |||
| void * | afterGettingClientData, | |||
| onCloseFunc * | onCloseFunc, | |||
| void * | onCloseClientData | |||
| ) | [inherited] |
Definition at line 57 of file FramedSource.cpp.
References FramedSource::doGetNextFrame(), Medium::envir(), FramedSource::fAfterGettingClientData, FramedSource::fAfterGettingFunc, FramedSource::fDurationInMicroseconds, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fMaxSize, FramedSource::fNumTruncatedBytes, FramedSource::fOnCloseClientData, FramedSource::fOnCloseFunc, FramedSource::fTo, and True.
Referenced by MPEG2TransportStreamFramer::afterGettingFrame1(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromPESSource::awaitNewBuffer(), QuickTimeFileSink::continuePlaying(), DummySink::continuePlaying(), HTTPSink::continuePlaying(), FileSink::continuePlaying(), AVIFileSink::continuePlaying(), BasicUDPSink::continuePlaying1(), EndianSwap16::doGetNextFrame(), HostFromNetworkOrder16::doGetNextFrame(), NetworkFromHostOrder16::doGetNextFrame(), PCMFromuLawAudioSource::doGetNextFrame(), uLawFromPCMAudioSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG4VideoStreamDiscreteFramer::doGetNextFrame(), MPEG2TransportStreamFramer::doGetNextFrame(), MPEG2IFrameIndexFromTransportStream::doGetNextFrame(), MPEG1or2VideoStreamDiscreteFramer::doGetNextFrame(), MP3ADUTranscoder::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), ByteStreamMultiFileSource::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), SegmentQueue::enqueueNewSegment(), StreamParser::ensureValidBytes1(), MultiFramedRTPSink::packFrame(), AC3AudioStreamParser::readAndSaveAFrame(), and MPEG2TransportStreamTrickModeFilter::readTransportPacket().
00061 { 00062 // Make sure we're not already being read: 00063 if (fIsCurrentlyAwaitingData) { 00064 envir() << "FramedSource[" << this << "]::getNextFrame(): attempting to read more than once at the same time!\n"; 00065 exit(1); 00066 } 00067 00068 fTo = to; 00069 fMaxSize = maxSize; 00070 fNumTruncatedBytes = 0; // by default; could be changed by doGetNextFrame() 00071 fDurationInMicroseconds = 0; // by default; could be changed by doGetNextFrame() 00072 fAfterGettingFunc = afterGettingFunc; 00073 fAfterGettingClientData = afterGettingClientData; 00074 fOnCloseFunc = onCloseFunc; 00075 fOnCloseClientData = onCloseClientData; 00076 fIsCurrentlyAwaitingData = True; 00077 00078 doGetNextFrame(); 00079 }
| void FramedSource::handleClosure | ( | void * | clientData | ) | [static, inherited] |
Definition at line 95 of file FramedSource.cpp.
References False, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fOnCloseClientData, FramedSource::fOnCloseFunc, and NULL.
Referenced by MPEG2TransportStreamFramer::afterGettingFrame1(), MP3ADUTranscoder::afterGettingFrame1(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromPESSource::awaitNewBuffer(), WAVAudioFileSource::doGetNextFrame(), EndianSwap16::doGetNextFrame(), HostFromNetworkOrder16::doGetNextFrame(), NetworkFromHostOrder16::doGetNextFrame(), PCMFromuLawAudioSource::doGetNextFrame(), uLawFromPCMAudioSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG4VideoStreamDiscreteFramer::doGetNextFrame(), MPEG2TransportStreamFramer::doGetNextFrame(), MPEG1or2VideoStreamDiscreteFramer::doGetNextFrame(), MPEG1or2DemuxedElementaryStream::doGetNextFrame(), MP3FileSource::doGetNextFrame(), MP3ADUTranscoder::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), ADUFromMP3Source::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), DeviceSource::doGetNextFrame(), ByteStreamMultiFileSource::doGetNextFrame(), ByteStreamFileSource::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), ByteStreamFileSource::doReadFromFile(), SegmentQueue::enqueueNewSegment(), MPEG2IFrameIndexFromTransportStream::handleInputClosure1(), and MPEG2TransportStreamTrickModeFilter::onSourceClosure1().
00095 { 00096 FramedSource* source = (FramedSource*)clientData; 00097 source->fIsCurrentlyAwaitingData = False; // because we got a close instead 00098 if (source->fOnCloseFunc != NULL) { 00099 (*(source->fOnCloseFunc))(source->fOnCloseClientData); 00100 } 00101 }
| void FramedSource::stopGettingFrames | ( | ) | [inherited] |
Definition at line 103 of file FramedSource.cpp.
References FramedSource::doStopGettingFrames(), False, and FramedSource::fIsCurrentlyAwaitingData.
Referenced by MPEG2TransportStreamFromPESSource::doStopGettingFrames(), FramedFilter::doStopGettingFrames(), AMRDeinterleaver::doStopGettingFrames(), and MediaSink::stopPlaying().
00103 { 00104 fIsCurrentlyAwaitingData = False; // indicates that we can be read again 00105 00106 // Perform any specialized action now: 00107 doStopGettingFrames(); 00108 }
| unsigned FramedSource::maxFrameSize | ( | ) | const [virtual, inherited] |
Reimplemented in MPEG1or2DemuxedElementaryStream.
Definition at line 116 of file FramedSource.cpp.
Referenced by StreamParser::ensureValidBytes1().
| Boolean FramedSource::isCurrentlyAwaitingData | ( | ) | const [inline, inherited] |
Definition at line 60 of file FramedSource.hh.
References FramedSource::fIsCurrentlyAwaitingData.
Referenced by afterPlaying(), InputESSourceRecord::askForNewData(), MPEG2TransportStreamFromESSource::awaitNewBuffer(), QuickTimeFileSink::continuePlaying(), AVIFileSink::continuePlaying(), DeviceSource::deliverFrame(), QCELPDeinterleaver::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), ByteStreamFileSource::fileReadableHandler(), and BasicUDPSource::incomingPacketHandler1().
00060 {return fIsCurrentlyAwaitingData;}
| void FramedSource::afterGetting | ( | FramedSource * | source | ) | [static, protected, inherited] |
Definition at line 81 of file FramedSource.cpp.
References FramedSource::fAfterGettingClientData, FramedSource::fAfterGettingFunc, False, FramedSource::fDurationInMicroseconds, FramedSource::fFrameSize, FramedSource::fIsCurrentlyAwaitingData, FramedSource::fNumTruncatedBytes, FramedSource::fPresentationTime, and NULL.
Referenced by ByteStreamMultiFileSource::afterGettingFrame(), EndianSwap16::afterGettingFrame1(), HostFromNetworkOrder16::afterGettingFrame1(), NetworkFromHostOrder16::afterGettingFrame1(), PCMFromuLawAudioSource::afterGettingFrame1(), uLawFromPCMAudioSource::afterGettingFrame1(), MPEG2TransportStreamFramer::afterGettingFrame1(), MPEG1or2DemuxedElementaryStream::afterGettingFrame1(), MP3ADUTranscoder::afterGettingFrame1(), MPEG2TransportStreamTrickModeFilter::attemptDeliveryToClient(), MPEGVideoStreamFramer::continueReadProcessing(), MPEG1or2AudioStreamFramer::continueReadProcessing(), H263plusVideoStreamFramer::continueReadProcessing(), DeviceSource::deliverFrame(), MPEG2IFrameIndexFromTransportStream::deliverIndexRecord(), WAVAudioFileSource::doGetNextFrame(), QCELPDeinterleaver::doGetNextFrame(), MPEG2TransportStreamTrickModeFilter::doGetNextFrame(), doGetNextFrame(), MP3FileSource::doGetNextFrame(), MP3ADUdeinterleaver::doGetNextFrame(), MP3ADUinterleaver::doGetNextFrame(), MP3FromADUSource::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), AMRDeinterleaver::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), MultiFramedRTPSource::doGetNextFrame1(), ADUFromMP3Source::doGetNextFrame1(), ByteStreamFileSource::doReadFromFile(), BasicUDPSource::incomingPacketHandler1(), and AC3AudioStreamFramer::parseNextFrame().
00081 { 00082 source->fIsCurrentlyAwaitingData = False; 00083 // indicates that we can be read again 00084 // Note that this needs to be done here, in case the "fAfterFunc" 00085 // called below tries to read another frame (which it usually will) 00086 00087 if (source->fAfterGettingFunc != NULL) { 00088 (*(source->fAfterGettingFunc))(source->fAfterGettingClientData, 00089 source->fFrameSize, source->fNumTruncatedBytes, 00090 source->fPresentationTime, 00091 source->fDurationInMicroseconds); 00092 } 00093 }
| void FramedSource::doStopGettingFrames | ( | ) | [protected, virtual, inherited] |
Reimplemented in AMRDeinterleaver, BasicUDPSource, ByteStreamFileSource, FramedFilter, MPEG1or2DemuxedElementaryStream, MPEG2TransportStreamFramer, MPEG2TransportStreamFromESSource, MPEG2TransportStreamFromPESSource, MPEG2TransportStreamTrickModeFilter, and MultiFramedRTPSource.
Definition at line 110 of file FramedSource.cpp.
Referenced by FramedSource::stopGettingFrames().
00110 { 00111 // Default implementation: Do nothing 00112 // Subclasses may wish to specialize this so as to ensure that a 00113 // subsequent reader can pick up where this one left off. 00114 }
| void MediaSource::getAttributes | ( | ) | const [virtual, inherited] |
Reimplemented in FramedFilter, MP3ADUTranscoder, MP3FileSource, and RTPSource.
Definition at line 79 of file MediaSource.cpp.
References Medium::envir(), and UsageEnvironment::setResultMsg().
Referenced by MP3ADUTranscoder::getAttributes(), and FramedFilter::getAttributes().
00079 { 00080 // Default implementation 00081 envir().setResultMsg(""); 00082 }
| char const * MediaSource::MIMEtype | ( | ) | const [virtual, inherited] |
Reimplemented in RawAMRRTPSource, AC3AudioRTPSource,