From patchwork Fri Jul 19 07:43:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leozhang X-Patchwork-Id: 13988 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 744FD449EBC for ; Fri, 19 Jul 2019 10:44:01 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4EB2C68AB78; Fri, 19 Jul 2019 10:44:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smg-bj-02.qiyi.com (unknown [202.108.14.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C06A68A56C for ; Fri, 19 Jul 2019 10:43:53 +0300 (EEST) X-AuditID: ca6c0e64-33bff700000057a5-0c-5d3174b678b9 Received: from mail.iqiyi.com (Unknown_Domain [10.11.69.96]) by smg-bj-02.qiyi.com (Qiyi mail Gateway) with SMTP id 30.C7.22437.6B4713D5; Fri, 19 Jul 2019 15:43:50 +0800 (HKT) From: leozhang To: Date: Fri, 19 Jul 2019 15:43:46 +0800 Message-ID: <1563522226-157837-1-git-send-email-leozhang@qiyi.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1562920274-85570-1-git-send-email-leozhang@qiyi.com> References: <1562920274-85570-1-git-send-email-leozhang@qiyi.com> MIME-Version: 1.0 X-Originating-IP: [10.13.40.213] X-ClientProxiedBy: BJ-CAS24.iqiyi.pps (10.15.221.33) To EXCH20.iqiyi.pps (10.16.148.50) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNLMWRmVeSWpSXmKPExsXCxe2aoLutxDDW4OIOWYtvn84wOzB6/Fm0 mSWAMYrbJimxpCw4Mz1P3y6BO+Pav63MBW8UK15MfcLcwLhMsouRk0NCwETix9Euli5GLg4h gY2MElcPNLODJNgElCTWr5jKCmKLCMhKrP43hQ3EFhYok3jwvY0JxGYRUJVYtPcZC4jNK+Ak sbt5MRvEUAWJKQ/fM4PYnEDx60seM4LYQgKOEj9uPmaHqBeUODnzCVgvs4CExMEXL5ghauQk nv76xQIz5+HUSewQdqTElZUP2Ccw8s9C0j4LSfsCRqZVjELFuem6SVm6BkZ6hZmVmXrJ+bmb GIHhdCqHL2UH48H5zocYBTgYlXh4f2QZxAqxJpYVV+YeYpTgYFYS4b39Uj9WiDclsbIqtSg/ vqg0J7X4EKM0B4uSOG82MISFBNITS1KzU1MLUotgskwcnCDdXFIixal5KalFiaUlGfGgUI8v Bga7VANjUJ/BIR8+y+Tm2CMJlxZdrqpjf7iq8akU1/9/vs+kE7U02Q+t33XEZOLPBW9n2SuJ apzZyyt+PV/CvEnZ2Uhi28EI9ksFzQaMy7f3Le3v3Og1Wfp8X2Do/MI9hZrNb2uaJuSrtDPO YPmxh+l9fPTmu3d9faSj/7abzJivs/lf66SlDW6Vz2YqsRRnJBpqMRcVJwIA5Vb6cz4CAAA= Subject: [FFmpeg-devel] dash: add descriptor which is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: leozhang --- Removed remarks which are not part of commit message. Thanks reminder doc/muxers.texi | 4 ++++ libavformat/dashenc.c | 27 +++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index b109297..bc38cf6 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -275,6 +275,10 @@ of the adaptation sets and a,b,c,d and e are the indices of the mapped streams. To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be used as stream identifier instead of IDs. When no assignment is defined, this defaults to an AdaptationSet for each stream. + +Optional syntax is "id=x,descriptor=descriptor_string,streams=a,b,c id=y,streams=d,e" and so on, descriptor is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015. +For example, -adaptation_sets "id=0,descriptor=,streams=v". +Please note that descriptor string should be a self-closing xml tag. @item timeout @var{timeout} Set timeout for socket I/O operations. Applicable only for HTTP output. @item index_correction @var{index_correction} diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index b25afb4..24f8d4d 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -68,6 +68,7 @@ typedef struct Segment { typedef struct AdaptationSet { char id[10]; + char *descriptor; enum AVMediaType media_type; AVDictionary *metadata; AVRational min_frame_rate, max_frame_rate; @@ -552,8 +553,10 @@ static void dash_free(AVFormatContext *s) int i, j; if (c->as) { - for (i = 0; i < c->nb_as; i++) + for (i = 0; i < c->nb_as; i++) { av_dict_free(&c->as[i].metadata); + av_freep(&c->as[i].descriptor); + } av_freep(&c->as); c->nb_as = 0; } @@ -748,7 +751,8 @@ static int write_adaptation_set(AVFormatContext *s, AVIOContext *out, int as_ind role = av_dict_get(as->metadata, "role", NULL, 0); if (role) avio_printf(out, "\t\t\t\n", role->value); - + if (as->descriptor) + avio_printf(out, "\t\t\t%s\n", as->descriptor); for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; char bandwidth_str[64] = {'\0'}; @@ -820,7 +824,7 @@ static int parse_adaptation_sets(AVFormatContext *s) { DASHContext *c = s->priv_data; const char *p = c->adaptation_sets; - enum { new_set, parse_id, parsing_streams } state; + enum { new_set, parse_id, parsing_streams, parse_descriptor } state; AdaptationSet *as; int i, n, ret; @@ -837,6 +841,9 @@ static int parse_adaptation_sets(AVFormatContext *s) } // syntax id=0,streams=0,1,2 id=1,streams=3,4 and so on + // option id=0,descriptor=descriptor_str,streams=0,1,2 and so on + // descriptor is useful to the scheme defined by ISO/IEC 23009-1:2014/Amd.2:2015 + // descriptor_str should be a self-closing xml tag. state = new_set; while (*p) { if (*p == ' ') { @@ -854,7 +861,19 @@ static int parse_adaptation_sets(AVFormatContext *s) if (*p) p++; state = parse_id; - } else if (state == parse_id && av_strstart(p, "streams=", &p)) { + } else if (state == parse_id && av_strstart(p, "descriptor=", &p)) { + n = strcspn(p, ">") + 1; //followed by one comma, so plus 1 + if (n < strlen(p)) { + as->descriptor = av_strndup(p, n); + } else { + av_log(s, AV_LOG_ERROR, "Parse error, descriptor string should be a self-closing xml tag\n"); + return AVERROR(EINVAL); + } + p += n; + if (*p) + p++; + state = parse_descriptor; + } else if ((state == parse_id || state == parse_descriptor) && av_strstart(p, "streams=", &p)) { //descriptor is optional state = parsing_streams; } else if (state == parsing_streams) { AdaptationSet *as = &c->as[c->nb_as - 1];