Rename EsParserAdts to EsParserAudio
Change-Id: I8d9fc265a4cf740970256e1a46b172349f1bf794
This commit is contained in:
parent
79a54d7748
commit
ad836a5cf1
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// 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>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ static bool LookForSyncWord(const uint8_t* raw_es,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EsParserAdts::EsParserAdts(uint32_t pid,
|
EsParserAudio::EsParserAudio(uint32_t pid,
|
||||||
const NewStreamInfoCB& new_stream_info_cb,
|
const NewStreamInfoCB& new_stream_info_cb,
|
||||||
const EmitSampleCB& emit_sample_cb,
|
const EmitSampleCB& emit_sample_cb,
|
||||||
bool sbr_in_mimetype)
|
bool sbr_in_mimetype)
|
||||||
|
@ -87,10 +87,9 @@ EsParserAdts::EsParserAdts(uint32_t pid,
|
||||||
emit_sample_cb_(emit_sample_cb),
|
emit_sample_cb_(emit_sample_cb),
|
||||||
sbr_in_mimetype_(sbr_in_mimetype) {}
|
sbr_in_mimetype_(sbr_in_mimetype) {}
|
||||||
|
|
||||||
EsParserAdts::~EsParserAdts() {
|
EsParserAudio::~EsParserAudio() {}
|
||||||
}
|
|
||||||
|
|
||||||
bool EsParserAdts::Parse(const uint8_t* buf,
|
bool EsParserAudio::Parse(const uint8_t* buf,
|
||||||
int size,
|
int size,
|
||||||
int64_t pts,
|
int64_t pts,
|
||||||
int64_t dts) {
|
int64_t dts) {
|
||||||
|
@ -129,8 +128,7 @@ bool EsParserAdts::Parse(const uint8_t* buf,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Get the PTS & the duration of this access unit.
|
// Get the PTS & the duration of this access unit.
|
||||||
while (!pts_list_.empty() &&
|
while (!pts_list_.empty() && pts_list_.front().first <= es_position) {
|
||||||
pts_list_.front().first <= es_position) {
|
|
||||||
audio_timestamp_helper_->SetBaseTimestamp(pts_list_.front().second);
|
audio_timestamp_helper_->SetBaseTimestamp(pts_list_.front().second);
|
||||||
pts_list_.pop_front();
|
pts_list_.pop_front();
|
||||||
}
|
}
|
||||||
|
@ -164,16 +162,15 @@ bool EsParserAdts::Parse(const uint8_t* buf,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsParserAdts::Flush() {
|
void EsParserAudio::Flush() {}
|
||||||
}
|
|
||||||
|
|
||||||
void EsParserAdts::Reset() {
|
void EsParserAudio::Reset() {
|
||||||
es_byte_queue_.Reset();
|
es_byte_queue_.Reset();
|
||||||
pts_list_.clear();
|
pts_list_.clear();
|
||||||
last_audio_decoder_config_ = std::shared_ptr<AudioStreamInfo>();
|
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);
|
const uint8_t kAacSampleSizeBits(16);
|
||||||
|
|
||||||
std::vector<uint8_t> audio_specific_config;
|
std::vector<uint8_t> audio_specific_config;
|
||||||
|
@ -195,8 +192,8 @@ bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) {
|
||||||
int samples_per_second = audio_header.GetSamplingFrequency();
|
int samples_per_second = audio_header.GetSamplingFrequency();
|
||||||
// TODO(kqyang): Review if it makes sense to have |sbr_in_mimetype_| in
|
// TODO(kqyang): Review if it makes sense to have |sbr_in_mimetype_| in
|
||||||
// es_parser.
|
// es_parser.
|
||||||
int extended_samples_per_second = sbr_in_mimetype_
|
int extended_samples_per_second =
|
||||||
? std::min(2 * samples_per_second, 48000)
|
sbr_in_mimetype_ ? std::min(2 * samples_per_second, 48000)
|
||||||
: samples_per_second;
|
: samples_per_second;
|
||||||
|
|
||||||
const Codec codec = kCodecAAC;
|
const Codec codec = kCodecAAC;
|
||||||
|
@ -230,7 +227,7 @@ bool EsParserAdts::UpdateAudioConfiguration(const AudioHeader& audio_header) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EsParserAdts::DiscardEs(int nbytes) {
|
void EsParserAudio::DiscardEs(int nbytes) {
|
||||||
DCHECK_GE(nbytes, 0);
|
DCHECK_GE(nbytes, 0);
|
||||||
if (nbytes <= 0)
|
if (nbytes <= 0)
|
||||||
return;
|
return;
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
|
#ifndef PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_
|
||||||
#define MEDIA_FORMATS_MP2T_ES_PARSER_ADTS_H_
|
#define PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -24,13 +24,13 @@ namespace mp2t {
|
||||||
|
|
||||||
class AudioHeader;
|
class AudioHeader;
|
||||||
|
|
||||||
class EsParserAdts : public EsParser {
|
class EsParserAudio : public EsParser {
|
||||||
public:
|
public:
|
||||||
EsParserAdts(uint32_t pid,
|
EsParserAudio(uint32_t pid,
|
||||||
const NewStreamInfoCB& new_stream_info_cb,
|
const NewStreamInfoCB& new_stream_info_cb,
|
||||||
const EmitSampleCB& emit_sample_cb,
|
const EmitSampleCB& emit_sample_cb,
|
||||||
bool sbr_in_mimetype);
|
bool sbr_in_mimetype);
|
||||||
~EsParserAdts() override;
|
~EsParserAudio() override;
|
||||||
|
|
||||||
// EsParser implementation.
|
// EsParser implementation.
|
||||||
bool Parse(const uint8_t* buf, int size, int64_t pts, int64_t dts) override;
|
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;
|
void Reset() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
EsParserAudio(const EsParserAudio&) = delete;
|
||||||
|
EsParserAudio& operator=(const EsParserAudio&) = delete;
|
||||||
|
|
||||||
// Used to link a PTS with a byte position in the ES stream.
|
// Used to link a PTS with a byte position in the ES stream.
|
||||||
typedef std::pair<int, int64_t> EsPts;
|
typedef std::pair<int, int64_t> EsPts;
|
||||||
typedef std::list<EsPts> EsPtsList;
|
typedef std::list<EsPts> EsPtsList;
|
||||||
|
@ -71,12 +74,10 @@ class EsParserAdts : public EsParser {
|
||||||
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
|
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
|
||||||
|
|
||||||
std::shared_ptr<StreamInfo> last_audio_decoder_config_;
|
std::shared_ptr<StreamInfo> last_audio_decoder_config_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(EsParserAdts);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mp2t
|
} // namespace mp2t
|
||||||
} // namespace media
|
} // namespace media
|
||||||
} // namespace shaka
|
} // namespace shaka
|
||||||
|
|
||||||
#endif
|
#endif // PACKAGER_MEDIA_FORMATS_MP2T_ES_PARSER_AUDIO_H_
|
|
@ -18,8 +18,8 @@
|
||||||
'audio_header.h',
|
'audio_header.h',
|
||||||
'continuity_counter.cc',
|
'continuity_counter.cc',
|
||||||
'continuity_counter.h',
|
'continuity_counter.h',
|
||||||
'es_parser_adts.cc',
|
'es_parser_audio.cc',
|
||||||
'es_parser_adts.h',
|
'es_parser_audio.h',
|
||||||
'es_parser_h264.cc',
|
'es_parser_h264.cc',
|
||||||
'es_parser_h264.h',
|
'es_parser_h264.h',
|
||||||
'es_parser_h265.cc',
|
'es_parser_h265.cc',
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "packager/media/base/media_sample.h"
|
#include "packager/media/base/media_sample.h"
|
||||||
#include "packager/media/base/stream_info.h"
|
#include "packager/media/base/stream_info.h"
|
||||||
#include "packager/media/formats/mp2t/es_parser.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_h264.h"
|
||||||
#include "packager/media/formats/mp2t/es_parser_h265.h"
|
#include "packager/media/formats/mp2t/es_parser_h265.h"
|
||||||
#include "packager/media/formats/mp2t/mp2t_common.h"
|
#include "packager/media/formats/mp2t/mp2t_common.h"
|
||||||
|
@ -308,13 +308,10 @@ void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
||||||
base::Bind(&Mp2tMediaParser::OnEmitSample,
|
base::Bind(&Mp2tMediaParser::OnEmitSample,
|
||||||
base::Unretained(this))));
|
base::Unretained(this))));
|
||||||
} else if (stream_type == kStreamTypeAAC) {
|
} else if (stream_type == kStreamTypeAAC) {
|
||||||
es_parser.reset(
|
es_parser.reset(new EsParserAudio(
|
||||||
new EsParserAdts(
|
|
||||||
pes_pid,
|
pes_pid,
|
||||||
base::Bind(&Mp2tMediaParser::OnNewStreamInfo,
|
base::Bind(&Mp2tMediaParser::OnNewStreamInfo, base::Unretained(this)),
|
||||||
base::Unretained(this)),
|
base::Bind(&Mp2tMediaParser::OnEmitSample, base::Unretained(this)),
|
||||||
base::Bind(&Mp2tMediaParser::OnEmitSample,
|
|
||||||
base::Unretained(this)),
|
|
||||||
sbr_in_mimetype_));
|
sbr_in_mimetype_));
|
||||||
is_audio = true;
|
is_audio = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue