From patchwork Mon Nov 12 09:48:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 10993 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 D57FE44DD67 for ; Mon, 12 Nov 2018 11:48:59 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3DF246882E3; Mon, 12 Nov 2018 11:48:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg65.qq.com (smtpbg65.qq.com [103.7.28.233]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D68C3680353 for ; Mon, 12 Nov 2018 11:48:23 +0200 (EET) X-QQ-mid: bizesmtp15t1542016131tipp1q52 Received: from localhost (unknown [106.2.229.242]) by esmtp4.qq.com (ESMTP) with id ; Mon, 12 Nov 2018 17:48:50 +0800 (CST) X-QQ-SSF: 01100000002000F0FMF0B00A0000000 X-QQ-FEAT: 9NFkmNiL4hd/K7fJBrzju15LvXSddgnLGNFvzbWz6ppWXAoKf7ke7kGtW8JJv UrmCWrIn90lXhBEuKu4Vlpqapcse+ZcdaF3ktVTutAa7tygttDlt5u5/JMThGGuK/y/cbQc NWM0zLpNP4XwsCueqSf2anUd1TY3FFlxmkH6H1Hm6EkgLgVqF+78UsQkOOop1zFaLGIQ0Cc pAiBT/ebNJGZkJUutBV155SROj0IODlf+pi4deDz28H50blyv839SQRZz2rBeoaUgXkdwq9 hmsCjOtO3UkAFGe95m/X5fikQ6+yekFX+sVg== X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Nov 2018 17:48:46 +0800 Message-Id: <20181112094846.87770-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign1 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avformat/async: remove unuse code 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" Signed-off-by: Steven Liu --- libavformat/async.c | 208 ---------------------------------------------------- 1 file changed, 208 deletions(-) diff --git a/libavformat/async.c b/libavformat/async.c index 54dbd2312a..d755f3471b 100644 --- a/libavformat/async.c +++ b/libavformat/async.c @@ -489,211 +489,3 @@ const URLProtocol ff_async_protocol = { .priv_data_class = &async_context_class, }; -#if 0 - -#define TEST_SEEK_POS (1536) -#define TEST_STREAM_SIZE (2048) - -typedef struct TestContext { - AVClass *class; - int64_t logical_pos; - int64_t logical_size; - - /* options */ - int opt_read_error; -} TestContext; - -static int async_test_open(URLContext *h, const char *arg, int flags, AVDictionary **options) -{ - TestContext *c = h->priv_data; - c->logical_pos = 0; - c->logical_size = TEST_STREAM_SIZE; - return 0; -} - -static int async_test_close(URLContext *h) -{ - return 0; -} - -static int async_test_read(URLContext *h, unsigned char *buf, int size) -{ - TestContext *c = h->priv_data; - int i; - int read_len = 0; - - if (c->opt_read_error) - return c->opt_read_error; - - if (c->logical_pos >= c->logical_size) - return AVERROR_EOF; - - for (i = 0; i < size; ++i) { - buf[i] = c->logical_pos & 0xFF; - - c->logical_pos++; - read_len++; - - if (c->logical_pos >= c->logical_size) - break; - } - - return read_len; -} - -static int64_t async_test_seek(URLContext *h, int64_t pos, int whence) -{ - TestContext *c = h->priv_data; - int64_t new_logical_pos; - - if (whence == AVSEEK_SIZE) { - return c->logical_size; - } else if (whence == SEEK_CUR) { - new_logical_pos = pos + c->logical_pos; - } else if (whence == SEEK_SET){ - new_logical_pos = pos; - } else { - return AVERROR(EINVAL); - } - if (new_logical_pos < 0) - return AVERROR(EINVAL); - - c->logical_pos = new_logical_pos; - return new_logical_pos; -} - -#define OFFSET(x) offsetof(TestContext, x) -#define D AV_OPT_FLAG_DECODING_PARAM - -static const AVOption async_test_options[] = { - { "async-test-read-error", "cause read fail", - OFFSET(opt_read_error), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, .flags = D }, - {NULL}, -}; - -#undef D -#undef OFFSET - -static const AVClass async_test_context_class = { - .class_name = "Async-Test", - .item_name = av_default_item_name, - .option = async_test_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -const URLProtocol ff_async_test_protocol = { - .name = "async-test", - .url_open2 = async_test_open, - .url_read = async_test_read, - .url_seek = async_test_seek, - .url_close = async_test_close, - .priv_data_size = sizeof(TestContext), - .priv_data_class = &async_test_context_class, -}; - -int main(void) -{ - URLContext *h = NULL; - int i; - int ret; - int64_t size; - int64_t pos; - int64_t read_len; - unsigned char buf[4096]; - AVDictionary *opts = NULL; - - ffurl_register_protocol(&ff_async_protocol); - ffurl_register_protocol(&ff_async_test_protocol); - - /* - * test normal read - */ - ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, NULL); - printf("open: %d\n", ret); - - size = ffurl_size(h); - printf("size: %"PRId64"\n", size); - - pos = ffurl_seek(h, 0, SEEK_CUR); - read_len = 0; - while (1) { - ret = ffurl_read(h, buf, sizeof(buf)); - if (ret == AVERROR_EOF) { - printf("read-error: AVERROR_EOF at %"PRId64"\n", ffurl_seek(h, 0, SEEK_CUR)); - break; - } - else if (ret == 0) - break; - else if (ret < 0) { - printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR)); - goto fail; - } else { - for (i = 0; i < ret; ++i) { - if (buf[i] != (pos & 0xFF)) { - printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n", - (int)buf[i], (int)(pos & 0xFF), pos); - break; - } - pos++; - } - } - - read_len += ret; - } - printf("read: %"PRId64"\n", read_len); - - /* - * test normal seek - */ - ret = ffurl_read(h, buf, 1); - printf("read: %d\n", ret); - - pos = ffurl_seek(h, TEST_SEEK_POS, SEEK_SET); - printf("seek: %"PRId64"\n", pos); - - read_len = 0; - while (1) { - ret = ffurl_read(h, buf, sizeof(buf)); - if (ret == AVERROR_EOF) - break; - else if (ret == 0) - break; - else if (ret < 0) { - printf("read-error: %d at %"PRId64"\n", ret, ffurl_seek(h, 0, SEEK_CUR)); - goto fail; - } else { - for (i = 0; i < ret; ++i) { - if (buf[i] != (pos & 0xFF)) { - printf("read-mismatch: actual %d, expecting %d, at %"PRId64"\n", - (int)buf[i], (int)(pos & 0xFF), pos); - break; - } - pos++; - } - } - - read_len += ret; - } - printf("read: %"PRId64"\n", read_len); - - ret = ffurl_read(h, buf, 1); - printf("read: %d\n", ret); - - /* - * test read error - */ - ffurl_close(h); - av_dict_set_int(&opts, "async-test-read-error", -10000, 0); - ret = ffurl_open(&h, "async:async-test:", AVIO_FLAG_READ, NULL, &opts); - printf("open: %d\n", ret); - - ret = ffurl_read(h, buf, 1); - printf("read: %d\n", ret); - -fail: - av_dict_free(&opts); - ffurl_close(h); - return 0; -} - -#endif