Commit ff327a58 authored by James Almer's avatar James Almer

avformat/dashenc: add a PlaybackRate element

Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 0ea41ee3
...@@ -356,6 +356,14 @@ protocol. Applicable only for HTTP output. ...@@ -356,6 +356,14 @@ protocol. Applicable only for HTTP output.
Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled. Set an intended target latency in seconds (fractional value can be set) for serving. Applicable only when @var{streaming} and @var{write_prft} options are enabled.
This is an informative fields clients can use to measure the latency of the service. This is an informative fields clients can use to measure the latency of the service.
@item min_playback_rate @var{min_playback_rate}
Set the minimum playback rate indicated as appropriate for the purposes of automatically
adjusting playback latency and buffer occupancy during normal playback by clients.
@item max_playback_rate @var{max_playback_rate}
Set the maximum playback rate indicated as appropriate for the purposes of automatically
adjusting playback latency and buffer occupancy during normal playback by clients.
@end table @end table
@anchor{framecrc} @anchor{framecrc}
......
...@@ -194,6 +194,8 @@ typedef struct DASHContext { ...@@ -194,6 +194,8 @@ typedef struct DASHContext {
int profile; int profile;
int64_t target_latency; int64_t target_latency;
int target_latency_refid; int target_latency_refid;
AVRational min_playback_rate;
AVRational max_playback_rate;
} DASHContext; } DASHContext;
static struct codec_string { static struct codec_string {
...@@ -1203,14 +1205,19 @@ static int write_manifest(AVFormatContext *s, int final) ...@@ -1203,14 +1205,19 @@ static int write_manifest(AVFormatContext *s, int final)
av_free(escaped); av_free(escaped);
} }
avio_printf(out, "\t</ProgramInformation>\n"); avio_printf(out, "\t</ProgramInformation>\n");
avio_printf(out, "\t<ServiceDescription id=\"0\">\n");
if (!final && c->target_latency && c->target_latency_refid >= 0) { if (!final && c->target_latency && c->target_latency_refid >= 0) {
avio_printf(out, "\t<ServiceDescription id=\"0\">\n");
avio_printf(out, "\t\t<Latency target=\"%"PRId64"\"", c->target_latency / 1000); avio_printf(out, "\t\t<Latency target=\"%"PRId64"\"", c->target_latency / 1000);
if (s->nb_streams > 1) if (s->nb_streams > 1)
avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid); avio_printf(out, " referenceId=\"%d\"", c->target_latency_refid);
avio_printf(out, "/>\n"); avio_printf(out, "/>\n");
avio_printf(out, "\t</ServiceDescription>\n");
} }
if (av_cmp_q(c->min_playback_rate, (AVRational) {1, 1}) ||
av_cmp_q(c->max_playback_rate, (AVRational) {1, 1}))
avio_printf(out, "\t\t<PlaybackRate min=\"%.2f\" max=\"%.2f\"/>\n",
av_q2d(c->min_playback_rate), av_q2d(c->max_playback_rate));
avio_printf(out, "\t</ServiceDescription>\n");
if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) { if (c->window_size && s->nb_streams > 0 && c->streams[0].nb_segments > 0 && !c->use_template) {
OutputStream *os = &c->streams[0]; OutputStream *os = &c->streams[0];
...@@ -1423,6 +1430,11 @@ static int dash_init(AVFormatContext *s) ...@@ -1423,6 +1430,11 @@ static int dash_init(AVFormatContext *s)
c->target_latency = 0; c->target_latency = 0;
} }
if (av_cmp_q(c->max_playback_rate, c->min_playback_rate) < 0) {
av_log(s, AV_LOG_WARNING, "Minimum playback rate value is higer than the Maximum. Both will be ignored\n");
c->min_playback_rate = c->max_playback_rate = (AVRational) {1, 1};
}
av_strlcpy(c->dirname, s->url, sizeof(c->dirname)); av_strlcpy(c->dirname, s->url, sizeof(c->dirname));
ptr = strrchr(c->dirname, '/'); ptr = strrchr(c->dirname, '/');
if (ptr) { if (ptr) {
...@@ -2370,6 +2382,8 @@ static const AVOption options[] = { ...@@ -2370,6 +2382,8 @@ static const AVOption options[] = {
{ "dvb_dash", "DVB-DASH profile", 0, AV_OPT_TYPE_CONST, {.i64 = MPD_PROFILE_DVB }, 0, UINT_MAX, E, "mpd_profile"}, { "dvb_dash", "DVB-DASH profile", 0, AV_OPT_TYPE_CONST, {.i64 = MPD_PROFILE_DVB }, 0, UINT_MAX, E, "mpd_profile"},
{ "http_opts", "HTTP protocol options", OFFSET(http_opts), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, E }, { "http_opts", "HTTP protocol options", OFFSET(http_opts), AV_OPT_TYPE_DICT, { .str = NULL }, 0, 0, E },
{ "target_latency", "Set desired target latency for Low-latency dash", OFFSET(target_latency), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E }, { "target_latency", "Set desired target latency for Low-latency dash", OFFSET(target_latency), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT_MAX, E },
{ "min_playback_rate", "Set desired minimum playback rate", OFFSET(min_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E },
{ "max_playback_rate", "Set desired maximum playback rate", OFFSET(max_playback_rate), AV_OPT_TYPE_RATIONAL, { .dbl = 1.0 }, 0.5, 1.5, E },
{ NULL }, { NULL },
}; };
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here // Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58 #define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 42 #define LIBAVFORMAT_VERSION_MINOR 42
#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment