From 14e5ef96c8a8d8bc243ff4f250ccb06d47e0d6d9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 16 Dec 2014 15:04:37 +0100 Subject: [PATCH] MPEG TS: parse PMT registration descriptor and get codec from it --- src/input/r_mpeg_ts.cpp | 33 +++++++++++++++++++++++++++++++++ src/input/r_mpeg_ts.h | 1 + 2 files changed, 34 insertions(+) diff --git a/src/input/r_mpeg_ts.cpp b/src/input/r_mpeg_ts.cpp index e8eb7b7eb..ee53d43b8 100644 --- a/src/input/r_mpeg_ts.cpp +++ b/src/input/r_mpeg_ts.cpp @@ -460,6 +460,36 @@ mpeg_ts_track_c::parse_srt_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_de return true; } +bool +mpeg_ts_track_c::parse_registration_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, + mpeg_ts_pmt_pid_info_t const &pmt_pid_info) { + if (pmt_pid_info.stream_type != ISO_13818_PES_PRIVATE) + return false; + + if (pmt_descriptor.length < 4) + return false; + + auto fourcc = fourcc_c{reinterpret_cast(&pmt_descriptor + 1)}; + auto reg_codec = codec_c::look_up(fourcc.str()); + + mxdebug_if(reader.m_debug_pat_pmt, boost::format("mpeg_ts:parse_pmt: Registration descriptor with FourCC: %1% codec: %2%\n") % fourcc % reg_codec); + + if (!reg_codec.valid()) + return false; + + switch (reg_codec.get_track_type()) { + case track_audio: type = ES_AUDIO_TYPE; break; + case track_video: type = ES_VIDEO_TYPE; break; + case track_subtitle: type = ES_SUBT_TYPE; break; + default: + return false; + } + + codec = reg_codec; + + return true; +} + bool mpeg_ts_track_c::parse_vobsub_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info) { @@ -911,6 +941,9 @@ mpeg_ts_reader_c::parse_pmt(unsigned char *pmt) { missing_tag = false; switch (pmt_descriptor->tag) { + case 0x05: // registration descriptor + track->parse_registration_pmt_descriptor(*pmt_descriptor, *pmt_pid_info); + break; case 0x0a: // ISO 639 language descriptor track->parse_iso639_language_from(pmt_descriptor + 1); break; diff --git a/src/input/r_mpeg_ts.h b/src/input/r_mpeg_ts.h index a2374f26e..c4af00dd3 100644 --- a/src/input/r_mpeg_ts.h +++ b/src/input/r_mpeg_ts.h @@ -359,6 +359,7 @@ public: bool parse_ac3_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info); bool parse_dts_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info); + bool parse_registration_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info); bool parse_srt_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info); bool parse_vobsub_pmt_descriptor(mpeg_ts_pmt_descriptor_t const &pmt_descriptor, mpeg_ts_pmt_pid_info_t const &pmt_pid_info);