From patchwork Sat Jul 18 00:19:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21151 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 53625449F78 for ; Sat, 18 Jul 2020 03:19:56 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AB0B68B6BB; Sat, 18 Jul 2020 03:19:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f66.google.com (mail-ej1-f66.google.com [209.85.218.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C561B68B5BA for ; Sat, 18 Jul 2020 03:19:49 +0300 (EEST) Received: by mail-ej1-f66.google.com with SMTP id a1so12665924ejg.12 for ; Fri, 17 Jul 2020 17:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YeEvKagSajrJ00bPYynjqKB0SxdZkeYxHmWeISUVAPU=; b=Z9a8B16c1PwLR5q3frdPTmhqNKAv0xQGIuUODYK/saDrr2IK0Rs57bbC3rAp1L52OW b0Z/acwxxrTwdZKjayWmx/z88/EoxUOqiAqx+u+rOrBpluh9nREJP7HWaY2jomftTSii Qk3sk0K/a9AHIwCtQxef83MxE7I89SkfY+R6Md4cugafanc2fv2rDSUtTbfvLxLgsUqo 5p1cg7ptoqCvcYotN9V7LcaM/ERt1HP0J1g2ZbcaJUD0Wbmv70QInze3LR59scNoKw6Z Bdx7lsEbwnAIwRSZhVR3FhmTYpM78tCOCCIetr7V3pJuOjqWsO63Dcm5m3IBL7Prw2Gx wCAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YeEvKagSajrJ00bPYynjqKB0SxdZkeYxHmWeISUVAPU=; b=bgTQaTFafIsNQdtCzlD1df/RMaIftyUY92Zo/YXwhRf3URAw7nmmqxdsMeg1+Z+PgT g7xl5cULnUgN/HVlEDBeIfXOlWzj3S3gsYzRIsQtX0/TPpwqlX0QwEI2abH/2k1N/soT H5J4P4yYoPPCeS9ODZp+tyqG7CWKchSZYYcxC4UigHnxzQ1g0ZgnwMpKSEPBYLg9yQXT msyfTe1e9HfcMHf9d0DKNJxx4YJG34H/8LYAMARai1+rG/lMzLJDozF/yJ3iLHiP8P6A uZ/6mE5zoxDZow499V5DpvBsFPoSghXZlA2X3NJ0D9pbFwLx69Xw5TmnQlOj/xe8O1gW 1sTQ== X-Gm-Message-State: AOAM532Ue+XJK+CnZ3OF4mwW/mT5qyAyiVBt5F0M+Cbl0j09vbIczt+x A+Fvw/TbJNoArTetP+ng6eGHM4fc X-Google-Smtp-Source: ABdhPJxr00u7IgC8h8aPXRv1dMHTItakvw0+KT1KB7sQzvSkNPpTVoaFfYDSjdk80HTrcJBq7atETw== X-Received: by 2002:a17:906:af6d:: with SMTP id os13mr10631557ejb.57.1595031588754; Fri, 17 Jul 2020 17:19:48 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id y7sm9299001ejd.73.2020.07.17.17.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 17:19:48 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Jul 2020 02:19:20 +0200 Message-Id: <20200718001928.10603-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200718000636.2167-1-andreas.rheinhardt@gmail.com> References: <20200718000636.2167-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/11] avformat/webmdashenc: Only check for existence of metadata if it is used 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Also return proper error codes when it is absent: AVERROR(EINVAL) instead of AVERROR_INVALIDDATA. Signed-off-by: Andreas Rheinhardt --- libavformat/webmdashenc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index a9edcf73b8..4d25d79846 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -165,21 +165,16 @@ static int write_representation(AVFormatContext *s, AVStream *stream, char *id, int output_width, int output_height, int output_sample_rate) { WebMDashMuxContext *w = s->priv_data; - AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0); - AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0); - AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0); - AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0); AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0); const char *bandwidth_str; - if (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth)) { - return AVERROR_INVALIDDATA; - } avio_printf(s->pb, "is_live && !bandwidth) { + if (bandwidth) { + bandwidth_str = bandwidth->value; + } else if (w->is_live) { + // if bandwidth for live was not provided, use a default bandwidth_str = (stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ? "128000" : "1000000"; } else { - bandwidth_str = bandwidth->value; + return AVERROR(EINVAL); } avio_printf(s->pb, " bandwidth=\"%s\"", bandwidth_str); if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && output_width) @@ -198,6 +193,13 @@ static int write_representation(AVFormatContext *s, AVStream *stream, char *id, avio_printf(s->pb, " startsWithSAP=\"1\""); avio_printf(s->pb, ">"); } else { + AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0); + AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0); + AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0); + AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0); + if (!irange || !cues_start || !cues_end || !filename) + return AVERROR(EINVAL); + avio_printf(s->pb, ">\n"); avio_printf(s->pb, "%s\n", filename->value); avio_printf(s->pb, "