OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/webm/webm_tracks_parser.h" | 5 #include "media/formats/webm/webm_tracks_parser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "media/base/timestamp_constants.h" | 10 #include "media/base/timestamp_constants.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 185 |
186 std::string encryption_key_id; | 186 std::string encryption_key_id; |
187 if (track_content_encodings_client_) { | 187 if (track_content_encodings_client_) { |
188 DCHECK(!track_content_encodings_client_->content_encodings().empty()); | 188 DCHECK(!track_content_encodings_client_->content_encodings().empty()); |
189 // If we have multiple ContentEncoding in one track. Always choose the | 189 // If we have multiple ContentEncoding in one track. Always choose the |
190 // key id in the first ContentEncoding as the key id of the track. | 190 // key id in the first ContentEncoding as the key id of the track. |
191 encryption_key_id = track_content_encodings_client_-> | 191 encryption_key_id = track_content_encodings_client_-> |
192 content_encodings()[0]->encryption_key_id(); | 192 content_encodings()[0]->encryption_key_id(); |
193 } | 193 } |
194 | 194 |
| 195 EncryptionScheme encryption_scheme( |
| 196 encryption_key_id.empty() ? EncryptionScheme::kCipherModeUnencrypted |
| 197 : EncryptionScheme::kCipherModeAesCtr); |
| 198 |
195 if (track_type_ == kWebMTrackTypeAudio) { | 199 if (track_type_ == kWebMTrackTypeAudio) { |
196 if (audio_track_num_ == -1) { | 200 if (audio_track_num_ == -1) { |
197 audio_track_num_ = track_num_; | 201 audio_track_num_ = track_num_; |
198 audio_encryption_key_id_ = encryption_key_id; | 202 audio_encryption_key_id_ = encryption_key_id; |
199 | 203 |
200 if (default_duration_ == 0) { | 204 if (default_duration_ == 0) { |
201 MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns audio TrackEntry " | 205 MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns audio TrackEntry " |
202 "DefaultDuration"; | 206 "DefaultDuration"; |
203 return false; | 207 return false; |
204 } | 208 } |
205 audio_default_duration_ = default_duration_; | 209 audio_default_duration_ = default_duration_; |
206 | 210 |
207 DCHECK(!audio_decoder_config_.IsValidConfig()); | 211 DCHECK(!audio_decoder_config_.IsValidConfig()); |
208 if (!audio_client_.InitializeConfig( | 212 if (!audio_client_.InitializeConfig( |
209 codec_id_, codec_private_, seek_preroll_, codec_delay_, | 213 codec_id_, codec_private_, seek_preroll_, codec_delay_, |
210 !audio_encryption_key_id_.empty(), &audio_decoder_config_)) { | 214 encryption_scheme, &audio_decoder_config_)) { |
211 return false; | 215 return false; |
212 } | 216 } |
213 } else { | 217 } else { |
214 MEDIA_LOG(DEBUG, media_log_) << "Ignoring audio track " << track_num_; | 218 MEDIA_LOG(DEBUG, media_log_) << "Ignoring audio track " << track_num_; |
215 ignored_tracks_.insert(track_num_); | 219 ignored_tracks_.insert(track_num_); |
216 } | 220 } |
217 } else if (track_type_ == kWebMTrackTypeVideo) { | 221 } else if (track_type_ == kWebMTrackTypeVideo) { |
218 if (video_track_num_ == -1) { | 222 if (video_track_num_ == -1) { |
219 video_track_num_ = track_num_; | 223 video_track_num_ = track_num_; |
220 video_encryption_key_id_ = encryption_key_id; | 224 video_encryption_key_id_ = encryption_key_id; |
221 | 225 |
222 if (default_duration_ == 0) { | 226 if (default_duration_ == 0) { |
223 MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns video TrackEntry " | 227 MEDIA_LOG(ERROR, media_log_) << "Illegal 0ns video TrackEntry " |
224 "DefaultDuration"; | 228 "DefaultDuration"; |
225 return false; | 229 return false; |
226 } | 230 } |
227 video_default_duration_ = default_duration_; | 231 video_default_duration_ = default_duration_; |
228 | 232 |
229 DCHECK(!video_decoder_config_.IsValidConfig()); | 233 DCHECK(!video_decoder_config_.IsValidConfig()); |
230 if (!video_client_.InitializeConfig( | 234 if (!video_client_.InitializeConfig(codec_id_, codec_private_, |
231 codec_id_, codec_private_, !video_encryption_key_id_.empty(), | 235 encryption_scheme, |
232 &video_decoder_config_)) { | 236 &video_decoder_config_)) { |
233 return false; | 237 return false; |
234 } | 238 } |
235 } else { | 239 } else { |
236 MEDIA_LOG(DEBUG, media_log_) << "Ignoring video track " << track_num_; | 240 MEDIA_LOG(DEBUG, media_log_) << "Ignoring video track " << track_num_; |
237 ignored_tracks_.insert(track_num_); | 241 ignored_tracks_.insert(track_num_); |
238 } | 242 } |
239 } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions || | 243 } else if (track_type_ == kWebMTrackTypeSubtitlesOrCaptions || |
240 track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { | 244 track_type_ == kWebMTrackTypeDescriptionsOrMetadata) { |
241 if (ignore_text_tracks_) { | 245 if (ignore_text_tracks_) { |
242 MEDIA_LOG(DEBUG, media_log_) << "Ignoring text track " << track_num_; | 246 MEDIA_LOG(DEBUG, media_log_) << "Ignoring text track " << track_num_; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 | 340 |
337 if (id == kWebMIdLanguage) { | 341 if (id == kWebMIdLanguage) { |
338 track_language_ = str; | 342 track_language_ = str; |
339 return true; | 343 return true; |
340 } | 344 } |
341 | 345 |
342 return true; | 346 return true; |
343 } | 347 } |
344 | 348 |
345 } // namespace media | 349 } // namespace media |
OLD | NEW |