Unlike Representation id, it's defined as an integer in the spec, and not as a
string.

Signed-off-by: James Almer <jamr...@gmail.com>
---
 libavformat/dashenc.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3d8515d9ca..243194d33e 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;
@@ -805,7 +805,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);
@@ -932,7 +932,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;
@@ -953,12 +953,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)
-- 
2.24.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to