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 1/2] =?UTF-8?q?=E6=89=93=E5=8C=85mjepg=20rtp=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81DRI(?= =?UTF-8?q?=E5=8E=9F=E5=85=88=E5=8F=AA=E5=9C=A8=E8=A7=A3=E5=8C=85=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E6=94=AF=E6=8C=81,=E6=89=93=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E5=B9=B6=E4=B8=8D=E6=94=AF=E6=8C=81?= =?UTF-8?q?)?= 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); From 6119ac9c53cc361da016c0999e46e7df8dd9c284 Mon Sep 17 00:00:00 2001 From: rayjay <526528945@qq.com> Date: Thu, 28 Mar 2024 11:21:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?rtp=E6=8E=A8=E6=B5=81=E5=A2=9E=E5=8A=A0PCM?= =?UTF-8?q?=E9=9F=B3=E9=A2=91=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/GB28181Process.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Rtp/GB28181Process.cpp b/src/Rtp/GB28181Process.cpp index 29c9704f..37756dd5 100644 --- a/src/Rtp/GB28181Process.cpp +++ b/src/Rtp/GB28181Process.cpp @@ -102,6 +102,16 @@ bool GB28181Process::inputRtp(bool, const char *data, size_t data_len) { _rtp_decoder[pt] = Factory::getRtpDecoderByCodecId(track->getCodecId()); break; } + case Rtsp::PT_L16_Mono: { + //L16 + ref = std::make_shared(16000, [this](RtpPacket::Ptr rtp) { onRtpSorted(std::move(rtp)); }); + auto track = Factory::getTrackByCodecId(CodecL16, 16000, 1, 16); + CHECK(track); + track->setIndex(pt); + _interface->addTrack(track); + _rtp_decoder[pt] = Factory::getRtpDecoderByCodecId(track->getCodecId()); + break; + } default: { if (pt == opus_pt) { // opus负载