Revision 798c6fac libavformat/mpegts.c

View differences:

libavformat/mpegts.c
30 30
#include "mpegts.h"
31 31
#include "internal.h"
32 32
#include "seek.h"
33
#include "isom.h"
33 34

  
34 35
/* 1.0 second at 24Mbit/s */
35 36
#define MAX_SCAN_PACKETS 32000
......
852 853
    return pes;
853 854
}
854 855

  
856
static int mp4_read_iods(AVFormatContext *s, uint8_t *buf, unsigned size,
857
                         uint16_t *es_id, uint8_t **dec_config_descr,
858
                         int *dec_config_descr_size)
859
{
860
    ByteIOContext pb;
861
    int tag;
862
    unsigned len;
863

  
864
    init_put_byte(&pb, buf, size, 0, NULL, NULL, NULL, NULL);
865

  
866
    len = ff_mp4_read_descr(s, &pb, &tag);
867
    if (tag == MP4IODescrTag) {
868
        get_be16(&pb); // ID
869
        get_byte(&pb);
870
        get_byte(&pb);
871
        get_byte(&pb);
872
        get_byte(&pb);
873
        get_byte(&pb);
874
        len = ff_mp4_read_descr(s, &pb, &tag);
875
        if (tag == MP4ESDescrTag) {
876
            *es_id = get_be16(&pb); /* ES_ID */
877
            dprintf(s, "ES_ID %#x\n", *es_id);
878
            get_byte(&pb); /* priority */
879
            len = ff_mp4_read_descr(s, &pb, &tag);
880
            if (tag == MP4DecConfigDescrTag) {
881
                *dec_config_descr = av_malloc(len);
882
                if (!*dec_config_descr)
883
                    return AVERROR(ENOMEM);
884
                *dec_config_descr_size = len;
885
                get_buffer(&pb, *dec_config_descr, len);
886
            }
887
        }
888
    }
889
    return 0;
890
}
891

  
855 892
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
856 893
{
857 894
    MpegTSContext *ts = filter->u.section_filter.opaque;
......
863 900
    int desc_list_len, desc_len, desc_tag;
864 901
    char language[4];
865 902
    uint32_t prog_reg_desc = 0; /* registration descriptor */
903
    uint8_t *mp4_dec_config_descr = NULL;
904
    int mp4_dec_config_descr_len = 0;
905
    int mp4_es_id = 0;
866 906

  
867 907
#ifdef DEBUG
868 908
    dprintf(ts->stream, "PMT: len %i\n", section_len);
......
895 935
        uint8_t tag, len;
896 936
        tag = get8(&p, p_end);
897 937
        len = get8(&p, p_end);
938

  
939
        dprintf(ts->stream, "program tag: 0x%02x len=%d\n", tag, len);
940

  
898 941
        if(len > program_info_length - 2)
899 942
            //something else is broken, exit the program_descriptors_loop
900 943
            break;
901 944
        program_info_length -= len + 2;
902
        if(tag == 0x05 && len >= 4) { // registration descriptor
945
        if (tag == 0x1d) { // IOD descriptor
946
            get8(&p, p_end); // scope
947
            get8(&p, p_end); // label
948
            len -= 2;
949
            mp4_read_iods(ts->stream, p, len, &mp4_es_id,
950
                          &mp4_dec_config_descr, &mp4_dec_config_descr_len);
951
        } else if (tag == 0x05 && len >= 4) { // registration descriptor
903 952
            prog_reg_desc = bytestream_get_le32(&p);
904 953
            len -= 4;
905 954
        }
......
968 1017
                mpegts_find_stream_type(st, desc_tag, DESC_types);
969 1018

  
970 1019
            switch(desc_tag) {
1020
            case 0x1F: /* FMC descriptor */
1021
                get16(&p, desc_end);
1022
                if (st->codec->codec_id == CODEC_ID_AAC_LATM &&
1023
                    mp4_dec_config_descr_len && mp4_es_id == pid) {
1024
                    ByteIOContext pb;
1025
                    init_put_byte(&pb, mp4_dec_config_descr,
1026
                                  mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL);
1027
                    ff_mp4_read_dec_config_descr(ts->stream, st, &pb);
1028
                    if (st->codec->codec_id == CODEC_ID_AAC &&
1029
                        st->codec->extradata_size > 0)
1030
                        st->need_parsing = 0;
1031
                }
1032
                break;
971 1033
            case 0x56: /* DVB teletext descriptor */
972 1034
                language[0] = get8(&p, desc_end);
973 1035
                language[1] = get8(&p, desc_end);

Also available in: Unified diff