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


Public Types | |
| typedef void( | afterGettingFunc )(void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) |
| typedef void( | onCloseFunc )(void *clientData) |
Public Member Functions | |
| u_int8_t | profile_and_level_indication () const |
| unsigned char * | getConfigBytes (unsigned &numBytes) const |
| Boolean & | pictureEndMarker () |
| void | flushInput () |
| FramedSource * | inputSource () const |
| 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 Boolean | isRTPSource () const |
| virtual Boolean | isMPEG1or2VideoStreamFramer () 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 MPEG4VideoStreamDiscreteFramer * | createNew (UsageEnvironment &env, FramedSource *inputSource) |
| 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 | |
| MPEG4VideoStreamDiscreteFramer (UsageEnvironment &env, FramedSource *inputSource) | |
| virtual | ~MPEG4VideoStreamDiscreteFramer () |
| virtual void | doGetNextFrame () |
| void | afterGettingFrame1 (unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) |
| Boolean | getNextFrameBit (u_int8_t &result) |
| Boolean | getNextFrameBits (unsigned numBits, u_int32_t &result) |
| void | analyzeVOLHeader () |
| void | startNewConfig () |
| void | appendToNewConfig (unsigned char *newConfigBytes, unsigned numNewBytes) |
| void | completeNewConfig () |
| void | computePresentationTime (unsigned numAdditionalPictures) |
| void | setTimeCode (unsigned hours, unsigned minutes, unsigned seconds, unsigned pictures, unsigned picturesSinceLastGOP) |
| virtual char const * | MIMEtype () const |
| virtual void | getAttributes () const |
| virtual void | doStopGettingFrames () |
| TaskToken & | nextTask () |
Static Protected Member Functions | |
| static void | afterGettingFrame (void *clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) |
| static void | afterGetting (FramedSource *source) |
Protected Attributes | |
| u_int32_t | vop_time_increment_resolution |
| unsigned | fNumVTIRBits |
| timeval | fLastNonBFramePresentationTime |
| unsigned | fLastNonBFrameVop_time_increment |
| u_int8_t | fProfileAndLevelIndication |
| unsigned char * | fConfigBytes |
| unsigned | fNumConfigBytes |
| double | fFrameRate |
| unsigned | fPictureCount |
| Boolean | fPictureEndMarker |
| MPEGVideoStreamParser * | fParser |
| FramedSource * | fInputSource |
| unsigned char * | fTo |
| unsigned | fMaxSize |
| unsigned | fFrameSize |
| unsigned | fNumTruncatedBytes |
| timeval | fPresentationTime |
| unsigned | fDurationInMicroseconds |
Private Attributes | |
| unsigned | fNumBitsSeenSoFar |
Friends | |
| class | MPEGVideoStreamParser |
Definition at line 31 of file MPEG4VideoStreamDiscreteFramer.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.
| MPEG4VideoStreamDiscreteFramer::MPEG4VideoStreamDiscreteFramer | ( | UsageEnvironment & | env, | |
| FramedSource * | inputSource | |||
| ) | [protected] |
Definition at line 34 of file MPEG4VideoStreamDiscreteFramer.cpp.
References fLastNonBFramePresentationTime.
Referenced by createNew().
00036 : MPEG4VideoStreamFramer(env, inputSource, False/*don't create a parser*/), 00037 vop_time_increment_resolution(0), fNumVTIRBits(0), 00038 fLastNonBFrameVop_time_increment(0) { 00039 fLastNonBFramePresentationTime.tv_sec = 0; 00040 fLastNonBFramePresentationTime.tv_usec = 0; 00041 }
| MPEG4VideoStreamDiscreteFramer::~MPEG4VideoStreamDiscreteFramer | ( | ) | [protected, virtual] |
| MPEG4VideoStreamDiscreteFramer * MPEG4VideoStreamDiscreteFramer::createNew | ( | UsageEnvironment & | env, | |
| FramedSource * | inputSource | |||
| ) | [static] |
Reimplemented from MPEG4VideoStreamFramer.
Definition at line 27 of file MPEG4VideoStreamDiscreteFramer.cpp.
References env, FramedFilter::inputSource(), and MPEG4VideoStreamDiscreteFramer().
00028 { 00029 // Need to add source type checking here??? ##### 00030 return new MPEG4VideoStreamDiscreteFramer(env, inputSource); 00031 }
| void MPEG4VideoStreamDiscreteFramer::doGetNextFrame | ( | ) | [protected, virtual] |
Reimplemented from MPEGVideoStreamFramer.
Definition at line 46 of file MPEG4VideoStreamDiscreteFramer.cpp.
References afterGettingFrame(), FramedFilter::fInputSource, FramedSource::fMaxSize, FramedSource::fTo, FramedSource::getNextFrame(), and FramedSource::handleClosure().
00046 { 00047 // Arrange to read data (which should be a complete MPEG-4 video frame) 00048 // from our data source, directly into the client's input buffer. 00049 // After reading this, we'll do some parsing on the frame. 00050 fInputSource->getNextFrame(fTo, fMaxSize, 00051 afterGettingFrame, this, 00052 FramedSource::handleClosure, this); 00053 }
| void MPEG4VideoStreamDiscreteFramer::afterGettingFrame | ( | void * | clientData, | |
| unsigned | frameSize, | |||
| unsigned | numTruncatedBytes, | |||
| struct timeval | presentationTime, | |||
| unsigned | durationInMicroseconds | |||
| ) | [static, protected] |
Definition at line 56 of file MPEG4VideoStreamDiscreteFramer.cpp.
References afterGettingFrame1().
Referenced by doGetNextFrame().
00059 { 00060 MPEG4VideoStreamDiscreteFramer* source = (MPEG4VideoStreamDiscreteFramer*)clientData; 00061 source->afterGettingFrame1(frameSize, numTruncatedBytes, 00062 presentationTime, durationInMicroseconds); 00063 }
| void MPEG4VideoStreamDiscreteFramer::afterGettingFrame1 | ( | unsigned | frameSize, | |
| unsigned | numTruncatedBytes, | |||
| struct timeval | presentationTime, | |||
| unsigned | durationInMicroseconds | |||
| ) | [protected] |
Definition at line 66 of file MPEG4VideoStreamDiscreteFramer.cpp.
References analyzeVOLHeader(), MPEG4VideoStreamFramer::fConfigBytes, fLastNonBFramePresentationTime, fLastNonBFrameVop_time_increment, MPEG4VideoStreamFramer::fNumConfigBytes, fNumVTIRBits, MPEGVideoStreamFramer::fPictureEndMarker, MPEG4VideoStreamFramer::fProfileAndLevelIndication, FramedSource::fTo, if(), MILLION, True, and vop_time_increment_resolution.
Referenced by afterGettingFrame().
00068 { 00069 // Check that the first 4 bytes are a system code: 00070 if (frameSize >= 4 && fTo[0] == 0 && fTo[1] == 0 && fTo[2] == 1) { 00071 fPictureEndMarker = True; // Assume that we have a complete 'picture' here 00072 unsigned i = 3; 00073 if (fTo[i] == 0xB0) { // VISUAL_OBJECT_SEQUENCE_START_CODE 00074 // The next byte is the "profile_and_level_indication": 00075 if (frameSize >= 5) fProfileAndLevelIndication = fTo[4]; 00076 00077 // The start of this frame - up to the first GROUP_VOP_START_CODE 00078 // or VOP_START_CODE - is stream configuration information. Save this: 00079 for (i = 7; i < frameSize; ++i) { 00080 if ((fTo[i] == 0xB3 /*GROUP_VOP_START_CODE*/ || 00081 fTo[i] == 0xB6 /*VOP_START_CODE*/) 00082 && fTo[i-1] == 1 && fTo[i-2] == 0 && fTo[i-3] == 0) { 00083 break; // The configuration information ends here 00084 } 00085 } 00086 fNumConfigBytes = i < frameSize ? i-3 : frameSize; 00087 delete[] fConfigBytes; fConfigBytes = new unsigned char[fNumConfigBytes]; 00088 for (unsigned j = 0; j < fNumConfigBytes; ++j) fConfigBytes[j] = fTo[j]; 00089 00090 // This information (should) also contain a VOL header, which we need 00091 // to analyze, to get "vop_time_increment_resolution" (which we need 00092 // - along with "vop_time_increment" - in order to generate accurate 00093 // presentation times for "B" frames). 00094 analyzeVOLHeader(); 00095 } 00096 00097 if (i < frameSize) { 00098 u_int8_t nextCode = fTo[i]; 00099 00100 if (nextCode == 0xB3 /*GROUP_VOP_START_CODE*/) { 00101 // Skip to the following VOP_START_CODE (if any): 00102 for (i += 4; i < frameSize; ++i) { 00103 if (fTo[i] == 0xB6 /*VOP_START_CODE*/ 00104 && fTo[i-1] == 1 && fTo[i-2] == 0 && fTo[i-3] == 0) { 00105 nextCode = fTo[i]; 00106 break; 00107 } 00108 } 00109 } 00110 00111 if (nextCode == 0xB6 /*VOP_START_CODE*/ && i+5 < frameSize) { 00112 ++i; 00113 00114 // Get the "vop_coding_type" from the next byte: 00115 u_int8_t nextByte = fTo[i++]; 00116 u_int8_t vop_coding_type = nextByte>>6; 00117 00118 // Next, get the "modulo_time_base" by counting the '1' bits that 00119 // follow. We look at the next 32-bits only. 00120 // This should be enough in most cases. 00121 u_int32_t next4Bytes 00122 = (fTo[i]<<24)|(fTo[i+1]<<16)|(fTo[i+2]<<8)|fTo[i+3]; 00123 i += 4; 00124 u_int32_t timeInfo = (nextByte<<(32-6))|(next4Bytes>>6); 00125 unsigned modulo_time_base = 0; 00126 u_int32_t mask = 0x80000000; 00127 while ((timeInfo&mask) != 0) { 00128 ++modulo_time_base; 00129 mask >>= 1; 00130 } 00131 mask >>= 2; 00132 00133 // Then, get the "vop_time_increment". 00134 unsigned vop_time_increment = 0; 00135 // First, make sure we have enough bits left for this: 00136 if ((mask>>(fNumVTIRBits-1)) != 0) { 00137 for (unsigned i = 0; i < fNumVTIRBits; ++i) { 00138 vop_time_increment |= timeInfo&mask; 00139 mask >>= 1; 00140 } 00141 while (mask != 0) { 00142 vop_time_increment >>= 1; 00143 mask >>= 1; 00144 } 00145 } 00146 00147 // If this is a "B" frame, then we have to tweak "presentationTime": 00148 if (vop_coding_type == 2/*B*/ 00149 && (fLastNonBFramePresentationTime.tv_usec > 0 || 00150 fLastNonBFramePresentationTime.tv_sec > 0)) { 00151 int timeIncrement 00152 = fLastNonBFrameVop_time_increment - vop_time_increment; 00153 if (timeIncrement<0) timeIncrement += vop_time_increment_resolution; 00154 unsigned const MILLION = 1000000; 00155 double usIncrement = vop_time_increment_resolution == 0 ? 0.0 00156 : ((double)timeIncrement*MILLION)/vop_time_increment_resolution; 00157 unsigned secondsToSubtract = (unsigned)(usIncrement/MILLION); 00158 unsigned uSecondsToSubtract = ((unsigned)usIncrement)%MILLION; 00159 00160 presentationTime = fLastNonBFramePresentationTime; 00161 if ((unsigned)presentationTime.tv_usec < uSecondsToSubtract) { 00162 presentationTime.tv_usec += MILLION; 00163 if (presentationTime.tv_sec > 0) --presentationTime.tv_sec; 00164 } 00165 presentationTime.tv_usec -= uSecondsToSubtract; 00166 if ((unsigned)presentationTime.tv_sec > secondsToSubtract) { 00167 presentationTime.tv_sec -= secondsToSubtract; 00168 } else { 00169 presentationTime.tv_sec = presentationTime.tv_usec = 0; 00170 } 00171 } else { 00172 fLastNonBFramePresentationTime = presentationTime; 00173 fLastNonBFrameVop_time_increment = vop_time_increment; 00174 } 00175 } 00176 } 00177 } 00178 00179 // Complete delivery to the client: 00180 fFrameSize = frameSize; 00181 fNumTruncatedBytes = numTruncatedBytes; 00182 fPresentationTime = presentationTime; 00183 fDurationInMicroseconds = durationInMicroseconds; 00184 afterGetting(this); 00185 }
| Boolean MPEG4VideoStreamDiscreteFramer::getNextFrameBit | ( | u_int8_t & | result | ) | [protected] |
Definition at line 187 of file MPEG4VideoStreamDiscreteFramer.cpp.
References False, MPEG4VideoStreamFramer::fConfigBytes, fNumBitsSeenSoFar, MPEG4VideoStreamFramer::fNumConfigBytes, and True.
Referenced by analyzeVOLHeader(), and getNextFrameBits().
00187 { 00188 if (fNumBitsSeenSoFar/8 >= fNumConfigBytes) return False; 00189 00190 u_int8_t nextByte = fConfigBytes[fNumBitsSeenSoFar/8]; 00191 result = (nextByte>>(7-fNumBitsSeenSoFar%8))&1; 00192 ++fNumBitsSeenSoFar; 00193 return True; 00194 }
| Boolean MPEG4VideoStreamDiscreteFramer::getNextFrameBits | ( | unsigned | numBits, | |
| u_int32_t & | result | |||
| ) | [protected] |
Definition at line 196 of file MPEG4VideoStreamDiscreteFramer.cpp.
References False, getNextFrameBit(), and True.
Referenced by analyzeVOLHeader().
00197 { 00198 result = 0; 00199 for (unsigned i = 0; i < numBits; ++i) { 00200 u_int8_t nextBit; 00201 if (!getNextFrameBit(nextBit)) return False; 00202 result = (result<<1)|nextBit; 00203 } 00204 return True; 00205 }
| void MPEG4VideoStreamDiscreteFramer::analyzeVOLHeader | ( | ) | [protected] |
Definition at line 207 of file MPEG4VideoStreamDiscreteFramer.cpp.
References MPEG4VideoStreamFramer::fConfigBytes, fNumBitsSeenSoFar, MPEG4VideoStreamFramer::fNumConfigBytes, fNumVTIRBits, getNextFrameBit(), getNextFrameBits(), and vop_time_increment_resolution.
Referenced by afterGettingFrame1().
00207 { 00208 // Begin by moving to the VOL header: 00209 unsigned i; 00210 for (i = 3; i < fNumConfigBytes; ++i) { 00211 if (fConfigBytes[i] >= 0x20 && fConfigBytes[i] <= 0x2F 00212 && fConfigBytes[i-1] == 1 00213 && fConfigBytes[i-2] == 0 && fConfigBytes[i-3] == 0) { 00214 ++i; 00215 break; 00216 } 00217 } 00218 00219 fNumBitsSeenSoFar = 8*i + 9; 00220 do { 00221 u_int8_t is_object_layer_identifier; 00222 if (!getNextFrameBit(is_object_layer_identifier)) break; 00223 if (is_object_layer_identifier) fNumBitsSeenSoFar += 7; 00224 00225 u_int32_t aspect_ratio_info; 00226 if (!getNextFrameBits(4, aspect_ratio_info)) break; 00227 if (aspect_ratio_info == 15 /*extended_PAR*/) fNumBitsSeenSoFar += 16; 00228 00229 u_int8_t vol_control_parameters; 00230 if (!getNextFrameBit(vol_control_parameters)) break; 00231 if (vol_control_parameters) { 00232 fNumBitsSeenSoFar += 3; // chroma_format; low_delay 00233 u_int8_t vbw_parameters; 00234 if (!getNextFrameBit(vbw_parameters)) break; 00235 if (vbw_parameters) fNumBitsSeenSoFar += 79; 00236 } 00237 00238 fNumBitsSeenSoFar += 2; // video_object_layer_shape 00239 u_int8_t marker_bit; 00240 if (!getNextFrameBit(marker_bit)) break; 00241 if (marker_bit != 1) break; // sanity check 00242 00243 if (!getNextFrameBits(16, vop_time_increment_resolution)) break; 00244 if (vop_time_increment_resolution == 0) break; // shouldn't happen 00245 00246 // Compute how many bits are necessary to represent this: 00247 fNumVTIRBits = 0; 00248 for (unsigned test = vop_time_increment_resolution; test>0; test /= 2) { 00249 ++fNumVTIRBits; 00250 } 00251 } while (0); 00252 }
| u_int8_t MPEG4VideoStreamFramer::profile_and_level_indication | ( | ) | const [inline, inherited] |
Definition at line 38 of file MPEG4VideoStreamFramer.hh.
References MPEG4VideoStreamFramer::fProfileAndLevelIndication.
Referenced by MPEG4ESVideoRTPSink::auxSDPLine().
00038 { 00039 return fProfileAndLevelIndication; 00040 }
| unsigned char * MPEG4VideoStreamFramer::getConfigBytes | ( | unsigned & | numBytes | ) | const [inherited] |
Definition at line 97 of file MPEG4VideoStreamFramer.cpp.
References MPEG4VideoStreamFramer::fConfigBytes, and MPEG4VideoStreamFramer::fNumConfigBytes.
Referenced by MPEG4ESVideoRTPSink::auxSDPLine().
00097 { 00098 numBytes = fNumConfigBytes; 00099 return fConfigBytes; 00100 }
| void MPEG4VideoStreamFramer::startNewConfig | ( | ) | [protected, inherited] |
Definition at line 118 of file MPEG4VideoStreamFramer.cpp.
References MPEG4VideoStreamFramer::fNewConfigBytes, MPEG4VideoStreamFramer::fNumNewConfigBytes, and NULL.
Referenced by MPEG4VideoStreamParser::parseVisualObjectSequence().
00118 { 00119 delete[] fNewConfigBytes; fNewConfigBytes = NULL; 00120 fNumNewConfigBytes = 0; 00121 }
| void MPEG4VideoStreamFramer::appendToNewConfig | ( | unsigned char * | newConfigBytes, | |
| unsigned | numNewBytes | |||
| ) | [protected, inherited] |
Definition at line 124 of file MPEG4VideoStreamFramer.cpp.
References MPEG4VideoStreamFramer::fNewConfigBytes, and MPEG4VideoStreamFramer::fNumNewConfigBytes.
Referenced by MPEG4VideoStreamParser::parseVideoObjectLayer(), MPEG4VideoStreamParser::parseVisualObject(), and MPEG4VideoStreamParser::parseVisualObjectSequence().
00124 { 00125 // Allocate a new block of memory for the new config bytes: 00126 unsigned char* configNew 00127 = new unsigned char[fNumNewConfigBytes + numNewBytes]; 00128 00129 // Copy the old, then the new, config bytes there: 00130 memmove(configNew, fNewConfigBytes, fNumNewConfigBytes); 00131 memmove(&configNew[fNumNewConfigBytes], newConfigBytes, numNewBytes); 00132 00133 delete[] fNewConfigBytes; fNewConfigBytes = configNew; 00134 fNumNewConfigBytes += numNewBytes; 00135 }
| void MPEG4VideoStreamFramer::completeNewConfig | ( | ) | [protected, inherited] |
Definition at line 137 of file MPEG4VideoStreamFramer.cpp.
References MPEG4VideoStreamFramer::fConfigBytes, MPEG4VideoStreamFramer::fNewConfigBytes, MPEG4VideoStreamFramer::fNumConfigBytes, MPEG4VideoStreamFramer::fNumNewConfigBytes, and NULL.
Referenced by MPEG4VideoStreamParser::parseVideoObjectLayer().
00137 { 00138 delete[] fConfigBytes; fConfigBytes = fNewConfigBytes; 00139 fNewConfigBytes = NULL; 00140 fNumConfigBytes = fNumNewConfigBytes; 00141 fNumNewConfigBytes = 0; 00142 }
| Boolean& MPEGVideoStreamFramer::pictureEndMarker | ( | ) | [inline, inherited] |
Definition at line 40 of file MPEGVideoStreamFramer.hh.
References MPEGVideoStreamFramer::fPictureEndMarker.
Referenced by MPEG4ESVideoRTPSink::doSpecialFrameHandling(), and MPEG1or2VideoRTPSink::doSpecialFrameHandling().
00040 { return fPictureEndMarker; }
| void MPEGVideoStreamFramer::flushInput | ( | ) | [inherited] |
Definition at line 53 of file MPEGVideoStreamFramer.cpp.
References StreamParser::flushInput(), MPEGVideoStreamFramer::fParser, NULL, and MPEGVideoStreamFramer::reset().
Referenced by MPEG1or2DemuxedServerMediaSubsession::seekStreamSource().
00053 { 00054 reset(); 00055 if (fParser != NULL) fParser->flushInput(); 00056 }
| void MPEGVideoStreamFramer::computePresentationTime | ( | unsigned | numAdditionalPictures | ) | [protected, inherited] |
Definition at line 74 of file MPEGVideoStreamFramer.cpp.
References TimeCode::days, MPEGVideoStreamFramer::fCurGOPTimeCode, MPEGVideoStreamFramer::fFrameRate, MPEGVideoStreamFramer::fPicturesAdjustment, MPEGVideoStreamFramer::fPictureTimeBase, FramedSource::fPresentationTime, MPEGVideoStreamFramer::fPresentationTimeBase, MPEGVideoStreamFramer::fTcSecsBase, TimeCode::hours, TimeCode::minutes, TimeCode::pictures, and TimeCode::seconds.
Referenced by MPEG1or2VideoStreamParser::parseGOPHeader(), MPEG4VideoStreamParser::parseGroupOfVideoObjectPlane(), MPEG1or2VideoStreamParser::parsePictureHeader(), MPEG1or2VideoStreamParser::parseSlice(), MPEG4VideoStreamParser::parseVideoObjectLayer(), MPEG4VideoStreamParser::parseVideoObjectPlane(), MPEG1or2VideoStreamParser::parseVideoSequenceHeader(), MPEG4VideoStreamParser::parseVisualObject(), and MPEG4VideoStreamParser::parseVisualObjectSequence().
00074 { 00075 // Computes "fPresentationTime" from the most recent GOP's 00076 // time_code, along with the "numAdditionalPictures" parameter: 00077 TimeCode& tc = fCurGOPTimeCode; 00078 00079 unsigned tcSecs 00080 = (((tc.days*24)+tc.hours)*60+tc.minutes)*60+tc.seconds - fTcSecsBase; 00081 double pictureTime = fFrameRate == 0.0 ? 0.0 00082 : (tc.pictures + fPicturesAdjustment + numAdditionalPictures)/fFrameRate; 00083 while (pictureTime < fPictureTimeBase) { // "if" should be enough, but just in case 00084 if (tcSecs > 0) tcSecs -= 1; 00085 pictureTime += 1.0; 00086 } 00087 pictureTime -= fPictureTimeBase; 00088 if (pictureTime < 0.0) pictureTime = 0.0; // sanity check 00089 unsigned pictureSeconds = (unsigned)pictureTime; 00090 double pictureFractionOfSecond = pictureTime - (double)pictureSeconds; 00091 00092 fPresentationTime = fPresentationTimeBase; 00093 fPresentationTime.tv_sec += tcSecs + pictureSeconds; 00094 fPresentationTime.tv_usec += (long)(pictureFractionOfSecond*1000000.0); 00095 if (fPresentationTime.tv_usec >= 1000000) { 00096 fPresentationTime.tv_usec -= 1000000; 00097 ++fPresentationTime.tv_sec; 00098 } 00099 #ifdef DEBUG 00100 if (firstPT.tv_sec == 0 && firstPT.tv_usec == 0) firstPT = fPresentationTime; 00101 struct timeval diffPT; 00102 diffPT.tv_sec = fPresentationTime.tv_sec - firstPT.tv_sec; 00103 diffPT.tv_usec = fPresentationTime.tv_usec - firstPT.tv_usec; 00104 if (fPresentationTime.tv_usec < firstPT.tv_usec) { 00105 --diffPT.tv_sec; 00106 diffPT.tv_usec += 1000000; 00107 } 00108 fprintf(stderr, "MPEGVideoStreamFramer::computePresentationTime(%d) -> %lu.%06ld [%lu.%06ld]\n", numAdditionalPictures, fPresentationTime.tv_sec, fPresentationTime.tv_usec, diffPT.tv_sec, diffPT.tv_usec); 00109 #endif 00110 }
| void MPEGVideoStreamFramer::setTimeCode | ( | unsigned | hours, | |
| unsigned | minutes, | |||
| unsigned | seconds, | |||
| unsigned | pictures, | |||
| unsigned | picturesSinceLastGOP | |||
| ) | [protected, inherited] |
Definition at line 113 of file MPEGVideoStreamFramer.cpp.
References TimeCode::days, MPEGVideoStreamFramer::fCurGOPTimeCode, MPEGVideoStreamFramer::fFrameRate, MPEGVideoStreamFramer::fHaveSeenFirstTimeCode, MPEGVideoStreamFramer::fPicturesAdjustment, MPEGVideoStreamFramer::fPictureTimeBase, MPEGVideoStreamFramer::fPrevGOPTimeCode, MPEGVideoStreamFramer::fTcSecsBase, TimeCode::hours, TimeCode::minutes, TimeCode::pictures, TimeCode::seconds, and True.
Referenced by MPEG1or2VideoStreamParser::parseGOPHeader(), and MPEG4VideoStreamParser::parseGroupOfVideoObjectPlane().
00114 { 00115 TimeCode& tc = fCurGOPTimeCode; // abbrev 00116 unsigned days = tc.days; 00117 if (hours < tc.hours) { 00118 // Assume that the 'day' has wrapped around: 00119 ++days; 00120 } 00121 tc.days = days; 00122 tc.hours = hours; 00123 tc.minutes = minutes; 00124 tc.seconds = seconds; 00125 tc.pictures = pictures; 00126 if (!fHaveSeenFirstTimeCode) { 00127 fPictureTimeBase = fFrameRate == 0.0 ? 0.0 : tc.pictures/fFrameRate; 00128 fTcSecsBase = (((tc.days*24)+tc.hours)*60+tc.minutes)*60+tc.seconds; 00129 fHaveSeenFirstTimeCode = True; 00130 } else if (fCurGOPTimeCode == fPrevGOPTimeCode) { 00131 // The time code has not changed since last time. Adjust for this: 00132 fPicturesAdjustment += picturesSinceLastGOP; 00133 } else { 00134 // Normal case: The time code changed since last time. 00135 fPrevGOPTimeCode = tc; 00136 fPicturesAdjustment = 0; 00137 } 00138 }
| FramedSource* FramedFilter::inputSource | ( | ) | const [inline, inherited] |
Definition at line 30 of file FramedFilter.hh.
References FramedFilter::fInputSource.
Referenced by AC3AudioStreamFramer::AC3AudioStreamFramer(), EndianSwap16::createNew(), HostFromNetworkOrder16::createNew(), NetworkFromHostOrder16::createNew(), PCMFromuLawAudioSource::createNew(), QCELPDeinterleaver::createNew(), MPEG4VideoStreamFramer::createNew(), createNew(), MPEG2IFrameIndexFromTransportStream::createNew(), MPEG1or2VideoStreamFramer::createNew(), MPEG1or2VideoStreamDiscreteFramer::createNew(), MPEG1or2AudioStreamFramer::createNew(), MP3Transcoder::createNew(), MP3ADUTranscoder::createNew(), MP3ADUdeinterleaver::createNew(), MP3ADUinterleaver::createNew(), MP3FromADUSource::createNew(), ADUFromMP3Source::createNew(), H263plusVideoStreamFramer::createNew(), AC3AudioStreamFramer::createNew(), H264VideoRTPSink::doSpecialFrameHandling(), MP3ADUinterleaverBase::getInputSource(), H263plusVideoStreamFramer::H263plusVideoStreamFramer(), MPEG1or2VideoStreamFramer::MPEG1or2VideoStreamFramer(), MPEG4VideoStreamFramer::MPEG4VideoStreamFramer(), MP3AudioFileServerMediaSubsession::seekStreamSource(), ClientTrickPlayState::setSource(), and MP3AudioFileServerMediaSubsession::setStreamSourceScale().
00030 { return fInputSource; }
| char const * FramedFilter::MIMEtype | ( | ) | const [protected, virtual, inherited] |
Reimplemented from MediaSource.
Reimplemented in ADUFromMP3Source, and MP3FromADUSource.
Definition at line 39 of file FramedFilter.cpp.
References FramedFilter::fInputSource, MediaSource::MIMEtype(), and NULL.
00039 { 00040 if (fInputSource == NULL) return ""; 00041 00042 return fInputSource->MIMEtype(); 00043 }
| void FramedFilter::getAttributes | ( | ) | const [protected, virtual, inherited] |
Reimplemented from MediaSource.
Reimplemented in MP3ADUTranscoder.
Definition at line 45 of file FramedFilter.cpp.
References FramedFilter::fInputSource, MediaSource::getAttributes(), and NULL.
00045 { 00046 if (fInputSource != NULL) fInputSource->getAttributes(); 00047 }
| void FramedFilter::doStopGettingFrames | ( | ) | [protected, virtual, inherited] |
Reimplemented from FramedSource.
Reimplemented in MPEG2TransportStreamFramer, and MPEG2TransportStreamTrickModeFilter.
Definition at line 49 of file FramedFilter.cpp.
References FramedFilter::fInputSource, NULL, and FramedSource::stopGettingFrames().
Referenced by MPEG2TransportStreamTrickModeFilter::doStopGettingFrames(), and MPEG2TransportStreamFramer::doStopGettingFrames().
00049 { 00050 if (fInputSource != NULL) fInputSource->stopGettingFrames(); 00051 }
| 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()<