From patchwork Wed Oct 23 16:51:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Louis Letourneau X-Patchwork-Id: 52453 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:aaed:0:b0:48e:c0f8:d0de with SMTP id k13csp597042vqw; Wed, 23 Oct 2024 09:59:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXtcYY6Jlw5Quy5KaCJos9yvgJ3R7TUAdmnlwTTiUpDAHwKeQvZIBh8Ll2M/gnvDV+q3Gwk9cVEc1i+kkRyHt3N@gmail.com X-Google-Smtp-Source: AGHT+IGA+mTKBCCeM4R6AZSa7yt9Ocw4J7rab73AU/Tqi9DKlrZSkM0mPNmu2Ld5ySzkXObX8Mgm X-Received: by 2002:a05:6512:3d0e:b0:539:f035:e158 with SMTP id 2adb3069b0e04-53b1a30824fmr1601170e87.18.1729702745492; Wed, 23 Oct 2024 09:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729702745; cv=none; d=google.com; s=arc-20240605; b=Qh17kZgX3pEPTP9eji9DCbGZiuScQdMajBOLt1+tc2fKilLSmNl/W2mLsKHE2iarzq S6r2hzEDuxNTj8K5ZlxRXKYyUaghOAenzPDsiYtrYokseQ+tUAOJ/ZCpXVY+v6bO0Nx+ 1uShlUb6AMwGcAs/GGg7bIrfEHZjKUdUvJPj818tt/MZYnBctRM+TpzEZt3VNxN5lmDy 3uZKiWgAVdwPNMObSh3yA5M21SkNJCV4wqmqoD4LIICuqBj4Sg2/0t/UJ9qNcZYMNZKW QgD430RFGMhzeUdpTTzmHe4jschI6zbyaRiO+Qggy7d1YTJAovM7qe1kBrGqEV37SJWj OzOw== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=nzKpyrdFw4M/rFPBfcUxqcMkn+5NFs7yVWooeywWsD8=; fh=CtTycoDPlAIBgjQjyMwJiKzVNbXWLkZfuZNQCepVrBE=; b=F8xK24xs0zfPeGPgPhyJMLCQN6N1hrl5xOn42Cv8gfQT+69ZmIddhxn35IXsL9BMA7 E6qfJ7tcw+rl/9Vqv8WKoOhXUK7weyPJr22G+hFIOCTUxMxIUPLVPDfh0qRMQKhrNvm3 sTMAPQAJCtFktqR6BEl55NA8pN6utPgSJEjbcAFW+CahSRDtD4R8b0kw+NV15JT6LBBi OE9MGtrI7dSOtTevsily1Dhrlxp/NJ8mfk065tgcehhZwU1f+ttTktmCL3FUBTyrBCyR IdNZIqKFpIf38kfZfsW/H3lrcPIfYAsPdkLBbRfGKrtF9vVyx9HoxFqZr8jYmEcV+OxW /bdw==; 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=nB+CHWIj; 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 2adb3069b0e04-53a223e656dsi2806958e87.102.2024.10.23.09.59.05; Wed, 23 Oct 2024 09:59: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=nB+CHWIj; 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 4A37B68DBC9; Wed, 23 Oct 2024 19:52:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 264AB68D463 for ; Wed, 23 Oct 2024 19:52:08 +0300 (EEST) Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6cbe9e8bbb1so418856d6.1 for ; Wed, 23 Oct 2024 09:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729702326; x=1730307126; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pr3IGVPb4eQq+tUV1RzNRs4TCjl+f2qc/h6BlIlQvgo=; b=nB+CHWIj2quUPLMXWFsQFmbsrhjZQq6mvy6SCZKcRCt0JLKm6Q7XP6M+JEsoDnorpi 1UaDSAJiE7trKgh4SNMYXTrPBxT7R0EIMyCekuNSPxbF6wGSCViyDZ+mmE0lWn9dO/2r 8C878XcBHGD93A1F8KT5+wXimk1WU4wvJK+zMikIOy/2Ymtwsf81/qlF3XQJVxADCU2z LPIyPJsiSJ0I6JDKEpDvMERzSPOoXuYX6rDRlOJvFL32YlDzggT0cCPDO+tDfGtfsXGJ GYulrBZ9vab+bTzgVLUYg7sRz7AOtdBjO4SlyACUCb0HIIbDqWw2ZgrR9qHdTKpRHVWK ygHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729702326; x=1730307126; h=content-transfer-encoding:mime-version: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=ZkjLRFYo679LM02eq3f4a+jHHcqTMBBtxxA83fAPyzPN7gVau+h8nQiznO64qcGhGM CcXU2MUkQOaLR1kJNRT7Uo5NjUcSeHjf+dox+ksa2mdTYN1dax7YJKQwL4uxXma4sYnx Hg9lymzwCqnPci+xFL3Y82lCLCfEnh9kJSFGv27sEnjeWm2QG+u3RXp0ku4l8HZoL7wF oljj7XmUe54XLApHbEWyFwt8/wslX4RmeK6HcHqltb6o7gB5hKa7pEwHZbcSQC5IF2ss 5h/RAKKcWMODwzM0zTHRNI8gBbGABfs61TqEyxs6JSRPgj2J+7gOFq5PfzbmrIqQo9iI x/KQ== X-Gm-Message-State: AOJu0YwQCMt2sP8ua5ZOJiIOdVZ5kgGTrLQngWoYTpQcHLACY6cTrDZt pwrQiEx3iiuHw3f7YTi7fOphPvSziGR4ryuRueUYVSCn4WxaPzuKYWXa5A== X-Received: by 2002:ad4:4150:0:b0:6ce:37cc:4911 with SMTP id 6a1803df08f44-6ce37cc4c2cmr23000076d6.8.1729702325763; Wed, 23 Oct 2024 09:52:05 -0700 (PDT) Received: from work-XPS15-9530.localdomain ([76.64.179.180]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ce00999c98sm40974536d6.99.2024.10.23.09.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 09:52:04 -0700 (PDT) From: Louis Letourneau X-Google-Original-From: Louis Letourneau To: ffmpeg-devel@ffmpeg.org Date: Wed, 23 Oct 2024 12:51:50 -0400 Message-ID: <20241023165150.26202-1-lletourn49@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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: qGvKuI0rR4mo 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"},