<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. 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"> </SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>void H264VideoStreamDiscreteFramer::doGetNextFrame()</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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> </SPAN>watchVariableforH264=0;</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> </SPAN>env->tashScheduler().doEventLoop(&watchVariableforH264);</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> </SPAN>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> </SPAN>}<SPAN> </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"><SPAN> </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> </SPAN>handleClosure(this);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN><SPAN> </SPAN>return;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN><SPAN> </SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"> </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">void<SPAN> </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> </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"> </SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>fFrameSize=LenOfEncode;<SPAN> </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> </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>if (fFrameSize > fMaxSize) {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>fNumTruncatedBytes = fFrameSize - fMaxSize;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>fFrameSize = fMaxSize;</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"><SPAN> </SPAN>memcpy(fTo,Encode_data,fFrameSize);<SPAN> </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> </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> </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> </SPAN></SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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> </SPAN>if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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> </SPAN>gettimeofday(&fPresentationTime, NULL);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>} else {</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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> </SPAN>unsigned uSeconds<SPAN> </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> </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> </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> </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"><SPAN> </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"> </SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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> </SPAN>// ?????????<SPAN> </SPAN>what does this mean?<SPAN> </SPAN>How to Deliver?</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"><SPAN> </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> </SPAN>FramedSource::afterGetting(this);</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"> </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></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun">Boolean<SPAN> </SPAN>H264VideoStreamDiscreteFramer::currentNALUnitEndsAccessUnit()</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </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"> </SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"><SPAN> </SPAN>}</SPAN></P>
<P class=EC_MsoNormal><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: #333333; FONT-FAMILY: Simsun"></SPAN> </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>