Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] lavf/fifo_test: sort options by name
@ 2024-03-12 10:56 Stefano Sabatini
  2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 2/3] lavf/fifo_test: use FifoTest in place of Failing Stefano Sabatini
  2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test Stefano Sabatini
  0 siblings, 2 replies; 6+ messages in thread
From: Stefano Sabatini @ 2024-03-12 10:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Stefano Sabatini

---
 libavformat/fifo_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/fifo_test.c b/libavformat/fifo_test.c
index 3861c4aee4..84b762db5f 100644
--- a/libavformat/fifo_test.c
+++ b/libavformat/fifo_test.c
@@ -122,12 +122,12 @@ static void failing_deinit(AVFormatContext *avf)
 }
 #define OFFSET(x) offsetof(FailingMuxerContext, 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},
         {"write_header_ret", "write_header() return value", OFFSET(write_header_ret),
          AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
         {"write_trailer_ret", "write_trailer() return value", OFFSET(write_trailer_ret),
          AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
-        {"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},
         {NULL}
     };
 
-- 
2.34.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] lavf/fifo_test: use FifoTest in place of Failing
  2024-03-12 10:56 [FFmpeg-devel] [PATCH 1/3] lavf/fifo_test: sort options by name Stefano Sabatini
@ 2024-03-12 10:56 ` Stefano Sabatini
  2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test Stefano Sabatini
  1 sibling, 0 replies; 6+ messages in thread
From: Stefano Sabatini @ 2024-03-12 10:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Stefano Sabatini

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

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test
  2024-03-12 10:56 [FFmpeg-devel] [PATCH 1/3] lavf/fifo_test: sort options by name Stefano Sabatini
  2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 2/3] lavf/fifo_test: use FifoTest in place of Failing Stefano Sabatini
@ 2024-03-12 10:56 ` Stefano Sabatini
  2024-03-12 12:25   ` Andreas Rheinhardt
  1 sibling, 1 reply; 6+ messages in thread
From: Stefano Sabatini @ 2024-03-12 10:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Stefano Sabatini

---
 doc/muxers.texi | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 0aaef2b520..ccbb741992 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1556,6 +1556,36 @@ ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv \
   -map 0:v -map 0:a rtmp://example.com/live/stream_name
 @end example
 
+@anchor{fifo_test}
+@section fifo_test
+@ref{fifo} muxer test muxer.
+
+This is a testing muxer, it is supposed to be used only to test the
+@ref{fifo} muxer.
+
+@subsection Options
+@table @option
+@item print_deinit_summary @var{bool}
+print summary when deinitializing muxer, default is @code{true}
+
+@item write_header_ret @var{int}
+set @code{write_header()} return value
+
+@item write_trailer_ret @var{int}
+set @code{write_trailer()} return value
+@end table
+
+@subsection Example
+
+Use @command{ffmpeg} to write to a file using the @samp{fifo} muxer
+using the internal @samp{fifo_test} muxer, simulate a write header
+error using the @option{write_header_ret} option:
+@example
+ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format fifo_test -format_opts write_header_ret=-22 \
+  -map 0:v -map 0:a \
+  -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 out.test
+@end example
+
 @section flv
 
 Adobe Flash Video Format muxer.
-- 
2.34.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test
  2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test Stefano Sabatini
@ 2024-03-12 12:25   ` Andreas Rheinhardt
  2024-03-12 16:57     ` Stefano Sabatini
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-12 12:25 UTC (permalink / raw)
  To: ffmpeg-devel

Stefano Sabatini:
> ---
>  doc/muxers.texi | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 0aaef2b520..ccbb741992 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -1556,6 +1556,36 @@ ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv \
>    -map 0:v -map 0:a rtmp://example.com/live/stream_name
>  @end example
>  
> +@anchor{fifo_test}
> +@section fifo_test
> +@ref{fifo} muxer test muxer.
> +
> +This is a testing muxer, it is supposed to be used only to test the
> +@ref{fifo} muxer.
> +
> +@subsection Options
> +@table @option
> +@item print_deinit_summary @var{bool}
> +print summary when deinitializing muxer, default is @code{true}
> +
> +@item write_header_ret @var{int}
> +set @code{write_header()} return value
> +
> +@item write_trailer_ret @var{int}
> +set @code{write_trailer()} return value
> +@end table
> +
> +@subsection Example
> +
> +Use @command{ffmpeg} to write to a file using the @samp{fifo} muxer
> +using the internal @samp{fifo_test} muxer, simulate a write header
> +error using the @option{write_header_ret} option:
> +@example
> +ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format fifo_test -format_opts write_header_ret=-22 \
> +  -map 0:v -map 0:a \
> +  -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 out.test
> +@end example
> +
>  @section flv
>  
>  Adobe Flash Video Format muxer.

I do not think that this muxer should be publically documented. In fact,
I think it would be better if this muxer would only exist inside the
fifo_muxer test and if it were not included in a normal libavformat at all.

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test
  2024-03-12 12:25   ` Andreas Rheinhardt
@ 2024-03-12 16:57     ` Stefano Sabatini
  2024-03-12 18:55       ` Andreas Rheinhardt
  0 siblings, 1 reply; 6+ messages in thread
From: Stefano Sabatini @ 2024-03-12 16:57 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On date Tuesday 2024-03-12 13:25:23 +0100, Andreas Rheinhardt wrote:
> Stefano Sabatini:
> > ---
> >  doc/muxers.texi | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> > 
[...]
> I do not think that this muxer should be publically documented. In fact,
> I think it would be better if this muxer would only exist inside the
> fifo_muxer test and if it were not included in a normal libavformat at all.

It looks like it is not possible to register a custom muxer outside of
the list in allformats.c, or do I miss something? (OTOH it would be
useful if one wants to registers a custom component, but this seems to
be disabled at the API level).

The simple alternative is to simply not to document the muxer,
although I don't like it very much, given that is output in the muxers
list, so I think at least we want to mention that this is only used
for testing.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test
  2024-03-12 16:57     ` Stefano Sabatini
@ 2024-03-12 18:55       ` Andreas Rheinhardt
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2024-03-12 18:55 UTC (permalink / raw)
  To: ffmpeg-devel

Stefano Sabatini:
> On date Tuesday 2024-03-12 13:25:23 +0100, Andreas Rheinhardt wrote:
>> Stefano Sabatini:
>>> ---
>>>  doc/muxers.texi | 30 ++++++++++++++++++++++++++++++
>>>  1 file changed, 30 insertions(+)
>>>
> [...]
>> I do not think that this muxer should be publically documented. In fact,
>> I think it would be better if this muxer would only exist inside the
>> fifo_muxer test and if it were not included in a normal libavformat at all.
> 
> It looks like it is not possible to register a custom muxer outside of
> the list in allformats.c, or do I miss something? (OTOH it would be
> useful if one wants to registers a custom component, but this seems to
> be disabled at the API level).
> 

It is possible to use custom muxers internally: The AVOutputFormat*
pointer one passes to avformat_alloc_output_context2() need not be in
the list of output formats in the lists in allformats.c/alldevices.c. In
order to make the fifo muxer actually use a custom muxer, a slight hack
is needed. See
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-March/323314.html

> The simple alternative is to simply not to document the muxer,
> although I don't like it very much, given that is output in the muxers
> list, so I think at least we want to mention that this is only used
> for testing.

Given that this muxer is dangerous (see the above commit message) it
should not be publicly accessible at all.

- Andreas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-03-12 18:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-12 10:56 [FFmpeg-devel] [PATCH 1/3] lavf/fifo_test: sort options by name Stefano Sabatini
2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 2/3] lavf/fifo_test: use FifoTest in place of Failing Stefano Sabatini
2024-03-12 10:56 ` [FFmpeg-devel] [PATCH 3/3] doc/muxers: add fifo_test Stefano Sabatini
2024-03-12 12:25   ` Andreas Rheinhardt
2024-03-12 16:57     ` Stefano Sabatini
2024-03-12 18:55       ` Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git