Chromium Code Reviews| 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 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 class WebMClusterParser; | 18 class WebMClusterParser; |
| 19 | 19 |
| 20 class WebMStreamParser : public StreamParser { | 20 class WebMStreamParser : public StreamParser { |
| 21 public: | 21 public: |
| 22 WebMStreamParser(); | 22 WebMStreamParser(); |
| 23 virtual ~WebMStreamParser(); | 23 virtual ~WebMStreamParser(); |
| 24 | 24 |
| 25 // StreamParser implementation. | 25 // StreamParser implementation. |
| 26 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, | 26 virtual void Init(const InitCB& init_cb, const NewConfigCB& config_cb, |
| 27 const NewBuffersCB& audio_cb, | 27 const NewBuffersCB& audio_cb, |
| 28 const NewBuffersCB& video_cb, | 28 const NewBuffersCB& video_cb, |
| 29 const NeedKeyCB& need_key_cb, | 29 const NeedKeyCB& need_key_cb, |
| 30 const AddTextTrackCB& add_text_track_cb, | |
| 31 //const NewBuffersCB& text_cb, | |
| 30 const NewMediaSegmentCB& new_segment_cb, | 32 const NewMediaSegmentCB& new_segment_cb, |
| 31 const base::Closure& end_of_segment_cb, | 33 const base::Closure& end_of_segment_cb, |
| 32 const LogCB& log_cb) OVERRIDE; | 34 const LogCB& log_cb) OVERRIDE; |
| 33 virtual void Flush() OVERRIDE; | 35 virtual void Flush() OVERRIDE; |
| 34 virtual bool Parse(const uint8* buf, int size) OVERRIDE; | 36 virtual bool Parse(const uint8* buf, int size) OVERRIDE; |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 enum State { | 39 enum State { |
| 38 kWaitingForInit, | 40 kWaitingForInit, |
| 39 kParsingHeaders, | 41 kParsingHeaders, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 58 // data in these elements. | 60 // data in these elements. |
| 59 // | 61 // |
| 60 // Returns < 0 if the parse fails. | 62 // Returns < 0 if the parse fails. |
| 61 // Returns 0 if more data is needed. | 63 // Returns 0 if more data is needed. |
| 62 // Returning > 0 indicates success & the number of bytes parsed. | 64 // Returning > 0 indicates success & the number of bytes parsed. |
| 63 int ParseCluster(const uint8* data, int size); | 65 int ParseCluster(const uint8* data, int size); |
| 64 | 66 |
| 65 // Fire needkey event through the |need_key_cb_|. | 67 // Fire needkey event through the |need_key_cb_|. |
| 66 void FireNeedKey(const std::string& key_id); | 68 void FireNeedKey(const std::string& key_id); |
| 67 | 69 |
| 70 // To push text track cues up the media stack. | |
| 71 void OnTextBuffers(const StreamParser::BufferQueue& buffers, | |
| 72 TextTrack* text_cb); | |
| 73 void OnTextBuffer(const StreamParserBuffer* buffer, | |
| 74 TextTrack* text_cb); | |
| 75 | |
| 68 State state_; | 76 State state_; |
| 69 InitCB init_cb_; | 77 InitCB init_cb_; |
| 70 NewConfigCB config_cb_; | 78 NewConfigCB config_cb_; |
| 71 NewBuffersCB audio_cb_; | 79 NewBuffersCB audio_cb_; |
| 72 NewBuffersCB video_cb_; | 80 NewBuffersCB video_cb_; |
| 73 NeedKeyCB need_key_cb_; | 81 NeedKeyCB need_key_cb_; |
| 82 AddTextTrackCB add_text_track_cb_; | |
| 83 | |
| 84 // TODO(matthewjheaney): my interpretation of Aaron's comments | |
| 85 // We also need a ruling about element type: scoped_refptr? etc | |
|
acolwell GONE FROM CHROMIUM
2013/05/10 02:22:08
No need for scoped_refptr. You just need to make s
Matthew Heaney (Chromium)
2013/05/10 05:21:08
Done.
| |
| 86 typedef std::map<int, TextTrack* > TextTrackMap; | |
| 87 TextTrackMap text_track_map_; | |
| 88 | |
| 74 NewMediaSegmentCB new_segment_cb_; | 89 NewMediaSegmentCB new_segment_cb_; |
| 75 base::Closure end_of_segment_cb_; | 90 base::Closure end_of_segment_cb_; |
| 76 LogCB log_cb_; | 91 LogCB log_cb_; |
| 77 | 92 |
| 78 // True if a new cluster id has been seen, but no audio or video buffers have | 93 // True if a new cluster id has been seen, but no audio or video buffers have |
| 79 // been parsed yet. | 94 // been parsed yet. |
| 80 bool waiting_for_buffers_; | 95 bool waiting_for_buffers_; |
| 81 | 96 |
| 82 scoped_ptr<WebMClusterParser> cluster_parser_; | 97 scoped_ptr<WebMClusterParser> cluster_parser_; |
| 83 ByteQueue byte_queue_; | 98 ByteQueue byte_queue_; |
| 84 | 99 |
| 85 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); | 100 DISALLOW_COPY_AND_ASSIGN(WebMStreamParser); |
| 86 }; | 101 }; |
| 87 | 102 |
| 88 } // namespace media | 103 } // namespace media |
| 89 | 104 |
| 90 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ | 105 #endif // MEDIA_WEBM_WEBM_STREAM_PARSER_H_ |
| OLD | NEW |