[FFmpeg-devel] pat/pmt changes on mpegts

Michael Niedermayer michaelni at gmx.at
Sat Dec 15 15:37:22 CET 2012


Hi

On Sat, Dec 01, 2012 at 09:31:30AM +0000, Rainer Hochecker wrote:
> Hi,
> 
> in order to select appropriate streams we (XBMC) need information about
> currently active streams of a program. Joakim and I discussed several approaches
> for a solution. This is the result:
> 
> - update streams in AVProgram
> - sent notification packet via a data stream
> 
> diff --git lib/ffmpeg/libavformat/mpegts.c lib/ffmpeg/libavformat/mpegts.c
> index 6da6db5..9f574e4 100644
> --- lib/ffmpeg/libavformat/mpegts.c
> +++ lib/ffmpeg/libavformat/mpegts.c
> @@ -183,10 +183,25 @@ typedef struct PESContext {
>  
>  extern AVInputFormat ff_mpegts_demuxer;
>  
> +static void clear_avprogram(MpegTSContext *ts, unsigned int programid)
> +{
> +    AVProgram *prg = NULL;
> +    int i;
> +    for(i=0; i<ts->stream->nb_programs; i++)
> +        if(ts->stream->programs[i]->id == programid){
> +            prg = ts->stream->programs[i];
> +            break;
> +        }
> +    if (!prg)
> +        return;
> +    prg->nb_stream_indexes = 0;
> +}
> +
>  static void clear_program(MpegTSContext *ts, unsigned int programid)
>  {
>      int i;
>  
> +    clear_avprogram(ts, programid);
>      for(i=0; i<ts->nb_prg; i++)
>          if(ts->prg[i].id == programid)
>              ts->prg[i].nb_pids = 0;

> @@ -194,6 +209,9 @@ static void clear_program(MpegTSContext *ts, unsigned int
> programid)

The patch is line wraped and cannot be applied automatically
also ideally patches should be git style formated with author and
commit message so they can simply be applied with "git am"

tha patch also breaks "make fate"
If the changes to fate are expected and correct then the patch should
update the checksums


>  
>  static void clear_programs(MpegTSContext *ts)
>  {
> +    int i;
> +    for(i=0; i<ts->nb_prg; i++)
> +        clear_avprogram(ts, ts->prg[i].id);
>      av_freep(&ts->prg);
>      ts->nb_prg=0;
>  }
> @@ -1542,6 +1560,25 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t
> *section, int section_len
>          p = desc_list_end;
>      }
>  
> +    if (ts->pkt) {
> +        AVStream *st;
> +        /* PID of PAT is 0x00, we use this for data stream id */
> +        int idx = ff_find_stream_index(ts->stream, 0x00);
> +        if (idx >= 0) {
> +            st = ts->stream->streams[idx];
> +        } else {
> +            st = avformat_new_stream(ts->stream, NULL);
> +            st->id = 0x00;
> +            st->codec->codec_type = AVMEDIA_TYPE_DATA;
> +        }

the data stream lacks a codec_id/codec_tag


> +        ff_program_add_stream_index(ts->stream, h->id, st->index);
> +        av_init_packet(ts->pkt);
> +        ts->pkt->data = section;
> +        ts->pkt->size = section_len;
> +        ts->pkt->stream_index = st->index;

the packets have no pts/dts/pos set

also the patch breaks
ffmpeg -i input.ts -map 0 out.ts
in some cases
(its because ffmpeg stupidly tries to encode the data stream in this
 case, this is admitedly a ffmpeg bug but it would be ideal if it
 would be fixed, though doesnt need to be in this patch)

Thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121215/ab69c6b6/attachment.asc>


More information about the ffmpeg-devel mailing list