[Live-devel] Live Streaming Mpeg4 with ffmpeg

devel at integra-sc.it devel at integra-sc.it
Fri Jun 5 02:52:32 PDT 2009


Hi all.
First my compliments for all your work, is very very great! ;-)
I'm writing a Framer for accessing Live RAW images copied in SHM  memory by
another application.
I use ffMpeg for encoding in MPEG4 (CODEC_ID_MPEG4)
I've created my Media SubSession for this scope whit these two methods:

FramedSource* MyMediaSubsession::createNewStreamSource(unsigned
clientSessionId, unsigned& estBitrate) {
...
// ffmpegStreamFramer is my implementation of a ffMpeg framer for MPEG4
InputSource = ffmpegStreamFramer::createNew(env, UrlParams);
return MPEG4VideoStreamFramer::createNew(env, InputSource);
}


RTPSink* MyMediaSubsession::createNewRTPSink(Groupsock* rtpGroupsock,
unsigned char rtpPayloadTypeIfDynamic,FramedSource* /*inputSource*/) {
...
return  MPEG4ESVideoRTPSink::createNew(envir(),
rtpGroupsock,rtpPayloadTypeIfDynamic);
}

Into ffmpegStreamFramer::doNextFrame()  i set  fPresentationTime to actual
timestamp
but it will not be considered by  MPEGVideoStreamFramer.
In fact in method: 

void MPEGVideoStreamFramer::continueReadProcessing(void* clientData,
unsigned char* /*ptr*/, unsigned /*size*/,
struct timeval /*presentationTime*/) {

  MPEGVideoStreamFramer* framer = (MPEGVideoStreamFramer*)clientData;
  framer->continueReadProcessing();
}

... the timeval parameter isn't considered

And in the method:

MPEG4VideoStreamParser::parseVideoObjectPlane() {
...
  // Compute this frame's presentation time:
  usingSource()->computePresentationTime(fTotalTicksSinceLastTimeCode);
  
  return curFrameSize();

}

is called a method for computing the new Presentation Time.


My video flow is about at 8.0 FPS, and
MPEGVideoStreamFramer::computePresentationTime()
will work fine for about first 3-4 images, after it will not compute the
rigth timestap: the flow will block, but if my video flow is  at 25 FPS all
work fine.

If in MPEGVideoStreamFramer::computePresentationTime() i try to use: 
....  
  timeval now;
  gettimeofday(&now,NULL);

  fPresentationTime.tv_sec=now.tv_sec; 
  fPresentationTime.tv_usec=now.tv_usec; 
}
And in this manner all work fine at 8.0 FPS.

But i don't want touch the library code......
I've thought:
I  subclassing MPEG4VideoStreamFramer for writing a new
computePresentationTime()

MyMPEG4VideoStreamFramer::MyMPEG4VideoStreamFramer(UsageEnvironment&
env,FramedSource* inputSource,Boolean createParser)
	: MPEG4VideoStreamFramer(env, inputSource)
{
	//delete fParser; 
	fParser = createParser ? new MyMPEG4VideoStreamParser(this, inputSource) :
NULL;
	
}


void MyMPEG4VideoStreamFramer::computePresentationTime(unsigned
numAdditionalPictures){
	timeval now;
	gettimeofday(&now,NULL);
	fPresentationTime=now;
}//

And subclassing MPEGV4ideoStreamParser for use the opportune
MyMPEG4VideoStreamFramer::computePresentationTime()
.....

But MPEGV4ideoStreamParser is a private class and i cannot subclassing it.

for do this I've to copy all the MPEGV4ideoStreamParser  code for
subclassing it: 

class MyMPEG4VideoStreamParser: public MPEGVideoStreamParser

and using the SAME code of MPEG4VideoStreamParser exept in the inline
method:

MyMPEG4VideoStreamFramer* usingSource() {
	    return (MyMPEG4VideoStreamFramer*)fUsingSource;
  }


Now the questions are:
How can i avoid this?
I dont' want to include all the MPEGV4ideoStreamParser parser code but i
want subclassing it:
can MPEGV4ideoStreamParser became public ?
can MPEG4VideoStreamParser have his parse() method plublic ?
Or there is another solution to this ?

Thanks for all in advance, i hope it is all clear;-)
Vito Covito.









More information about the live-devel mailing list