| 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/renderer_cdm_manager.h" | 5 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/common/media/cdm_messages.h" | 8 #include "content/common/media/cdm_messages.h" |
| 9 #include "content/renderer/media/crypto/proxy_media_keys.h" | 9 #include "content/renderer/media/crypto/proxy_media_keys.h" |
| 10 #include "media/base/cdm_context.h" | 10 #include "media/base/cdm_context.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 uint32_t promise_id, | 67 uint32_t promise_id, |
| 68 const std::vector<uint8_t>& certificate) { | 68 const std::vector<uint8_t>& certificate) { |
| 69 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; | 69 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 70 Send(new CdmHostMsg_SetServerCertificate(routing_id(), cdm_id, promise_id, | 70 Send(new CdmHostMsg_SetServerCertificate(routing_id(), cdm_id, promise_id, |
| 71 certificate)); | 71 certificate)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void RendererCdmManager::CreateSessionAndGenerateRequest( | 74 void RendererCdmManager::CreateSessionAndGenerateRequest( |
| 75 int cdm_id, | 75 int cdm_id, |
| 76 uint32_t promise_id, | 76 uint32_t promise_id, |
| 77 media::MediaKeys::SessionType session_type, |
| 77 CdmHostMsg_CreateSession_InitDataType init_data_type, | 78 CdmHostMsg_CreateSession_InitDataType init_data_type, |
| 78 const std::vector<uint8_t>& init_data) { | 79 const std::vector<uint8_t>& init_data) { |
| 79 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; | 80 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 80 Send(new CdmHostMsg_CreateSessionAndGenerateRequest( | 81 CdmHostMsg_CreateSessionAndGenerateRequest_Params params; |
| 81 routing_id(), cdm_id, promise_id, init_data_type, init_data)); | 82 params.render_frame_id = routing_id(); |
| 83 params.cdm_id = cdm_id; |
| 84 params.promise_id = promise_id; |
| 85 params.session_type = session_type; |
| 86 params.init_data_type = init_data_type; |
| 87 params.init_data = init_data; |
| 88 Send(new CdmHostMsg_CreateSessionAndGenerateRequest(params)); |
| 89 } |
| 90 |
| 91 void RendererCdmManager::LoadSession( |
| 92 int cdm_id, |
| 93 uint32_t promise_id, |
| 94 media::MediaKeys::SessionType session_type, |
| 95 const std::string& session_id) { |
| 96 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 97 Send(new CdmHostMsg_LoadSession(routing_id(), cdm_id, promise_id, |
| 98 session_type, session_id)); |
| 82 } | 99 } |
| 83 | 100 |
| 84 void RendererCdmManager::UpdateSession(int cdm_id, | 101 void RendererCdmManager::UpdateSession(int cdm_id, |
| 85 uint32_t promise_id, | 102 uint32_t promise_id, |
| 86 const std::string& session_id, | 103 const std::string& session_id, |
| 87 const std::vector<uint8_t>& response) { | 104 const std::vector<uint8_t>& response) { |
| 88 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; | 105 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 89 Send(new CdmHostMsg_UpdateSession(routing_id(), cdm_id, promise_id, | 106 Send(new CdmHostMsg_UpdateSession(routing_id(), cdm_id, promise_id, |
| 90 session_id, response)); | 107 session_id, response)); |
| 91 } | 108 } |
| 92 | 109 |
| 93 void RendererCdmManager::CloseSession(int cdm_id, | 110 void RendererCdmManager::CloseSession(int cdm_id, |
| 94 uint32_t promise_id, | 111 uint32_t promise_id, |
| 95 const std::string& session_id) { | 112 const std::string& session_id) { |
| 96 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; | 113 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 97 Send(new CdmHostMsg_CloseSession(routing_id(), cdm_id, promise_id, | 114 Send(new CdmHostMsg_CloseSession(routing_id(), cdm_id, promise_id, |
| 98 session_id)); | 115 session_id)); |
| 99 } | 116 } |
| 100 | 117 |
| 118 void RendererCdmManager::RemoveSession(int cdm_id, |
| 119 uint32_t promise_id, |
| 120 const std::string& session_id) { |
| 121 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 122 Send(new CdmHostMsg_RemoveSession(routing_id(), cdm_id, promise_id, |
| 123 session_id)); |
| 124 } |
| 125 |
| 101 void RendererCdmManager::DestroyCdm(int cdm_id) { | 126 void RendererCdmManager::DestroyCdm(int cdm_id) { |
| 102 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; | 127 DCHECK(GetMediaKeys(cdm_id)) << "|cdm_id| not registered."; |
| 103 Send(new CdmHostMsg_DestroyCdm(routing_id(), cdm_id)); | 128 Send(new CdmHostMsg_DestroyCdm(routing_id(), cdm_id)); |
| 104 } | 129 } |
| 105 | 130 |
| 106 void RendererCdmManager::OnSessionMessage( | 131 void RendererCdmManager::OnSessionMessage( |
| 107 int cdm_id, | 132 int cdm_id, |
| 108 const std::string& session_id, | 133 const std::string& session_id, |
| 109 media::MediaKeys::MessageType message_type, | 134 media::MediaKeys::MessageType message_type, |
| 110 const std::vector<uint8>& message, | 135 const std::vector<uint8>& message, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 proxy_media_keys_map_.erase(cdm_id); | 238 proxy_media_keys_map_.erase(cdm_id); |
| 214 } | 239 } |
| 215 | 240 |
| 216 ProxyMediaKeys* RendererCdmManager::GetMediaKeys(int cdm_id) { | 241 ProxyMediaKeys* RendererCdmManager::GetMediaKeys(int cdm_id) { |
| 217 std::map<int, ProxyMediaKeys*>::iterator iter = | 242 std::map<int, ProxyMediaKeys*>::iterator iter = |
| 218 proxy_media_keys_map_.find(cdm_id); | 243 proxy_media_keys_map_.find(cdm_id); |
| 219 return (iter != proxy_media_keys_map_.end()) ? iter->second : NULL; | 244 return (iter != proxy_media_keys_map_.end()) ? iter->second : NULL; |
| 220 } | 245 } |
| 221 | 246 |
| 222 } // namespace content | 247 } // namespace content |
| OLD | NEW |