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 ESMTPS id 94F1B49EFC for ; Tue, 29 Apr 2025 12:28:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91C8F68B3F9; Tue, 29 Apr 2025 15:28:23 +0300 (EEST) Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B7E3C687C02 for ; Tue, 29 Apr 2025 15:28:16 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1745929692; bh=BiGVLmnAKBDIRVnhszZAznSuMhoFHxK6Gpa3mnG827s=; h=From:Subject:Date:References:To:In-Reply-To; b=gzf72Uq2dcGpXXRDs9G6R/yCS+sCMo8YinHe++g9yM2KtMkYKP/H40RVUW77QBHax /GptATpv+dqm1PDs+8wmm/i2L+UlHPbsXov4XuwBf2sbEk7fG3VOiWrOAnTdYRyprq HFa16pwWaFN32pmqZnpk1McIY5hKKg/Zfxh56pXQ= Received: from smtpclient.apple ([119.147.10.242]) by newxmesmtplogicsvrszgpua8-1.qq.com (NewEsmtp) with SMTP id 70B94AAB; Tue, 29 Apr 2025 20:28:11 +0800 X-QQ-mid: xmsmtpt1745929691tyoosrr83 Message-ID: X-QQ-XMAILINFO: MoXwTY6T4qpUAN4vvFGnj596gATxdJdD1fFLH5huSrhDqq8WBizDkx7a0UbySR uDS1pPuTBIeiw5S+9m1K74/RFveCMCGDeAXzOUW5zTjM5e9g9reP9VDY4rLSsxM/Q5pA9mfD5DPF hOi4T+/IF8VkCZ8WL4dt/qPsqVypYfadTYIz1aXznsYdrA0OmW7Ct1unGiIKmlBFXMVuAUkV+fop D0FC3ZfcAqXNySv9/bbpHB2CKdt+bhC2ViEkAPV0O1+ox4wJZJ8sw44cnkiqXBQLCOTxMDfoS9HX /g2wCWFws5J+AyKsbh/g2BjaAx2ok5T33FfhiKlPN0eC2PEaouJ1daIhPW6KdP14BcqwutqY6E5d 2LujTqqZbkWblUYSkqmlsfxgjFGqayvFoVTsR1wjhFKLmTxc7j5xHW3sumLPI+zOwjl6xK7GdXJu t0eSGdAi0/8q1plmuht0fk/VN137oozx4Pp+HcuqIJiAm4rj1GhLhj4nLUDdoohAMY60SiLSwQIN 0hopbWEJPu8fOAvo8XyKFOoVt4WcGXhp8FEQ57Kh0fUgEoobNnz7d+icnA9/+5wC6b32uHfnQc1O 4ramyGCLRy/IOaEL9WxfRLfGhiSEIWsYBOn/c40uRyVtweSDL3MmasQuzmY05z26KvoLCd/+sToK D/JmxB2LbrGI9hL7PuWpjJF3DYd8W+G+pji0GmlYTDLxJpDRbxhO+/LsZzQz64XFXg1xw6APIi48 jjB/6cxx/QRwM9UhL3BIR/nfJtGQYku89rruh50y1B3MvrZuidKPFkTIaH3dHw14DtOQyIaZv9qP IOSA4VUHIRwNLQ/sddjV/hQXdAba1PDXH9z17cokrgEBJY3XTgz4VWIERFsTpZv7bXtoeCSf81w3 ndJG0WyRArvCwZ/SKvhtToGzBCRWxF/ajTB/56w4pnCyb8Qtb2mxDHorMusDbNbmwhyQ6RygX1jA ujTlPIaMFFBtiMsPodCKwwZ4z7Z8Ds/CS6GzWHE98roSf6xe7qPle6GamT8NU8sMbRAEmwsmO3wQ j5+jlyI5iYGJnGqEIs X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= From: Zhao Zhili Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.400.131.1.6\)) Date: Tue, 29 Apr 2025 20:28:01 +0800 References: To: FFmpeg development discussions and patches In-Reply-To: X-OQ-MSGID: X-Mailer: Apple Mail (2.3826.400.131.1.6) Subject: Re: [FFmpeg-devel] [PATCH v3] avformat/hls: Return error code when read key file failed 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: > On Apr 29, 2025, at 20:15, Andreas Rheinhardt wrote: > > Zhao Zhili: >> From: Zhao Zhili >> >> --- >> libavformat/hls.c | 47 ++++++++++++++++++++++++++++++++++------------- >> 1 file changed, 34 insertions(+), 13 deletions(-) >> >> diff --git a/libavformat/hls.c b/libavformat/hls.c >> index 6623c80309..fe908a563b 100644 >> --- a/libavformat/hls.c >> +++ b/libavformat/hls.c >> @@ -1331,6 +1331,37 @@ static void intercept_id3(struct playlist *pls, uint8_t *buf, >> pls->is_id3_timestamped = (pls->id3_mpegts_timestamp != AV_NOPTS_VALUE); >> } >> >> +static int read_key(HLSContext *c, struct playlist *pls, struct segment *seg) >> +{ >> + AVIOContext *pb = NULL; >> + >> + int ret = open_url(pls->parent, &pb, seg->key, &c->avio_opts, NULL, NULL); >> + if (ret < 0) { >> + av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s, %s\n", >> + seg->key, av_err2str(ret)); >> + return ret; >> + } >> + >> + ret = avio_read(pb, pls->key, sizeof(pls->key)); >> + ff_format_io_close(pls->parent, &pb); >> + if (ret != sizeof(pls->key)) { >> + if (ret < 0) { >> + av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s, %s\n", >> + seg->key, av_err2str(ret)); >> + } else { >> + av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s, read bytes %d != %zu\n", > > SIZE_SPECIFIER Please elaborate. > > Apart from that: Do we really need to two different log messages? IO error vs invalid data can be important for this case. Any suggestions? > >> + seg->key, ret, sizeof(pls->key)); >> + ret = AVERROR(AVERROR_INVALIDDATA); > > AVERROR() is wrong. OK. > >> + } >> + >> + return ret; >> + } >> + >> + av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url)); >> + >> + return 0; >> +} >> + >> static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, AVIOContext **in) >> { >> AVDictionary *opts = NULL; >> @@ -1352,19 +1383,9 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, >> >> if (seg->key_type == KEY_AES_128 || seg->key_type == KEY_SAMPLE_AES) { >> if (strcmp(seg->key, pls->key_url)) { >> - AVIOContext *pb = NULL; >> - if (open_url(pls->parent, &pb, seg->key, &c->avio_opts, NULL, NULL) == 0) { >> - ret = avio_read(pb, pls->key, sizeof(pls->key)); >> - if (ret != sizeof(pls->key)) { >> - av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n", >> - seg->key); >> - } >> - ff_format_io_close(pls->parent, &pb); >> - } else { >> - av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s\n", >> - seg->key); >> - } >> - av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url)); >> + ret = read_key(c, pls, seg); >> + if (ret < 0) >> + goto cleanup; >> } >> } >> > > _______________________________________________ > 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". _______________________________________________ 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".