30 #define MAX_TST_PACKETS 128 
   31 #define SLEEPTIME_50_MS 50000 
   32 #define SLEEPTIME_10_MS 10000 
   82             while (slept < data->sleep_time) {
 
  114     printf(
"pts seen: ");
 
  120 #define OFFSET(x) offsetof(FailingMuxerContext, x) 
  122         {
"write_header_ret", 
"write_header() return value", 
OFFSET(write_header_ret),
 
  124         {
"write_trailer_ret", 
"write_trailer() return value", 
OFFSET(write_trailer_ret),
 
  126         {
"print_deinit_summary", 
"print summary when deinitializing muxer", 
OFFSET(print_deinit_summary),
 
  146     .priv_class     = &failing_muxer_class,
 
  173         fprintf(stderr, 
"Failed to create format context: %s\n",
 
  180         fprintf(stderr, 
"Failed to create stream: %s\n",
 
  199         fprintf(stderr, 
"Unexpected write_header failure: %s\n",
 
  204     for (i = 0; i < 15; i++ ) {
 
  207             fprintf(stderr, 
"Failed to prepare test packet: %s\n",
 
  209             goto write_trailer_and_fail;
 
  214             fprintf(stderr, 
"Unexpected write_frame error: %s\n",
 
  216             goto write_trailer_and_fail;
 
  222         fprintf(stderr, 
"Unexpected write_frame error during flushing: %s\n",
 
  224         goto write_trailer_and_fail;
 
  229         fprintf(stderr, 
"Unexpected write_trailer error during flushing: %s\n",
 
  235 write_trailer_and_fail:
 
  251         fprintf(stderr, 
"Unexpected write_header failure: %s\n",
 
  259             fprintf(stderr, 
"Failed to prepare test packet: %s\n",
 
  261             goto write_trailer_and_fail;
 
  271         fprintf(stderr, 
"write_packet not failed when supposed to.\n");
 
  273     } 
else if (ret != -1) {
 
  274         fprintf(stderr, 
"Unexpected write_packet error: %s\n", 
av_err2str(ret));
 
  280         fprintf(stderr, 
"Unexpected write_trailer error: %s\n", 
av_err2str(ret));
 
  283 write_trailer_and_fail:
 
  293     int64_t write_pkt_start, write_pkt_end, 
duration;
 
  300         fprintf(stderr, 
"Unexpected write_header failure: %s\n",
 
  306     for (i = 0; i < 6; i++ ) {
 
  309             fprintf(stderr, 
"Failed to prepare test packet: %s\n",
 
  320     duration = write_pkt_end - write_pkt_start;
 
  322         fprintf(stderr, 
"Writing packets to fifo muxer took too much time while testing" 
  323                         "buffer overflow with drop_pkts_on_overflow was on.\n");
 
  329         fprintf(stderr, 
"Unexpected write_packet error: %s\n", 
av_err2str(ret));
 
  335         fprintf(stderr, 
"Unexpected write_trailer error: %s\n", 
av_err2str(ret));
 
  356 #define BUFFER_SIZE 64 
  367         fprintf(stderr, 
"Muxer initialization failed: %s\n", 
av_err2str(ret));
 
  374             fprintf(stderr, 
"Failed to parse options: %s\n", 
av_err2str(ret));
 
  380              "print_deinit_summary=%d:write_header_ret=%d:write_trailer_ret=%d",
 
  383     ret = 
av_dict_set(&opts, 
"format_opts", buffer, 0);
 
  384     ret1 = 
av_dict_set(&opts, 
"fifo_format", 
"fail", 0);
 
  385     if (ret < 0 || ret1 < 0) {
 
  386         fprintf(stderr, 
"Failed to set options for test muxer: %s\n",
 
  394     printf(
"%s: %s\n", test->
test_name, ret < 0 ? 
"fail" : 
"ok");
 
  412         {
fifo_basic_test, 
"recovery test", 
"attempt_recovery=1:recovery_wait_time=0",
 
  413          0, 0, 0, {
AVERROR(ETIMEDOUT), 3, 0}},
 
  433 int main(
int argc, 
char *argv[])
 
  435     int i, ret, ret_all = 0;
 
  442         if (!ret_all && ret < 0)
 
static int run_test(const TestCase *test)
 
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
 
static int initialize_fifo_tst_muxer_chain(AVFormatContext **oc)
 
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer. 
 
ptrdiff_t const GLvoid * data
 
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file. 
 
#define LIBAVUTIL_VERSION_INT
 
int main(int argc, char *argv[])
 
int av_usleep(unsigned usec)
Sleep for a period of time. 
 
AVOutputFormat tst_failing_muxer
 
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
 
int pts_written[MAX_TST_PACKETS]
 
FailingMuxerPacketData pkt_data
 
static av_cold int end(AVCodecContext *avctx)
 
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown. 
 
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
Initialize a reference-counted packet from av_malloc()ed data. 
 
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file. 
 
static int failing_write_trailer(AVFormatContext *avf)
 
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding 
 
static int fifo_write_header_err_tst(AVFormatContext *oc, AVDictionary **opts, const FailingMuxerPacketData *pkt_data)
 
static const AVOption options[]
 
static const AVClass failing_muxer_class
 
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
 
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
 
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)
 
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. 
 
static int write_trailer(AVFormatContext *s1)
 
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
 
static int fifo_basic_test(AVFormatContext *oc, AVDictionary **opts, const FailingMuxerPacketData *pkt_data)
 
static int failing_write_packet(AVFormatContext *avf, AVPacket *pkt)
 
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted. 
 
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. 
 
void av_register_output_format(AVOutputFormat *format)
 
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb. 
 
static void test(const char *pattern, const char *host)
 
void av_packet_unref(AVPacket *pkt)
Wipe the packet. 
 
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry. 
 
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2. 
 
Describe the class of an AVClass context structure. 
 
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams. 
 
static int64_t pts
Global timestamp for the audio frames. 
 
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point. 
 
uint8_t print_summary_on_deinit
 
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values. 
 
void * priv_data
Format private data. 
 
static void write_header(FFV1Context *f)
 
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
 
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data. 
 
static int fifo_overflow_drop_test(AVFormatContext *oc, AVDictionary **opts, const FailingMuxerPacketData *data)
 
unbuffered private I/O API 
 
static int failing_write_header(AVFormatContext *avf)
 
This structure stores compressed data. 
 
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols. 
 
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
 
int(* test_func)(AVFormatContext *, AVDictionary **, const FailingMuxerPacketData *pkt_data)
 
static void failing_deinit(AVFormatContext *avf)