[FFmpeg-devel] [PATCH 2/3] lavf/fifo_test: use FifoTest in place of Failing

Stefano Sabatini stefasab at gmail.com
Tue Mar 12 12:56:53 EET 2024


Use a more consistent and sensible prefix for the muxer structs and functions.
---
 libavformat/fifo_test.c | 45 ++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c
index 84b762db5f..903f4bc34b 100644
--- a/libavformat/fifo_test.c
+++ b/libavformat/fifo_test.c
@@ -1,5 +1,5 @@
 /*
- * FIFO test pseudo-muxer
+ * FIFO pseudo-muxer test
  * Copyright (c) 2016 Jan Sebechlebsky
  *
  * This file is part of FFmpeg.
@@ -38,14 +38,13 @@
 
 /* This is structure of data sent in packets to
  * failing muxer */
-typedef struct FailingMuxerPacketData {
+typedef struct FifoTestMuxerPacketData {
     int ret;             /* return value of write_packet call*/
     int recover_after;   /* set ret to zero after this number of recovery attempts */
     unsigned sleep_time; /* sleep for this long in write_packet to simulate long I/O operation */
-} FailingMuxerPacketData;
+} FifoTestMuxerPacketData;
 
-
-typedef struct FailingMuxerContext {
+typedef struct FifoTestMuxerContext {
     AVClass *class;
     int write_header_ret;
     int write_trailer_ret;
@@ -55,22 +54,22 @@ typedef struct FailingMuxerContext {
     int flush_count;
     int pts_written[MAX_TST_PACKETS];
     int pts_written_nr;
-} FailingMuxerContext;
+} FifoTestMuxerContext;
 
-static int failing_write_header(AVFormatContext *avf)
+static int fifo_test_write_header(AVFormatContext *avf)
 {
-    FailingMuxerContext *ctx = avf->priv_data;
+    FifoTestMuxerContext *ctx = avf->priv_data;
     return ctx->write_header_ret;
 }
 
-static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
+static int fifo_test_write_packet(AVFormatContext *avf, AVPacket *pkt)
 {
-    FailingMuxerContext *ctx = avf->priv_data;
+    FifoTestMuxerContext *ctx = avf->priv_data;
     int ret = 0;
     if (!pkt) {
         ctx->flush_count++;
     } else {
-        FailingMuxerPacketData *data = (FailingMuxerPacketData*) pkt->data;
+        FifoTestMuxerPacketData *data = (FifoTestMuxerPacketData*) pkt->data;
 
         if (!data->recover_after) {
             data->ret = 0;
@@ -98,16 +97,16 @@ static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
     return ret;
 }
 
-static int failing_write_trailer(AVFormatContext *avf)
+static int fifo_test_write_trailer(AVFormatContext *avf)
 {
-    FailingMuxerContext *ctx = avf->priv_data;
+    FifoTestMuxerContext *ctx = avf->priv_data;
     return ctx->write_trailer_ret;
 }
 
-static void failing_deinit(AVFormatContext *avf)
+static void fifo_test_deinit(AVFormatContext *avf)
 {
     int i;
-    FailingMuxerContext *ctx = avf->priv_data;
+    FifoTestMuxerContext *ctx = avf->priv_data;
 
     if (!ctx->print_deinit_summary)
         return;
@@ -120,7 +119,7 @@ static void failing_deinit(AVFormatContext *avf)
     }
     printf("\n");
 }
-#define OFFSET(x) offsetof(FailingMuxerContext, x)
+#define OFFSET(x) offsetof(FifoTestMuxerContext, x)
 static const AVOption options[] = {
         {"print_deinit_summary", "print summary when deinitializing muxer", OFFSET(print_deinit_summary),
          AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
@@ -131,7 +130,7 @@ static const AVOption options[] = {
         {NULL}
     };
 
-static const AVClass failing_muxer_class = {
+static const AVClass fifo_test_muxer_class = {
     .class_name = "Fifo test muxer",
     .item_name  = av_default_item_name,
     .option     = options,
@@ -141,12 +140,12 @@ static const AVClass failing_muxer_class = {
 const FFOutputFormat ff_fifo_test_muxer = {
     .p.name         = "fifo_test",
     .p.long_name    = NULL_IF_CONFIG_SMALL("Fifo test muxer"),
-    .priv_data_size = sizeof(FailingMuxerContext),
-    .write_header   = failing_write_header,
-    .write_packet   = failing_write_packet,
-    .write_trailer  = failing_write_trailer,
-    .deinit         = failing_deinit,
-    .p.priv_class   = &failing_muxer_class,
+    .priv_data_size = sizeof(FifoTestMuxerContext),
+    .write_header   = fifo_test_write_header,
+    .write_packet   = fifo_test_write_packet,
+    .write_trailer  = fifo_test_write_trailer,
+    .deinit         = fifo_test_deinit,
+    .p.priv_class   = &fifo_test_muxer_class,
 #if FF_API_ALLOW_FLUSH
     .p.flags        = AVFMT_NOFILE | AVFMT_ALLOW_FLUSH,
 #else
-- 
2.34.1



More information about the ffmpeg-devel mailing list