Thanks Cristiano!, I'm going to add the restart marker header as you are showing.<br><br><div class="gmail_quote">2010/10/27 Cristiano Belloni <span dir="ltr"><<a href="mailto:belloni@imavis.com">belloni@imavis.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div text="#000000" bgcolor="#ffffff">
Il 27/10/2010 02:39, Ross Finlayson ha scritto:
<div class="im"><blockquote type="cite">
<blockquote type="cite">I'm trying to create a rtsp server to
stream MJPEG images.
<br>
</blockquote>
<br>
Ugh. JPEG is a *terrible* codec for video streaming.
<br>
</blockquote>
<br></div>
I agree, but *everyone* requests JPEG as an entry point. Onvif, for
example, requests MJPEG/RTP streaming as a MUST IMPLEMENT.<div class="im"><br>
<br>
<blockquote type="cite">
<br>
<br>
<blockquote type="cite"> I have implemented a new
TestJPEGFileServerMediaSubsession that creates a
TestJPEGVideoRTPSink.
<br>
<br>
In TestJPEGVideoRTPSink::doSpecialFrameHandling I'm adding the
quantization tables of the image into the header using
setSpecialHeaderBytes
<br>
</blockquote>
<br>
Note that the existing "JPEGVideoRTPSink" code already does this.
You should not have to reinvent the wheel here.
<br>
<br>
<br>
<blockquote type="cite">This is working fine using some JPEG
images, but fails with others.
<br>
<br>
I'm testing one image that has the marker 0xFF, 0xDD ( Define
Restart Interval) and I think I have to do something else seeing
this comment in the code
<br>
<br>
// Note: We assume that there are no 'restart markers'
<br>
<br>
So, what should I do with images containing restart markers and
macroblocks?
<br>
</blockquote>
<br>
The JPEG transmitting code ("JPEGVideoSource" and
"JPEGVideoRTPSink") currently don't support "Restart Marker
Headers" (see RFC 2435, section 3.1.7). You will need to update
the (definition and implementation) of these two classes to
support them.
<br>
</blockquote></div>
I did something similar, Francisco. In a nutshell, you've got to
extend JPEGVideoSource and look for DRI markers like this:<br>
<br>
//Look for the DRI marker<br>
for (unsigned i = 0; i < JPEGHeaderSize; ++i) {<br>
if (fBuffer[i] == 0xFF) {<br>
if (fBuffer[i+1] == 0xDD) { // DRI<br>
if ((fBuffer[i+2] != 0) || (fBuffer[i+3] != 4)) {<br>
envir() << "Wrong DRI marker!\n";<br>
continue;<br>
}<br>
else {<br>
fRestartInterval = (fBuffer[i+4] << 8) +
fBuffer[i+5];<br>
printf ("DRI restart Interval found @ %d is
%d\n", i, fRestartInterval);<br>
break;<br>
}<br>
}<br>
}<br>
}<br>
<br>
Then, extend JPEGVideoRTPSink to take care about the restart markers
in doSpecialFrameHandling():<br>
(In reality, here I extended VideoRTPSink because I needed to, feel
free to do your adaptations)<br>
<br>
u_int8_t RestartMarkerHeader[4]; // the special header<br>
u_int16_t restartInterval = source->restartInterval();<br>
<br>
RestartMarkerHeader[0] = restartInterval >> 8;<br>
RestartMarkerHeader[1] = restartInterval;<br>
RestartMarkerHeader[2] = 0xFF;<br>
RestartMarkerHeader[3] = 0xFF;<br>
<br>
setSpecialHeaderBytes(RestartMarkerHeader, sizeof
RestartMarkerHeader, sizeof mainJPEGHeader /* start position */);<br>
<br>
Finally, reflect the size change in the headers in
specialHeaderSize():<br>
<br>
// We assume that there are 'restart markers'<br>
headerSize += 4;<br>
<br>
<div>-- <br>
Belloni Cristiano<br>
Imavis Srl.<br>
<a href="http://www.imavis.com" target="_blank">www.imavis.com</a><br>
<a href="mailto://belloni@imavis.com" target="_blank">belloni@imavis.com</a><br>
</div>
</div>
<br>_______________________________________________<br>
live-devel mailing list<br>
<a href="mailto:live-devel@lists.live555.com">live-devel@lists.live555.com</a><br>
<a href="http://lists.live555.com/mailman/listinfo/live-devel" target="_blank">http://lists.live555.com/mailman/listinfo/live-devel</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Francisco Feijoo<br>Software Engineer<br>J2K Video Limited<br><br>T: +34 654967246<br>E: <a href="mailto:francisco@j2kvideo.com">francisco@j2kvideo.com</a><br>W: <a href="http://www.j2kvideo.com">www.j2kvideo.com</a><br>