Chromium Code Reviews| Index: media/mpeg2/es_parser_adts.h |
| diff --git a/media/mpeg2/es_parser_adts.h b/media/mpeg2/es_parser_adts.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5c605d08fb6286345c0b7bd939b68ea9202c0534 |
| --- /dev/null |
| +++ b/media/mpeg2/es_parser_adts.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright (c) 2013 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_MPEG2_ES_PARSER_ADTS_H_ |
| +#define MEDIA_MPEG2_ES_PARSER_ADTS_H_ |
| + |
| +#include <list> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/time/time.h" |
| +#include "media/mpeg2/es_parser.h" |
| + |
| +namespace media { |
| +class BitReader; |
| +class AudioDecoderConfig; |
| +class StreamParserBuffer; |
| +} |
| + |
| +namespace media { |
| +namespace mpeg2ts { |
| + |
| +class EsParserAdts : public EsParser { |
| + public: |
| + typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; |
| + typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; |
| + |
| + EsParserAdts(NewAudioConfigCB new_audio_config_cb, |
| + EmitBufferCB emit_buffer_cb); |
| + virtual ~EsParserAdts(); |
| + |
| + // EsParser implementation. |
| + virtual void Parse(const uint8* buf, int size, |
| + bool is_pts_valid, base::TimeDelta pts, |
|
acolwell GONE FROM CHROMIUM
2013/08/29 20:44:24
nit: use kNoTimestamp() to signal invalid timestam
damienv1
2013/09/04 01:37:14
Done.
|
| + bool is_dts_valid, base::TimeDelta dts) OVERRIDE; |
| + virtual void Flush() OVERRIDE; |
| + |
| + private: |
| + // Used to link a PTS with a byte position in the ES stream. |
| + typedef std::pair<int, base::TimeDelta> EsPts; |
| + typedef std::list<EsPts> EsPtsList; |
| + |
| + // Signal any audio configuration change (if any). |
| + void UpdateAudioConfiguration(const uint8* adts_header); |
| + |
| + // Discard some bytes from the ES stream. |
| + void DiscardEs(int nbytes); |
| + |
| + // Bytes of the ES stream that have not been emitted yet. |
| + std::vector<uint8> raw_es_; |
| + |
| + // List of PTS associated with a position in the ES stream. |
| + EsPtsList pts_list_; |
| + |
| + // Interpolated PTS for frames that don't have one. |
| + base::TimeDelta estimated_pts_; |
| + |
| + bool first_frame_; |
| + base::TimeDelta last_frame_pts_; |
| + |
| + // Callbacks: |
| + // - to signal a new audio configuration, |
| + // - to send ES buffers. |
| + NewAudioConfigCB new_audio_config_cb_; |
| + EmitBufferCB emit_buffer_cb_; |
| + |
| + // Last audio config. |
| + bool is_audio_config_known_; |
| + int sampling_frequency_; |
| + int channel_configuration_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(EsParserAdts); |
| +}; |
| + |
| +} // namespace mpeg2ts |
| +} // namespace media |
| + |
| +#endif |