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 #include "media/webm/webm_tracks_parser.h" | 5 #include "media/webm/webm_tracks_parser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/webm/webm_constants.h" | 10 #include "media/webm/webm_constants.h" |
11 #include "media/webm/webm_content_encodings.h" | 11 #include "media/webm/webm_content_encodings.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // Values for TrackType element. | 15 // Values for TrackType element. |
16 static const int kWebMTrackTypeVideo = 1; | 16 static const int kWebMTrackTypeVideo = 1; |
17 static const int kWebMTrackTypeAudio = 2; | 17 static const int kWebMTrackTypeAudio = 2; |
18 | 18 |
19 WebMTracksParser::WebMTracksParser() | 19 WebMTracksParser::WebMTracksParser() |
20 : track_type_(-1), | 20 : track_type_(-1), |
21 track_num_(-1), | 21 track_num_(-1), |
22 audio_track_num_(-1), | 22 audio_track_num_(-1), |
23 video_track_num_(-1) { | 23 video_track_num_(-1) { |
24 } | 24 } |
25 | 25 |
26 WebMTracksParser::~WebMTracksParser() {} | 26 WebMTracksParser::~WebMTracksParser() {} |
27 | 27 |
28 const uint8* WebMTracksParser::video_encryption_key_id() const { | 28 const std::string& WebMTracksParser::video_encryption_key_id() const { |
29 if (!video_content_encodings_client_.get()) | 29 if (!video_content_encodings_client_.get()) |
30 return NULL; | 30 return EmptyString(); |
31 | 31 |
32 DCHECK(!video_content_encodings_client_->content_encodings().empty()); | 32 DCHECK(!video_content_encodings_client_->content_encodings().empty()); |
33 return video_content_encodings_client_->content_encodings()[0]-> | 33 return video_content_encodings_client_->content_encodings()[0]-> |
34 encryption_key_id(); | 34 encryption_key_id(); |
35 } | 35 } |
36 | 36 |
37 int WebMTracksParser::video_encryption_key_id_size() const { | |
38 if (!video_content_encodings_client_.get()) | |
39 return 0; | |
40 | |
41 DCHECK(!video_content_encodings_client_->content_encodings().empty()); | |
42 return video_content_encodings_client_->content_encodings()[0]-> | |
43 encryption_key_id_size(); | |
44 } | |
45 | |
46 int WebMTracksParser::Parse(const uint8* buf, int size) { | 37 int WebMTracksParser::Parse(const uint8* buf, int size) { |
47 track_type_ =-1; | 38 track_type_ =-1; |
48 track_num_ = -1; | 39 track_num_ = -1; |
49 audio_track_num_ = -1; | 40 audio_track_num_ = -1; |
50 video_track_num_ = -1; | 41 video_track_num_ = -1; |
51 | 42 |
52 WebMListParser parser(kWebMIdTracks, this); | 43 WebMListParser parser(kWebMIdTracks, this); |
53 int result = parser.Parse(buf, size); | 44 int result = parser.Parse(buf, size); |
54 | 45 |
55 if (result <= 0) | 46 if (result <= 0) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 bool WebMTracksParser::OnString(int id, const std::string& str) { | 141 bool WebMTracksParser::OnString(int id, const std::string& str) { |
151 if (id == kWebMIdCodecID && str != "A_VORBIS" && str != "V_VP8") { | 142 if (id == kWebMIdCodecID && str != "A_VORBIS" && str != "V_VP8") { |
152 DVLOG(1) << "Unexpected CodecID " << str; | 143 DVLOG(1) << "Unexpected CodecID " << str; |
153 return false; | 144 return false; |
154 } | 145 } |
155 | 146 |
156 return true; | 147 return true; |
157 } | 148 } |
158 | 149 |
159 } // namespace media | 150 } // namespace media |
OLD | NEW |