Skip to content

Commit 2f1bfa9

Browse files
committed
do not use source TS as RTP TS by default
Do not use source TS as (a base for) RTP TS by default anymore. Since this was essential for synchronized DeckLink playback, require `--incompatible` to enable this. The reason to disable for now is because it breaks compressed audio. Eg. for Opus, one receives 2 packets for 40 ms input. Currently only the first gets source TS, second is undefined, thus getting the default, loosely related TS, that may however create TS discontinuity (especially with the time, when PC and DeckLink time diverges). There is no good solution for the above yet, sending both packet with the same TS and m-bit on second isn't sufficient now, because it gets joined in receiver buffer and eg. Opus is not self delimiting so it will need changes on receiver side to pass RTP packets to Opus decoder as Opus packets. refer to GH-326
1 parent b634053 commit 2f1bfa9

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/host.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ using namespace std;
107107
unsigned int audio_capture_channels = 0;
108108
unsigned int audio_capture_bps = 0;
109109
unsigned int audio_capture_sample_rate = 0;
110-
110+
bool incompatible_features = false;
111111
unsigned int cuda_devices[MAX_CUDA_DEVICES] = { 0 };
112112
unsigned int cuda_devices_count = 1;
113113

@@ -426,6 +426,10 @@ struct init_data *common_preinit(int argc, char *argv[])
426426

427427
load_libgcc();
428428

429+
if (get_commandline_param("incompatible") != nullptr) {
430+
incompatible_features = true;
431+
}
432+
429433
return new init_data{init};
430434
}
431435

@@ -1065,6 +1069,8 @@ ADD_TO_PARAM("debug-dump", "* debug-dump=<module>[=<n>][,<module2>[=<n>]\n"
10651069
" Dumps specified buffer for debugging, n-th buffer may be selected, name is <module>.dump.\n"
10661070
" Avaiable modules: lavd-uncompressed\n");
10671071
#endif
1072+
ADD_TO_PARAM("incompatible", "* incompatible\n"
1073+
" Features that may possibly not be compatible with at least older or even any other UG version.\n");
10681074
ADD_TO_PARAM("low-latency-audio", "* low-latency-audio[=ultra]\n"
10691075
" Try to reduce audio latency at the expense of worse reliability\n"
10701076
" Add ultra for even more aggressive setting.\n");

src/host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ extern void *mainloop_udata;
109109
extern int glfw_init_count;
110110
extern char pixfmt_conv_pref[]; // defined in video_codec.c
111111
extern char *sage_network_device;
112+
extern bool incompatible_features;
112113

113114
// Both of following varables are non-negative. It indicates amount of milliseconds that
114115
// audio or video should be delayed. This shall be used for AV sync control. For

src/transmit.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ tx_send(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session)
389389
fec_check_messages(tx);
390390

391391
uint32_t ts =
392-
(frame->flags & TIMESTAMP_VALID) == 0
393-
? get_local_mediatime()
394-
: get_local_mediatime_offset() + frame->timestamp;
392+
incompatible_features && (frame->flags & TIMESTAMP_VALID) != 0
393+
? get_local_mediatime_offset() + frame->timestamp
394+
: get_local_mediatime();
395395
if(frame->fragment &&
396396
tx->last_frame_fragment_id == frame->frame_fragment_id) {
397397
ts = tx->last_ts;
@@ -774,9 +774,9 @@ void audio_tx_send(struct tx* tx, struct rtp *rtp_session, const audio_frame2 *
774774
fec_check_messages(tx);
775775

776776
const uint32_t timestamp =
777-
buffer->get_timestamp() == -1
778-
? get_local_mediatime()
779-
: get_local_mediatime_offset() + buffer->get_timestamp();
777+
incompatible_features && buffer->get_timestamp() != -1
778+
? get_local_mediatime_offset() + buffer->get_timestamp()
779+
: get_local_mediatime();
780780

781781
for (int channel = 0; channel < buffer->get_channel_count(); ++channel)
782782
{

0 commit comments

Comments
 (0)