From patchwork Sun Aug 25 14:53:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 14703 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id A74154497EB for ; Sun, 25 Aug 2019 17:54:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9283E68AC05; Sun, 25 Aug 2019 17:54:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from SMTPBG357.QQ.COM (SMTPBG357.QQ.COM [183.61.51.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFA7268AC04 for ; Sun, 25 Aug 2019 17:54:07 +0300 (EEST) X-QQ-mid: bizesmtp22t1566744801t2nojs8w Received: from localhost (unknown [47.90.47.25]) by esmtp6.qq.com (ESMTP) with id ; Sun, 25 Aug 2019 22:53:21 +0800 (CST) X-QQ-SSF: 01100000004000K0ZQF1B00A0000000 X-QQ-FEAT: 3EGeizTikuwp82LwbZGR2pESnu0EgymduiTCk1yU8/Vxhc3hhYAv36mxPg40E EVPlNa0CA9rSOMHvQb2qRTGfLg0C5oiCh8nfOY+Q0Sbqtky38XLJXuIKr6RR3bXqRdCNb86 noWUWvr61hOt9S0o1Y7yz6jhDTJqjKCb1aXxHWrGINKJOnUUPgvqAwo4yaiRHijfBVbtfRO aqyV5WRmrmU6ECkDjAGmW8kmptm8nxSufqpZrNr7FJ+wVyiSLIeAqvGGZ0roFaI/Io0tp6e 1SqMSG9vqIub4susgUQKh4lP+hHqNl/ciC/YEkKRVPFN6VcR7d61J5+rs= X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Aug 2019 22:53:19 +0800 Message-Id: <20190825145319.22263-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.10.1.382.ga23ca1b.dirty X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/http: add ff_http_get_shutdown_status api for check the status of shutdown X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" this function is used to get the previous shutdown status when reusing the old connection in block mode. Signed-off-by: Steven Liu --- libavformat/http.c | 16 ++++++++++++++++ libavformat/http.h | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 579debcd35..71dd6c2b1f 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -304,6 +304,22 @@ fail: return location_changed; return ff_http_averror(s->http_code, AVERROR(EIO)); } +int ff_http_get_shutdown_status(URLContext *h) +{ + int ret = 0; + HTTPContext *s = h->priv_data; + + /* flush the receive buffer when it is write only mode */ + char buf[1024]; + int read_ret; + read_ret = ffurl_read(s->hd, buf, sizeof(buf)); + if (read_ret < 0) { + ret = read_ret; + } + + return ret; +} + int ff_http_do_new_request(URLContext *h, const char *uri) { diff --git a/libavformat/http.h b/libavformat/http.h index 7d02713e31..a48897b0b8 100644 --- a/libavformat/http.h +++ b/libavformat/http.h @@ -37,6 +37,15 @@ */ void ff_http_init_auth_state(URLContext *dest, const URLContext *src); +/** + * Get the HTTP shurdown reponse status, be used after http_shutdown. + * + * @param h pointer to the resource + * @return a negative value if an error condition occurred, 0 + * otherwise + */ +int ff_http_get_shutdown_status(URLContext *h); + /** * Send a new HTTP request, reusing the old connection. *