1 #include "libavformat/avformat.h"
4 AVFormatContext *open_output_stream(const char *dst, int port, enum CodecType codec_type)
7 static AVOutputFormat *rtp_format;
10 s = av_alloc_format_context();
11 rtp_format = guess_format("rtp", NULL, NULL);
13 fprintf(stderr, "Unable for find the RTP format for output\n");
18 s->oformat = rtp_format;
19 st = av_new_stream(s, 0);
21 fprintf(stderr, "Cannot allocate stream\n");
26 snprintf(s->filename, sizeof(s->filename), "rtp://%s:%d", dst, port);
28 /* open the UDP sockets for RTP and RTCP */
29 if (url_fopen(&s->pb, s->filename, URL_WRONLY) < 0) {
30 fprintf(stderr, "Cannot open '%s'\n", s->filename);
31 /* FIXME: Free the stream! */
35 avcodec_get_context_defaults2(s->streams[0]->codec, codec_type);
36 s->streams[0]->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, NULL, codec_type);
37 s->streams[0]->codec->codec_id = CODEC_ID_MPEG4;
38 s->streams[0]->codec->pix_fmt = PIX_FMT_YUV420P;
43 int pkt_send(AVFormatContext *ctx, AVPacket *pkt)
45 static int inited; /* FIXME: HACK! */
51 fprintf(stderr,"initing!\n");
52 res = av_write_header(ctx);
54 fprintf(stderr, "Cannot open the out RTP stream!\n");
61 return av_write_frame(ctx, pkt);