| 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_CLUSTER_PARSER_H_ | 5 #ifndef MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 6 #define MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ | 6 #define MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // Resets the parser state so it can accept a new cluster. | 31 // Resets the parser state so it can accept a new cluster. |
| 32 void Reset(); | 32 void Reset(); |
| 33 | 33 |
| 34 // Parses a WebM cluster element in |buf|. | 34 // Parses a WebM cluster element in |buf|. |
| 35 // | 35 // |
| 36 // Returns -1 if the parse fails. | 36 // Returns -1 if the parse fails. |
| 37 // Returns 0 if more data is needed. | 37 // Returns 0 if more data is needed. |
| 38 // Returns the number of bytes parsed on success. | 38 // Returns the number of bytes parsed on success. |
| 39 int Parse(const uint8* buf, int size); | 39 int Parse(const uint8* buf, int size); |
| 40 | 40 |
| 41 const BufferQueue& audio_buffers() const { return audio_buffers_; } | 41 const BufferQueue& audio_buffers() const { return audio_.buffers(); } |
| 42 const BufferQueue& video_buffers() const { return video_buffers_; } | 42 const BufferQueue& video_buffers() const { return video_.buffers(); } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 // Helper class that manages per-track state. |
| 46 class Track { |
| 47 public: |
| 48 Track(int track_num, base::TimeDelta default_duration); |
| 49 ~Track(); |
| 50 |
| 51 int track_num() const { return track_num_; } |
| 52 const BufferQueue& buffers() const { return buffers_; } |
| 53 |
| 54 bool AddBuffer(const scoped_refptr<StreamParserBuffer>& buffer); |
| 55 |
| 56 // Clears all buffer state. |
| 57 void Reset(); |
| 58 |
| 59 // Clears only the |buffers_|. |
| 60 void ClearBufferQueue(); |
| 61 |
| 62 private: |
| 63 int track_num_; |
| 64 base::TimeDelta default_duration_; |
| 65 BufferQueue buffers_; |
| 66 scoped_refptr<StreamParserBuffer> delayed_buffer_; |
| 67 }; |
| 68 |
| 45 // WebMParserClient methods. | 69 // WebMParserClient methods. |
| 46 virtual WebMParserClient* OnListStart(int id) OVERRIDE; | 70 virtual WebMParserClient* OnListStart(int id) OVERRIDE; |
| 47 virtual bool OnListEnd(int id) OVERRIDE; | 71 virtual bool OnListEnd(int id) OVERRIDE; |
| 48 virtual bool OnUInt(int id, int64 val) OVERRIDE; | 72 virtual bool OnUInt(int id, int64 val) OVERRIDE; |
| 49 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; | 73 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; |
| 50 | 74 |
| 51 bool ParseBlock(const uint8* buf, int size, int duration); | 75 bool ParseBlock(const uint8* buf, int size, int duration); |
| 52 bool OnBlock(int track_num, int timecode, int duration, int flags, | 76 bool OnBlock(int track_num, int timecode, int duration, int flags, |
| 53 const uint8* data, int size); | 77 const uint8* data, int size); |
| 54 | 78 |
| 55 double timecode_multiplier_; // Multiplier used to convert timecodes into | 79 double timecode_multiplier_; // Multiplier used to convert timecodes into |
| 56 // microseconds. | 80 // microseconds. |
| 57 int audio_track_num_; | |
| 58 base::TimeDelta audio_default_duration_; | |
| 59 int video_track_num_; | |
| 60 base::TimeDelta video_default_duration_; | |
| 61 scoped_array<uint8> video_encryption_key_id_; | 81 scoped_array<uint8> video_encryption_key_id_; |
| 62 int video_encryption_key_id_size_; | 82 int video_encryption_key_id_size_; |
| 63 | 83 |
| 64 WebMListParser parser_; | 84 WebMListParser parser_; |
| 65 | 85 |
| 66 int64 last_block_timecode_; | 86 int64 last_block_timecode_; |
| 67 scoped_array<uint8> block_data_; | 87 scoped_array<uint8> block_data_; |
| 68 int block_data_size_; | 88 int block_data_size_; |
| 69 int64 block_duration_; | 89 int64 block_duration_; |
| 70 | 90 |
| 71 int64 cluster_timecode_; | 91 int64 cluster_timecode_; |
| 72 BufferQueue audio_buffers_; | 92 |
| 73 BufferQueue video_buffers_; | 93 Track audio_; |
| 94 Track video_; |
| 74 | 95 |
| 75 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 96 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
| 76 }; | 97 }; |
| 77 | 98 |
| 78 } // namespace media | 99 } // namespace media |
| 79 | 100 |
| 80 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ | 101 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
| OLD | NEW |