diff --git a/packager/media/formats/mp2t/es_parser_adts.cc b/packager/media/formats/mp2t/es_parser_audio.cc similarity index 89% rename from packager/media/formats/mp2t/es_parser_adts.cc rename to packager/media/formats/mp2t/es_parser_audio.cc index 14b7f14b41..1d4116e224 100644 --- a/packager/media/formats/mp2t/es_parser_adts.cc +++ b/packager/media/formats/mp2t/es_parser_audio.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "packager/media/formats/mp2t/es_parser_adts.h" +#include "packager/media/formats/mp2t/es_parser_audio.h" #include @@ -77,23 +77,22 @@ static bool LookForSyncWord(const uint8_t* raw_es, return false; } -EsParserAdts::EsParserAdts(uint32_t pid, - const NewStreamInfoCB& new_stream_info_cb, - const EmitSampleCB& emit_sample_cb, - bool sbr_in_mimetype) +EsParserAudio::EsParserAudio(uint32_t pid, + const NewStreamInfoCB& new_stream_info_cb, + const EmitSampleCB& emit_sample_cb, + bool sbr_in_mimetype) : EsParser(pid), audio_header_(new AdtsHeader), new_stream_info_cb_(new_stream_info_cb), emit_sample_cb_(emit_sample_cb), sbr_in_mimetype_(sbr_in_mimetype) {} -EsParserAdts::~EsParserAdts() { -} +EsParserAudio::~EsParserAudio() {} -bool EsParserAdts::Parse(const uint8_t* buf, - int size, - int64_t pts, - int64_t dts) { +bool EsParserAudio::Parse(const uint8_t* buf, + int size, + int64_t pts, + int64_t dts) { int raw_es_size; const uint8_t* raw_es; @@ -129,8 +128,7 @@ bool EsParserAdts::Parse(const uint8_t* buf, return false; // Get the PTS & the duration of this access unit. - while (!pts_list_.empty() && - pts_list_.front().first <= es_position) { + while (!pts_list_.empty() && pts_list_.front().first <= es_position) { audio_timestamp_helper_->SetBaseTimestamp(pts_list_.front().second); pts_list_.pop_front(); } @@ -164,16 +162,15 @@ bool EsParserAdts::Parse(const uint8_t* buf, return true; } -void EsParserAdts::Flush() { -} +void EsParserAudio::Flush() {} -void EsParserAdts::Reset() { +void EsParserAudio::Reset() { es_byte_queue_.Reset(); pts_list_.clear(); last_audio_decoder_config_ = std::shared_ptr(); } -bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) { +bool EsParserAudio::UpdateAudioConfiguration(const AudioHeader& audio_header) { const uint8_t kAacSampleSizeBits(16); std::vector audio_specific_config; @@ -195,9 +192,9 @@ bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) { int samples_per_second = audio_header.GetSamplingFrequency(); // TODO(kqyang): Review if it makes sense to have |sbr_in_mimetype_| in // es_parser. - int extended_samples_per_second = sbr_in_mimetype_ - ? std::min(2 * samples_per_second, 48000) - : samples_per_second; + int extended_samples_per_second = + sbr_in_mimetype_ ? std::min(2 * samples_per_second, 48000) + : samples_per_second; const Codec codec = kCodecAAC; last_audio_decoder_config_ = std::make_shared( @@ -230,7 +227,7 @@ bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) { return true; } -void EsParserAdts::DiscardEs(int nbytes) { +void EsParserAudio::DiscardEs(int nbytes) { DCHECK_GE(nbytes, 0); if (nbytes <= 0) return; diff --git a/packager/media/formats/mp2t/es_parser_adts.h b/packager/media/formats/mp2t/es_parser_audio.h similarity index 78% rename from packager/media/formats/mp2t/es_parser_adts.h rename to packager/media/formats/mp2t/es_parser_audio.h index 4428a543d8..c846ff4472 100644 --- a/packager/media/formats/mp2t/es_parser_adts.h +++ b/packager/media/formats/mp2t/es_parser_audio.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ -#define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_ +#ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_ +#define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_ #include #include @@ -24,13 +24,13 @@ namespace mp2t { class AudioHeader; -class EsParserAdts : public EsParser { +class EsParserAudio : public EsParser { public: - EsParserAdts(uint32_t pid, - const NewStreamInfoCB& new_stream_info_cb, - const EmitSampleCB& emit_sample_cb, - bool sbr_in_mimetype); - ~EsParserAdts() override; + EsParserAudio(uint32_t pid, + const NewStreamInfoCB& new_stream_info_cb, + const EmitSampleCB& emit_sample_cb, + bool sbr_in_mimetype); + ~EsParserAudio() override; // EsParser implementation. bool Parse(const uint8_t* buf, int size, int64_t pts, int64_t dts) override; @@ -38,6 +38,9 @@ class EsParserAdts : public EsParser { void Reset() override; private: + EsParserAudio(const EsParserAudio&) = delete; + EsParserAudio& operator=(const EsParserAudio&) = delete; + // Used to link a PTS with a byte position in the ES stream. typedef std::pair EsPts; typedef std::list EsPtsList; @@ -71,12 +74,10 @@ class EsParserAdts : public EsParser { std::unique_ptr audio_timestamp_helper_; std::shared_ptr last_audio_decoder_config_; - - DISALLOW_COPY_AND_ASSIGN(EsParserAdts); }; } // namespace mp2t } // namespace media } // namespace shaka -#endif +#endif // PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_ diff --git a/packager/media/formats/mp2t/mp2t.gyp b/packager/media/formats/mp2t/mp2t.gyp index 43e0c37798..7a99a0f7fb 100644 --- a/packager/media/formats/mp2t/mp2t.gyp +++ b/packager/media/formats/mp2t/mp2t.gyp @@ -18,8 +18,8 @@ 'audio_header.h', 'continuity_counter.cc', 'continuity_counter.h', - 'es_parser_adts.cc', - 'es_parser_adts.h', + 'es_parser_audio.cc', + 'es_parser_audio.h', 'es_parser_h264.cc', 'es_parser_h264.h', 'es_parser_h265.cc', diff --git a/packager/media/formats/mp2t/mp2t_media_parser.cc b/packager/media/formats/mp2t/mp2t_media_parser.cc index fc274aa1cf..c80e495d97 100644 --- a/packager/media/formats/mp2t/mp2t_media_parser.cc +++ b/packager/media/formats/mp2t/mp2t_media_parser.cc @@ -9,7 +9,7 @@ #include "packager/media/base/media_sample.h" #include "packager/media/base/stream_info.h" #include "packager/media/formats/mp2t/es_parser.h" -#include "packager/media/formats/mp2t/es_parser_adts.h" +#include "packager/media/formats/mp2t/es_parser_audio.h" #include "packager/media/formats/mp2t/es_parser_h264.h" #include "packager/media/formats/mp2t/es_parser_h265.h" #include "packager/media/formats/mp2t/mp2t_common.h" @@ -308,14 +308,11 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid, base::Bind(&Mp2tMediaParser::OnEmitSample, base::Unretained(this)))); } else if (stream_type == kStreamTypeAAC) { - es_parser.reset( - new EsParserAdts( - pes_pid, - base::Bind(&Mp2tMediaParser::OnNewStreamInfo, - base::Unretained(this)), - base::Bind(&Mp2tMediaParser::OnEmitSample, - base::Unretained(this)), - sbr_in_mimetype_)); + es_parser.reset(new EsParserAudio( + pes_pid, + base::Bind(&Mp2tMediaParser::OnNewStreamInfo, base::Unretained(this)), + base::Bind(&Mp2tMediaParser::OnEmitSample, base::Unretained(this)), + sbr_in_mimetype_)); is_audio = true; } else { VLOG(1) << "Ignore unsupported stream type 0x" << std::hex << stream_type