[FFmpeg-devel] [PATCH] change PAT/PMT/SDT playout to be dependant on PTS and not a number of packets.

Baptiste Coudurier baptiste.coudurier at gmail.com
Wed May 18 21:57:54 CEST 2011


Hi,

On 05/18/2011 06:21 AM, JULIAN GARDNER wrote:
> Change the way in which the PAT, PMT and SDT are inserted into the Mpeg TS, now dependant on time.
> 
> Set to repeat at
> 
> PAT     250ms
> PMT     375ms
> SDT     1250ms
> 
> Maybe add a way of the user setting these values to give faster or slower playout rates, as this does add to the TS overhead.

You can use AVOptions in the ts muxer.

> [...]
>
> @@ -568,17 +587,15 @@ static int mpegts_write_header(AVFormatContext *s)
>  
>      // output a PCR as soon as possible
>      service->pcr_packet_count = service->pcr_packet_period;
> -    ts->pat_packet_count = ts->pat_packet_period-1;
> -    ts->sdt_packet_count = ts->sdt_packet_period-1;
>  
>      if (ts->mux_rate == 1)
>          av_log(s, AV_LOG_INFO, "muxrate VBR, ");
>      else
>          av_log(s, AV_LOG_INFO, "muxrate %d, ", ts->mux_rate);
>      av_log(s, AV_LOG_INFO, "pcr every %d pkts, "
> -           "sdt every %d, pat/pmt every %d pkts\n",
> +           "sdt every %d, pat %d, pmt every %d pkts\n",

It's not pkts anymore

> [...]
>
> @@ -594,21 +611,31 @@ static int mpegts_write_header(AVFormatContext *s)
>  }
>  
>  /* send SDT, PAT and PMT tables regulary */
> -static void retransmit_si_info(AVFormatContext *s)
> +static void retransmit_si_info(AVFormatContext *s, int64_t pts)	// MpegTSWriteStream *ts_st)

pts can be out of order, I think you should based the timing on pcr.

>  {
>      MpegTSWrite *ts = s->priv_data;
>      int i;
> +    int64_t temp_pts;
>  
> -    if (++ts->sdt_packet_count == ts->sdt_packet_period) {
> -        ts->sdt_packet_count = 0;
> +    temp_pts = 90*SDT_RETRANS_TIME;
> +    if (ts->sdt_pts==-1 || (abs(ts->sdt_pts-pts)>temp_pts)) {
>          mpegts_write_sdt(s);
> +//	av_log( s, AV_LOG_INFO, "SDT %llx\r\n", pts); // ts_st->payload_pts);
> +        ts->sdt_pts = pts;
>      }
> -    if (++ts->pat_packet_count == ts->pat_packet_period) {
> -        ts->pat_packet_count = 0;
> +    temp_pts = 90*PAT_RETRANS_TIME;
> +    if (ts->pat_pts==-1 || (abs(ts->pat_pts-pts)>temp_pts)) {
>          mpegts_write_pat(s);
> +//        av_log( s, AV_LOG_INFO, "PAT %llx\r\n", pts); // ts_st->payload_pts);
> +        ts->pat_pts = pts;
> +    }
> +    temp_pts = 90*PMT_RETRANS_TIME;
> +    if (ts->pmt_pts==-1 || (abs(ts->pmt_pts-pts)>temp_pts)) {

You don't need a temp variable for that.

The debugging code looks a bit messy as well, can you please remove it ?

[...]

-- 
Baptiste COUDURIER
Key fingerprint          8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                           http://www.ffmpeg.org


More information about the ffmpeg-devel mailing list