From 3f956dfabbea9a0f7184ca98889350cd9d483915 Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Tue, 6 Feb 2024 10:14:01 +0200 Subject: [PATCH] formats: H26x flush queue after each NAL unit --- src/formats/h26x.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/formats/h26x.cc b/src/formats/h26x.cc index 9d5e273..45786d4 100644 --- a/src/formats/h26x.cc +++ b/src/formats/h26x.cc @@ -386,12 +386,21 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(sockaddr_in& addr, sockaddr_ } (void)finalize_aggregation_pkt(); + // actually send the packets + ret = fqueue_->flush_queue(addr, addr6, ssrc); + clear_aggregation_info(); } for (auto& nal : nals) // non-aggregatable NAL units { + + UVG_LOG_DEBUG("NAL size %u", nal.size); if (!nal.aggregate || !should_aggregate) { + if ((ret = fqueue_->init_transaction(data + nal.offset)) != RTP_OK) { + UVG_LOG_ERROR("Invalid frame queue or failed to initialize transaction!"); + return ret; + } // single NAL unit uses the NAL unit header as the payload header meaning that it does not // add anything extra to the packet and we can just compare the NAL size with the payload size allowed if (nal.size <= payload_size) // send as a single NAL unit packet @@ -409,13 +418,9 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(sockaddr_in& addr, sockaddr_ fqueue_->deinit_transaction(); return ret; } + ret = fqueue_->flush_queue(addr, addr6, ssrc); } } - - // actually send the packets - ret = fqueue_->flush_queue(addr, addr6, ssrc); - clear_aggregation_info(); - return ret; }