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_cluster_parser.h" | 5 #include "media/webm/webm_cluster_parser.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 | 338 |
339 // The first bit of the flags is set when a SimpleBlock contains only | 339 // The first bit of the flags is set when a SimpleBlock contains only |
340 // keyframes. If this is a Block, then inspection of the payload is | 340 // keyframes. If this is a Block, then inspection of the payload is |
341 // necessary to determine whether it contains a keyframe or not. | 341 // necessary to determine whether it contains a keyframe or not. |
342 // http://www.matroska.org/technical/specs/index.html | 342 // http://www.matroska.org/technical/specs/index.html |
343 bool is_keyframe = | 343 bool is_keyframe = |
344 is_simple_block ? (flags & 0x80) != 0 : track->IsKeyframe(data, size); | 344 is_simple_block ? (flags & 0x80) != 0 : track->IsKeyframe(data, size); |
345 | 345 |
346 scoped_refptr<StreamParserBuffer> buffer; | 346 scoped_refptr<StreamParserBuffer> buffer; |
347 if (!is_text) { | 347 if (!is_text) { |
348 buffer = StreamParserBuffer::CopyFrom(data, size, | 348 // Every encrypted Block has a signal byte and IV prepended to it. Current |
349 additional, additional_size, | 349 // encrypted WebM request for comments specification is here |
350 is_keyframe); | 350 // http://wiki.webmproject.org/encryption/webm-encryption-rfc |
351 scoped_ptr<DecryptConfig> decrypt_config; | |
352 int data_offset = 0; | |
353 if (!encryption_key_id.empty() && | |
354 !WebMCreateDecryptConfig( | |
355 data, size, | |
356 reinterpret_cast<const uint8*>(encryption_key_id.data()), | |
357 encryption_key_id.size(), | |
358 &decrypt_config, &data_offset)) { | |
359 return false; | |
360 } | |
361 | |
362 buffer = StreamParserBuffer::CopyFrom( | |
363 data + data_offset, size - data_offset, | |
364 additional, additional_size, | |
365 is_keyframe); | |
366 | |
367 if (decrypt_config) | |
368 buffer->set_decrypt_config(decrypt_config.Pass()); | |
351 } else { | 369 } else { |
DaleCurtis
2014/01/02 19:31:09
Does this not need a DecryptConfig? Presumably we
xhwang
2014/01/08 00:43:36
As you can see from l.314-l.319, encryption_key_id
| |
352 std::string id, settings, content; | 370 std::string id, settings, content; |
353 WebMWebVTTParser::Parse(data, size, | 371 WebMWebVTTParser::Parse(data, size, &id, &settings, &content); |
354 &id, &settings, &content); | |
355 | 372 |
356 std::vector<uint8> side_data; | 373 std::vector<uint8> side_data; |
357 MakeSideData(id.begin(), id.end(), | 374 MakeSideData(id.begin(), id.end(), |
358 settings.begin(), settings.end(), | 375 settings.begin(), settings.end(), |
359 &side_data); | 376 &side_data); |
360 | 377 |
361 buffer = StreamParserBuffer::CopyFrom( | 378 buffer = StreamParserBuffer::CopyFrom( |
362 reinterpret_cast<const uint8*>(content.data()), | 379 reinterpret_cast<const uint8*>(content.data()), |
363 content.length(), | 380 content.length(), |
364 &side_data[0], | 381 &side_data[0], |
365 side_data.size(), | 382 side_data.size(), |
366 is_keyframe); | 383 is_keyframe); |
367 } | 384 } |
368 | 385 |
369 // Every encrypted Block has a signal byte and IV prepended to it. Current | |
370 // encrypted WebM request for comments specification is here | |
371 // http://wiki.webmproject.org/encryption/webm-encryption-rfc | |
372 if (!encryption_key_id.empty()) { | |
373 scoped_ptr<DecryptConfig> config(WebMCreateDecryptConfig( | |
374 data, size, | |
375 reinterpret_cast<const uint8*>(encryption_key_id.data()), | |
376 encryption_key_id.size())); | |
377 if (!config) | |
378 return false; | |
379 buffer->set_decrypt_config(config.Pass()); | |
380 } | |
381 | |
382 buffer->set_timestamp(timestamp); | 386 buffer->set_timestamp(timestamp); |
383 if (cluster_start_time_ == kNoTimestamp()) | 387 if (cluster_start_time_ == kNoTimestamp()) |
384 cluster_start_time_ = timestamp; | 388 cluster_start_time_ = timestamp; |
385 | 389 |
386 if (block_duration >= 0) { | 390 if (block_duration >= 0) { |
387 buffer->set_duration(base::TimeDelta::FromMicroseconds( | 391 buffer->set_duration(base::TimeDelta::FromMicroseconds( |
388 block_duration * timecode_multiplier_)); | 392 block_duration * timecode_multiplier_)); |
389 } | 393 } |
390 | 394 |
391 if (discard_padding != 0) { | 395 if (discard_padding != 0) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
454 WebMClusterParser::FindTextTrack(int track_num) { | 458 WebMClusterParser::FindTextTrack(int track_num) { |
455 const TextTrackMap::iterator it = text_track_map_.find(track_num); | 459 const TextTrackMap::iterator it = text_track_map_.find(track_num); |
456 | 460 |
457 if (it == text_track_map_.end()) | 461 if (it == text_track_map_.end()) |
458 return NULL; | 462 return NULL; |
459 | 463 |
460 return &it->second; | 464 return &it->second; |
461 } | 465 } |
462 | 466 |
463 } // namespace media | 467 } // namespace media |
OLD | NEW |