formats: Make restoration of stream the default option

This may break some implementation if they don't want start code prefix
for some reason or if they already implemented start code prefix in
their code.

Those who implemented themselves are using an inferior solution
(one extra stream copy for fragmented frames) and should update anyway.
Those who use the flag will just get a warning to update their flags.
Those whose decoder doesn't want start code prefix may not work without
adding a flag.
This commit is contained in:
Joni Räsänen 2022-09-08 08:10:33 +03:00
parent dbcb327051
commit f7040a4992
3 changed files with 10 additions and 10 deletions

View File

@ -169,7 +169,8 @@ enum RTP_CTX_ENABLE_FLAGS {
RCE_SYSTEM_CALL_DISPATCHER = 1, // removed feature
RCE_NO_H26X_INTRA_DELAY = 1, // removed feature
RCE_NO_H26X_SCL = 1, // this flag was moved to be an RTP flag
RCE_H26X_NO_DEPENDENCY_ENFORCEMENT = 1, // the feature is disabled by default
RCE_H26X_NO_DEPENDENCY_ENFORCEMENT = 1, // the feature is already disabled by default
RCE_H26X_PREPEND_SC = 1, // the feature is already enabled by default
// These can be used to specify what the address does for one address create session
RCE_SEND_ONLY = 1 << 1, // address interpreted as remote, no binding to socket
@ -198,11 +199,10 @@ enum RTP_CTX_ENABLE_FLAGS {
* with RCE_SRTP_KMNGMNT_ZRTP */
RCE_SRTP_KMNGMNT_USER = 1 << 5,
/** By default, the RTP packet payload does not include the start code prefixes.
* Use this flag to prepend the 4-byte start code (0x00000001) to each received
* H26x frame, so there is no difference with sender input. Recommended in
* most cases. */
RCE_H26X_PREPEND_SC = 1 << 6,
/** By default, uvgRTP restores the stream by prepending 3 or 4 byte start code to each received
* H26x frame, so there is no difference with sender input. You can remove start code prefix with
* this flag */
RCE_H26X_DO_NOT_PREPEND_SC = 1 << 6,
/** Use this flag to discard inter frames that don't have their previous dependencies
arrived. Does not work if the dependencies are not in monotonic order. */

View File

@ -187,7 +187,7 @@ uvgrtp::frame::rtp_frame* uvgrtp::formats::h264::allocate_rtp_frame_with_startco
void uvgrtp::formats::h264::prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out)
{
if (rce_flags & RCE_H26X_PREPEND_SC) {
if (!(rce_flags & RCE_H26X_DO_NOT_PREPEND_SC)) {
uint8_t* pl = new uint8_t[(*out)->payload_len + 3];
pl[0] = 0;

View File

@ -507,7 +507,7 @@ 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)
{
if (rce_flags & RCE_H26X_PREPEND_SC) {
if (!(rce_flags & RCE_H26X_DO_NOT_PREPEND_SC)) {
uint8_t* pl = new uint8_t[(*out)->payload_len + 4];
pl[0] = 0;
@ -585,7 +585,7 @@ rtp_error_t uvgrtp::formats::h26x::handle_aggregation_packet(uvgrtp::frame::rtp_
for (size_t i = 0; i < nalus.size(); ++i) {
size_t fptr = 0;
bool prepend_startcode = rce_flags & RCE_H26X_PREPEND_SC;
bool prepend_startcode = !(rce_flags & RCE_H26X_DO_NOT_PREPEND_SC);
uvgrtp::frame::rtp_frame* retframe =
allocate_rtp_frame_with_startcode(prepend_startcode, (*out)->header, nalus[i].first, fptr);
@ -908,7 +908,7 @@ 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_H26X_PREPEND_SC),
uvgrtp::frame::rtp_frame* complete = allocate_rtp_frame_with_startcode(!(rce_flags & RCE_H26X_DO_NOT_PREPEND_SC),
frame->header, get_nal_header_size() + frames_[frame_timestamp].total_size, fptr);
// construct the NAL header from fragment header of current fragment