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 "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 <cstring> | 8 #include <cstring> |
9 #include <sstream> | 9 #include <sstream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 case media::CdmKeyInformation::KeyStatus::RELEASED: | 199 case media::CdmKeyInformation::KeyStatus::RELEASED: |
200 return cdm::kReleased; | 200 return cdm::kReleased; |
201 } | 201 } |
202 NOTREACHED(); | 202 NOTREACHED(); |
203 return cdm::kInternalError; | 203 return cdm::kInternalError; |
204 } | 204 } |
205 | 205 |
206 // Shallow copy all the key information from |keys_info| into |keys_vector|. | 206 // Shallow copy all the key information from |keys_info| into |keys_vector|. |
207 // |keys_vector| is only valid for the lifetime of |keys_info| because it | 207 // |keys_vector| is only valid for the lifetime of |keys_info| because it |
208 // contains pointers into the latter. | 208 // contains pointers into the latter. |
209 void ConvertCdmKeysInfo(const std::vector<media::CdmKeyInformation*>& keys_info, | 209 void ConvertCdmKeysInfo(const media::CdmKeysInfo& keys_info, |
210 std::vector<cdm::KeyInformation>* keys_vector) { | 210 std::vector<cdm::KeyInformation>* keys_vector) { |
211 keys_vector->reserve(keys_info.size()); | 211 keys_vector->reserve(keys_info.size()); |
212 for (const auto& key_info : keys_info) { | 212 for (const auto& key_info : keys_info) { |
213 cdm::KeyInformation key; | 213 cdm::KeyInformation key; |
214 key.key_id = key_info->key_id.data(); | 214 key.key_id = key_info->key_id.data(); |
215 key.key_id_size = key_info->key_id.size(); | 215 key.key_id_size = key_info->key_id.size(); |
216 key.status = ConvertKeyStatus(key_info->status); | 216 key.status = ConvertKeyStatus(key_info->status); |
217 key.system_code = key_info->system_code; | 217 key.system_code = key_info->system_code; |
218 keys_vector->push_back(key); | 218 keys_vector->push_back(key); |
219 } | 219 } |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 keys_info_for_emulated_loadsession_.swap(keys_info); | 861 keys_info_for_emulated_loadsession_.swap(keys_info); |
862 return; | 862 return; |
863 } | 863 } |
864 | 864 |
865 // Loadable session has already been created, so pass this event on, | 865 // Loadable session has already been created, so pass this event on, |
866 // using the session_id callers expect to see. | 866 // using the session_id callers expect to see. |
867 new_session_id = std::string(kLoadableSessionId); | 867 new_session_id = std::string(kLoadableSessionId); |
868 } | 868 } |
869 | 869 |
870 std::vector<cdm::KeyInformation> keys_vector; | 870 std::vector<cdm::KeyInformation> keys_vector; |
871 ConvertCdmKeysInfo(keys_info.get(), &keys_vector); | 871 ConvertCdmKeysInfo(keys_info, &keys_vector); |
872 host_->OnSessionKeysChange(new_session_id.data(), new_session_id.length(), | 872 host_->OnSessionKeysChange(new_session_id.data(), new_session_id.length(), |
873 has_additional_usable_key, keys_vector.data(), | 873 has_additional_usable_key, keys_vector.data(), |
874 keys_vector.size()); | 874 keys_vector.size()); |
875 } | 875 } |
876 | 876 |
877 void ClearKeyCdm::OnSessionClosed(const std::string& session_id) { | 877 void ClearKeyCdm::OnSessionClosed(const std::string& session_id) { |
878 std::string new_session_id = session_id; | 878 std::string new_session_id = session_id; |
879 if (new_session_id == session_id_for_emulated_loadsession_) | 879 if (new_session_id == session_id_for_emulated_loadsession_) |
880 new_session_id = std::string(kLoadableSessionId); | 880 new_session_id = std::string(kLoadableSessionId); |
881 host_->OnSessionClosed(new_session_id.data(), new_session_id.length()); | 881 host_->OnSessionClosed(new_session_id.data(), new_session_id.length()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 // was seen. | 936 // was seen. |
937 // TODO(jrummell): Once the order of events is fixed in the spec, either | 937 // TODO(jrummell): Once the order of events is fixed in the spec, either |
938 // require the keyschange event to have happened, or remove this code. | 938 // require the keyschange event to have happened, or remove this code. |
939 // http://crbug.com/448225 | 939 // http://crbug.com/448225 |
940 if (has_received_keys_change_event_for_emulated_loadsession_) { | 940 if (has_received_keys_change_event_for_emulated_loadsession_) { |
941 std::vector<cdm::KeyInformation> keys_vector; | 941 std::vector<cdm::KeyInformation> keys_vector; |
942 CdmKeysInfo keys_info; | 942 CdmKeysInfo keys_info; |
943 keys_info.swap(keys_info_for_emulated_loadsession_); | 943 keys_info.swap(keys_info_for_emulated_loadsession_); |
944 has_received_keys_change_event_for_emulated_loadsession_ = false; | 944 has_received_keys_change_event_for_emulated_loadsession_ = false; |
945 DCHECK(!keys_vector.empty()); | 945 DCHECK(!keys_vector.empty()); |
946 ConvertCdmKeysInfo(keys_info.get(), &keys_vector); | 946 ConvertCdmKeysInfo(keys_info, &keys_vector); |
947 host_->OnSessionKeysChange(kLoadableSessionId, strlen(kLoadableSessionId), | 947 host_->OnSessionKeysChange(kLoadableSessionId, strlen(kLoadableSessionId), |
948 !keys_vector.empty(), keys_vector.data(), | 948 !keys_vector.empty(), keys_vector.data(), |
949 keys_vector.size()); | 949 keys_vector.size()); |
950 } | 950 } |
951 } | 951 } |
952 | 952 |
953 void ClearKeyCdm::OnPromiseResolved(uint32_t promise_id) { | 953 void ClearKeyCdm::OnPromiseResolved(uint32_t promise_id) { |
954 host_->OnResolvePromise(promise_id); | 954 host_->OnResolvePromise(promise_id); |
955 } | 955 } |
956 | 956 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 challenge.data(), challenge.size()); | 1063 challenge.data(), challenge.size()); |
1064 } | 1064 } |
1065 | 1065 |
1066 void ClearKeyCdm::VerifyCdmHostTest() { | 1066 void ClearKeyCdm::VerifyCdmHostTest() { |
1067 // VerifyCdmHost() should have already been called and test result stored | 1067 // VerifyCdmHost() should have already been called and test result stored |
1068 // in |g_verify_host_files_result|. | 1068 // in |g_verify_host_files_result|. |
1069 OnUnitTestComplete(g_verify_host_files_result); | 1069 OnUnitTestComplete(g_verify_host_files_result); |
1070 } | 1070 } |
1071 | 1071 |
1072 } // namespace media | 1072 } // namespace media |
OLD | NEW |