| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/renderer/media/crypto/proxy_media_keys.h" | 5 #include "content/renderer/media/crypto/proxy_media_keys.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 scoped_ptr<media::SimpleCdmPromise> promise) { | 53 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 54 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 54 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 55 manager_->SetServerCertificate(cdm_id_, promise_id, certificate); | 55 manager_->SetServerCertificate(cdm_id_, promise_id, certificate); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ProxyMediaKeys::CreateSessionAndGenerateRequest( | 58 void ProxyMediaKeys::CreateSessionAndGenerateRequest( |
| 59 SessionType session_type, | 59 SessionType session_type, |
| 60 media::EmeInitDataType init_data_type, | 60 media::EmeInitDataType init_data_type, |
| 61 const std::vector<uint8_t>& init_data, | 61 const std::vector<uint8_t>& init_data, |
| 62 scoped_ptr<media::NewSessionCdmPromise> promise) { | 62 scoped_ptr<media::NewSessionCdmPromise> promise) { |
| 63 if (session_type != media::MediaKeys::TEMPORARY_SESSION) { | |
| 64 promise->reject(NOT_SUPPORTED_ERROR, 0, | |
| 65 "Only the temporary session type is supported."); | |
| 66 return; | |
| 67 } | |
| 68 | |
| 69 // TODO(xhwang): Move these checks up to blink and DCHECK here. | 63 // TODO(xhwang): Move these checks up to blink and DCHECK here. |
| 70 // See http://crbug.com/342510 | 64 // See http://crbug.com/342510 |
| 71 CdmHostMsg_CreateSession_InitDataType create_session_init_data_type = | 65 CdmHostMsg_CreateSession_InitDataType create_session_init_data_type = |
| 72 INIT_DATA_TYPE_WEBM; | 66 INIT_DATA_TYPE_WEBM; |
| 73 switch (init_data_type) { | 67 switch (init_data_type) { |
| 74 case media::EmeInitDataType::CENC: | 68 case media::EmeInitDataType::CENC: |
| 75 create_session_init_data_type = INIT_DATA_TYPE_CENC; | 69 create_session_init_data_type = INIT_DATA_TYPE_CENC; |
| 76 break; | 70 break; |
| 77 case media::EmeInitDataType::WEBM: | 71 case media::EmeInitDataType::WEBM: |
| 78 create_session_init_data_type = INIT_DATA_TYPE_WEBM; | 72 create_session_init_data_type = INIT_DATA_TYPE_WEBM; |
| 79 break; | 73 break; |
| 80 case media::EmeInitDataType::KEYIDS: | 74 case media::EmeInitDataType::KEYIDS: |
| 81 case media::EmeInitDataType::UNKNOWN: | 75 case media::EmeInitDataType::UNKNOWN: |
| 82 DLOG(ERROR) << "Unsupported EME CreateSession init data type"; | 76 DLOG(ERROR) << "Unsupported EME CreateSession init data type"; |
| 83 promise->reject(NOT_SUPPORTED_ERROR, 0, | 77 promise->reject(NOT_SUPPORTED_ERROR, 0, |
| 84 "Unsupported EME CreateSession init data type"); | 78 "Unsupported EME CreateSession init data type"); |
| 85 return; | 79 return; |
| 86 } | 80 } |
| 87 | 81 |
| 88 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 82 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 89 manager_->CreateSessionAndGenerateRequest( | 83 manager_->CreateSessionAndGenerateRequest( |
| 90 cdm_id_, promise_id, create_session_init_data_type, init_data); | 84 cdm_id_, promise_id, session_type, create_session_init_data_type, |
| 85 init_data); |
| 91 } | 86 } |
| 92 | 87 |
| 93 void ProxyMediaKeys::LoadSession( | 88 void ProxyMediaKeys::LoadSession( |
| 94 SessionType session_type, | 89 SessionType session_type, |
| 95 const std::string& session_id, | 90 const std::string& session_id, |
| 96 scoped_ptr<media::NewSessionCdmPromise> promise) { | 91 scoped_ptr<media::NewSessionCdmPromise> promise) { |
| 97 // TODO(xhwang): Check key system and platform support for LoadSession in | 92 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 98 // blink and add NOTREACHED() here. See http://crbug.com/384152 | 93 manager_->LoadSession(cdm_id_, promise_id, session_type, session_id); |
| 99 DLOG(ERROR) << "ProxyMediaKeys doesn't support session loading."; | |
| 100 promise->reject(NOT_SUPPORTED_ERROR, 0, "LoadSession() is not supported."); | |
| 101 } | 94 } |
| 102 | 95 |
| 103 void ProxyMediaKeys::UpdateSession( | 96 void ProxyMediaKeys::UpdateSession( |
| 104 const std::string& session_id, | 97 const std::string& session_id, |
| 105 const std::vector<uint8_t>& response, | 98 const std::vector<uint8_t>& response, |
| 106 scoped_ptr<media::SimpleCdmPromise> promise) { | 99 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 107 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 100 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 108 manager_->UpdateSession(cdm_id_, promise_id, session_id, response); | 101 manager_->UpdateSession(cdm_id_, promise_id, session_id, response); |
| 109 } | 102 } |
| 110 | 103 |
| 111 void ProxyMediaKeys::CloseSession(const std::string& session_id, | 104 void ProxyMediaKeys::CloseSession(const std::string& session_id, |
| 112 scoped_ptr<media::SimpleCdmPromise> promise) { | 105 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 113 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 106 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 114 manager_->CloseSession(cdm_id_, promise_id, session_id); | 107 manager_->CloseSession(cdm_id_, promise_id, session_id); |
| 115 } | 108 } |
| 116 | 109 |
| 117 void ProxyMediaKeys::RemoveSession( | 110 void ProxyMediaKeys::RemoveSession( |
| 118 const std::string& session_id, | 111 const std::string& session_id, |
| 119 scoped_ptr<media::SimpleCdmPromise> promise) { | 112 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 120 // TODO(xhwang): Check key system and platform support for LoadSession in | 113 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 121 // blink and add NOTREACHED() here. See http://crbug.com/384152 | 114 manager_->RemoveSession(cdm_id_, promise_id, session_id); |
| 122 promise->reject(NOT_SUPPORTED_ERROR, 0, "RemoveSession() not supported."); | |
| 123 } | 115 } |
| 124 | 116 |
| 125 media::CdmContext* ProxyMediaKeys::GetCdmContext() { | 117 media::CdmContext* ProxyMediaKeys::GetCdmContext() { |
| 126 return this; | 118 return this; |
| 127 } | 119 } |
| 128 | 120 |
| 129 media::Decryptor* ProxyMediaKeys::GetDecryptor() { | 121 media::Decryptor* ProxyMediaKeys::GetDecryptor() { |
| 130 return nullptr; | 122 return nullptr; |
| 131 } | 123 } |
| 132 | 124 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 const std::string& key_system, | 198 const std::string& key_system, |
| 207 const GURL& security_origin, | 199 const GURL& security_origin, |
| 208 bool use_hw_secure_codecs, | 200 bool use_hw_secure_codecs, |
| 209 scoped_ptr<media::SimpleCdmPromise> promise) { | 201 scoped_ptr<media::SimpleCdmPromise> promise) { |
| 210 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); | 202 uint32_t promise_id = cdm_promise_adapter_.SavePromise(promise.Pass()); |
| 211 manager_->InitializeCdm(cdm_id_, promise_id, this, key_system, | 203 manager_->InitializeCdm(cdm_id_, promise_id, this, key_system, |
| 212 security_origin, use_hw_secure_codecs); | 204 security_origin, use_hw_secure_codecs); |
| 213 } | 205 } |
| 214 | 206 |
| 215 } // namespace content | 207 } // namespace content |
| OLD | NEW |