30 #define MAX_TST_PACKETS 128
31 #define SLEEPTIME_50_MS 50000
32 #define SLEEPTIME_10_MS 10000
47 memcpy(
pkt->
data, pkt_data,
sizeof(*pkt_data));
62 fprintf(stderr,
"Failed to create format context: %s\n",
69 fprintf(stderr,
"Failed to create stream: %s\n",
88 fprintf(stderr,
"Unexpected write_header failure: %s\n",
93 for (
i = 0;
i < 15;
i++ ) {
96 fprintf(stderr,
"Failed to prepare test packet: %s\n",
98 goto write_trailer_and_fail;
103 fprintf(stderr,
"Unexpected write_frame error: %s\n",
105 goto write_trailer_and_fail;
111 fprintf(stderr,
"Unexpected write_frame error during flushing: %s\n",
113 goto write_trailer_and_fail;
118 fprintf(stderr,
"Unexpected write_trailer error during flushing: %s\n",
124 write_trailer_and_fail:
138 fprintf(stderr,
"Unexpected write_header failure: %s\n",
144 for (
i = 0;
i < 6;
i++ ) {
147 fprintf(stderr,
"Failed to prepare test packet: %s\n",
159 duration = write_pkt_end - write_pkt_start;
161 fprintf(stderr,
"Writing packets to fifo muxer took too much time while testing"
162 "buffer overflow with drop_pkts_on_overflow was on.\n");
168 fprintf(stderr,
"Unexpected write_packet error: %s\n",
av_err2str(ret));
174 fprintf(stderr,
"Unexpected write_trailer error: %s\n",
av_err2str(ret));
196 #define BUFFER_SIZE 64
208 fprintf(stderr,
"Muxer initialization failed: %s\n",
av_err2str(ret));
215 fprintf(stderr,
"Failed to parse options: %s\n",
av_err2str(ret));
221 "print_deinit_summary=%d:write_header_ret=%d:write_trailer_ret=%d",
222 (
int)
test->print_summary_on_deinit,
test->write_header_ret,
223 test->write_trailer_ret);
226 if (ret < 0 || ret1 < 0) {
227 fprintf(stderr,
"Failed to set options for test muxer: %s\n",
235 printf(
"%s: %s\n",
test->test_name, ret < 0 ?
"fail" :
"ok");
250 {
fifo_basic_test,
"recovery test",
"attempt_recovery=1:recovery_wait_time=0",
251 0, 0, 0, {
AVERROR(ETIMEDOUT), 3, 0}},
271 int main(
int argc,
char *argv[])
273 int i, ret, ret_all = 0;
277 if (!ret_all && ret < 0)
simple assert() macros that are a bit more flexible than ISO C assert().
static int prepare_packet(AVPacket *pkt, const FailingMuxerPacketData *pkt_data, int64_t pts)
int main(int argc, char *argv[])
static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc, AVPacket **pkt)
static int run_test(const TestCase *test)
static int fifo_overflow_drop_test(AVFormatContext *oc, AVDictionary **opts, AVPacket *pkt, const FailingMuxerPacketData *data)
static int fifo_basic_test(AVFormatContext *oc, AVDictionary **opts, AVPacket *pkt, const FailingMuxerPacketData *pkt_data)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void test(const char *pattern, const char *host)
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
uint8_t print_summary_on_deinit
int(* test_func)(AVFormatContext *, AVDictionary **, AVPacket *, const FailingMuxerPacketData *pkt_data)
FailingMuxerPacketData pkt_data
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
unbuffered private I/O API