From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E620146AE4 for ; Mon, 3 Jul 2023 01:50:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E130C68C4F6; Mon, 3 Jul 2023 04:50:24 +0300 (EEST) Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A03168C2A3 for ; Mon, 3 Jul 2023 04:50:18 +0300 (EEST) Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-39ca120c103so2524417b6e.2 for ; Sun, 02 Jul 2023 18:50:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688349016; x=1690941016; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=FmqTB+NM+uyfu+Ql6vQa4A9GBIy1LJ/5lV5jvrhasAs=; b=BgXY5w5QIAopsoJzNW3iX4hnfe6IWNKjzXXvNIhMsFj5m2tqunoxephu8ESjQBKikF 4u79ex8rQLrvQcIoHE//s7nNqCpg43U0SVdfVkhN3bLusazR5VebC6EvFnzuoE03nQA0 mhbaKYS7UHxtM5QQYaJ4di6VObStluFYgTUSwWYA4gbpr+6u//nFh+vPrdtVRQxMGR09 cPWfMyGEnpLUxNlCE4JGK6WPjgxOoBinwJslKO7+rIgdMaWvrEOVKo5NjTYMcQaqJzC8 70Q2RcnAV1dLTp72z22N8QnIdzbbs3NpPd5k7Q59McfTziGciE6VtIdAnfEsO/9mvYFe dvKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688349016; x=1690941016; h=content-transfer-encoding:content-language:to:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=FmqTB+NM+uyfu+Ql6vQa4A9GBIy1LJ/5lV5jvrhasAs=; b=JY00wFVYlPWWZJWsg/I07XYsM2DhIJKU1nifhZgjOmQQELm0LICV/BGUUkSiiFpZUV V9cigwbGbklt2lN4cwWOoa1Hmkm9T4nPSIV2/7x3I3MmGzldmJ+oqpVb2vsDQbgKkWfY Udg3FYLwuzMktlvQIyZTTQ54na0KC1+eokekQ5VUjcCDtibEu3JOOJ7Rasc4KAXYc3uT ypZPN7NxIAJDtpTkeTz6QqUKpV+8/SI42e8cG7SHBieV8Kb7BIeQsh6B8yfPrBWuF0Mz vRQZe0IN5CLpjCgCYoMMuChSR54EbGg+iH0YspBIdmAQJA8LZJngIW2AdIA64aEMcRnr zkbA== X-Gm-Message-State: AC+VfDxIKO9h1OLL1uH7BB6nxcXdfD6JbC9wPiEGIEIVwlI/z3Y8gJJ7 hAPCgiuDgSSrptPcIsyfotXP3t4z3n304TPM X-Google-Smtp-Source: ACHHUZ67XZMw7CG+/Fk3rLUDY/kOEXMFgt8XZQPzRrw+ODVvyZt9SbplCwYYMCUpleO2liPFPk0lFw== X-Received: by 2002:a05:6808:21a6:b0:3a3:7b77:bb1c with SMTP id be38-20020a05680821a600b003a37b77bb1cmr9480956oib.19.1688349016259; Sun, 02 Jul 2023 18:50:16 -0700 (PDT) Received: from [192.168.1.10] ([222.164.24.244]) by smtp.gmail.com with ESMTPSA id y13-20020aa7804d000000b0067978a01246sm9162975pfm.14.2023.07.02.18.50.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Jul 2023 18:50:15 -0700 (PDT) Message-ID: Date: Mon, 3 Jul 2023 09:50:11 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 From: David Lou To: ffmpeg-devel@ffmpeg.org Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] export mime_type of data urls 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fix the fact that ffprobe no longer detect m3u8 in a data url correctly. For example, ffprobe data:application/vnd.apple.mpegurl;base64,I0VYVE0zVQojRVhULVgtVkVSU0lPTjozCiNFWFQtWC1UQVJHRVREVVJBVElPTjozMAojRVhUSU5GOjMwLApodHRwczovL2Rvd25sb2FkLnNhbXBsZWxpYi5jb20vbXA0L3NhbXBsZS0zMHMubXA0 This provides the mime_type hls detection requires. Signed-off-by: David Lou --- libavformat/data_uri.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/libavformat/data_uri.c b/libavformat/data_uri.c index 28eb2b9e08..fdc1a2eef9 100644 --- a/libavformat/data_uri.c +++ b/libavformat/data_uri.c @@ -19,18 +19,24 @@ */ #include + #include "libavutil/avstring.h" #include "libavutil/avutil.h" #include "libavutil/base64.h" +#include "libavutil/opt.h" + #include "url.h" typedef struct { + const AVClass *class; const uint8_t *data; void *tofree; size_t size; size_t pos; + char *mime_type; } DataContext; + static av_cold int data_open(URLContext *h, const char *uri, int flags) { DataContext *dc = h->priv_data; @@ -56,8 +62,10 @@ static av_cold int data_open(URLContext *h, const char *uri, int flags) (int)(next - opt), opt); return AVERROR(EINVAL); } - av_log(h, AV_LOG_VERBOSE, "Content-type: %.*s\n", - (int)(next - opt), opt); + av_free(dc->mime_type); + dc->mime_type = av_strndup(opt, (int)(next - opt)); + av_log(h, AV_LOG_VERBOSE, "Content-type: %s\n", + dc->mime_type); } else { if (!av_strncasecmp(opt, "base64", next - opt)) { base64 = 1; @@ -110,10 +118,25 @@ static int data_read(URLContext *h, unsigned char *buf, int size) return size; } +#define OFFSET(x) offsetof(DataContext, x) + +static const AVOption options[] = { + { "mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, + { NULL } +}; + +static const AVClass data_context_class = { + .class_name = "data", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + const URLProtocol ff_data_protocol = { - .name = "data", - .url_open = data_open, - .url_close = data_close, - .url_read = data_read, - .priv_data_size = sizeof(DataContext), + .name = "data", + .url_open = data_open, + .url_close = data_close, + .url_read = data_read, + .priv_data_size = sizeof(DataContext), + .priv_data_class = &data_context_class, }; -- 2.41.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".