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 "webkit/media/crypto/ppapi/clear_key_cdm.h" | 5 #include "webkit/media/crypto/ppapi/clear_key_cdm.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 return 0; | 478 return 0; |
479 | 479 |
480 int64 bytes_per_sample = channel_count_ * bits_per_channel_ / 8; | 480 int64 bytes_per_sample = channel_count_ * bits_per_channel_ / 8; |
481 // |frame_size| must be a multiple of |bytes_per_sample|. | 481 // |frame_size| must be a multiple of |bytes_per_sample|. |
482 int64 frame_size = bytes_per_sample * samples_to_generate; | 482 int64 frame_size = bytes_per_sample * samples_to_generate; |
483 | 483 |
484 int64 timestamp = CurrentTimeStampInMicroseconds(); | 484 int64 timestamp = CurrentTimeStampInMicroseconds(); |
485 | 485 |
486 const int kHeaderSize = sizeof(timestamp) + sizeof(frame_size); | 486 const int kHeaderSize = sizeof(timestamp) + sizeof(frame_size); |
487 audio_frames->set_buffer(allocator_->Allocate(kHeaderSize + frame_size)); | 487 audio_frames->set_buffer(allocator_->Allocate(kHeaderSize + frame_size)); |
488 int64* data = reinterpret_cast<int64*>(audio_frames->buffer()->data()); | 488 uint8_t* data = audio_frames->buffer()->data(); |
489 | 489 |
490 *(data++) = timestamp; | 490 memcpy(data, ×tamp, sizeof(timestamp)); |
491 *(data++) = frame_size; | 491 data += sizeof(timestamp); |
| 492 memcpy(data, &frame_size, sizeof(frame_size)); |
| 493 data += sizeof(frame_size); |
492 // You won't hear anything because we have all zeros here. But the video | 494 // You won't hear anything because we have all zeros here. But the video |
493 // should play just fine! | 495 // should play just fine! |
494 memset(data, 0, frame_size); | 496 memset(data, 0, frame_size); |
495 | 497 |
496 return samples_to_generate; | 498 return samples_to_generate; |
497 } | 499 } |
498 | 500 |
499 cdm::Status ClearKeyCdm::GenerateFakeAudioFrames( | 501 cdm::Status ClearKeyCdm::GenerateFakeAudioFrames( |
500 int64 timestamp_in_microseconds, | 502 int64 timestamp_in_microseconds, |
501 cdm::AudioFrames* audio_frames) { | 503 cdm::AudioFrames* audio_frames) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 555 |
554 static unsigned char color = 0; | 556 static unsigned char color = 0; |
555 color += 10; | 557 color += 10; |
556 | 558 |
557 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), | 559 memset(reinterpret_cast<void*>(video_frame->frame_buffer()->data()), |
558 color, frame_size); | 560 color, frame_size); |
559 } | 561 } |
560 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER | 562 #endif // CLEAR_KEY_CDM_USE_FAKE_VIDEO_DECODER |
561 | 563 |
562 } // namespace webkit_media | 564 } // namespace webkit_media |
OLD | NEW |