1 /*
2 * RTP/mpegts muxer
3 * Copyright (c) 2011 Martin Storsjo
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
9 * License 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 GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
25
29 };
30
32 {
34
39 }
43 }
44 return 0;
45 }
46
48 {
55
56 if (!mpegts_format || !rtp_format)
59 if (!mpegts_ctx)
61 mpegts_ctx->
oformat = mpegts_format;
65 if (!st)
70 }
77
80
82 if (!rtp_ctx) {
85 }
86 rtp_ctx->oformat = rtp_format;
95
96 return 0;
97
99 if (mpegts_ctx) {
102 }
103 if (rtp_ctx)
106 return ret;
107 }
108
110 {
115
118 return ret;
119 }
121 return ret;
126 return 0;
127 }
142
143 return ret;
144 }
145
147 .
name =
"rtp_mpegts",
149 .priv_data_size =
sizeof(
struct MuxChain),
155 };
AVOutputFormat ff_rtp_mpegts_muxer
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static int rtp_mpegts_write_header(AVFormatContext *s)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
struct AVOutputFormat * oformat
The output container format.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static int rtp_mpegts_write_close(AVFormatContext *s)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
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 rtp_mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
AVIOContext * pb
I/O context.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
void * priv_data
Format private data.
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.
AVFormatContext * mpegts_ctx
AVCodecParameters * codecpar
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
AVFormatContext * rtp_ctx
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.