Rename EsParserAdts to EsParserAudio

Change-Id: I8d9fc265a4cf740970256e1a46b172349f1bf794
This commit is contained in:
KongQun Yang 2017-10-22 22:58:52 -07:00
parent 79a54d7748
commit ad836a5cf1
4 changed files with 38 additions and 43 deletions

View File

@ -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 <stdint.h>
@ -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<AudioStreamInfo>();
}
bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) {
bool EsParserAudio::UpdateAudioConfiguration(const AudioHeader& audio_header) {
const uint8_t kAacSampleSizeBits(16);
std::vector<uint8_t> 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<AudioStreamInfo>(
@ -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;

View File

@ -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 <list>
#include <memory>
@ -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<int, int64_t> EsPts;
typedef std::list<EsPts> EsPtsList;
@ -71,12 +74,10 @@ class EsParserAdts : public EsParser {
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
std::shared_ptr<StreamInfo> 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_

View File

@ -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',

View File

@ -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