From patchwork Sat May 14 09:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 35764 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp658351pzb; Sat, 14 May 2022 02:18:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNM+10Ny7oq5VcSFN0WDxy2Gaxz1DsyIXpTZGOrGLGTHVLEcIiVNoq4aJTjPHMJO+zh2Ci X-Received: by 2002:aa7:d651:0:b0:425:c3a4:2291 with SMTP id v17-20020aa7d651000000b00425c3a42291mr2778200edr.54.1652519908035; Sat, 14 May 2022 02:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652519908; cv=none; d=google.com; s=arc-20160816; b=V2NqdlxCeBWow4+Pzm7URzu6yGETEit9dsAWoX384zg9Cxu3ooaB1AEbl4fpvy7P68 O1HLEszoFmAOe64pzXLhNNY2N7I+KPrgyh/kY+zZOgE/TYd+jsQTaatDzwnMAqSGFgm/ 5SUesceq0NXiV9y3lcRVIca+QghIsB3tPFq+4xVKEOfpIqMScvn+l7cZOKQnR9Fkd4SO 3xxFoRe4mxDU/cLhG5C/O2BSKZGE9nZ46G9d+A2pGG8flsTZUO7HiOzviBqpozgEpitE dYznXyXJy8P0+Xq6ffvn4hsqaa2vGVr9oZIqcPLyHL4zuLx4ZYKzpZPiPNdevFt80eAn uhUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=ndXUNBoLsv2JVojd5paTUJHN6RZLm2nq9vCfIkAdLXY=; b=iN1zYSDa9dfAH2jbFFlhs4Lfv4igoNHjicJRfq3LU1aonibInPyGy2wgMU7IlM8J5k 6hSAWYUFyqFx8UwHtBOkBtu1n+NngyD4vIznP3Whu5clG6t1st5VDkRGpXTrvYjuMkzQ i1myEsTfUkSlp6unR9hLLAgVVnN3mxdifmnquOc2iQQZvq168hgx4JV8r2dDiFahpT13 5KtkyxMRiNb3WlMTSx5l27jspexNR5GWVjLS/OgiErs4t/OHv4hrGPcVtJaYAeUoHZ/l +LjDGSYJrcuzH8Tlm5VWv3AFDSyA4vGZKRS0tpwzdqtvrjOnWPQ2bq4Wfes1MbvV6D4Y kwtw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id rv12-20020a17090710cc00b006f496889e5dsi3807913ejb.516.2022.05.14.02.18.27; Sat, 14 May 2022 02:18:28 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2090768B3D1; Sat, 14 May 2022 12:18:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B82FE68B2DC for ; Sat, 14 May 2022 12:18:15 +0300 (EEST) Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4L0g0h2qCXz9sbw for ; Sat, 14 May 2022 11:18:12 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 May 2022 14:47:56 +0530 Message-Id: <20220514091756.6255-1-ffmpeg@gyani.pro> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/dashdec: accept and relay CENC decryption key 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZxIhAinRt/bj Allows to process CENC-encrypted media segments. Option arg syntax is same as that for option decryption_key in MOV demuxer --- doc/demuxers.texi | 11 +++++++++++ libavformat/dashdec.c | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 238b8e03a8..c95a9ae594 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -274,6 +274,17 @@ which streams to actually receive. Each stream mirrors the @code{id} and @code{bandwidth} properties from the @code{} as metadata keys named "id" and "variant_bitrate" respectively. +@subsection Options + +This demuxer accepts the following option: + +@table @option + +@item cenc_decryption_key +16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). + +@end table + @section imf Interoperable Master Format demuxer. diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 0b5ff5aeb9..0f66251354 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -150,6 +150,7 @@ typedef struct DASHContext { char *allowed_extensions; AVDictionary *avio_opts; int max_url_size; + char *cenc_decryption_key; /* Flags for init section*/ int is_init_section_common_video; @@ -1893,6 +1894,9 @@ static int reopen_demux_for_component(AVFormatContext *s, struct representation pls->ctx->pb = &pls->pb.pub; pls->ctx->io_open = nested_io_open; + if (c->cenc_decryption_key) + av_dict_set(&in_fmt_opts, "decryption_key", c->cenc_decryption_key, AV_OPT_FLAG_DECODING_PARAM); + // provide additional information from mpd if available ret = avformat_open_input(&pls->ctx, "", in_fmt, &in_fmt_opts); //pls->init_section->url av_dict_free(&in_fmt_opts); @@ -2344,6 +2348,7 @@ static const AVOption dash_options[] = { OFFSET(allowed_extensions), AV_OPT_TYPE_STRING, {.str = "aac,m4a,m4s,m4v,mov,mp4,webm,ts"}, INT_MIN, INT_MAX, FLAGS}, + { "cenc_decryption_key", "Media decryption key (hex)", OFFSET(cenc_decryption_key), AV_OPT_TYPE_STRING, {.str = NULL}, INT_MIN, INT_MAX, .flags = FLAGS }, {NULL} };