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/clear_key_cdm.h" | 5 #include "media/cdm/ppapi/clear_key_cdm.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "media/base/decoder_buffer.h" | 16 #include "media/base/decoder_buffer.h" |
17 #include "media/base/decrypt_config.h" | 17 #include "media/base/decrypt_config.h" |
18 #include "webkit/renderer/media/crypto/ppapi/cdm_video_decoder.h" | 18 #include "media/cdm/ppapi/cdm_video_decoder.h" |
19 | 19 |
20 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 20 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
21 #include "base/basictypes.h" | 21 #include "base/basictypes.h" |
22 static const int64 kNoTimestamp = kint64min; | 22 static const int64 kNoTimestamp = kint64min; |
23 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 23 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
24 | 24 |
25 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 25 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
26 #include "base/at_exit.h" | 26 #include "base/at_exit.h" |
27 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
28 #include "base/path_service.h" | 28 #include "base/path_service.h" |
29 #include "media/base/media.h" | 29 #include "media/base/media.h" |
30 #include "webkit/renderer/media/crypto/ppapi/ffmpeg_cdm_audio_decoder.h" | 30 #include "media/cdm/ppapi/ffmpeg_cdm_audio_decoder.h" |
31 #include "webkit/renderer/media/crypto/ppapi/ffmpeg_cdm_video_decoder.h" | 31 #include "media/cdm/ppapi/ffmpeg_cdm_video_decoder.h" |
32 | 32 |
33 // Include FFmpeg avformat.h for av_register_all(). | 33 // Include FFmpeg avformat.h for av_register_all(). |
34 extern "C" { | 34 extern "C" { |
35 // Temporarily disable possible loss of data warning. | 35 // Temporarily disable possible loss of data warning. |
36 MSVC_PUSH_DISABLE_WARNING(4244); | 36 MSVC_PUSH_DISABLE_WARNING(4244); |
37 #include <libavformat/avformat.h> | 37 #include <libavformat/avformat.h> |
38 MSVC_POP_WARNING(); | 38 MSVC_POP_WARNING(); |
39 } // extern "C" | 39 } // extern "C" |
40 | 40 |
41 // TODO(tomfinegan): When COMPONENT_BUILD is not defined an AtExitManager must | 41 // TODO(tomfinegan): When COMPONENT_BUILD is not defined an AtExitManager must |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 if (cdm_interface_version != cdm::kCdmInterfaceVersion) | 134 if (cdm_interface_version != cdm::kCdmInterfaceVersion) |
135 return NULL; | 135 return NULL; |
136 | 136 |
137 cdm::Host* host = static_cast<cdm::Host*>( | 137 cdm::Host* host = static_cast<cdm::Host*>( |
138 get_cdm_host_func(cdm::kHostInterfaceVersion, user_data)); | 138 get_cdm_host_func(cdm::kHostInterfaceVersion, user_data)); |
139 if (!host) | 139 if (!host) |
140 return NULL; | 140 return NULL; |
141 | 141 |
142 return static_cast<cdm::ContentDecryptionModule*>( | 142 return static_cast<cdm::ContentDecryptionModule*>( |
143 new webkit_media::ClearKeyCdm(host)); | 143 new media::ClearKeyCdm(host)); |
144 } | 144 } |
145 | 145 |
146 const char* GetCdmVersion() { | 146 const char* GetCdmVersion() { |
147 return kClearKeyCdmVersion; | 147 return kClearKeyCdmVersion; |
148 } | 148 } |
149 | 149 |
150 namespace webkit_media { | 150 namespace media { |
151 | 151 |
152 ClearKeyCdm::Client::Client() : status_(kKeyError) {} | 152 ClearKeyCdm::Client::Client() : status_(kKeyError) {} |
153 | 153 |
154 ClearKeyCdm::Client::~Client() {} | 154 ClearKeyCdm::Client::~Client() {} |
155 | 155 |
156 void ClearKeyCdm::Client::Reset() { | 156 void ClearKeyCdm::Client::Reset() { |
157 status_ = kKeyError; | 157 status_ = kKeyError; |
158 session_id_.clear(); | 158 session_id_.clear(); |
159 key_message_.clear(); | 159 key_message_.clear(); |
160 default_url_.clear(); | 160 default_url_.clear(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 decrypted_block->DecryptedBuffer()->SetSize(buffer->data_size()); | 308 decrypted_block->DecryptedBuffer()->SetSize(buffer->data_size()); |
309 decrypted_block->SetTimestamp(buffer->timestamp().InMicroseconds()); | 309 decrypted_block->SetTimestamp(buffer->timestamp().InMicroseconds()); |
310 | 310 |
311 return cdm::kSuccess; | 311 return cdm::kSuccess; |
312 } | 312 } |
313 | 313 |
314 cdm::Status ClearKeyCdm::InitializeAudioDecoder( | 314 cdm::Status ClearKeyCdm::InitializeAudioDecoder( |
315 const cdm::AudioDecoderConfig& audio_decoder_config) { | 315 const cdm::AudioDecoderConfig& audio_decoder_config) { |
316 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) | 316 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) |
317 if (!audio_decoder_) | 317 if (!audio_decoder_) |
318 audio_decoder_.reset(new webkit_media::FFmpegCdmAudioDecoder(host_)); | 318 audio_decoder_.reset(new media::FFmpegCdmAudioDecoder(host_)); |
319 | 319 |
320 if (!audio_decoder_->Initialize(audio_decoder_config)) | 320 if (!audio_decoder_->Initialize(audio_decoder_config)) |
321 return cdm::kSessionError; | 321 return cdm::kSessionError; |
322 | 322 |
323 return cdm::kSuccess; | 323 return cdm::kSuccess; |
324 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) | 324 #elif defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) |
325 channel_count_ = audio_decoder_config.channel_count; | 325 channel_count_ = audio_decoder_config.channel_count; |
326 bits_per_channel_ = audio_decoder_config.bits_per_channel; | 326 bits_per_channel_ = audio_decoder_config.bits_per_channel; |
327 samples_per_second_ = audio_decoder_config.samples_per_second; | 327 samples_per_second_ = audio_decoder_config.samples_per_second; |
328 return cdm::kSuccess; | 328 return cdm::kSuccess; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 548 |
549 int samples_generated = GenerateFakeAudioFramesFromDuration( | 549 int samples_generated = GenerateFakeAudioFramesFromDuration( |
550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), | 550 timestamp_in_microseconds - CurrentTimeStampInMicroseconds(), |
551 audio_frames); | 551 audio_frames); |
552 total_samples_generated_ += samples_generated; | 552 total_samples_generated_ += samples_generated; |
553 | 553 |
554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; | 554 return samples_generated == 0 ? cdm::kNeedMoreData : cdm::kSuccess; |
555 } | 555 } |
556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER | 556 #endif // CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER |
557 | 557 |
558 } // namespace webkit_media | 558 } // namespace media |
OLD | NEW |