<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Il 27/10/2010 02:39, Ross Finlayson ha scritto:
<blockquote cite="mid:f06240800c8ed24424f62@%5B66.80.62.44%5D"
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>
I agree, but *everyone* requests JPEG as an entry point. Onvif, for
example, requests MJPEG/RTP streaming as a MUST IMPLEMENT.<br>
<br>
<blockquote cite="mid:f06240800c8ed24424f62@%5B66.80.62.44%5D"
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>
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 class="moz-signature">-- <br>
Belloni Cristiano<br>
Imavis Srl.<br>
<a href="http://www.imavis.com">www.imavis.com</a><br>
<a href="mailto://belloni@imavis.com">belloni@imavis.com</a><br>
</div>
</body>
</html>