From patchwork Wed Oct 23 16:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Letourneau X-Patchwork-Id: 52475 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1c41:b0:48e:c0f8:d0de with SMTP id im1csp275543vqb; Thu, 24 Oct 2024 04:44:06 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDlHdu8BEkjodNncE4QjvGBvY15SmMeg62ZaAdp3fNlPXjc5Sj+12ALMXGevXnhp6PncmDnA4ks1Ml8+SMYz3S@gmail.com X-Google-Smtp-Source: AGHT+IH3WuCRsbjkvIuVNXSa91zEeuLCaecjpGV+796r3NghkTIWaSl6c0c63l7xfouGqRfdsk7p X-Received: by 2002:a17:907:3e20:b0:a9a:161:7863 with SMTP id a640c23a62f3a-a9abf96eb06mr461024966b.58.1729770245816; Thu, 24 Oct 2024 04:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729770245; cv=none; d=google.com; s=arc-20240605; b=aqnM7on43mKzdKf/gRA6YUmQmSjDJzK+dZuljoTVMoBR3yewT2blSqrcda/fmXA7ZD UbDjv54ctC8+lSCCNv/IsVsnlCVf0zu8folmMtlrr1ugzxFXUnQV1lyw2aQrDa0ORsOf 7kP8yobslA0thoZJEJllqMOZtS/13NxQnVEXeE7Qay4sjQIq9xvMyL+NS/d8p4gnYUXo MBSpAMfnh54LgDrnqh0VPeOd6ILpp43NtUgD/BqPF5P/jhg1OA1MACXdzUwGxl2RBHFQ gA+tDpvnXGuXbhouuF3yHwMVLj93grToiTS97yedmDl2XevgxBLbB0HY3t2hpiVgcAmj 89MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=nzKpyrdFw4M/rFPBfcUxqcMkn+5NFs7yVWooeywWsD8=; fh=CtTycoDPlAIBgjQjyMwJiKzVNbXWLkZfuZNQCepVrBE=; b=NexdEzJlueHCU/mqg43XbU9F6nWmvd8Mi+XK3OGQWA+F5ntBPourYm/l/BVSB5AFKu Ct5nNnq9Rehfgg1akVXC7mU6ar8LCmsPA1s9K9IPIXZSZFNfO3HNJyHyPtKp8ALoF/C4 o70tAyYRU1fujDJFK2E6BHV7/Wm/EAP56C9SGccGZEFWk0PoJ7AbeMOEWCfzjnSq3XP3 saOFRWNp9D+iwoEh23YB0Xtiy1qH6fb1NiTnSS4Ev7a6bnbgsUdbGMtgnDcyNx/tYzLU fmXmHP8iGO/EpeFF1eD0CJ48kUc0WZhkK7qdRQJvcl74FXTk4KFLyppU0UbHZOfCEyBl y2Qg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=hgr9rKW4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a9acfa2de9esi123203266b.559.2024.10.24.04.44.02; Thu, 24 Oct 2024 04:44:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=hgr9rKW4; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D95968DCD2; Wed, 23 Oct 2024 19:57:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 815D468DC7A for ; Wed, 23 Oct 2024 19:57:44 +0300 (EEST) Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-460c316fc37so169161cf.0 for ; Wed, 23 Oct 2024 09:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729702662; x=1730307462; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pr3IGVPb4eQq+tUV1RzNRs4TCjl+f2qc/h6BlIlQvgo=; b=hgr9rKW4vq3Qe8iz3BrX7cjTEkEyo/211pHZ+s0ooRwyhdc3d3NxhXdvCrYrjhVz1H FEK8KBG2YCKIKQ/6clc4seU0r76Df4GqmYtisV7ZVa3jCqpLy3/ivWU3FKQX2Mkg7G6l SROkI+DeR7sPfMbsJik5W3yvtCG8sLxQY10tKzBAijwc0R1Q0PvYpXD3XKlvpxXOflzZ Vl9daVSBwSUWeigWltNh52+zFqmzxL1dpmYHz1v8BxBduOdSR1ehCW4FErt+iuGIg9vo hN/gGx/lLkdFnAWWZWqC4+H6EWQO6Sfxa8FxQ9JIUwOFAyYjKOnr9fcCGqrU17rDxew3 mZ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729702662; x=1730307462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pr3IGVPb4eQq+tUV1RzNRs4TCjl+f2qc/h6BlIlQvgo=; b=jOiiIzLlEnRg3gyT6hXqjp85ihNYwQV5aa5sbwm+fxkJtCNHOVujdjagm7umUvHLLf hsLivQjoypO+xzwG+ukpFw1tv3Q9kNZ4JqW6NovcXXt4ixjPoIGYIMwtx1fi89/qocV9 wxW2a5IV3a54H5bOATvi+Gv9DciRo4VTVDtflxSHPW5WGNLXrcBFdC3vo8KcCshAqqCk k0N0cQENBkDZcjJoZ0abTsfA8a2exszzF7h70HPPGMWRadclv2E/AS9QNarNDYtm0bPw tNpM6eyxM+LZ8EsaDTQVxD4I5M+0DbV6470HOjwXXAWBq7uU4xxbsM7kj7oJaVC2zsx+ w+4g== X-Gm-Message-State: AOJu0Yy744G9O4qoquA4X3XVJ4i96EDK2bNfIKMwPAV9mX7sGrDg9G1K 4BwwTq7RanpbfmJtv0F1Q6pi1vgwEQLHy3UAI7WD1st7oj/3+x1Tt6uuJg== X-Received: by 2002:a05:6214:4341:b0:6cb:f6de:3dc4 with SMTP id 6a1803df08f44-6ce34295a7emr39433156d6.28.1729702660201; Wed, 23 Oct 2024 09:57:40 -0700 (PDT) Received: from work-XPS15-9530.localdomain ([76.64.179.180]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ce009db6a2sm40541526d6.104.2024.10.23.09.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 09:57:37 -0700 (PDT) From: Louis Letourneau X-Google-Original-From: Louis Letourneau To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Oct 2024 12:57:14 -0400 Message-ID: <20241023165714.26360-2-lletourn49@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023165714.26360-1-lletourn49@gmail.com> References: <20241023165714.26360-1-lletourn49@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/1] Added support to get specific periods from the mpeg-dash demuxer instead of just the longest one. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Louis Letourneau Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: yFw/HndEUgeq From: Louis Letourneau --- libavformat/dashdec.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index a1d274f2f0..345454e6b6 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -150,6 +150,7 @@ typedef struct DASHContext { int is_live; AVIOInterruptCB *interrupt_callback; + int64_t period_index; char *allowed_extensions; AVDictionary *avio_opts; int max_url_size; @@ -1220,6 +1221,7 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) char *val = NULL; uint32_t period_duration_sec = 0; uint32_t period_start_sec = 0; + int64_t period_index = -1; if (!in) { close_in = 1; @@ -1314,6 +1316,7 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) // at now we can handle only one period, with the longest duration node = xmlFirstElementChild(node); while (node) { + period_index++; if (!av_strcasecmp(node->name, "Period")) { period_duration_sec = 0; period_start_sec = 0; @@ -1328,13 +1331,15 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) attr = attr->next; xmlFree(val); } - if ((period_duration_sec) >= (c->period_duration)) { + if ((period_duration_sec) >= (c->period_duration) || period_index == c->period_index) { period_node = node; c->period_duration = period_duration_sec; c->period_start = period_start_sec; if (c->period_start > 0) c->media_presentation_duration = c->period_duration; } + if(period_index == c->period_index) + break; } else if (!av_strcasecmp(node->name, "ProgramInformation")) { parse_programinformation(s, node); } @@ -1345,6 +1350,11 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) ret = AVERROR_INVALIDDATA; goto cleanup; } + if(c->period_index > period_index) { + av_log(s, AV_LOG_ERROR, "Period index out of bounds. Asked '%ld' vs Highest period index '%ld'\n", c->period_index, period_index); + ret = AVERROR_INVALIDDATA; + goto cleanup; + } adaptionset_node = xmlFirstElementChild(period_node); while (adaptionset_node) { @@ -2341,6 +2351,8 @@ static int dash_probe(const AVProbeData *p) #define OFFSET(x) offsetof(DASHContext, x) #define FLAGS AV_OPT_FLAG_DECODING_PARAM static const AVOption dash_options[] = { + {"period_index", "Period to use in a multi period dash. If negative, the longest period is used", + OFFSET(period_index), AV_OPT_TYPE_INT64, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS}, {"allowed_extensions", "List of file extensions that dash is allowed to access", OFFSET(allowed_extensions), AV_OPT_TYPE_STRING, {.str = "aac,m4a,m4s,m4v,mov,mp4,webm,ts"},