Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: webkit/media/crypto/ppapi/clear_key_cdm.cc

Issue 11304010: Fix type punning error in (de)serializing audio frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, &timestamp, 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
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
OLDNEW
« no previous file with comments | « no previous file | webkit/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698