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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 CastCdm::~CastCdm() { | 69 CastCdm::~CastCdm() { |
70 DCHECK(thread_checker_.CalledOnValidThread()); | 70 DCHECK(thread_checker_.CalledOnValidThread()); |
71 DCHECK(player_tracker_impl_.get()); | 71 DCHECK(player_tracker_impl_.get()); |
72 player_tracker_impl_->NotifyCdmUnset(); | 72 player_tracker_impl_->NotifyCdmUnset(); |
73 media_resource_tracker_->DecrementUsageCount(); | 73 media_resource_tracker_->DecrementUsageCount(); |
74 } | 74 } |
75 | 75 |
76 void CastCdm::Initialize( | 76 void CastCdm::Initialize( |
77 const ::media::SessionMessageCB& session_message_cb, | 77 const ::media::SessionMessageCB& session_message_cb, |
78 const ::media::SessionClosedCB& session_closed_cb, | 78 const ::media::SessionClosedCB& session_closed_cb, |
79 const ::media::LegacySessionErrorCB& legacy_session_error_cb, | |
80 const ::media::SessionKeysChangeCB& session_keys_change_cb, | 79 const ::media::SessionKeysChangeCB& session_keys_change_cb, |
81 const ::media::SessionExpirationUpdateCB& session_expiration_update_cb) { | 80 const ::media::SessionExpirationUpdateCB& session_expiration_update_cb) { |
82 DCHECK(thread_checker_.CalledOnValidThread()); | 81 DCHECK(thread_checker_.CalledOnValidThread()); |
83 | 82 |
84 media_resource_tracker_->IncrementUsageCount(); | 83 media_resource_tracker_->IncrementUsageCount(); |
85 player_tracker_impl_.reset(new ::media::PlayerTrackerImpl()); | 84 player_tracker_impl_.reset(new ::media::PlayerTrackerImpl()); |
86 | 85 |
87 session_message_cb_ = session_message_cb; | 86 session_message_cb_ = session_message_cb; |
88 session_closed_cb_ = session_closed_cb; | 87 session_closed_cb_ = session_closed_cb; |
89 legacy_session_error_cb_ = legacy_session_error_cb; | |
90 session_keys_change_cb_ = session_keys_change_cb; | 88 session_keys_change_cb_ = session_keys_change_cb; |
91 session_expiration_update_cb_ = session_expiration_update_cb; | 89 session_expiration_update_cb_ = session_expiration_update_cb; |
92 | 90 |
93 InitializeInternal(); | 91 InitializeInternal(); |
94 } | 92 } |
95 | 93 |
96 int CastCdm::RegisterPlayer(const base::Closure& new_key_cb, | 94 int CastCdm::RegisterPlayer(const base::Closure& new_key_cb, |
97 const base::Closure& cdm_unset_cb) { | 95 const base::Closure& cdm_unset_cb) { |
98 DCHECK(thread_checker_.CalledOnValidThread()); | 96 DCHECK(thread_checker_.CalledOnValidThread()); |
99 return player_tracker_impl_->RegisterPlayer(new_key_cb, cdm_unset_cb); | 97 return player_tracker_impl_->RegisterPlayer(new_key_cb, cdm_unset_cb); |
100 } | 98 } |
101 | 99 |
102 void CastCdm::UnregisterPlayer(int registration_id) { | 100 void CastCdm::UnregisterPlayer(int registration_id) { |
103 DCHECK(thread_checker_.CalledOnValidThread()); | 101 DCHECK(thread_checker_.CalledOnValidThread()); |
104 player_tracker_impl_->UnregisterPlayer(registration_id); | 102 player_tracker_impl_->UnregisterPlayer(registration_id); |
105 } | 103 } |
106 | 104 |
107 ::media::CdmContext* CastCdm::GetCdmContext() { | 105 ::media::CdmContext* CastCdm::GetCdmContext() { |
108 return cast_cdm_context_.get(); | 106 return cast_cdm_context_.get(); |
109 } | 107 } |
110 | 108 |
111 void CastCdm::OnSessionMessage(const std::string& session_id, | 109 void CastCdm::OnSessionMessage(const std::string& session_id, |
112 const std::vector<uint8_t>& message, | 110 const std::vector<uint8_t>& message, |
113 ::media::MediaKeys::MessageType message_type) { | 111 ::media::MediaKeys::MessageType message_type) { |
114 session_message_cb_.Run(session_id, message_type, message, GURL::EmptyGURL()); | 112 session_message_cb_.Run(session_id, message_type, message); |
115 } | 113 } |
116 | 114 |
117 void CastCdm::OnSessionClosed(const std::string& session_id) { | 115 void CastCdm::OnSessionClosed(const std::string& session_id) { |
118 session_closed_cb_.Run(session_id); | 116 session_closed_cb_.Run(session_id); |
119 } | 117 } |
120 | 118 |
121 void CastCdm::OnSessionKeysChange(const std::string& session_id, | 119 void CastCdm::OnSessionKeysChange(const std::string& session_id, |
122 bool newly_usable_keys, | 120 bool newly_usable_keys, |
123 ::media::CdmKeysInfo keys_info) { | 121 ::media::CdmKeysInfo keys_info) { |
124 session_keys_change_cb_.Run(session_id, newly_usable_keys, | 122 session_keys_change_cb_.Run(session_id, newly_usable_keys, |
(...skipping 13 matching lines...) Expand all Loading... |
138 keys_info->push_back(cdm_key_information.release()); | 136 keys_info->push_back(cdm_key_information.release()); |
139 } | 137 } |
140 } | 138 } |
141 | 139 |
142 // A default empty implementation for subclasses that don't need to provide | 140 // A default empty implementation for subclasses that don't need to provide |
143 // any key system specific initialization. | 141 // any key system specific initialization. |
144 void CastCdm::InitializeInternal() {} | 142 void CastCdm::InitializeInternal() {} |
145 | 143 |
146 } // namespace media | 144 } // namespace media |
147 } // namespace chromecast | 145 } // namespace chromecast |
OLD | NEW |