<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 9pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body><BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #008080 2px solid; MARGIN-RIGHT: 0px"><BR><BR>
<META content="Microsoft SafeHTML" name=Generator>
<STYLE>
.ExternalClass P
{padding:0px;}
.ExternalClass
{font-size:9pt;font-family:Tahoma;}
</STYLE>

<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">Hi all,</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">I want to stream h.264 video from a live source using live555, and I have read the FAQ but still I feel it is difficulty to fill the member function.&nbsp; I list some codes I wrote myself below and I have not validate it. I should appreciate if you can give me some suggestions.</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp; </SPAN>void H264VideoStreamDiscreteFramer::doGetNextFrame()</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>{</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">//**************************non-blocking fashion**************************//</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">while(1){</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>watchVariableforH264=0;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>env-&gt;tashScheduler().doEventLoop(&amp;watchVariableforH264);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>deliverFrame();</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>if (fFramsize==0 /* the source stops being readable */) {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp; </SPAN>handleClosure(this);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN><SPAN>&nbsp; </SPAN>return;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN><SPAN>&nbsp;</SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">void<SPAN>&nbsp; </SPAN>H264VideoStreamDiscreteFramer::deliverFrame()</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">{</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>if (!isCurrentlyAwaitingData()) return; // we're not ready for the data yet</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>fFrameSize=LenOfEncode;<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//LENOFENCODE is defined in another thread</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>if (fFrameSize &gt; fMaxSize) {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>fNumTruncatedBytes = fFrameSize - fMaxSize;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>fFrameSize = fMaxSize;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>memcpy(fTo,Encode_data,fFrameSize);<SPAN>&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//Encode_data is defined in another thread</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">//?????????<SPAN>&nbsp; </SPAN>I am not sure how to copy encoded data to the address point by fTo, especially how to deal with </SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">//<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>data which be truncated (fNumTruncatedBytes).</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>// Set the 'presentation time':</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp; </SPAN>if (fPresentationTime.tv_sec == 0 &amp;&amp; fPresentationTime.tv_usec == 0) {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// This is the first frame, so use the current time:</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>gettimeofday(&amp;fPresentationTime, NULL);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp; </SPAN>} else {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>// Increment by the play time of the previous frame (64ms), my encoder</SPAN><SPAN style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: ËÎÌå">¡¯</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">s frame rate is 15.6fps</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp; </SPAN>unsigned uSeconds<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>= fPresentationTime.tv_usec + 64000;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp; </SPAN>fPresentationTime.tv_sec += uSeconds/1000000;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;&nbsp;&nbsp; </SPAN>fPresentationTime.tv_usec = uSeconds%1000000;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp;</SPAN>fDurationInMicroseconds = 64000; // each frame is 64 ms</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>// Deliver the data here:</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>// ?????????<SPAN>&nbsp;&nbsp; </SPAN>what does this mean?<SPAN>&nbsp; </SPAN>How to Deliver?</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>// After delivering the data, inform the reader that it is now available:</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>FramedSource::afterGetting(this);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">Boolean<SPAN>&nbsp; </SPAN>H264VideoStreamDiscreteFramer::currentNALUnitEndsAccessUnit()</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>{</SPAN></P>
<P class=EC_MsoNormal style="TEXT-ALIGN: left" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">// How to know whether the NAL unit that you're currently delivering is the last NAL unit in an access unit (video frame).</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">&nbsp;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN>&nbsp; </SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"></SPAN>&nbsp;</P></BLOCKQUOTE><br /><hr />ÂÊÏȳ¢ÊÔ Windows Live Mail¡£ <a href='http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d' target='_new'>Windows Live Mail</a></body>
</html>