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..a8b7654672ba5685be81c678890444f5732c3c78 |
| --- /dev/null |
| +++ b/media/mpeg2/es_parser_adts.h |
| @@ -0,0 +1,85 @@ |
| +// 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 <utility> |
| +#include <vector> |
|
damienv1
2013/09/10 04:57:01
<vector> not needed anymore.
damienv1
2013/09/10 21:03:48
Done.
|
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| +#include "media/base/audio_decoder_config.h" |
| +#include "media/base/byte_queue.h" |
| +#include "media/mpeg2/es_parser.h" |
| + |
| +namespace media { |
| +class AudioDecoderConfig; |
| +class AudioTimestampHelper; |
| +class BitReader; |
| +class StreamParserBuffer; |
| +} |
| + |
| +namespace media { |
| +namespace mpeg2ts { |
| + |
| +class EsParserAdts : public EsParser { |
| + public: |
| + typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; |
| + |
| + EsParserAdts(NewAudioConfigCB new_audio_config_cb, |
| + EmitBufferCB emit_buffer_cb); |
| + virtual ~EsParserAdts(); |
| + |
| + // EsParser implementation. |
| + virtual bool Parse(const uint8* buf, int size, |
| + base::TimeDelta pts, |
| + base::TimeDelta dts) OVERRIDE; |
| + virtual void Flush() OVERRIDE; |
| + virtual void Reset() 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). |
| + // Return false if the current audio config is not |
| + // a supported ADTS audio config. |
| + bool UpdateAudioConfiguration(const uint8* adts_header); |
| + |
| + // Discard some bytes from the ES stream. |
| + void DiscardEs(int nbytes); |
| + |
| + // Callbacks: |
| + // - to signal a new audio configuration, |
| + // - to send ES buffers. |
| + NewAudioConfigCB new_audio_config_cb_; |
| + EmitBufferCB emit_buffer_cb_; |
| + |
| + // 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_; |
| + |
| + // Last audio config. |
| + AudioDecoderConfig last_audio_decoder_config_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(EsParserAdts); |
| +}; |
| + |
| +} // namespace mpeg2ts |
| +} // namespace media |
| + |
| +#endif |
| + |