OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MEDIA_MPEG2_ES_PARSER_ADTS_H_ |
| 6 #define MEDIA_MPEG2_ES_PARSER_ADTS_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <utility> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/time/time.h" |
| 17 #include "media/base/byte_queue.h" |
| 18 #include "media/mpeg2/es_parser.h" |
| 19 |
| 20 namespace media { |
| 21 class BitReader; |
| 22 class AudioDecoderConfig; |
| 23 class StreamParserBuffer; |
| 24 } |
| 25 |
| 26 namespace media { |
| 27 namespace mpeg2ts { |
| 28 |
| 29 class EsParserAdts : public EsParser { |
| 30 public: |
| 31 typedef base::Callback<void(const AudioDecoderConfig&)> NewAudioConfigCB; |
| 32 typedef base::Callback<void(scoped_refptr<StreamParserBuffer>)> EmitBufferCB; |
| 33 |
| 34 EsParserAdts(NewAudioConfigCB new_audio_config_cb, |
| 35 EmitBufferCB emit_buffer_cb); |
| 36 virtual ~EsParserAdts(); |
| 37 |
| 38 // EsParser implementation. |
| 39 virtual void Parse(const uint8* buf, int size, |
| 40 base::TimeDelta pts, |
| 41 base::TimeDelta dts) OVERRIDE; |
| 42 virtual void Flush() OVERRIDE; |
| 43 |
| 44 private: |
| 45 // Used to link a PTS with a byte position in the ES stream. |
| 46 typedef std::pair<int, base::TimeDelta> EsPts; |
| 47 typedef std::list<EsPts> EsPtsList; |
| 48 |
| 49 // Signal any audio configuration change (if any). |
| 50 void UpdateAudioConfiguration(const uint8* adts_header); |
| 51 |
| 52 // Discard some bytes from the ES stream. |
| 53 void DiscardEs(int nbytes); |
| 54 |
| 55 // Callbacks: |
| 56 // - to signal a new audio configuration, |
| 57 // - to send ES buffers. |
| 58 NewAudioConfigCB new_audio_config_cb_; |
| 59 EmitBufferCB emit_buffer_cb_; |
| 60 |
| 61 // Bytes of the ES stream that have not been emitted yet. |
| 62 ByteQueue es_byte_queue_; |
| 63 |
| 64 // List of PTS associated with a position in the ES stream. |
| 65 EsPtsList pts_list_; |
| 66 |
| 67 // Interpolated PTS for frames that don't have one. |
| 68 base::TimeDelta estimated_pts_; |
| 69 |
| 70 bool first_frame_; |
| 71 base::TimeDelta last_frame_pts_; |
| 72 |
| 73 // Last audio config. |
| 74 bool is_audio_config_known_; |
| 75 int sampling_frequency_; |
| 76 int channel_configuration_; |
| 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(EsParserAdts); |
| 79 }; |
| 80 |
| 81 } // namespace mpeg2ts |
| 82 } // namespace media |
| 83 |
| 84 #endif |
| 85 |
OLD | NEW |