| 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 "chromecast/media/cdm/cast_cdm.h" | 5 #include "chromecast/media/cdm/cast_cdm.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 session_message_cb_.Run(session_id, message_type, message); | 118 session_message_cb_.Run(session_id, message_type, message); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void CastCdm::OnSessionClosed(const std::string& session_id) { | 121 void CastCdm::OnSessionClosed(const std::string& session_id) { |
| 122 session_closed_cb_.Run(session_id); | 122 session_closed_cb_.Run(session_id); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void CastCdm::OnSessionKeysChange(const std::string& session_id, | 125 void CastCdm::OnSessionKeysChange(const std::string& session_id, |
| 126 bool newly_usable_keys, | 126 bool newly_usable_keys, |
| 127 ::media::CdmKeysInfo keys_info) { | 127 ::media::CdmKeysInfo keys_info) { |
| 128 logging::LogMessage log_message(__FILE__, __LINE__, logging::LOG_INFO); |
| 129 log_message.stream() << "keystatuseschange "; |
| 130 int status_count[::media::CdmKeyInformation::KEY_STATUS_MAX] = {0}; |
| 131 for (const auto* key_info : keys_info) { |
| 132 status_count[key_info->status]++; |
| 133 } |
| 134 for (int i = 0; i != ::media::CdmKeyInformation::KEY_STATUS_MAX; ++i) { |
| 135 if (status_count[i] == 0) |
| 136 continue; |
| 137 log_message.stream() |
| 138 << status_count[i] << " " |
| 139 << ::media::CdmKeyInformation::KeyStatusToString( |
| 140 static_cast<::media::CdmKeyInformation::KeyStatus>(i)) |
| 141 << " "; |
| 142 } |
| 143 |
| 128 session_keys_change_cb_.Run(session_id, newly_usable_keys, | 144 session_keys_change_cb_.Run(session_id, newly_usable_keys, |
| 129 std::move(keys_info)); | 145 std::move(keys_info)); |
| 130 | 146 |
| 131 if (newly_usable_keys) | 147 if (newly_usable_keys) |
| 132 player_tracker_impl_->NotifyNewKey(); | 148 player_tracker_impl_->NotifyNewKey(); |
| 133 } | 149 } |
| 134 | 150 |
| 135 void CastCdm::OnSessionExpirationUpdate(const std::string& session_id, | 151 void CastCdm::OnSessionExpirationUpdate(const std::string& session_id, |
| 136 base::Time new_expiry_time) { | 152 base::Time new_expiry_time) { |
| 137 session_expiration_update_cb_.Run(session_id, new_expiry_time); | 153 session_expiration_update_cb_.Run(session_id, new_expiry_time); |
| 138 } | 154 } |
| 139 | 155 |
| 140 void CastCdm::KeyIdAndKeyPairsToInfo(const ::media::KeyIdAndKeyPairs& keys, | 156 void CastCdm::KeyIdAndKeyPairsToInfo(const ::media::KeyIdAndKeyPairs& keys, |
| 141 ::media::CdmKeysInfo* keys_info) { | 157 ::media::CdmKeysInfo* keys_info) { |
| 142 DCHECK(keys_info); | 158 DCHECK(keys_info); |
| 143 for (const std::pair<std::string, std::string>& key : keys) { | 159 for (const std::pair<std::string, std::string>& key : keys) { |
| 144 std::unique_ptr<::media::CdmKeyInformation> cdm_key_information( | 160 std::unique_ptr<::media::CdmKeyInformation> cdm_key_information( |
| 145 new ::media::CdmKeyInformation(key.first, | 161 new ::media::CdmKeyInformation(key.first, |
| 146 ::media::CdmKeyInformation::USABLE, 0)); | 162 ::media::CdmKeyInformation::USABLE, 0)); |
| 147 keys_info->push_back(cdm_key_information.release()); | 163 keys_info->push_back(cdm_key_information.release()); |
| 148 } | 164 } |
| 149 } | 165 } |
| 150 | 166 |
| 151 // A default empty implementation for subclasses that don't need to provide | 167 // A default empty implementation for subclasses that don't need to provide |
| 152 // any key system specific initialization. | 168 // any key system specific initialization. |
| 153 void CastCdm::InitializeInternal() {} | 169 void CastCdm::InitializeInternal() {} |
| 154 | 170 |
| 155 } // namespace media | 171 } // namespace media |
| 156 } // namespace chromecast | 172 } // namespace chromecast |
| OLD | NEW |