v3c: Automatically disable Start Code related functionality when format is V3C

This commit is contained in:
Heikki Tampio 2023-08-09 14:47:43 +03:00
parent 15eb553236
commit b5905bcae2
2 changed files with 16 additions and 6 deletions

View File

@ -328,7 +328,9 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(sockaddr_in& addr, sockaddr_
std::vector<nal_info> nals;
bool should_aggregate = false;
if (rtp_flags & RTP_NO_H26X_SCL) {
rtp_format_t fmt = rtp_ctx_->get_payload();
if ((rtp_flags & RTP_NO_H26X_SCL) || (fmt == RTP_FORMAT_V3C)) {
nal_info nal;
nal.offset = 0;
nal.prefix_len = 0;
@ -514,6 +516,10 @@ uvgrtp::frame::rtp_frame* uvgrtp::formats::h26x::allocate_rtp_frame_with_startco
void uvgrtp::formats::h26x::prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out)
{
rtp_format_t fmt = rtp_ctx_->get_payload();
if (fmt == RTP_FORMAT_V3C) {
return;
}
if (!(rce_flags & RCE_NO_H26X_PREPEND_SC)) {
uint8_t* pl = new uint8_t[(*out)->payload_len + 4];
@ -960,7 +966,11 @@ rtp_error_t uvgrtp::formats::h26x::reconstruction(uvgrtp::frame::rtp_frame** out
size_t fptr = 0;
// allocating the frame with start code ready saves a copy operation for the frame
uvgrtp::frame::rtp_frame* complete = allocate_rtp_frame_with_startcode(!(rce_flags & RCE_NO_H26X_PREPEND_SC),
bool start_code = !(rce_flags & RCE_NO_H26X_PREPEND_SC);
if (rtp_ctx_->get_payload() == RTP_FORMAT_V3C) {
start_code = false;
}
uvgrtp::frame::rtp_frame* complete = allocate_rtp_frame_with_startcode(start_code,
frame->header, get_nal_header_size() + frames_[frame_timestamp].total_size, fptr);
// construct the NAL header from fragment header of current fragment

View File

@ -519,10 +519,10 @@ TEST(FormatTests, v3c_single_nal_unit)
if (sess)
{
sender = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_V3C, RCE_NO_FLAGS);
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_V3C, RCE_NO_H26X_PREPEND_SC);
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_V3C, RCE_NO_FLAGS);
}
int rtp_flags = RTP_NO_H26X_SCL;
int rtp_flags = RTP_NO_FLAGS;
rtp_format_t format = RTP_FORMAT_V3C;
int test_runs = 5;
int size = 8;
@ -574,7 +574,7 @@ TEST(FormatTests, v3c_fragmentation)
if (sess)
{
sender = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_V3C, RCE_NO_FLAGS);
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_V3C, RCE_NO_H26X_PREPEND_SC);
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_V3C, RCE_NO_FLAGS);
receiver->install_receive_hook(nullptr, v3c_rtp_hook);
}
@ -587,7 +587,7 @@ TEST(FormatTests, v3c_fragmentation)
5000, 7500, 10000, 25000, 50000 });
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
int rtp_flags = RTP_NO_H26X_SCL;
int rtp_flags = RTP_NO_FLAGS;
int nal_type = 5;
rtp_format_t format = RTP_FORMAT_V3C;
int test_runs = 10;