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