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 |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
13 #include "media/base/stream_parser_buffer.h" | 13 #include "media/base/stream_parser_buffer.h" |
14 #include "media/webm/webm_parser.h" | 14 #include "media/webm/webm_parser.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { | 18 class MEDIA_EXPORT WebMClusterParser : public WebMParserClient { |
19 public: | 19 public: |
20 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; | 20 typedef std::deque<scoped_refptr<StreamParserBuffer> > BufferQueue; |
21 | 21 |
22 WebMClusterParser(int64 timecode_scale, | 22 WebMClusterParser(int64 timecode_scale, |
23 int audio_track_num, | 23 int audio_track_num, |
24 int video_track_num, | 24 int video_track_num, |
25 const uint8* video_encryption_key_id, | 25 const std::string& video_encryption_key_id); |
26 int video_encryption_key_id_size); | |
27 virtual ~WebMClusterParser(); | 26 virtual ~WebMClusterParser(); |
28 | 27 |
29 // Resets the parser state so it can accept a new cluster. | 28 // Resets the parser state so it can accept a new cluster. |
30 void Reset(); | 29 void Reset(); |
31 | 30 |
32 // Parses a WebM cluster element in |buf|. | 31 // Parses a WebM cluster element in |buf|. |
33 // | 32 // |
34 // Returns -1 if the parse fails. | 33 // Returns -1 if the parse fails. |
35 // Returns 0 if more data is needed. | 34 // Returns 0 if more data is needed. |
36 // Returns the number of bytes parsed on success. | 35 // Returns the number of bytes parsed on success. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 virtual bool OnListEnd(int id) OVERRIDE; | 67 virtual bool OnListEnd(int id) OVERRIDE; |
69 virtual bool OnUInt(int id, int64 val) OVERRIDE; | 68 virtual bool OnUInt(int id, int64 val) OVERRIDE; |
70 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; | 69 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; |
71 | 70 |
72 bool ParseBlock(const uint8* buf, int size, int duration); | 71 bool ParseBlock(const uint8* buf, int size, int duration); |
73 bool OnBlock(int track_num, int timecode, int duration, int flags, | 72 bool OnBlock(int track_num, int timecode, int duration, int flags, |
74 const uint8* data, int size); | 73 const uint8* data, int size); |
75 | 74 |
76 double timecode_multiplier_; // Multiplier used to convert timecodes into | 75 double timecode_multiplier_; // Multiplier used to convert timecodes into |
77 // microseconds. | 76 // microseconds. |
78 scoped_array<uint8> video_encryption_key_id_; | 77 std::string video_encryption_key_id_; |
79 int video_encryption_key_id_size_; | |
80 | 78 |
81 WebMListParser parser_; | 79 WebMListParser parser_; |
82 | 80 |
83 int64 last_block_timecode_; | 81 int64 last_block_timecode_; |
84 scoped_array<uint8> block_data_; | 82 scoped_array<uint8> block_data_; |
85 int block_data_size_; | 83 int block_data_size_; |
86 int64 block_duration_; | 84 int64 block_duration_; |
87 | 85 |
88 int64 cluster_timecode_; | 86 int64 cluster_timecode_; |
89 base::TimeDelta cluster_start_time_; | 87 base::TimeDelta cluster_start_time_; |
90 bool cluster_ended_; | 88 bool cluster_ended_; |
91 | 89 |
92 Track audio_; | 90 Track audio_; |
93 Track video_; | 91 Track video_; |
94 | 92 |
95 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 93 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
96 }; | 94 }; |
97 | 95 |
98 } // namespace media | 96 } // namespace media |
99 | 97 |
100 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ | 98 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
OLD | NEW |