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