From 6f39a4e1381e6e6eb1f9fd4f21cd9b19b5dbdea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joni=20R=C3=A4s=C3=A4nen?= Date: Fri, 17 Jun 2022 10:34:22 +0300 Subject: [PATCH] formats: Fix the correct NAL types in h264 and h266 This fix revealed an error in h266 fragmentation which is not fixed. --- src/formats/h264.cc | 2 +- src/formats/h266.cc | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/formats/h264.cc b/src/formats/h264.cc index a6387d5..0a21c7f 100644 --- a/src/formats/h264.cc +++ b/src/formats/h264.cc @@ -71,7 +71,7 @@ uvgrtp::formats::FRAG_TYPE uvgrtp::formats::h264::get_fragment_type(uvgrtp::fram uvgrtp::formats::NAL_TYPE uvgrtp::formats::h264::get_nal_type(uvgrtp::frame::rtp_frame* frame) const { switch (frame->payload[1] & 0x1f) { - case 19: return uvgrtp::formats::NAL_TYPE::NT_INTRA; + case 5: return uvgrtp::formats::NAL_TYPE::NT_INTRA; case 1: return uvgrtp::formats::NAL_TYPE::NT_INTER; default: break; } diff --git a/src/formats/h266.cc b/src/formats/h266.cc index 9099a03..0f720b8 100644 --- a/src/formats/h266.cc +++ b/src/formats/h266.cc @@ -76,11 +76,12 @@ uvgrtp::formats::FRAG_TYPE uvgrtp::formats::h266::get_fragment_type(uvgrtp::fram uvgrtp::formats::NAL_TYPE uvgrtp::formats::h266::get_nal_type(uvgrtp::frame::rtp_frame* frame) const { - switch (frame->payload[2] & 0x3f) { - case 19: return uvgrtp::formats::NAL_TYPE::NT_INTRA; - case 1: return uvgrtp::formats::NAL_TYPE::NT_INTER; - default: break; - } + uint8_t nal_type = frame->payload[2] & 0x3f; + + if (nal_type == 7) + return uvgrtp::formats::NAL_TYPE::NT_INTRA; + else if (nal_type == 0) + return uvgrtp::formats::NAL_TYPE::NT_INTER; return uvgrtp::formats::NAL_TYPE::NT_OTHER; }