OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_WEBM_WEBM_STREAM_PARSER_H_ | 5 #ifndef MEDIA_WEBM_WEBM_STREAM_PARSER_H_ |
6 #define MEDIA_WEBM_WEBM_STREAM_PARSER_H_ | 6 #define MEDIA_WEBM_WEBM_STREAM_PARSER_H_ |
7 | 7 |
8 #include <map> | |
9 | |
10 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
11 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
12 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
13 #include "media/base/buffers.h" | 11 #include "media/base/buffers.h" |
14 #include "media/base/byte_queue.h" | 12 #include "media/base/byte_queue.h" |
15 #include "media/base/stream_parser.h" | 13 #include "media/base/stream_parser.h" |
16 #include "media/base/video_decoder_config.h" | 14 #include "media/base/video_decoder_config.h" |
17 | 15 |
18 namespace media { | 16 namespace media { |
19 | 17 |
20 class WebMClusterParser; | 18 class WebMClusterParser; |
21 | 19 |
22 class WebMStreamParser : public StreamParser { | 20 class WebMStreamParser : public StreamParser { |
23 public: | 21 public: |
24 WebMStreamParser(); | 22 WebMStreamParser(); |
25 virtual ~WebMStreamParser(); | 23 virtual ~WebMStreamParser(); |
26 | 24 |
27 // StreamParser implementation. | 25 // StreamParser implementation. |
28 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, | 26 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, |
29 const NewBuffersCB& new_buffers_cb, | 27 const NewBuffersCB& new_buffers_cb, |
30 const NewTextBuffersCB& text_cb, | 28 const NewTextBuffersCB& text_cb, |
31 const NeedKeyCB& need_key_cb, | 29 const NeedKeyCB& need_key_cb, |
32 const AddTextTrackCB& add_text_track_cb, | |
33 const NewMediaSegmentCB& new_segment_cb, | 30 const NewMediaSegmentCB& new_segment_cb, |
34 const base::Closure& end_of_segment_cb, | 31 const base::Closure& end_of_segment_cb, |
35 const LogCB& log_cb) OVERRIDE; | 32 const LogCB& log_cb) OVERRIDE; |
36 virtual void Flush() OVERRIDE; | 33 virtual void Flush() OVERRIDE; |
37 virtual bool Parse(const uint8* buf, int size) OVERRIDE; | 34 virtual bool Parse(const uint8* buf, int size) OVERRIDE; |
38 | 35 |
39 private: | 36 private: |
40 enum State { | 37 enum State { |
41 kWaitingForInit, | 38 kWaitingForInit, |
42 kParsingHeaders, | 39 kParsingHeaders, |
(...skipping 24 matching lines...) Expand all Loading... |
67 | 64 |
68 // Fire needkey event through the |need_key_cb_|. | 65 // Fire needkey event through the |need_key_cb_|. |
69 void FireNeedKey(const std::string& key_id); | 66 void FireNeedKey(const std::string& key_id); |
70 | 67 |
71 State state_; | 68 State state_; |
72 InitCB init_cb_; | 69 InitCB init_cb_; |
73 NewConfigCB config_cb_; | 70 NewConfigCB config_cb_; |
74 NewBuffersCB new_buffers_cb_; | 71 NewBuffersCB new_buffers_cb_; |
75 NewTextBuffersCB text_cb_; | 72 NewTextBuffersCB text_cb_; |
76 NeedKeyCB need_key_cb_; | 73 NeedKeyCB need_key_cb_; |
77 AddTextTrackCB add_text_track_cb_; | |
78 | |
79 typedef std::map<int, TextTrack* > TextTrackMap; | |
80 TextTrackMap text_track_map_; | |
81 | 74 |
82 NewMediaSegmentCB new_segment_cb_; | 75 NewMediaSegmentCB new_segment_cb_; |
83 base::Closure end_of_segment_cb_; | 76 base::Closure end_of_segment_cb_; |
84 LogCB log_cb_; | 77 LogCB log_cb_; |
85 | 78 |
86 // True if a new cluster id has been seen, but no audio or video buffers have | 79 // True if a new cluster id has been seen, but no audio or video buffers have |
87 // been parsed yet. | 80 // been parsed yet. |
88 bool waiting_for_buffers_; | 81 bool waiting_for_buffers_; |
89 | 82 |
90 scoped_ptr<WebMClusterParser> cluster_parser_; | 83 scoped_ptr<WebMClusterParser> cluster_parser_; |
91 ByteQueue byte_queue_; | 84 ByteQueue byte_queue_; |
92 | 85 |
93 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); | 86 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); |
94 }; | 87 }; |
95 | 88 |
96 } // namespace media | 89 } // namespace media |
97 | 90 |
98 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ | 91 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ |
OLD | NEW |