[FFmpeg-devel] [PATCH v3] * mpegts demuxer recognizes private streams on demand

Wolfgang Lorenz wl-chmw at gmx.de
Thu Jun 4 23:46:21 CEST 2015


The option went into the MpegTSContext struct and can be addressed via
dictionary:

    AVFormatContext * formatContext = NULL;

    /* enable mpeg-ts private stream recognition */
    AVDictionary * dict = NULL;
    av_dict_set_int(&dict, "mpegts_recognize_private_streams", 1, 0);

    /* open file */
    avformat_open_input(&formatContext, fileName, NULL, &dict);


---
 libavformat/mpegts.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index aeb2335..9c883a8 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -147,6 +147,8 @@ struct MpegTSContext {
 
     int resync_size;
 
+    int recognize_private_streams;
+
     /******************************************/
     /* private mpegts data */
     /* scan context */
@@ -175,6 +177,8 @@ static const AVOption options[] = {
      {.i64 = 0}, 0, 1, 0 },
     {"skip_clear", "Skip clearing programs.", offsetof(MpegTSContext, skip_clear), AV_OPT_TYPE_INT,
      {.i64 = 0}, 0, 1, 0 },
+    {"mpegts_recognize_private_streams", "Assign AVMEDIA_TYPE_DATA and AV_CODEC_ID_BIN_DATA to data streams", offsetof(MpegTSContext, recognize_private_streams), AV_OPT_TYPE_INT,
+     {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
@@ -705,6 +709,11 @@ static const StreamType ISO_types[] = {
     { 0 },
 };
 
+static const StreamType ISO_type_private_stream[] = {
+    { 0x06, AVMEDIA_TYPE_DATA,  AV_CODEC_ID_BIN_DATA   },
+    { 0 },
+};
+
 static const StreamType HDMV_types[] = {
     { 0x80, AVMEDIA_TYPE_AUDIO,    AV_CODEC_ID_PCM_BLURAY        },
     { 0x81, AVMEDIA_TYPE_AUDIO,    AV_CODEC_ID_AC3               },
@@ -800,6 +809,10 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
     st->codec->codec_tag = pes->stream_type;
 
     mpegts_find_stream_type(st, pes->stream_type, ISO_types);
+    if (st->codec->codec_id == AV_CODEC_ID_NONE &&
+        pes->ts->recognize_private_streams) {
+        mpegts_find_stream_type(st, pes->stream_type, ISO_type_private_stream);
+    }
     if ((prog_reg_desc == AV_RL32("HDMV") ||
          prog_reg_desc == AV_RL32("HDPR")) &&
         st->codec->codec_id == AV_CODEC_ID_NONE) {
-- 
1.9.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150604/58a32b61/attachment.asc>


More information about the ffmpeg-devel mailing list