<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=gb2312"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><base href="x-msg://6545/"><style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:宋体;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.apple-style-span
{mso-style-name:apple-style-span;}
span.apple-tab-span
{mso-style-name:apple-tab-span;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=ZH-CN link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>I did as you said, then use vlc to access.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>But it would stop automatically after some seconds, and shows that “Program doesn’t contain anymore ES”.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>Buf if I comment the fDurationInMicroseconds=5000, it was getting the buffer although it’s 0%.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt'>发件人<span lang=EN-US>:</span></span></b><span lang=EN-US style='font-size:10.0pt'> live-devel-bounces@ns.live555.com [mailto:live-devel-bounces@ns.live555.com] </span><b><span style='font-size:10.0pt'>代表 </span></b><span lang=EN-US style='font-size:10.0pt'>Ross Finlayson<br></span><b><span style='font-size:10.0pt'>发送时间<span lang=EN-US>:</span></span></b><span lang=EN-US style='font-size:10.0pt'> 2012</span><span style='font-size:10.0pt'>年<span lang=EN-US>9</span>月<span lang=EN-US>14</span>日<span lang=EN-US> 14:22<br></span><b>收件人<span lang=EN-US>:</span></b><span lang=EN-US> LIVE555 Streaming Media - development & use<br></span><b>主题<span lang=EN-US>:</span></b><span lang=EN-US> Re: [Live-devel] </span>答复<span lang=EN-US>: regardint every rtp packet's timestamp is same<o:p></o:p></span></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thank you for your answer.</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>Now I change the code as below:</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>AudioFramedSource::AudioFrameSource()</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>{</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>gettimeofday(&m_timescale);</span><span lang=EN-US><o:p></o:p></span></p></div></div></blockquote><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><p class=MsoNormal><span lang=EN-US>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<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>Boolean fIsFirstPresentationTime;<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>and, in the constructor, do<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>fIsFirstPresentationTime = True;<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><p class=MsoNormal><span class=apple-style-span><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>void AudioFrameSource::doGetNextFrame()</span><span lang=EN-US><o:p></o:p></span></span></p><div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>{</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> CamerManager::GetInstance()->GetAudioFrame(“test”,(char*)fTo,fMaxSize,&fFrameSize,&fNumTruncatedBytes);</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> Int64_t usec = m_timescale.tv_usec;</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> usec += 40/8; //since every frame has 40 samples.</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> If(usec>=1000)</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>{</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> m_timescale.tv_sec+= usec/1000;</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> m_timescale.tv_usec += usec%1000;</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>}</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>else</span><span lang=EN-US><o:p></o:p></span></p></div><div style='margin-left:12.0pt'><p class=MsoNormal><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>{</span><span lang=EN-US><o:p></o:p></span></p></div><div style='margin-left:12.0pt'><p class=MsoNormal style='text-indent:10.5pt'><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>m_timescale.tv_usec = usec;<br>}</span><span lang=EN-US><o:p></o:p></span></p></div></div></blockquote><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><p class=MsoNormal><span lang=EN-US>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:<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><div><p class=MsoNormal><span lang=EN-US>void AudioFrameSource::doGetNextFrame() {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>CamerManager::GetInstance()->GetAudioFrame(“test”,(char*)fTo,fMaxSize,&fFrameSize,&fNumTruncatedBytes);<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>if (fIsFirstPresentationTime) {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span class=apple-style-span><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>gettimeofday(&m_timescale);</span></span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'> </span></span><span class=apple-style-span><span lang=EN-US style='font-size:10.5pt;font-family:"Calibri","sans-serif";color:#1F497D'>fIsFirstPresentationTime = False; // from now on</span></span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'> </span></span><span lang=EN-US style='font-family:"Calibri","sans-serif";color:#1F497D'>}</span><span lang=EN-US><o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>fPresentationTime = m_timescale;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>fDurationInMicroseconds = 5000; // because 40 samples at 8000 samples-per-second have a duration of 5 ms (== 5000 us)<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>// Compute the next presentation time (i.e., to be used on the next call to "doGetNextFrame()"):<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>m_timescale.tv_usec += fDurationInMicroseconds;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>if (m_timescale.tv_usec > 1000000) {<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>++m_timescale.tv_sec;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>m_timescale.tv_usec -= 1000000;<o:p></o:p></span></p></div><div><p class=MsoNormal><span class=apple-tab-span><span lang=EN-US> </span></span><span lang=EN-US>}<o:p></o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US>}<o:p></o:p></span></p></div></div><p class=MsoNormal style='margin-bottom:12.0pt'><span lang=EN-US><o:p> </o:p></span></p><div><p class=MsoNormal><span class=apple-style-span><span lang=EN-US style='font-size:13.5pt;font-family:"Helvetica","sans-serif";color:black'>Ross Finlayson</span></span><span lang=EN-US style='font-size:13.5pt;font-family:"Helvetica","sans-serif";color:black'><br><span class=apple-style-span>Live Networks, Inc.</span><br><span class=apple-style-span><a href="http://www.live555.com/">http://www.live555.com/</a></span></span><span lang=EN-US> <o:p></o:p></span></p></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>