[FFmpeg-devel] [patch] export pmt and pcr pids from mpegts demuxer
Baptiste Coudurier
baptiste.coudurier
Sun Jun 6 22:36:10 CEST 2010
On 6/6/10 10:11 AM, Mike Scheutzow wrote:
> This patch allows a libav application to obtain the pmt pid(s) and pcr
> pid(s) values parsed by the mpegts demuxer. This is useful for
> applications that need the output stream pids to match the input stream
> pids.
>
> The pid values are added to AVProgram.metadata inside the AVFormatContext.
>
> Example: key="pmt_pid" value="129"
> key="pcr_pid" value="1064"
>
> Values are base10. This patch supports multiple programs per transport
> stream.
>
> Feedback appreciated.
>
>
> mpegts_export_psi_pids_v1.patch
>
>
> Index: libavformat/mpegts.c
> ===================================================================
> --- libavformat/mpegts.c (revision 23373)
> +++ libavformat/mpegts.c (working copy)
> @@ -863,6 +863,8 @@
> int comp_page, anc_page;
> char language[4];
> uint32_t prog_reg_desc = 0; /* registration descriptor */
> + AVProgram *program;
> + char pcr_str[8];
>
> #ifdef DEBUG
> dprintf(ts->stream, "PMT: len %i\n", section_len);
> @@ -880,12 +882,23 @@
> if (h->tid != PMT_TID)
> return;
>
> + /* returns existing if previously created */
> + program = av_new_program(ts->stream, h->id);
> + if (!program)
> + return;
> +
> clear_program(ts, h->id);
> pcr_pid = get16(&p, p_end)& 0x1fff;
> - if (pcr_pid< 0)
> + if (pcr_pid< 0) {
> + /* delete key if present */
> + av_metadata_set2(&program->metadata, "pcr_pid", NULL, 0);
> return;
> + }
> add_pid_to_pmt(ts, h->id, pcr_pid);
>
> + snprintf(pcr_str, sizeof(pcr_str), "%d", pcr_pid);
> + av_metadata_set2(&program->metadata, "pcr_pid", pcr_str, 0);
> +
Note to Michael:
Why did deprecate av_metadata_set already ? Having this useless 0 at the
end is ulgy.
Patch looks good to me.
[...]
--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list