| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.h" | 5 #include "webkit/renderer/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 frames_to_interleave *= codec_context_->channels; | 330 frames_to_interleave *= codec_context_->channels; |
| 331 } | 331 } |
| 332 | 332 |
| 333 converter_bus_->set_frames(total_frames); | 333 converter_bus_->set_frames(total_frames); |
| 334 for (int i = 0; i < converter_bus_->channels(); ++i) { | 334 for (int i = 0; i < converter_bus_->channels(); ++i) { |
| 335 converter_bus_->SetChannelData(i, reinterpret_cast<float*>( | 335 converter_bus_->SetChannelData(i, reinterpret_cast<float*>( |
| 336 av_frame_->extended_data[i])); | 336 av_frame_->extended_data[i])); |
| 337 } | 337 } |
| 338 | 338 |
| 339 output = new media::DataBuffer(decoded_audio_size); | 339 output = new media::DataBuffer(decoded_audio_size); |
| 340 output->SetDataSize(decoded_audio_size); | 340 output->set_data_size(decoded_audio_size); |
| 341 | 341 |
| 342 DCHECK_EQ(frames_to_interleave, converter_bus_->frames() - skip_frames); | 342 DCHECK_EQ(frames_to_interleave, converter_bus_->frames() - skip_frames); |
| 343 converter_bus_->ToInterleavedPartial( | 343 converter_bus_->ToInterleavedPartial( |
| 344 skip_frames, frames_to_interleave, bits_per_channel_ / 8, | 344 skip_frames, frames_to_interleave, bits_per_channel_ / 8, |
| 345 output->GetWritableData()); | 345 output->writable_data()); |
| 346 } else { | 346 } else { |
| 347 output = media::DataBuffer::CopyFrom( | 347 output = media::DataBuffer::CopyFrom( |
| 348 av_frame_->extended_data[0] + start_sample * bytes_per_frame_, | 348 av_frame_->extended_data[0] + start_sample * bytes_per_frame_, |
| 349 decoded_audio_size); | 349 decoded_audio_size); |
| 350 } | 350 } |
| 351 | 351 |
| 352 base::TimeDelta output_timestamp = | 352 base::TimeDelta output_timestamp = |
| 353 output_timestamp_helper_->GetTimestamp(); | 353 output_timestamp_helper_->GetTimestamp(); |
| 354 output_timestamp_helper_->AddBytes(decoded_audio_size); | 354 output_timestamp_helper_->AddBytes(decoded_audio_size); |
| 355 | 355 |
| 356 // Serialize the audio samples into |serialized_audio_frames_|. | 356 // Serialize the audio samples into |serialized_audio_frames_|. |
| 357 SerializeInt64(output_timestamp.InMicroseconds()); | 357 SerializeInt64(output_timestamp.InMicroseconds()); |
| 358 SerializeInt64(output->GetDataSize()); | 358 SerializeInt64(output->data_size()); |
| 359 serialized_audio_frames_.insert( | 359 serialized_audio_frames_.insert( |
| 360 serialized_audio_frames_.end(), | 360 serialized_audio_frames_.end(), |
| 361 output->GetData(), | 361 output->data(), |
| 362 output->GetData() + output->GetDataSize()); | 362 output->data() + output->data_size()); |
| 363 } | 363 } |
| 364 } while (packet.size > 0); | 364 } while (packet.size > 0); |
| 365 | 365 |
| 366 if (!serialized_audio_frames_.empty()) { | 366 if (!serialized_audio_frames_.empty()) { |
| 367 decoded_frames->SetFrameBuffer( | 367 decoded_frames->SetFrameBuffer( |
| 368 host_->Allocate(serialized_audio_frames_.size())); | 368 host_->Allocate(serialized_audio_frames_.size())); |
| 369 if (!decoded_frames->FrameBuffer()) { | 369 if (!decoded_frames->FrameBuffer()) { |
| 370 LOG(ERROR) << "DecodeBuffer() cdm::Host::Allocate failed."; | 370 LOG(ERROR) << "DecodeBuffer() cdm::Host::Allocate failed."; |
| 371 return cdm::kDecodeError; | 371 return cdm::kDecodeError; |
| 372 } | 372 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 403 } | 403 } |
| 404 } | 404 } |
| 405 | 405 |
| 406 void FFmpegCdmAudioDecoder::SerializeInt64(int64 value) { | 406 void FFmpegCdmAudioDecoder::SerializeInt64(int64 value) { |
| 407 int previous_size = serialized_audio_frames_.size(); | 407 int previous_size = serialized_audio_frames_.size(); |
| 408 serialized_audio_frames_.resize(previous_size + sizeof(value)); | 408 serialized_audio_frames_.resize(previous_size + sizeof(value)); |
| 409 memcpy(&serialized_audio_frames_[0] + previous_size, &value, sizeof(value)); | 409 memcpy(&serialized_audio_frames_[0] + previous_size, &value, sizeof(value)); |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace webkit_media | 412 } // namespace webkit_media |
| OLD | NEW |