Skip to content

Commit

Permalink
do not use source TS as RTP TS by default
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MartinPulec committed Jul 26, 2023
1 parent b634053 commit 2f1bfa9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ using namespace std;
unsigned int audio_capture_channels = 0;
unsigned int audio_capture_bps = 0;
unsigned int audio_capture_sample_rate = 0;

bool incompatible_features = false;
unsigned int cuda_devices[MAX_CUDA_DEVICES] = { 0 };
unsigned int cuda_devices_count = 1;

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

load_libgcc();

if (get_commandline_param("incompatible") != nullptr) {
incompatible_features = true;
}

return new init_data{init};
}

Expand Down Expand Up @@ -1065,6 +1069,8 @@ ADD_TO_PARAM("debug-dump", "* debug-dump=<module>[=<n>][,<module2>[=<n>]\n"
" Dumps specified buffer for debugging, n-th buffer may be selected, name is <module>.dump.\n"
" Avaiable modules: lavd-uncompressed\n");
#endif
ADD_TO_PARAM("incompatible", "* incompatible\n"
" Features that may possibly not be compatible with at least older or even any other UG version.\n");
ADD_TO_PARAM("low-latency-audio", "* low-latency-audio[=ultra]\n"
" Try to reduce audio latency at the expense of worse reliability\n"
" Add ultra for even more aggressive setting.\n");
Expand Down
1 change: 1 addition & 0 deletions src/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ extern void *mainloop_udata;
extern int glfw_init_count;
extern char pixfmt_conv_pref[]; // defined in video_codec.c
extern char *sage_network_device;
extern bool incompatible_features;

// Both of following varables are non-negative. It indicates amount of milliseconds that
// audio or video should be delayed. This shall be used for AV sync control. For
Expand Down
12 changes: 6 additions & 6 deletions src/transmit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ tx_send(struct tx *tx, struct video_frame *frame, struct rtp *rtp_session)
fec_check_messages(tx);

uint32_t ts =
(frame->flags & TIMESTAMP_VALID) == 0
? get_local_mediatime()
: get_local_mediatime_offset() + frame->timestamp;
incompatible_features && (frame->flags & TIMESTAMP_VALID) != 0
? get_local_mediatime_offset() + frame->timestamp
: get_local_mediatime();
if(frame->fragment &&
tx->last_frame_fragment_id == frame->frame_fragment_id) {
ts = tx->last_ts;
Expand Down Expand Up @@ -774,9 +774,9 @@ void audio_tx_send(struct tx* tx, struct rtp *rtp_session, const audio_frame2 *
fec_check_messages(tx);

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

for (int channel = 0; channel < buffer->get_channel_count(); ++channel)
{
Expand Down

0 comments on commit 2f1bfa9

Please sign in to comment.