2014-04-01 01:34:59 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// 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_
|
|
|
|
|
|
|
|
#include <list>
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2014-04-01 01:34:59 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/callback.h"
|
|
|
|
#include "packager/base/compiler_specific.h"
|
|
|
|
#include "packager/media/base/audio_stream_info.h"
|
|
|
|
#include "packager/media/base/byte_queue.h"
|
|
|
|
#include "packager/media/formats/mp2t/es_parser.h"
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2014-04-01 01:34:59 +00:00
|
|
|
namespace media {
|
|
|
|
class AudioTimestampHelper;
|
|
|
|
class BitReader;
|
|
|
|
|
|
|
|
namespace mp2t {
|
|
|
|
|
2017-10-23 05:27:27 +00:00
|
|
|
class AudioHeader;
|
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
class EsParserAdts : public EsParser {
|
|
|
|
public:
|
2014-09-30 21:52:21 +00:00
|
|
|
EsParserAdts(uint32_t pid,
|
2014-04-10 19:57:10 +00:00
|
|
|
const NewStreamInfoCB& new_stream_info_cb,
|
2014-04-07 17:48:25 +00:00
|
|
|
const EmitSampleCB& emit_sample_cb,
|
2014-04-01 01:34:59 +00:00
|
|
|
bool sbr_in_mimetype);
|
2015-07-22 23:40:45 +00:00
|
|
|
~EsParserAdts() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// EsParser implementation.
|
2015-07-22 23:40:45 +00:00
|
|
|
bool Parse(const uint8_t* buf, int size, int64_t pts, int64_t dts) override;
|
|
|
|
void Flush() override;
|
|
|
|
void Reset() override;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Used to link a PTS with a byte position in the ES stream.
|
2014-09-30 21:52:21 +00:00
|
|
|
typedef std::pair<int, int64_t> EsPts;
|
2014-04-01 01:34:59 +00:00
|
|
|
typedef std::list<EsPts> EsPtsList;
|
|
|
|
|
|
|
|
// Signal any audio configuration change (if any).
|
2017-10-23 05:27:27 +00:00
|
|
|
// Return false if the current audio config is not a supported audio config.
|
|
|
|
bool UpdateAudioConfiguration(const AudioHeader& audio_header);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Discard some bytes from the ES stream.
|
|
|
|
void DiscardEs(int nbytes);
|
|
|
|
|
2017-10-23 05:27:27 +00:00
|
|
|
std::unique_ptr<AudioHeader> audio_header_;
|
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
// Callbacks:
|
|
|
|
// - to signal a new audio configuration,
|
|
|
|
// - to send ES buffers.
|
2014-04-10 19:57:10 +00:00
|
|
|
NewStreamInfoCB new_stream_info_cb_;
|
2014-04-07 17:48:25 +00:00
|
|
|
EmitSampleCB emit_sample_cb_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// True when AAC SBR extension is signalled in the mimetype
|
|
|
|
// (mp4a.40.5 in the codecs parameter).
|
|
|
|
bool sbr_in_mimetype_;
|
|
|
|
|
|
|
|
// Bytes of the ES stream that have not been emitted yet.
|
|
|
|
ByteQueue es_byte_queue_;
|
|
|
|
|
|
|
|
// List of PTS associated with a position in the ES stream.
|
|
|
|
EsPtsList pts_list_;
|
|
|
|
|
|
|
|
// Interpolated PTS for frames that don't have one.
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<AudioTimestampHelper> audio_timestamp_helper_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2017-01-24 00:55:02 +00:00
|
|
|
std::shared_ptr<StreamInfo> last_audio_decoder_config_;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(EsParserAdts);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#endif
|