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

Side by Side Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 116443009: Handle plugin instance crash in ContentDecryptorDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 11 months 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
OLDNEW
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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" 5 #include "media/cdm/ppapi/external_clear_key/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>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries(); 60 static bool g_ffmpeg_lib_initialized = InitializeFFmpegLibraries();
61 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER 61 #endif // CLEAR_KEY_CDM_USE_FFMPEG_DECODER
62 62
63 const char kClearKeyCdmVersion[] = "0.1.0.1"; 63 const char kClearKeyCdmVersion[] = "0.1.0.1";
64 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey"; 64 const char kExternalClearKeyKeySystem[] = "org.chromium.externalclearkey";
65 const char kExternalClearKeyDecryptOnlyKeySystem[] = 65 const char kExternalClearKeyDecryptOnlyKeySystem[] =
66 "org.chromium.externalclearkey.decryptonly"; 66 "org.chromium.externalclearkey.decryptonly";
67 const char kExternalClearKeyFileIOTestKeySystem[] = 67 const char kExternalClearKeyFileIOTestKeySystem[] =
68 "org.chromium.externalclearkey.fileiotest"; 68 "org.chromium.externalclearkey.fileiotest";
69 const char kExternalClearKeyCrashKeySystem[] =
70 "org.chromium.externalclearkey.crash";
71
69 const int64 kSecondsPerMinute = 60; 72 const int64 kSecondsPerMinute = 60;
70 const int64 kMsPerSecond = 1000; 73 const int64 kMsPerSecond = 1000;
71 const int64 kInitialTimerDelayMs = 200; 74 const int64 kInitialTimerDelayMs = 200;
72 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond; 75 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond;
73 // Heart beat message header. If a key message starts with |kHeartBeatHeader|, 76 // Heart beat message header. If a key message starts with |kHeartBeatHeader|,
74 // it's a heart beat message. Otherwise, it's a key request. 77 // it's a heart beat message. Otherwise, it's a key request.
75 const char kHeartBeatHeader[] = "HEARTBEAT"; 78 const char kHeartBeatHeader[] = "HEARTBEAT";
76 // CDM file IO test result header. 79 // CDM file IO test result header.
77 const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT"; 80 const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT";
78 81
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 143
141 void* CreateCdmInstance(int cdm_interface_version, 144 void* CreateCdmInstance(int cdm_interface_version,
142 const char* key_system, uint32_t key_system_size, 145 const char* key_system, uint32_t key_system_size,
143 GetCdmHostFunc get_cdm_host_func, 146 GetCdmHostFunc get_cdm_host_func,
144 void* user_data) { 147 void* user_data) {
145 DVLOG(1) << "CreateCdmInstance()"; 148 DVLOG(1) << "CreateCdmInstance()";
146 149
147 std::string key_system_string(key_system, key_system_size); 150 std::string key_system_string(key_system, key_system_size);
148 if (key_system_string != kExternalClearKeyKeySystem && 151 if (key_system_string != kExternalClearKeyKeySystem &&
149 key_system_string != kExternalClearKeyDecryptOnlyKeySystem && 152 key_system_string != kExternalClearKeyDecryptOnlyKeySystem &&
150 key_system_string != kExternalClearKeyFileIOTestKeySystem) { 153 key_system_string != kExternalClearKeyFileIOTestKeySystem &&
154 key_system_string != kExternalClearKeyCrashKeySystem) {
151 DVLOG(1) << "Unsupported key system:" << key_system_string; 155 DVLOG(1) << "Unsupported key system:" << key_system_string;
152 return NULL; 156 return NULL;
153 } 157 }
154 158
155 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion) 159 if (cdm_interface_version != media::ClearKeyCdmInterface::kVersion)
156 return NULL; 160 return NULL;
157 161
158 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>( 162 media::ClearKeyCdmHost* host = static_cast<media::ClearKeyCdmHost*>(
159 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data)); 163 get_cdm_host_func(media::ClearKeyCdmHost::kVersion, user_data));
160 if (!host) 164 if (!host)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 } 388 }
385 389
386 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); 390 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame);
387 } 391 }
388 392
389 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( 393 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
390 const cdm::InputBuffer& encrypted_buffer, 394 const cdm::InputBuffer& encrypted_buffer,
391 cdm::AudioFrames* audio_frames) { 395 cdm::AudioFrames* audio_frames) {
392 DVLOG(1) << "DecryptAndDecodeSamples()"; 396 DVLOG(1) << "DecryptAndDecodeSamples()";
393 397
398 // Trigger a crash on purpose for testing purpose.
399 if (key_system_ == kExternalClearKeyCrashKeySystem)
400 CHECK(false);
401
394 scoped_refptr<media::DecoderBuffer> buffer; 402 scoped_refptr<media::DecoderBuffer> buffer;
395 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 403 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
396 404
397 if (status != cdm::kSuccess) 405 if (status != cdm::kSuccess)
398 return status; 406 return status;
399 407
400 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER) 408 #if defined(CLEAR_KEY_CDM_USE_FFMPEG_DECODER)
401 const uint8_t* data = NULL; 409 const uint8_t* data = NULL;
402 int32_t size = 0; 410 int32_t size = 0;
403 int64_t timestamp = 0; 411 int64_t timestamp = 0;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 588
581 void ClearKeyCdm::OnFileIOTestComplete(bool success) { 589 void ClearKeyCdm::OnFileIOTestComplete(bool success) {
582 DVLOG(1) << __FUNCTION__ << ": " << success; 590 DVLOG(1) << __FUNCTION__ << ": " << success;
583 std::string message = GetFileIOTestResultMessage(success); 591 std::string message = GetFileIOTestResultMessage(success);
584 host_->OnSessionMessage( 592 host_->OnSessionMessage(
585 last_session_id_, message.data(), message.size(), NULL, 0); 593 last_session_id_, message.data(), message.size(), NULL, 0);
586 file_io_test_runner_.reset(); 594 file_io_test_runner_.reset();
587 } 595 }
588 596
589 } // namespace media 597 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698