[FFmpeg-devel] [patch] export pmt and pcr pids from mpegts demuxer

Michael Niedermayer michaelni
Sun Jun 6 23:05:56 CEST 2010


On Sun, Jun 06, 2010 at 01:36:10PM -0700, Baptiste Coudurier wrote:
> 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.

if C vararg functions passed the number of arguments we could support default
values for the last N arguments to functions.
but as they dont IIRC i dont know how defaults could be done in C.

iam not sure if we want to have duplicate functions that have rarely used
arguments set to defaults, iam not opposed to this but we should do this
consistently with all functions where it makes sense and we should do it
in a consistent and easy to understand way if we do it at all.


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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100606/7e0697a9/attachment.pgp>



More information about the ffmpeg-devel mailing list