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>
|
|
|
|
#include <utility>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/callback.h"
|
|
|
|
#include "packager/base/compiler_specific.h"
|
|
|
|
#include "packager/base/memory/scoped_ptr.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 {
|
|
|
|
|
|
|
|
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).
|
|
|
|
// Return false if the current audio config is not
|
|
|
|
// a supported ADTS audio config.
|
2014-09-30 21:52:21 +00:00
|
|
|
bool UpdateAudioConfiguration(const uint8_t* adts_frame, size_t frame_size);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Discard some bytes from the ES stream.
|
|
|
|
void DiscardEs(int nbytes);
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
scoped_refptr<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
|