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