diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 143a5be8db..abc22fd856 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -3381,6 +3381,32 @@ static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, return AV_NOPTS_VALUE; } +int avpriv_mpegts_add_stream(AVFormatContext *s, int pid, uint32_t stream_type, int program) +{ + MpegTSContext *ts = s->priv_data; + MpegTSFilter *tss = ts->pids[pid]; + PESContext *pes = NULL; + AVStream *st = NULL; + + if (tss) + return -1; + + pes = add_pes_stream(ts, pid, -1); + if (!pes) + return -1; + + st = avformat_new_stream(pes->stream, NULL); + st->id = pes->pid; + + if (!st) + return -1; + + mpegts_set_stream_info(st, pes, stream_type, AV_RL32("HDMV")); + if (program >= 0) + av_program_add_stream_index(s, program, st->index); + return 0; +} + /**************************************************************/ /* parsing functions - called from other demuxers such as RTP */ diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h index 14ae312c50..bfdb15b68c 100644 --- a/libavformat/mpegts.h +++ b/libavformat/mpegts.h @@ -232,4 +232,6 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type */ int ff_check_h264_startcode(AVFormatContext *s, const AVStream *st, const AVPacket *pkt); +int avpriv_mpegts_add_stream(AVFormatContext *s, int pid, uint32_t stream_type, int program); + #endif /* AVFORMAT_MPEGTS_H */