Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dash context target_latency #56

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions libavformat/dashenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ static const struct codec_string {
{ AV_CODEC_ID_NONE }
};

static atomic_int deviations_happened = 0;
static atomic_int deviations_allowed = 0;
static atomic_int_fast64_t target_latency = 0;

void av_set_target_latency(int64_t latency, int deviations_allowed) {
target_latency = latency;
deviations_allowed = deviations_allowed;
}

static atomic_int availability_time_offset = -1;
void av_set_availability_time_offset(int64_t offset) {
availability_time_offset = offset;
}

/* Still being used by deleting of old files */
static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
AVDictionary **options) {
Expand Down Expand Up @@ -1314,6 +1328,10 @@ static int write_manifest(AVFormatContext *s, int final)

avio_printf(out, "\t<ServiceDescription id=\"0\">\n");
if (!final && c->target_latency && c->target_latency_refid >= 0) {
if (c->target_latency != target_latency) {
c->target_latency = target_latency;
}

avio_printf(out, "\t\t<Latency target=\"%"PRId64"\"", c->target_latency / 1000);
if (s->nb_streams > 1)
avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid);
Expand Down Expand Up @@ -2080,20 +2098,6 @@ static inline void dashenc_delete_media_segments(AVFormatContext *s, OutputStrea
memmove(os->segments, os->segments + remove_count, os->nb_segments * sizeof(*os->segments));
}

static atomic_int deviations_happened = 0;
static atomic_int deviations_allowed = 0;
static atomic_int_fast64_t target_latency = 0;

void av_set_target_latency(int64_t latency, int deviations_allowed) {
target_latency = latency;
deviations_allowed = deviations_allowed;
}

static atomic_int availability_time_offset = -1;
void av_set_availability_time_offset(int64_t offset) {
availability_time_offset = offset;
}

static int dash_flush(AVFormatContext *s, int final, int stream)
{
DASHContext *c = s->priv_data;
Expand Down