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 // Size is defined by the WebM encryption specification. | 22 // Size is defined by the WebM encryption specification. |
23 // http://wiki.webmproject.org/encryption/webm-encryption-rfc | 23 // http://wiki.webmproject.org/encryption/webm-encryption-rfc |
24 static const int kIvSize = 8; | 24 static const int kIvSize = 8; |
25 | 25 |
26 WebMClusterParser(int64 timecode_scale, | 26 WebMClusterParser(int64 timecode_scale, |
27 int audio_track_num, | 27 int audio_track_num, |
28 int video_track_num, | 28 int video_track_num, |
29 const uint8* video_encryption_key_id, | 29 const std::string& video_encryption_key_id); |
30 int video_encryption_key_id_size); | |
31 virtual ~WebMClusterParser(); | 30 virtual ~WebMClusterParser(); |
32 | 31 |
33 // Resets the parser state so it can accept a new cluster. | 32 // Resets the parser state so it can accept a new cluster. |
34 void Reset(); | 33 void Reset(); |
35 | 34 |
36 // Parses a WebM cluster element in |buf|. | 35 // Parses a WebM cluster element in |buf|. |
37 // | 36 // |
38 // Returns -1 if the parse fails. | 37 // Returns -1 if the parse fails. |
39 // Returns 0 if more data is needed. | 38 // Returns 0 if more data is needed. |
40 // Returns the number of bytes parsed on success. | 39 // Returns the number of bytes parsed on success. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 virtual bool OnListEnd(int id) OVERRIDE; | 71 virtual bool OnListEnd(int id) OVERRIDE; |
73 virtual bool OnUInt(int id, int64 val) OVERRIDE; | 72 virtual bool OnUInt(int id, int64 val) OVERRIDE; |
74 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; | 73 virtual bool OnBinary(int id, const uint8* data, int size) OVERRIDE; |
75 | 74 |
76 bool ParseBlock(const uint8* buf, int size, int duration); | 75 bool ParseBlock(const uint8* buf, int size, int duration); |
77 bool OnBlock(int track_num, int timecode, int duration, int flags, | 76 bool OnBlock(int track_num, int timecode, int duration, int flags, |
78 const uint8* data, int size); | 77 const uint8* data, int size); |
79 | 78 |
80 double timecode_multiplier_; // Multiplier used to convert timecodes into | 79 double timecode_multiplier_; // Multiplier used to convert timecodes into |
81 // microseconds. | 80 // microseconds. |
82 scoped_array<uint8> video_encryption_key_id_; | 81 std::string video_encryption_key_id_; |
83 int video_encryption_key_id_size_; | |
84 | 82 |
85 WebMListParser parser_; | 83 WebMListParser parser_; |
86 | 84 |
87 int64 last_block_timecode_; | 85 int64 last_block_timecode_; |
88 scoped_array<uint8> block_data_; | 86 scoped_array<uint8> block_data_; |
89 int block_data_size_; | 87 int block_data_size_; |
90 int64 block_duration_; | 88 int64 block_duration_; |
91 | 89 |
92 int64 cluster_timecode_; | 90 int64 cluster_timecode_; |
93 base::TimeDelta cluster_start_time_; | 91 base::TimeDelta cluster_start_time_; |
94 bool cluster_ended_; | 92 bool cluster_ended_; |
95 | 93 |
96 Track audio_; | 94 Track audio_; |
97 Track video_; | 95 Track video_; |
98 | 96 |
99 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMClusterParser); |
100 }; | 98 }; |
101 | 99 |
102 } // namespace media | 100 } // namespace media |
103 | 101 |
104 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ | 102 #endif // MEDIA_WEBM_WEBM_CLUSTER_PARSER_H_ |
OLD | NEW |