Note that there are some explanatory texts on larger screens.

plurals
  1. PORTP Buffer Side Effects
    primarykey
    data
    text
    <p>In previous version of my <code>RTSP Source Filter</code>, I was immediately packing the RTP packets in order I receive them. There was no buffer, sorting by sequence number, dropping frames with missing pieces etc. but result was ok since I made my tests on LAN. I decided to add an RTP buffer, sorting mechanism etc. Actually, core code was successful. But now I have some problems with sending the frames with correct timing.</p> <p>I have a debugging mechanism. I'm able to store all the frames into seperate files like frame0.bin, frame1.bin etc. and I have a tool which is able to read these files and send it to h.264 decoder. When I playback these frames, result is perfect. I believe that proves my RTP and frame buffers work fine.</p> <p>When I try to pass the frame to <code>FillBuffer</code> function as soon as a frame is created (actually when my frame queue has more than 1 frames), result is really crappy (I get the image but with delays and corrupted frames). It's probably caused by passing frames to <code>FillBuffer</code> function immediatelly. My <code>DoBufferProcessingLoop</code> function looks like below (I removed most of the error checks from the code);</p> <pre><code>HRESULT RtspSourceFilterOutputPin::DoBufferProcessingLoop() { Command com; REFERENCE_TIME rtNow = 0L; REFERENCE_TIME rtAdvise = 0L; OnThreadStartPlay(); do { while (!CheckRequest(&amp;com)) { if(streamReader-&gt;frames.size() &gt; 1) { IMediaSample *pSample; GetDeliveryBuffer(&amp;pSample,NULL,NULL,FALSE); hr = FillBuffer(pSample); if (hr == S_OK) { HRESULT result = Deliver(pSample); } else if (hr == S_FALSE) { pSample-&gt;Release(); DeliverEndOfStream(); return S_OK; } else { //error } pSample-&gt;Release(); } } if (com == CMD_RUN || com == CMD_PAUSE) { com = GetRequest(); } else if (com != CMD_STOP) { //error } } while (com != CMD_STOP); return S_OK; } </code></pre> <p>Since streaming is realtime, I removed all timestamps (<code>SetTime</code>, <code>SetMediaTime</code> etc.) from <code>FillBuffer</code> function. There is nothing special with <code>FillBuffer</code>. It just pops a frame from frames queue and pass it to the decoder. And it works if a remove my buffer mechanism.</p> <p>Finally, the quesiton is...</p> <p>Should I wait for some time like "received time + buffer time" before sending a frame instead of passing it to <code>FillBuffer</code> as soon as its created? Or should I use <code>SetTime</code> in <code>FillBuffer</code> function? I already tried it and failed. I also tried to give start/stop time values with buffer time added but didn't work any better.</p> <p>Why is the result crappy when I pass the frame to the decoder but result is ok if I save these frames to binary files and playback from these files? What am I missing here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload