diff --git a/src/rtp/obu_parser.cpp b/src/rtp/obu_parser.cpp index c3f982b..ebe6639 100644 --- a/src/rtp/obu_parser.cpp +++ b/src/rtp/obu_parser.cpp @@ -95,14 +95,13 @@ std::vector ParseObus(uint8_t* payload, int payload_size) { // Skip obus that shouldn't be transfered over rtp. int obu_type = ObuType(obu.header_); - // if (obu_type != kObuTypeTemporalDelimiter && // - // obu_type != kObuTypeTileList && // - // obu_type != kObuTypePadding) { - // result.push_back(obu); - // } - if (1) { + if (obu_type != kObuTypeTemporalDelimiter && obu_type != kObuTypeTileList && + obu_type != kObuTypePadding) { result.push_back(obu); } + // if (1) { + // result.push_back(obu); + // } } // for (int i = 0; i < result.size(); i++) { diff --git a/src/rtp/rtp_codec.cpp b/src/rtp/rtp_codec.cpp index aff7dbc..6e79459 100644 --- a/src/rtp/rtp_codec.cpp +++ b/src/rtp/rtp_codec.cpp @@ -17,7 +17,7 @@ RtpCodec ::RtpCodec(RtpPacket::PAYLOAD_TYPE payload_type) has_padding_(false), has_extension_(false), payload_type_(payload_type), - sequence_number_(0) { + sequence_number_(1) { fec_encoder_.Init(); } @@ -541,7 +541,7 @@ void RtpCodec::Encode(VideoFrameType frame_type, uint8_t* buffer, size_t size, rtp_packet.SetAv1AggrHeader(0, 0, 1, 0); rtp_packet.EncodeAv1(obus[i].data_, obus[i].size_); - // LOG_ERROR("enc payload size = {}", rtp_packet.PayloadSize()); + packets.emplace_back(rtp_packet); } else { size_t last_packet_size = obus[i].size_ % MAX_NALU_LEN; @@ -583,7 +583,6 @@ void RtpCodec::Encode(VideoFrameType frame_type, uint8_t* buffer, size_t size, MAX_NALU_LEN); } - // LOG_ERROR("enc payload size = {}", rtp_packet.PayloadSize()); packets.emplace_back(rtp_packet); } } diff --git a/src/rtp/rtp_packet.cpp b/src/rtp/rtp_packet.cpp index 0f2803d..8e885a6 100644 --- a/src/rtp/rtp_packet.cpp +++ b/src/rtp/rtp_packet.cpp @@ -2,8 +2,6 @@ #include -#include "log.h" - void RtpPacket::TryToDecodeRtpPacket() { if (PAYLOAD_TYPE::H264 == PAYLOAD_TYPE(buffer_[1] & 0x7F)) { nal_unit_type_ = NAL_UNIT_TYPE(buffer_[12] & 0x1F); diff --git a/src/rtp/rtp_packet.h b/src/rtp/rtp_packet.h index 611442c..6c3829b 100644 --- a/src/rtp/rtp_packet.h +++ b/src/rtp/rtp_packet.h @@ -7,6 +7,8 @@ #include +#include "log.h" + // Common // 0 1 2 3 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 @@ -350,14 +352,30 @@ class RtpPacket { ParseRtpData(); int z, y, w, n; GetAv1AggrHeader(z, y, w, n); - return !z && !y; + // return !z && !y; + + if (z == 0 && y == 0 && w == 1) { + return true; + } else if (z == 0 && y == 1 & w == 1) { + return true; + } else { + return false; + } } bool Av1FrameEnd() { ParseRtpData(); int z, y, w, n; GetAv1AggrHeader(z, y, w, n); - return z && !y; + // return z && !y; + + if (z == 0 && y == 0 && w == 1) { + return true; + } else if (z == 1 && y == 0 & w == 1) { + return true; + } else { + return false; + } } private: @@ -372,7 +390,7 @@ class RtpPacket { uint32_t total_csrc_number_ = 0; bool marker_ = false; uint32_t payload_type_ = 0; - uint16_t sequence_number_ = 0; + uint16_t sequence_number_ = 1; uint32_t timestamp_ = 0; uint32_t ssrc_ = 0; std::vector csrcs_; diff --git a/src/rtp/rtp_video_receiver.cpp b/src/rtp/rtp_video_receiver.cpp index 2614e3b..a17cca0 100644 --- a/src/rtp/rtp_video_receiver.cpp +++ b/src/rtp/rtp_video_receiver.cpp @@ -241,11 +241,7 @@ bool RtpVideoReceiver::CheckIsH264FrameCompleted(RtpPacket& rtp_packet) { bool RtpVideoReceiver::CheckIsAv1FrameCompleted(RtpPacket& rtp_packet) { if (rtp_packet.Av1FrameEnd()) { uint16_t end_seq = rtp_packet.SequenceNumber(); - if (incomplete_frame_list_.size() == end_seq) { - return true; - } - - size_t start = rtp_packet.SequenceNumber(); + size_t start = end_seq; bool start_count = 0; while (end_seq--) { auto it = incomplete_frame_list_.find(end_seq); @@ -258,19 +254,14 @@ bool RtpVideoReceiver::CheckIsAv1FrameCompleted(RtpPacket& rtp_packet) { continue; } else if (it->second.Av1FrameStart()) { start = it->second.SequenceNumber(); - // skip temporal delimiter OBU - start_count++; - if (start_count == 1) - break; - else - break; + break; } else { LOG_WARN("What happened?") return false; } } - if (start != rtp_packet.SequenceNumber()) { + if (start <= rtp_packet.SequenceNumber()) { if (!nv12_data_) { nv12_data_ = new uint8_t[NV12_BUFFER_SIZE]; } diff --git a/xmake.lua b/xmake.lua index 378c89f..b0c6256 100644 --- a/xmake.lua +++ b/xmake.lua @@ -12,7 +12,7 @@ add_defines("ASIO_STANDALONE", "ASIO_HAS_STD_TYPE_TRAITS", "ASIO_HAS_STD_SHARED_ "ASIO_HAS_CSTDINT", "ASIO_HAS_STD_ARRAY", "ASIO_HAS_STD_SYSTEM_ERROR") add_requires("asio 1.24.0", "nlohmann_json", "spdlog 1.11.0", "openfec", "libopus 1.4", "dav1d 1.1.0", "libyuv") -add_packages("asio", "nlohmann_json", "spdlog", "openfec", "libopus", "libyuv") +add_packages("asio", "nlohmann_json", "spdlog", "openfec", "libopus", "dav1d", "libyuv") includes("thirdparty") @@ -21,7 +21,7 @@ if is_os("windows") then add_requires("vcpkg::libnice 0.1.21") add_requires("vcpkg::aom") add_requires("openh264 2.1.1", {configs = {shared = false}}) - add_packages("vcpkg::ffmpeg", "vcpkg::libnice", "vcpkg::aom", "openh264", "dav1d", "cuda") + add_packages("vcpkg::ffmpeg", "vcpkg::libnice", "vcpkg::aom", "openh264", "cuda") add_defines("_WEBSOCKETPP_CPP11_INTERNAL_") add_requires("cuda") elseif is_os("linux") then