montage-tech/src/kware/demux_mp/mplayer/libmpdemux/demux_rtp.cpp
// >= the largest conceivable frame composed from one or more RTP packets
>= the largest conceivable frame composed from one or more RTP packets
> = the largest conceivable frame composed from one or more RTP packets
static void afterReading(void* clientData, unsigned frameSize,
		unsigned ,
		struct timeval presentationTime,
		unsigned ) {
	int headersize = 0;
	if (frameSize >= MAX_RTP_FRAME_SIZE) {
#ifdef __LINUX__	  	  	
		fprintf(stderr, "Saw an input frame too large (>=%d).  Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
				MAX_RTP_FRAME_SIZE);
#else
		OS_PRINTF("Saw an input frame too large (>=%d).  Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
				MAX_RTP_FRAME_SIZE);
#endif
	}
	ReadBufferQueue* bufferQueue = (ReadBufferQueue*)clientData;
	demuxer_t* demuxer = bufferQueue->ourDemuxer();
	RTPState* rtpState = (RTPState*)(demuxer->priv);
	if (frameSize > 0) 
		demuxer->stream->eof = 0;
	demux_packet_t* dp = bufferQueue->dp;
	if (bufferQueue->readSource()->isAMRAudioSource())
		headersize = 1;
	else if (bufferQueue == rtpState->videoBufferQueue &&
			((sh_video_t*)demuxer->video->sh)->format == mmioFOURCC('H','2','6','4')) {
		dp->buffer[0]=0x00;
		dp->buffer[1]=0x00;
		dp->buffer[2]=0x01;
		headersize = 3;
	}
	resize_demux_packet(dp, frameSize + headersize);
	Boolean hasBeenSynchronized
		= bufferQueue->rtpSource()->hasBeenSynchronizedUsingRTCP();
	hasBeenSynchronized = 1;
	if (hasBeenSynchronized) {
		if (verbose > 0 && !bufferQueue->prevPacketWasSynchronized) {
#ifdef __LINUX__	  			
			fprintf(stderr, "%s stream has been synchronized using RTCP \n",
					bufferQueue->tag());
#else
			OS_PRINTF("%s stream has been synchronized using RTCP \n",
					bufferQueue->tag());
#endif
		}
		struct timeval* fst = &(rtpState->firstSyncTime); 
		if (fst->tv_sec == 0 && fst->tv_usec == 0) {
			*fst = presentationTime;
			OS_PRINTF("[%s] -------- update fst with present time [%d %d]\n",__func__,\
	(int)(fst->tv_sec),(int)(fst->tv_usec));
		}
		dp->pts = presentationTime.tv_sec - fst->tv_sec
			+ (presentationTime.tv_usec - fst->tv_usec)/1000000.0;
		bufferQueue->prevPacketPTS = dp->pts;
	} else {
		if (verbose > 0 && bufferQueue->prevPacketWasSynchronized) {
#ifdef __LINUX__	  			
			fprintf(stderr, "%s stream is no longer RTCP-synchronized \n",
					bufferQueue->tag());
#else
			OS_PRINTF("%s stream is no longer RTCP-synchronized \n",
					bufferQueue->tag());
#endif
		}
		dp->pts = bufferQueue->prevPacketPTS;
	}
	bufferQueue->prevPacketWasSynchronized = hasBeenSynchronized;
	dp->pos = demuxer->filepos;
	demuxer->filepos += frameSize + headersize;
	bufferQueue->blockingFlag = ~0;
}
static void afterReading ( void * clientData , unsigned frameSize , unsigned , struct timeval presentationTime , unsigned ) { int headersize = 0 ; if ( frameSize >= MAX_RTP_FRAME_SIZE ) { #ifdef __LINUX__ fprintf ( stderr , " \" \" \n " , MAX_RTP_FRAME_SIZE ) ; #else OS_PRINTF ( " \" \" \n " , MAX_RTP_FRAME_SIZE ) ; #endif } ReadBufferQueue * bufferQueue = ( ReadBufferQueue * ) clientData ; demuxer_t * demuxer = bufferQueue -> ourDemuxer ( ) ; RTPState * rtpState = ( RTPState * ) ( demuxer -> priv ) ; if ( frameSize > 0 ) demuxer -> stream -> eof = 0 ; demux_packet_t * dp = bufferQueue -> dp ; if ( bufferQueue -> readSource ( ) -> isAMRAudioSource ( ) ) headersize = 1 ; else if ( bufferQueue == rtpState -> videoBufferQueue && ( ( sh_video_t * ) demuxer -> video -> sh ) -> format == mmioFOURCC ( ' ' , ' ' , ' ' , ' ' ) ) { dp -> buffer [ 0 ] = 0x00 ; dp -> buffer [ 1 ] = 0x00 ; dp -> buffer [ 2 ] = 0x01 ; headersize = 3 ; } resize_demux_packet ( dp , frameSize + headersize ) ; Boolean hasBeenSynchronized = bufferQueue -> rtpSource ( ) -> hasBeenSynchronizedUsingRTCP ( ) ; hasBeenSynchronized = 1 ; if ( hasBeenSynchronized ) { if ( verbose > 0 && ! bufferQueue -> prevPacketWasSynchronized ) { #ifdef __LINUX__ fprintf ( stderr , " \n " , bufferQueue -> tag ( ) ) ; #else OS_PRINTF ( " \n " , bufferQueue -> tag ( ) ) ; #endif } struct timeval * fst = & ( rtpState -> firstSyncTime ) ; if ( fst -> tv_sec == 0 && fst -> tv_usec == 0 ) { * fst = presentationTime ; OS_PRINTF ( " \n " , __func__ , ( int ) ( fst -> tv_sec ) , ( int ) ( fst -> tv_usec ) ) ; } dp -> pts = presentationTime . tv_sec - fst -> tv_sec + ( presentationTime . tv_usec - fst -> tv_usec ) / 1000000.0 ; bufferQueue -> prevPacketPTS = dp -> pts ; } else { if ( verbose > 0 && bufferQueue -> prevPacketWasSynchronized ) { #ifdef __LINUX__ fprintf ( stderr , " \n " , bufferQueue -> tag ( ) ) ; #else OS_PRINTF ( " \n " , bufferQueue -> tag ( ) ) ; #endif } dp -> pts = bufferQueue -> prevPacketPTS ; } bufferQueue -> prevPacketWasSynchronized = hasBeenSynchronized ; dp -> pos = demuxer -> filepos ; demuxer -> filepos += frameSize + headersize ; bufferQueue -> blockingFlag = ~ 0 ; }
>= the largest conceivable frame composed from one or more RTP packets
> = the largest conceivable frame composed from one or more RTP packets
/*numTruncatedBytes*/ /*durationInMicroseconds*/ // Set the packet's presentation time stamp, depending on whether or // not our RTP source's timestamps have been synchronized yet: //OS_PRINTF("[%s]-- hasBeenSynchronized: %d\n",__func__, hasBeenSynchronized); // abbrev // For the "pts" field, use the time differential from the first // synchronized time, rather than absolute time, in order to avoid // round-off errors when converting to a float: //if(dp->pts < 0) //OS_PRINTF("[%s] -------- dp->pts: %d prst[%d %d] fst[%d %d]\n",__func__,\
	(int)(dp->pts*1000),(int)(presentationTime.tv_sec),(int)(presentationTime.tv_usec),(int)(fst->tv_sec),(int)(fst->tv_usec)); // use the previous packet's "pts" once again: //OS_PRINTF("[%s]-- use pre pts, dp->pts: %d\n",__func__, (int)(dp->pts*1000)); // Signal any pending 'doEventLoop()' call on this queue: //OS_PRINTF("[%s]-- demuxer->filepos: %lld, frameSize: %d, headersize: %d\n",__func__,demuxer->filepos, frameSize, headersize);