1 /*
2 * FIFO test pseudo-muxer
3 * Copyright (c) 2016 Jan Sebechlebsky
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with FFmpeg; if not, write to the Free Software * Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdlib.h>
23
26
30
31 /* Implementation of mock muxer to simulate real muxer failures */
32
33 #define MAX_TST_PACKETS 128
34 #define SLEEPTIME_50_MS 50000
35 #define SLEEPTIME_10_MS 10000
36
37 /* Implementation of mock muxer to simulate real muxer failures */
38
39 /* This is structure of data sent in packets to
40 * failing muxer */
42 int ret;
/* return value of write_packet call*/
43 int recover_after;
/* set ret to zero after this number of recovery attempts */
44 unsigned sleep_time;
/* sleep for this long in write_packet to simulate long I/O operation */
46
47
52 /* If non-zero, summary of processed packets will be printed in deinit */
54
59
61 {
63 return ctx->write_header_ret;
64 }
65
67 {
72 } else {
74
75 if (!
data->recover_after) {
77 } else {
78 data->recover_after--;
79 }
80
82
83 if (
data->sleep_time) {
84 int64_t slept = 0;
85 while (slept < data->sleep_time) {
90 }
91 }
92
96 }
97 }
99 }
100
102 {
104 return ctx->write_trailer_ret;
105 }
106
108 {
111
112 if (!
ctx->print_deinit_summary)
113 return;
114
115 printf(
"flush count: %d\n",
ctx->flush_count);
116 printf(
"pts seen nr: %d\n",
ctx->pts_written_nr);
118 for (
i = 0;
i <
ctx->pts_written_nr; ++
i ) {
120 }
122 }
123 #define OFFSET(x) offsetof(FailingMuxerContext, x)
125 {
"write_header_ret",
"write_header() return value",
OFFSET(write_header_ret),
127 {
"write_trailer_ret",
"write_trailer() return value",
OFFSET(write_trailer_ret),
129 {
"print_deinit_summary",
"print summary when deinitializing muxer",
OFFSET(print_deinit_summary),
132 };
133
139 };
140
142 .
p.
name =
"fifo_test",
151 };
152