diff options
author | James Almer <jamrial@gmail.com> | 2020-01-08 13:47:08 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-02-16 13:11:16 -0300 |
commit | 4d27def59c922eafc7092af7096eb048db8e0db3 (patch) | |
tree | baa82679844ad5e82ca8b17e7f541b56eb7108eb | |
parent | f3d8f517dbc42de8e2f97cc01bf5171bb05fbcc7 (diff) | |
download | ffmpeg-4d27def59c922eafc7092af7096eb048db8e0db3.tar.gz |
avformat/dashenc: make AdaptationSet id an integer value
Unlike Representation id, it's defined as an integer in the spec, and not as a
string.
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavformat/dashenc.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 9a8dde98e9..59ce3cb6a9 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -80,7 +80,7 @@ typedef struct Segment { } Segment; typedef struct AdaptationSet { - char id[10]; + int id; char *descriptor; int64_t seg_duration; int64_t frag_duration; @@ -802,7 +802,7 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind AVDictionaryEntry *lang, *role; int i; - avio_printf(out, "\t\t<AdaptationSet id=\"%s\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"", + avio_printf(out, "\t\t<AdaptationSet id=\"%d\" contentType=\"%s\" segmentAlignment=\"true\" bitstreamSwitching=\"true\"", as->id, as->media_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio"); if (as->media_type == AVMEDIA_TYPE_VIDEO && as->max_frame_rate.num && !as->ambiguous_frame_rate && av_cmp_q(as->min_frame_rate, as->max_frame_rate) < 0) avio_printf(out, " maxFrameRate=\"%d/%d\"", as->max_frame_rate.num, as->max_frame_rate.den); @@ -929,7 +929,7 @@ static int parse_adaptation_sets(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { if ((ret = add_adaptation_set(s, &as, s->streams[i]->codecpar->codec_type)) < 0) return ret; - snprintf(as->id, sizeof(as->id), "%d", i); + as->id = i; c->streams[i].as_idx = c->nb_as; ++as->nb_streams; @@ -950,12 +950,20 @@ static int parse_adaptation_sets(AVFormatContext *s) p++; continue; } else if (state == new_set && av_strstart(p, "id=", &p)) { + char id_str[10], *end_str; + + n = strcspn(p, ","); + snprintf(id_str, sizeof(id_str), "%.*s", n, p); + + i = strtol(id_str, &end_str, 10); + if (id_str == end_str || i < 0 || i > c->nb_as) { + av_log(s, AV_LOG_ERROR, "\"%s\" is not a valid value for an AdaptationSet id\n", id_str); + return AVERROR(EINVAL); + } if ((ret = add_adaptation_set(s, &as, AVMEDIA_TYPE_UNKNOWN)) < 0) return ret; - - n = strcspn(p, ","); - snprintf(as->id, sizeof(as->id), "%.*s", n, p); + as->id = i; p += n; if (*p) |