| 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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "media/base/audio_decoder_config.h" | 10 #include "media/base/audio_decoder_config.h" |
| 11 #include "media/base/buffers.h" | 11 #include "media/base/buffers.h" |
| 12 #include "media/base/byte_queue.h" | 12 #include "media/base/byte_queue.h" |
| 13 #include "media/base/stream_parser.h" | 13 #include "media/base/stream_parser.h" |
| 14 #include "media/base/video_decoder_config.h" | 14 #include "media/base/video_decoder_config.h" |
| 15 #include "media/webm/webm_cluster_parser.h" | 15 #include "media/webm/webm_cluster_parser.h" |
| 16 | 16 |
| 17 namespace media { | 17 namespace media { |
| 18 | 18 |
| 19 class WebMStreamParser : public StreamParser { | 19 class WebMStreamParser : public StreamParser { |
| 20 public: | 20 public: |
| 21 WebMStreamParser(); | 21 WebMStreamParser(); |
| 22 virtual ~WebMStreamParser(); | 22 virtual ~WebMStreamParser(); |
| 23 | 23 |
| 24 // StreamParser implementation. | 24 // StreamParser implementation. |
| 25 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, | 25 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, |
| 26 const NewBuffersCB& audio_cb, | 26 const NewBuffersCB& audio_cb, |
| 27 const NewBuffersCB& video_cb, | 27 const NewBuffersCB& video_cb, |
| 28 const KeyNeededCB& key_needed_cb) OVERRIDE; | 28 const NeedKeyCB& need_key_cb) OVERRIDE; |
| 29 virtual void Flush() OVERRIDE; | 29 virtual void Flush() OVERRIDE; |
| 30 virtual bool Parse(const uint8* buf, int size) OVERRIDE; | 30 virtual bool Parse(const uint8* buf, int size) OVERRIDE; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 enum State { | 33 enum State { |
| 34 kWaitingForInit, | 34 kWaitingForInit, |
| 35 kParsingHeaders, | 35 kParsingHeaders, |
| 36 kParsingClusters, | 36 kParsingClusters, |
| 37 kError | 37 kError |
| 38 }; | 38 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 56 // Returns < 0 if the parse fails. | 56 // Returns < 0 if the parse fails. |
| 57 // Returns 0 if more data is needed. | 57 // Returns 0 if more data is needed. |
| 58 // Returning > 0 indicates success & the number of bytes parsed. | 58 // Returning > 0 indicates success & the number of bytes parsed. |
| 59 int ParseCluster(const uint8* data, int size); | 59 int ParseCluster(const uint8* data, int size); |
| 60 | 60 |
| 61 State state_; | 61 State state_; |
| 62 InitCB init_cb_; | 62 InitCB init_cb_; |
| 63 NewConfigCB config_cb_; | 63 NewConfigCB config_cb_; |
| 64 NewBuffersCB audio_cb_; | 64 NewBuffersCB audio_cb_; |
| 65 NewBuffersCB video_cb_; | 65 NewBuffersCB video_cb_; |
| 66 KeyNeededCB key_needed_cb_; | 66 NeedKeyCB need_key_cb_; |
| 67 | 67 |
| 68 scoped_ptr<WebMClusterParser> cluster_parser_; | 68 scoped_ptr<WebMClusterParser> cluster_parser_; |
| 69 ByteQueue byte_queue_; | 69 ByteQueue byte_queue_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); | 71 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace media | 74 } // namespace media |
| 75 | 75 |
| 76 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ | 76 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ |
| OLD | NEW |