From e7e157c3128b9498d4b3cb2a2fbbbbb1e61e1e97 Mon Sep 17 00:00:00 2001 From: rayjay <526528945@qq.com> Date: Mon, 19 Feb 2024 11:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85mjepg=20rtp=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81DRI(=E5=8E=9F?= =?UTF-8?q?=E5=85=88=E5=8F=AA=E5=9C=A8=E8=A7=A3=E5=8C=85=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E6=94=AF=E6=8C=81,=E6=89=93=E5=8C=85=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=B9=B6=E4=B8=8D=E6=94=AF=E6=8C=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext-codec/JPEGRtp.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ext-codec/JPEGRtp.cpp b/ext-codec/JPEGRtp.cpp index 7d1ae084..99456b21 100644 --- a/ext-codec/JPEGRtp.cpp +++ b/ext-codec/JPEGRtp.cpp @@ -605,6 +605,7 @@ void JPEGRtpEncoder::rtpSendJpeg(const uint8_t *buf, int size, uint64_t pts, uin int i; int default_huffman_tables = 0; uint8_t *out = nullptr; + uint16_t restart_interval = 0; /* preparse the header for getting some info */ for (i = 0; i < size; i++) { @@ -714,6 +715,9 @@ void JPEGRtpEncoder::rtpSendJpeg(const uint8_t *buf, int size, uint64_t pts, uin return; } break; + } else if (buf[i + 1] == DRI) { + type |= 0x40; + restart_interval = AV_RB16(&buf[i + 4]); } } if (default_huffman_tables && default_huffman_tables != 31) { @@ -744,6 +748,9 @@ void JPEGRtpEncoder::rtpSendJpeg(const uint8_t *buf, int size, uint64_t pts, uin if (off == 0 && nb_qtables) hdr_size += 4 + 64 * nb_qtables; + if (type & 0x40) + hdr_size += 4; + /* payload max in one packet */ len = MIN(size, (int)getRtpInfo().getMaxSize() - hdr_size); @@ -759,6 +766,13 @@ void JPEGRtpEncoder::rtpSendJpeg(const uint8_t *buf, int size, uint64_t pts, uin bytestream_put_byte(&p, w); bytestream_put_byte(&p, h); + /* set dri */ + if (type & 0x40) { + bytestream_put_be16(&p, restart_interval); + bytestream_put_byte(&p, 0xff); + bytestream_put_byte(&p, 0xff); + } + if (off == 0 && nb_qtables) { /* set quantization tables header */ bytestream_put_byte(&p, 0);