From 0fdb0d02aada3d400ca85707ced44188b77c503b Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Fri, 1 Dec 2017 14:53:20 -0800 Subject: [PATCH] Log an error when seeing unsupported stream type in MPEG2TS The error is logged only once to avoid log spamming. Added definitions for the unsupported stream types for easy look up. Change-Id: I097e2f05759bc84ef03f264cfabd2fb20da7c711 --- packager/media/formats/mp2t/mp2t_media_parser.cc | 9 ++++++--- packager/media/formats/mp2t/mp2t_media_parser.h | 4 ++++ packager/media/formats/mp2t/ts_stream_type.h | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packager/media/formats/mp2t/mp2t_media_parser.cc b/packager/media/formats/mp2t/mp2t_media_parser.cc index 093bbd1489..4ecb9dd76a 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser.cc @@ -306,10 +306,13 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid, sbr_in_mimetype_)); is_audio = true; break; - default: - VLOG(1) << "Ignore unsupported stream type 0x" << std::hex << stream_type - << std::dec; + default: { + LOG_IF(ERROR, !stream_type_logged_once_[stream_type]) + << "Ignore unsupported MPEG2TS stream type 0x" << std::hex + << stream_type << std::dec; + stream_type_logged_once_[stream_type] = true; return; + } } // Create the PES state here. diff --git a/packager/media/formats/mp2t/mp2t_media_parser.h b/packager/media/formats/mp2t/mp2t_media_parser.h index ec9f9d286a..a74b20570c 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser.h +++ b/packager/media/formats/mp2t/mp2t_media_parser.h @@ -87,6 +87,10 @@ class Mp2tMediaParser : public MediaParser { // Whether |init_cb_| has been invoked. bool is_initialized_; + // A map used to track unsupported stream types and make sure the error is + // only logged once. + std::map stream_type_logged_once_; + DISALLOW_COPY_AND_ASSIGN(Mp2tMediaParser); }; diff --git a/packager/media/formats/mp2t/ts_stream_type.h b/packager/media/formats/mp2t/ts_stream_type.h index 990b428ed4..9258706c0e 100644 --- a/packager/media/formats/mp2t/ts_stream_type.h +++ b/packager/media/formats/mp2t/ts_stream_type.h @@ -15,12 +15,26 @@ namespace mp2t { enum class TsStreamType { // ISO-13818.1 / ITU H.222 Table 2-34 "Stream type assignments" + kMpeg1Video = 0x01, // ISO/IEC 11172-2 Video + kMpeg2Video = 0x02, // ITU-T H.262 | ISO/IEC 13818-2 Video | + // ISO/IEC 11172-2 constrained parameter video stream + kMpeg1Audio = 0x03, // ISO/IEC 11172-3 Audio + kMpeg2Audio = 0x04, // ISO/IEC 13818-3 Audio + kPesPrivateData = + 0x06, // ISO/IEC 13818-1 PES packets containing private data. It is also + // used by DVB (TS 101 154 DVB specification ...) to carry AC3 in + // TS (while ATSC uses 0x81 defined below). kAdtsAac = 0x0F, kAvc = 0x1B, kHevc = 0x24, - // ATSC Standard A/52. + // Below are extensions defined in other specifications. + // AC3 and E-AC3 are defined in ATSC Standard A/52. + // Cannot find specification for DTS-HD and DTS. They are extracted from + // https://sno.phy.queensu.ca/~phil/exiftool/TagNames/M2TS.html. kAc3 = 0x81, + kDtsHd = 0x86, kEac3 = 0x87, + kDts = 0x8A, // MPEG-2 Stream Encryption Format for HTTP Live Streaming: // https://goo.gl/N7Tvqi. kEncryptedAc3 = 0xC1,