OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 6 #define MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 7 |
| 8 #include <deque> |
| 9 |
| 10 #include "base/scoped_ptr.h" |
| 11 #include "media/base/buffers.h" |
| 12 #include "media/webm/webm_parser.h" |
| 13 |
| 14 namespace media { |
| 15 |
| 16 class WebMClusterParser : public WebMParserClient { |
| 17 public: |
| 18 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; |
| 19 |
| 20 WebMClusterParser(int64 timecode_scale, |
| 21 int audio_track_num, |
| 22 base::TimeDelta audio_default_duration, |
| 23 int video_track_num, |
| 24 base::TimeDelta video_default_duration); |
| 25 virtual ~WebMClusterParser(); |
| 26 |
| 27 // Parses a WebM cluster element in |buf|. |
| 28 // |
| 29 // Returns the number of bytes parsed on success. Returns -1 |
| 30 // if a parse error occurs. |
| 31 int Parse(const uint8* buf, int size); |
| 32 |
| 33 const BufferQueue& audio_buffers() const { return audio_buffers_; } |
| 34 const BufferQueue& video_buffers() const { return video_buffers_; } |
| 35 |
| 36 private: |
| 37 // WebMParserClient methods. |
| 38 virtual bool OnListStart(int id); |
| 39 virtual bool OnListEnd(int id); |
| 40 virtual bool OnUInt(int id, int64 val); |
| 41 virtual bool OnFloat(int id, double val); |
| 42 virtual bool OnBinary(int id, const uint8* data, int size); |
| 43 virtual bool OnString(int id, const std::string& str); |
| 44 virtual bool OnSimpleBlock(int track_num, int timecode, int flags, |
| 45 const uint8* data, int size); |
| 46 |
| 47 double timecode_multiplier_; // Multiplier used to convert timecodes into |
| 48 // microseconds. |
| 49 int audio_track_num_; |
| 50 base::TimeDelta audio_default_duration_; |
| 51 int video_track_num_; |
| 52 base::TimeDelta video_default_duration_; |
| 53 |
| 54 int64 last_block_timecode_; |
| 55 |
| 56 int64 cluster_timecode_; |
| 57 BufferQueue audio_buffers_; |
| 58 BufferQueue video_buffers_; |
| 59 |
| 60 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
| 61 }; |
| 62 |
| 63 } // namespace media |
| 64 |
| 65 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
OLD | NEW |