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