[Live-devel] 答复: 答复: regardint every rtp packet's timestamp is same

梦幻工作室 fantasyvideo at 126.com
Fri Sep 14 02:03:45 PDT 2012


I did as you said, then use vlc to access.

But it would stop  automatically after some seconds, and shows that
“Program doesn’t contain anymore ES”.

Buf if I comment the fDurationInMicroseconds=5000, it was getting the buffer
although it’s 0%.

 

发件人: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] 代表 Ross Finlayson
发送时间: 2012年9月14日 14:22
收件人: LIVE555 Streaming Media - development & use
主题: Re: [Live-devel] 答复: regardint every rtp packet's timestamp is same

 

Thank you for your answer.

Now I change the code as below:

AudioFramedSource::AudioFrameSource()

{

gettimeofday(&m_timescale);

 

OK, this is good, in principle.  It aligns the presentation time with
'wall-clock' time.  However, the constructor is not the right time to be
calling "gettimeofday()", because you don't know how long you'll be waiting
until "doGetNextFrame()" is first called.  Instead, declare a member
variable

    Boolean fIsFirstPresentationTime;

and, in the constructor, do

    fIsFirstPresentationTime = True;

 

 

void AudioFrameSource::doGetNextFrame()

{

 
CamerManager::GetInstance()->GetAudioFrame(“test”,(char*)fTo,fMaxSize,&fFr
ameSize,&fNumTruncatedBytes);

      Int64_t usec = m_timescale.tv_usec;

      usec += 40/8; //since every frame has 40 samples.

     If(usec>=1000)

{

   m_timescale.tv_sec+= usec/1000;

  m_timescale.tv_usec += usec%1000;

}

else

{

m_timescale.tv_usec = usec;
}

 

This is all very wrong, because the "tv_usec" field is in microseconds, but
you're treating it as if it were in milliseconds.  Also, you're incrementing
"fPresentationTime" too soon.  The correct code would be something like
this:

 

void AudioFrameSource::doGetNextFrame() {

    CamerManager::GetInstance()->GetAudioFrame(“test”,(char*)fTo,fMaxSize,
&fFrameSize,&fNumTruncatedBytes);

    if (fIsFirstPresentationTime) {

       gettimeofday(&m_timescale);

                   fIsFirstPresentationTime = False; // from now on

       }

    fPresentationTime = m_timescale;

    fDurationInMicroseconds = 5000; // because 40 samples at 8000
samples-per-second have a duration of 5 ms (== 5000 us)

 

    // Compute the next presentation time (i.e., to be used on the next call
to "doGetNextFrame()"):

    m_timescale.tv_usec += fDurationInMicroseconds;

    if (m_timescale.tv_usec > 1000000) {

       ++m_timescale.tv_sec;

       m_timescale.tv_usec -= 1000000;

    }

}

 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/ 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120914/738b75e6/attachment-0001.html>


More information about the live-devel mailing list