No. Assuming that your "afterGettingFrame()" function was passed as a parameter to "getNextFrame()", then it will be called by "FramedSource::afterGetting()" (which your "doGetNextFrame()" implementation should have called once it completed delivery of incoming data).So is my code correct? If the frame is not completely decodable, I call getNextFrame() again (on MPEG1or2VideoRTPSource). As I said, sometimes (irregular) there are ~10 to 20ms delay between consecutive calls of afterGettingFrame(). Sometimes the afterGettingFrame() function is called twice even if the first one has not come to an end. How can that be? Could you please have a look at the code? Thank you very much!
void Transcoder::doGetNextFrame()
{
fInputSource->getNextFrame(inbuf, INBUF_SIZE, afterGettingFrame,
this, handleClosure, this);
}void Transcoder::afterGettingFrame(void* clientData, unsigned numBytesRead, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
{
Transcoder* transcoder = (Transcoder*)clientData;
transcoder->afterGettingFrame1(numBytesRead, numTruncatedBytes,
presentationTime, durationInMicroseconds);
}void Transcoder::afterGettingFrame1(unsigned numBytesRead, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds) { //Decoding dec_bytes = avcodec_decode_video(dec_codec_ctx, dec_frame, &got_frame, inbuf, size); //decoding inbuf (data chunks) to dec_frame
if(got_frame) //decoded one complete frame
{
//Encoding
gettimeofday(&begin_encoding_frame, NULL);
enc_bytes = avcodec_encode_video(enc_codec_ctx, outbuf,
fMaxSize, dec_frame); //encoding dec_frame to outbuf
if(enc_bytes > fMaxSize) //more bytes encoded than framer can handle
{
fFrameSize = fMaxSize;
fNumTruncatedBytes = enc_bytes - fMaxSize;
}
else
{
fFrameSize = enc_bytes;
fNumTruncatedBytes = 0;
}
//Delivering
memcpy(fTo, outbuf, fFrameSize); //copy outbuf to fTo for framer
fPresentationTime = begin_encoding_frame;
fDurationInMicroseconds = durationInMicroseconds; //just pass
through durationInMicroseconds
frame_ready = true; //frame ready for delivery
}
if(!frame_ready) //get more data
{
fInputSource->getNextFrame(inbuf, INBUF_SIZE, afterGettingFrame,
this, handleClosure, this); //*problems*
}
else //deliver data and return
{
frame_ready = false;
afterGetting(this);
}
}
After that I have the MPEG4VideoStreamDiscreteFramer (without that,
Transcoder::doGetNextFrame() isn't even called... why is that btw?) and
an MPEG4ESVideoRTPSink. The streaming actually works, but I temporarily
exceed 40ms to transcode one frame.
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ live-devel mailing list [email protected] http://lists.live555.com/mailman/listinfo/live-devel
