[Live-devel] My MPEG4 Source does not make MPEG4ESVideoRTPSink set marker bits.

Cristiano Belloni belloni at imavis.com
Tue Feb 26 00:38:09 PST 2008


Cristiano Belloni wrote:
> Hi, I'm streaming MPEG4 and use FFMPEG library to encode MPEG4 frames 
> from my own live source.
>
> I wrote my own FramedSource subclass and that does the trick.
>
> The problem is, MPEG4ESVideoRTPSink does not set the marker bits at 
> all. I took a look at the code in the MPEG4ESVideoRTPSink.cpp file and 
> it goes like that:
>
> 00066   // Set the RTP 'M' (marker) bit iff this frame ends a VOP
> 00067   // (and there are no fragments remaining).
> 00068   // This relies on the source being a "MPEG4VideoStreamFramer".
> 00069   MPEG4VideoStreamFramer* framerSource = 
> (MPEG4VideoStreamFramer*)fSource;
> 00070   if (framerSource != NULL && framerSource->pictureEndMarker()
> 00071       && numRemainingBytes == 0) {
> 00072     setMarkerBit();
> 00073     framerSource->pictureEndMarker() = False;
> 00074   }
>
> This means I should instead subclass MPEG4VideoStreamFramer and set 
> the pictureEndMarker everytime I have a complete frame? Is there no 
> way to have my marker bits set just subclassing FramedSource, just 
> like I did with H263 streaming?
>
> Thanks and regards,
>
> Cristiano.
>
Pardon, I think I just figured it out.
Should I do something like that in my createNewStreamSource?:

// Creating a video source

 MyFramedSource* encoderSource = MyFramedSource::createNew(envir(), 
params);

 if (encoderSource == NULL) {
     //Problems creating encoder
     return NULL;
 }

 //Encoder created successfully!

 if (toServe == H263) {
   return H263plusVideoStreamFramer::createNew(envir(), encoderSource);
 }
 else if (toServe == MPEG4) {
   return MPEG4VideoStreamFramer::createNew(envir(), encoderSource);
 }
 else {
      //Invalide encoding type!
     return NULL;
 }

(Class MyFramedSource handles H263 and MPEG4 video, depending on params)

And then, in createNewRTPSink():

if (toServe == H263) {

       //Creating new H263 sink.
       return H263plusVideoRTPSink::createNew(envir(), rtpGroupsock, 
rtpPayloadTypeIfDynamic);
         }
   else if (toServe == MPEG4) {

       //Creating new MPEG4 sink.
       return     MPEG4ESVideoRTPSink::createNew(envir(), rtpGroupsock, 
rtpPayloadTypeIfDynamic);

   }
   else {
       std::cout << "WTF? Unknown type?" << std::endl;
   }

Is this approach correct?

Regards,
Cristiano.

-- 
Belloni Cristiano
Imavis Srl.
www.imavis.com <http://www.imavis.com>
belloni at imavis.com <mailto://belloni@imavis.com>


More information about the live-devel mailing list