<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Courier New, monospace" size="3">
<div><b>Hi All,</b></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><b>I</b><b>’</b><b>m trying to s</b><b>tream</b><b> </b><b>(unicast) </b><b>an H264 </b><b>from </b><b>elementary stream </b><b>file. </b><b>The final goal is to stream </b><b>NAL packets </b><b>from a hardware encoder but </b><b>this should be easily
adopted once the file streamer works.</b><b> </b></div>
<div><b>The </b><b>ES </b><b>file was created by a remux software</b><b> and is play</b><b>able</b><b> by mplayer.</b></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><b>The </b><b>problem is my </b><b>streamer exits after about 1 sec and the </b><b>afterPlaying</b><b> callback is called</b><b>. The </b><b>ByteStreamFileSource::doGetNextFrame()</b><b> function fails on </b><b>feof(fFid)</b><b> with 16, which means the
code trys to read 16 bytes past the end of</b> <b>file marker.</b></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><b>T</b><b>his is what I do to stream it:</b></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Courier New, monospace" size="2"><b>Groupsock rtpGroupsock(*env, destinationAddress, rtpPort, ttl);</b></font></font></div>
<div><font size="2"> <b>Groupsock rtcpGroupsock(*env, destinationAddress, rtcpPort, ttl);</b></font></div>
<div><font size="2"> </font></div>
<div style="padding-left: 36pt; "><font size="2"><b>videoSink = SimpleRTPSink::createNew(*env, &rtpGroupsock, 33, 90000, "video", "mp2t",</b><b> </b><b>1, True, False /*no 'M' bit*/);</b></font></div>
<div style="text-indent: 36pt; "><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="text-indent: 36pt; "><font size="2"><b>estimatedSessionBandwidth = 5000; // in kbps; for RTCP b/w share</b></font></div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Courier New, monospace" size="2"><b>const unsigned maxCNAMElen = 100;</b></font></font></div>
<div><font size="2"> <b>unsigned char CNAME[maxCNAMElen+1];</b></font></div>
<div><font size="2"> <b>gethostname((char*)CNAME, maxCNAMElen);</b></font></div>
<div><font size="2"> <b>CNAME[maxCNAMElen] = '\0'; // just in case</b></font></div>
<div><font size="2"> <b>RTCPInstance* rtcp = RTCPInstance::createNew(*env, &rtcpGroupsock,</b></font></div>
<div><font size="2"> <b>estimatedSessionBandwidth, CNAME,</b></font></div>
<div><font size="2"> <b>videoSink, NULL /* we're a server */, false);</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"> <b>play();</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"> <b>env->taskScheduler().doEventLoop(&exit_flag); // does not return</b></font></div>
<div><font size="2"> <b>Medium::close(videoSource);</b></font></div>
<div><font size="2"> <b>Medium::close(rtcp);</b></font></div>
<div><font size="2"> <b>return 0; // only to prevent compiler warning</b></font></div>
<div><font size="2"><b>}</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><b>void afterPlaying(void* /*clientData*/) </b></font></div>
<div><font size="2"><b>{</b></font></div>
<div><font size="2"> <b>*env << "...done reading from file\n";</b></font></div>
<div><font size="2"> <b>exit_flag = 1;</b></font></div>
<div><font size="2"><b>}</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"><b>void play() </b></font></div>
<div><font size="2"><b>{</b></font></div>
<div><font size="2"> <b>unsigned const inputDataChunkSize</b><b> </b><b>= </b><b>7</b><b>*</b><b>188</b><b>;</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"> <b>// Open the input file as a 'byte-stream file source':</b></font></div>
<div><font size="2"> <b>ByteStreamFileSource* videoFile</b></font></div>
<div><font size="2"> <b>= ByteStreamFileSource::createNew(*env, video, inputDataChunkSize);</b></font></div>
<div><font size="2"> </font></div>
<div><font size="2"> <b>if (!videoFile ) </b></font></div>
<div><font size="2"> <b>exit(1);</b></font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Courier New, monospace" size="2"><b>// Create a 'framer' for the input source (to give us proper inter-packet gaps):</b></font></font></div>
<div><font size="2"> <b>videoSource = MPEG2TransportStreamFromESSource::createNew(*env);</b></font></div>
<div><font size="2"> <b>((MPEG2TransportStreamFromESSource*)videoSource)->addNewVideoSource(videoFile, 10);</b></font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Courier New, monospace" size="2"><b>// Finally, start playing:</b></font></font></div>
<div><font size="2"> <b>*env << "Beginning to read from file...\n";</b></font></div>
<div><font size="2"> <b>videoSink->startPlaying(*videoSource, afterPlaying, videoSink);</b></font></div>
<div><font size="2"><b>}</b></font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><b>What am I missing here?</b></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
</body>
</html>