From patchwork Mon Sep 25 22:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 43909 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:2a18:b0:15d:8365:d4b8 with SMTP id e24csp1531735pzh; Mon, 25 Sep 2023 15:44:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXO8NsyWWR3T/S5I3lf7gKafcR8m+QLYDtnVXf4DqOBafu3Q4eg4+RGJ7Y9WNRLWCusQlD X-Received: by 2002:ac2:5298:0:b0:500:ac0b:8d52 with SMTP id q24-20020ac25298000000b00500ac0b8d52mr6560881lfm.7.1695681889670; Mon, 25 Sep 2023 15:44:49 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o8-20020aa7c508000000b00530bd7bfd90si1667139edq.373.2023.09.25.15.44.49; Mon, 25 Sep 2023 15:44:49 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=pR1jEUf1; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 313ED68C9CF; Tue, 26 Sep 2023 01:44:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2097.outbound.protection.outlook.com [40.92.89.97]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4905F68C5CE for ; Tue, 26 Sep 2023 01:44:39 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fo/zLkAwPqyyqCVgoEhVo9muZk9q7GM4LZAXeRFbTDx2ze245SD5U86eEdGp+uMqmsNFMADVScQHVH2yfDo3Nm6VjphMAPQ6gzUKkRi+UCMT8gzqycNJQeMHtEZQEbqdX8fU4uBOZGuPgb5hgZvx7MB5onyxA52U0h1Wf/jjRQntAVWv4Ro/qkVKK+uVprVTtRqjnfHQI2c/DhXpFcr1XXw8Ns5USE7Grfbtl4HBgv6QltLE2LNMbcBb798vuhla69TkpE6zfQ6C74beifadqBQ7N3+67q0yz5qQ0o0TYyKEaH0ZaBZ3hao1ry21BkWWL0xHTbjk6WS43NS2Q3T9gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v5Ql6tgXkW8ohYtTi7uc0Bwf9q8YdvvCxznVAP8NuQE=; b=bA+WumTgRqzT6CegLwexVetZIv8r9lBrqroWKd8tvIXhwoiUWYMGMf8QNqF8kTDnWsUnVpK9Kg3A1ghZ5P2PFKyfmZ3ZF63tw/ZlaPvUyoubK5jbNW3cjndRuvo2gjf4sVlJNuwwyn1BIAihvinmG4UhgoOy6Kbdb5qf4lFrO9wcs69eod2YwogjloEMLvMSkaNEObevN4PtTFFgSn3MFaLbDDsHZlB5YKOCpw+CvYfVhmJoiXVPoRZQvrf008tk87jZZ2rbUieZhXlQOcWR6i9QOW/F+odmpjR9vttFz35l7x7gTR2Tge/dvl2/FS5eoyjH26EAQLaKhNKFr5ZUaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v5Ql6tgXkW8ohYtTi7uc0Bwf9q8YdvvCxznVAP8NuQE=; b=pR1jEUf1+Ft0vAkJqzFp6VdZWm7oLjN4xSWlsP7hAgCKr2Ddnmn/NrbLgl65pFAAqk0Ur6T3LF+OAT0DQ8D1sPO9yvR1ftpkMHCQ4u7LPzI5UMmHC9tY/3svbWYaTg9liZgu5v4U3ZoAhx0rt1wBoZh8UmnF7keylK3/4TJZclkS0b+BcqGbA5va9qWRRVw+YpTgVbdov9f7iA+2zTNQ/0zVWZcLp/wbziwUmzj8iTxaHm98rAyGztMjXtsOnc8xcz39UR1c2uO4cnArdzvdTAcHYhYjsK+WZS+P4lIxGYAxlIt7oLCrPhgcr8S5W810s5BOKsA65/mTwOho6sJErw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0209.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:178::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Mon, 25 Sep 2023 22:44:36 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::5e01:aea5:d3a8:cafa%3]) with mapi id 15.20.6792.026; Mon, 25 Sep 2023 22:44:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 26 Sep 2023 00:45:41 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [FI6xcch94ICwW7XS5rB0ibkugCHNmaJ3] X-ClientProxiedBy: ZR2P278CA0042.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::13) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20230925224541.2405565-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0209:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d73ae7c-1bac-4329-8a4d-08dbbe18fc9b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ee+nhXNDt3OdBZcfA4AVPSyR0VsBgZLnlPOeXaYfKAPhKFjhBpmCMvDQVaWGMuMUlbbNyo+YRj+FZQzsJ8O6JC8KtjSz5VwM4qe15mkkJwoNXzsiUe/sNRO8eSCAwMq5Hn3RgJKpSNoTMUsweci0ICLD5tqJc7bAydQ0fLO8+Mde+hlaE6fjS06KyupU/vPV7Nh+bmfhTLd4IWUHou7apmQbLRIv+sxPJ7nEyc++pV30w612LG1MBhkskuzi2NUspnK9T/4PT7NCa9v5kKmbZAcTOk3Uat6sn05ceBCAF2TxpJk365tIqnCotriIvhViLpBNd7ZGFdsBrq78GXLzh85POw+WrNWzcNZK2uXArXxgJiY+OFQqFh5KUwetDwhp1foKwrY+qhfho6r4RoMsw9H2HcvyOnwuAEVBCN+1AVX3/72YUhaIZlrXoGrtukz1rlvFKdGHaFGrN/CrO1CqMfmSCRvhgrHNPjQWkiiYPQMpeUDkhM0wkjrrbyAvcTRci2llfCTH6wZPh8j8paWqRbV1dpiISsCi94L/xfYSHNhGlKG0fxYgvTDny16VOE9sA6Yn/u+0Ez54LS5RjGJ4r/4yp3cakMzV5sRKLqNMF4cVi9pM/BbB9v1AvuCgwhYB X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3g0K7LlIg0gSqh4ZNoKQvnEwoL3DWtV0w3y8XEJTC+TVuHUAL3MGKxAOro2IverDPuA2DX8qfVSgbz0GNcqE2vX7Ik0pSez1uG+7jYCZqKrJ9a7XWdVsvc16RmR1ek+6fN9hxVRLH6m0/okt3pvLHRyqSTOzVUI/PA6KqfWzAmZ/l2l2ReOI56v8hJSvA4LsoByrJRdv6VmaY4TLijV5zLWrf3JuuVxQIlTGp1OzDhx/rQPM9isImPh04wXVT3+daCDj5pfm6ayTP9zm0cUZbvSUDoYPw3hRbWc7LEQ4Qc+IWJQMr5qmC25C2JNrSsSQNICa+QWBPbOsRtzF97tY3V1BmREKgB6mFw1kM3cqHvzAPwtceg7ggPneR+xcLiYhigUUkz+lgWZkxGDt6N3zs4kJE5if1ZX47VxkY2z+jt31Iew07HgSiGnpjifAu8Hi+oozn2D/Xj1gpBBfvWFCsaXYPXSYP1OXfWQ/T+21zOPpSfMtL/eDStjYFMeswzJClP8RFYhed0oomH02tLIUGBkAwiveu9HA8OO4/upBFONHpvQDuMkqyV7z5G/fU1j5kRvDr4VpnIFtgsjKD2g09eDI1TLTB8vR3iOpT2rPCensqo21+rJ4BTfHHzQsjUbP2eswCYNs3VAcT7hehlWR3YzTUj7eafXPKA/d+esRbIVw9Ir0jHKCfBkifR2xb6BXUqmSMdxYMD4ESgzM3s9E3nUFnR1aZCsd/BqKEI+PD8Qej8bvQ0JkujPI/QXkCIvssRxIgpjbNI/TOl4ymnoNarr4E5QyVazdMAgL+D+h2yQi+53EIrznvdcKSxqbJBJBEqkzWB152uEPsrFciRBF3yrCMTbGbSaZz8qj4FOBg6PcV2usjtud78PNfWzTeO9eX4YGq0f1qu3zXD1Bv/is0u+Dx3LWXX6BULRwLj6IkuCzHkFlLVXPy74WmcEzZOSga6C6jzZ/7kMFygqWt3ZptICSc8yfOObpt3qEXXW7TOzKeo90ZCYHoQ5t2w9f14HYlfIEDM9/AHeA3Y8r2+mQQh8Ps8rKCkS02gxlNToXmELgX7QuDMcTmLwgldya1DJS1T7k4FKQ+FDG7tVWZPzX+pKSjixpidtepyqTNq2BKaOKBxDT/S+EZ7481kuG0cjHlLzPjK1OKanX43woAhSYEoaOfywQAE18KecRF+0KAuWx0PBRuUpKzo2shB0ESQD5c1ZjzT5l4b2JwCkdTj+VFzhUprtoOmZ67h6WR8NJhMjHtMSA33J9YXMug29d3fVS X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d73ae7c-1bac-4329-8a4d-08dbbe18fc9b X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2023 22:44:36.3762 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0209 Subject: [FFmpeg-devel] [PATCH] avformat/avformat: Deprecate AVFMT_ALLOW_FLUSH 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ksH4OmTqZiCh It is of no value to the user, because every muxer can always be flushed with a NULL packet. As its documentation shows ("If not set, the muxer will not receive a NULL packet in the write_packet function") it is actually an internal flag that has been publically exposed because there were no internal flags for output formats for a long time. But now there is and so use it by replacing the public flag with a private one. Signed-off-by: Andreas Rheinhardt --- doc/APIchanges | 4 ++++ libavdevice/pulse_audio_enc.c | 5 ++++ libavformat/avformat.h | 6 +++-- libavformat/fifo.c | 5 ++++ libavformat/fifo_test.c | 5 ++++ libavformat/hlsenc.c | 5 ++++ libavformat/matroskaenc.c | 15 ++++++++++++ libavformat/movenc.c | 45 +++++++++++++++++++++++++++++++++++ libavformat/mpegtsenc.c | 5 ++++ libavformat/mux.c | 6 +++++ libavformat/mux.h | 6 +++-- libavformat/oggenc.c | 25 +++++++++++++++++++ libavformat/tee.c | 5 ++++ libavformat/version_major.h | 1 + 14 files changed, 134 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f333ff5b24..b9d50b1db5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-09-26 - xxxxxxxxxx - lavf 60.xx.100 - avformat.h + Deprecate AVFMT_ALLOW_FLUSH without replacement. Users can always + flush any muxer by sending a NULL muxer. + 2023-09-19 - xxxxxxxxxx - lavu 58.25.100 - avutil.h Make AV_TIME_BASE_Q compatible with C++. diff --git a/libavdevice/pulse_audio_enc.c b/libavdevice/pulse_audio_enc.c index 9e594c6424..5acbf798ef 100644 --- a/libavdevice/pulse_audio_enc.c +++ b/libavdevice/pulse_audio_enc.c @@ -802,6 +802,11 @@ const FFOutputFormat ff_pulse_muxer = { .get_output_timestamp = pulse_get_output_timestamp, .get_device_list = pulse_get_device_list, .control_message = pulse_control_message, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_NOFILE, +#endif .p.priv_class = &pulse_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 43175ba332..a8e245000f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -486,7 +486,9 @@ typedef struct AVProbeData { #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */ #define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ -#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */ +#if FF_API_ALLOW_FLUSH +#define AVFMT_ALLOW_FLUSH 0x10000 /**< @deprecated: Just send a NULL packet if you want to flush a muxer. */ +#endif #define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly increasing timestamps, but they must still be monotonic */ @@ -522,7 +524,7 @@ typedef struct AVOutputFormat { /** * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, - * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, + * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE */ int flags; diff --git a/libavformat/fifo.c b/libavformat/fifo.c index 9a3a23729c..8fb4975a5c 100644 --- a/libavformat/fifo.c +++ b/libavformat/fifo.c @@ -715,11 +715,16 @@ const FFOutputFormat ff_fifo_muxer = { .p.name = "fifo", .p.long_name = NULL_IF_CONFIG_SMALL("FIFO queue pseudo-muxer"), .p.priv_class = &fifo_muxer_class, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_NOFILE | AVFMT_TS_NEGATIVE, +#endif .priv_data_size = sizeof(FifoContext), .init = fifo_init, .write_header = fifo_write_header, .write_packet = fifo_write_packet, .write_trailer = fifo_write_trailer, .deinit = fifo_deinit, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c index 0f12d88b0f..3861c4aee4 100644 --- a/libavformat/fifo_test.c +++ b/libavformat/fifo_test.c @@ -147,6 +147,11 @@ const FFOutputFormat ff_fifo_test_muxer = { .write_trailer = failing_write_trailer, .deinit = failing_deinit, .p.priv_class = &failing_muxer_class, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_NOFILE, +#endif + .flags_internal = FF_FMT_ALLOW_FLUSH, }; diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 08f3746ce7..999fc0de75 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -3184,8 +3184,13 @@ const FFOutputFormat ff_hls_muxer = { .p.audio_codec = AV_CODEC_ID_AAC, .p.video_codec = AV_CODEC_ID_H264, .p.subtitle_codec = AV_CODEC_ID_WEBVTT, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_NODIMENSIONS, +#else + .p.flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER | AVFMT_NODIMENSIONS, +#endif .p.priv_class = &hls_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, .priv_data_size = sizeof(HLSContext), .init = hls_init, .write_header = hls_write_header, diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index ba54f5f98e..c1a4425eb7 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -3512,7 +3512,11 @@ const FFOutputFormat ff_matroska_muxer = { .write_packet = mkv_write_flush_packet, .write_trailer = mkv_write_trailer, .p.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS | +#if FF_API_ALLOW_FLUSH AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH, +#else + AVFMT_TS_NONSTRICT, +#endif .p.codec_tag = (const AVCodecTag* const []){ ff_codec_bmp_tags, ff_codec_wav_tags, additional_audio_tags, additional_subtitle_tags, 0 @@ -3521,6 +3525,7 @@ const FFOutputFormat ff_matroska_muxer = { .query_codec = mkv_query_codec, .check_bitstream = mkv_check_bitstream, .p.priv_class = &matroska_webm_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -3551,8 +3556,13 @@ const FFOutputFormat ff_webm_muxer = { .query_codec = webm_query_codec, .check_bitstream = mkv_check_bitstream, .p.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS | +#if FF_API_ALLOW_FLUSH AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH, +#else + AVFMT_TS_NONSTRICT, +#endif .p.priv_class = &matroska_webm_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -3572,11 +3582,16 @@ const FFOutputFormat ff_matroska_audio_muxer = { .write_packet = mkv_write_flush_packet, .write_trailer = mkv_write_trailer, .check_bitstream = mkv_check_bitstream, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NONSTRICT, +#endif .p.codec_tag = (const AVCodecTag* const []){ ff_codec_wav_tags, additional_audio_tags, 0 }, .p.priv_class = &matroska_webm_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7e96e7435f..a394ff8ddf 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -7932,12 +7932,17 @@ const FFOutputFormat ff_mov_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = (const AVCodecTag* const []){ ff_codec_movvideo_tags, ff_codec_movaudio_tags, ff_codec_movsubtitle_tags, 0 }, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_TGP_MUXER @@ -7953,10 +7958,15 @@ const FFOutputFormat ff_tgp_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = codec_3gp_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_MP4_MUXER @@ -7974,10 +7984,15 @@ const FFOutputFormat ff_mp4_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = mp4_codec_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_PSP_MUXER @@ -7994,10 +8009,15 @@ const FFOutputFormat ff_psp_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = mp4_codec_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_TG2_MUXER @@ -8013,10 +8033,15 @@ const FFOutputFormat ff_tg2_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = codec_3gp_tags_list, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_IPOD_MUXER @@ -8033,10 +8058,15 @@ const FFOutputFormat ff_ipod_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = (const AVCodecTag* const []){ codec_ipod_tags, 0 }, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_ISMV_MUXER @@ -8053,11 +8083,16 @@ const FFOutputFormat ff_ismv_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_GLOBALHEADER | AVFMT_TS_NEGATIVE, +#endif .p.codec_tag = (const AVCodecTag* const []){ codec_mp4_tags, codec_ism_tags, 0 }, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_F4V_MUXER @@ -8074,10 +8109,15 @@ const FFOutputFormat ff_f4v_muxer = { .write_packet = mov_write_packet, .write_trailer = mov_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_GLOBALHEADER, +#endif .p.codec_tag = (const AVCodecTag* const []){ codec_f4v_tags, 0 }, .check_bitstream = mov_check_bitstream, .p.priv_class = &mov_isobmff_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif #if CONFIG_AVIF_MUXER @@ -8093,8 +8133,13 @@ const FFOutputFormat ff_avif_muxer = { .write_packet = mov_write_packet, .write_trailer = avif_write_trailer, .deinit = mov_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_GLOBALHEADER | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_GLOBALHEADER, +#endif .p.codec_tag = codec_avif_tags_list, .p.priv_class = &mov_avif_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 46ed16985f..84edd418f0 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -2361,6 +2361,11 @@ const FFOutputFormat ff_mpegts_muxer = { .write_trailer = mpegts_write_end, .deinit = mpegts_deinit, .check_bitstream = mpegts_check_bitstream, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_ALLOW_FLUSH | AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS, +#else + .p.flags = AVFMT_VARIABLE_FPS | AVFMT_NODIMENSIONS, +#endif + .flags_internal = FF_FMT_ALLOW_FLUSH, .p.priv_class = &mpegts_muxer_class, }; diff --git a/libavformat/mux.c b/libavformat/mux.c index d3779202f0..5a1d6e41cb 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -1206,7 +1206,13 @@ int av_write_frame(AVFormatContext *s, AVPacket *in) int ret; if (!in) { +#if FF_API_ALLOW_FLUSH || LIBAVFORMAT_VERSION_MAJOR >= 61 + // Hint: The pulse audio output device has this set, + // so we can't switch the check to FF_FMT_ALLOW_FLUSH immediately. if (s->oformat->flags & AVFMT_ALLOW_FLUSH) { +#else + if (ffofmt(s->oformat)->flags_internal & FF_FMT_ALLOW_FLUSH) { +#endif ret = ffofmt(s->oformat)->write_packet(s, NULL); flush_if_needed(s); if (ret >= 0 && s->pb && s->pb->error < 0) diff --git a/libavformat/mux.h b/libavformat/mux.h index 9de5c2852a..b9ec75641d 100644 --- a/libavformat/mux.h +++ b/libavformat/mux.h @@ -27,6 +27,8 @@ struct AVDeviceInfoList; +#define FF_FMT_ALLOW_FLUSH (1 << 1) + typedef struct FFOutputFormat { /** * The public AVOutputFormat. See avformat.h for it. @@ -38,13 +40,13 @@ typedef struct FFOutputFormat { int priv_data_size; /** - * Internal flags. See FF_FMT_FLAG_* in internal.h. + * Internal flags. See FF_FMT_* in internal.h and mux.h. */ int flags_internal; int (*write_header)(AVFormatContext *); /** - * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, + * Write a packet. If FF_FMT_ALLOW_FLUSH is set in flags_internal, * pkt can be NULL in order to flush data buffered in the muxer. * When flushing, return 0 if there still is more data to flush, * or 1 if everything was flushed and there is no more buffered diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c index c669aea25a..69a66f586d 100644 --- a/libavformat/oggenc.c +++ b/libavformat/oggenc.c @@ -771,8 +771,13 @@ const FFOutputFormat ff_ogg_muxer = { .write_packet = ogg_write_packet, .write_trailer = ogg_write_trailer, .deinit = ogg_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT, +#endif .p.priv_class = &ogg_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -789,8 +794,13 @@ const FFOutputFormat ff_oga_muxer = { .write_packet = ogg_write_packet, .write_trailer = ogg_write_trailer, .deinit = ogg_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_TS_NEGATIVE, +#endif .p.priv_class = &ogg_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -810,8 +820,13 @@ const FFOutputFormat ff_ogv_muxer = { .write_packet = ogg_write_packet, .write_trailer = ogg_write_trailer, .deinit = ogg_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_TS_NEGATIVE | AVFMT_TS_NONSTRICT, +#endif .p.priv_class = &ogg_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -828,8 +843,13 @@ const FFOutputFormat ff_spx_muxer = { .write_packet = ogg_write_packet, .write_trailer = ogg_write_trailer, .deinit = ogg_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_TS_NEGATIVE, +#endif .p.priv_class = &ogg_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif @@ -846,7 +866,12 @@ const FFOutputFormat ff_opus_muxer = { .write_packet = ogg_write_packet, .write_trailer = ogg_write_trailer, .deinit = ogg_free, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_TS_NEGATIVE | AVFMT_ALLOW_FLUSH, +#else + .p.flags = AVFMT_TS_NEGATIVE, +#endif .p.priv_class = &ogg_muxer_class, + .flags_internal = FF_FMT_ALLOW_FLUSH, }; #endif diff --git a/libavformat/tee.c b/libavformat/tee.c index cb555f52fd..cfa8346bc9 100644 --- a/libavformat/tee.c +++ b/libavformat/tee.c @@ -614,5 +614,10 @@ const FFOutputFormat ff_tee_muxer = { .write_trailer = tee_write_trailer, .write_packet = tee_write_packet, .p.priv_class = &tee_muxer_class, +#if FF_API_ALLOW_FLUSH .p.flags = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH | AVFMT_TS_NEGATIVE, +#else + .p.flags = AVFMT_NOFILE | AVFMT_TS_NEGATIVE, +#endif + .flags_internal = FF_FMT_ALLOW_FLUSH, }; diff --git a/libavformat/version_major.h b/libavformat/version_major.h index d1d6f95b15..ca9dccc94d 100644 --- a/libavformat/version_major.h +++ b/libavformat/version_major.h @@ -47,6 +47,7 @@ #define FF_API_AVFORMAT_IO_CLOSE (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_AVIO_WRITE_NONCONST (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_LAVF_SHORTEST (LIBAVFORMAT_VERSION_MAJOR < 61) +#define FF_API_ALLOW_FLUSH (LIBAVFORMAT_VERSION_MAJOR < 61) #define FF_API_R_FRAME_RATE 1