Hi All,<div><br></div><div>I am wanting to stream a single JPEG file over RTP for test purposes, I load the file and then create a video source to stream it to a client, in this case VLC. I am using the following code on each frame:</div>
<div><br></div><div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span style="color: #b519a1">void</span> <span style="color: #558187">TestJPEGVideoSource</span>::doGetNextFrame()</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo">{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>fFrameSize = <span style="color: #b519a1">this</span>-><span style="color: #558187">sosSize</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #b519a1">if</span> ( fFrameSize > fMaxSize )</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #c92722"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">                </span>printf( </span>"Truncating frame!!\n"<span style="color: #000000"> );</span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span>fNumTruncatedBytes = fFrameSize - fMaxSize;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span>fFrameSize = fMaxSize;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>memcpy( fTo, <span style="color: #b519a1">this</span>-><span style="color: #558187">buffer</span> + <span style="color: #b519a1">this</span>-><span style="color: #558187">sosIndex</span>, fFrameSize );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #b519a1">if</span> ( fPresentationTime.tv_sec == <span style="color: #380dd6">0</span> && fPresentationTime.tv_usec == <span style="color: #380dd6">0</span> )</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span>gettimeofday( &fPresentationTime, <span style="color: #b519a1">NULL</span> );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>} </p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #b519a1"><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>else</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>{</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #b519a1">unsigned</span> uSeconds = fPresentationTime.tv_usec + ( fTimePerFrame * <span style="color: #380dd6">1000</span> );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span>fPresentationTime.tv_sec += uSeconds / <span style="color: #380dd6">1000000</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">                </span>fPresentationTime.tv_usec = uSeconds % <span style="color: #380dd6">1000000</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>}</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; min-height: 14.0px"><br></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>fDurationInMicroseconds = fTimePerFrame * <span style="color: #380dd6">1000</span>;</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; min-height: 14.0px"><span class="Apple-tab-span" style="white-space:pre">        </span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo"><span class="Apple-tab-span" style="white-space:pre">        </span>nextTask() = envir().taskScheduler().scheduleDelayedTask( <span style="color: #380dd6">0</span>, (TaskFunc*)FramedSource::afterGetting, <span style="color: #b519a1">this</span> );</p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo">}</p></div><div><br></div><div>Where 'buffer' is the JPEG file, and sosIndex is the SOS marker index of the file. The problem is that when I come to decode the stream in VLC the image is far blockier than the original. Why is this? What am I doing wrong?</div>
<div><br></div><div>Thanks in advance</div><div><br></div><div>Andy<br>
</div>