OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/base/android/media_drm_bridge.h" | 5 #include "media/base/android/media_drm_bridge.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 | 294 |
295 return GetKeySystemManager()->GetPlatformKeySystemNames(); | 295 return GetKeySystemManager()->GetPlatformKeySystemNames(); |
296 } | 296 } |
297 | 297 |
298 // static | 298 // static |
299 scoped_refptr<MediaDrmBridge> MediaDrmBridge::CreateInternal( | 299 scoped_refptr<MediaDrmBridge> MediaDrmBridge::CreateInternal( |
300 const std::string& key_system, | 300 const std::string& key_system, |
301 const GURL& security_origin, | 301 const GURL& security_origin, |
302 SecurityLevel security_level, | 302 SecurityLevel security_level, |
303 const CreateFetcherCB& create_fetcher_cb, | 303 const CreateFetcherCB& create_fetcher_cb, |
304 const CreateStorageCB& create_storage_cb, | |
304 const SessionMessageCB& session_message_cb, | 305 const SessionMessageCB& session_message_cb, |
305 const SessionClosedCB& session_closed_cb, | 306 const SessionClosedCB& session_closed_cb, |
306 const SessionKeysChangeCB& session_keys_change_cb, | 307 const SessionKeysChangeCB& session_keys_change_cb, |
307 const SessionExpirationUpdateCB& session_expiration_update_cb) { | 308 const SessionExpirationUpdateCB& session_expiration_update_cb) { |
308 // All paths requires the MediaDrmApis. | 309 // All paths requires the MediaDrmApis. |
309 DCHECK(AreMediaDrmApisAvailable()); | 310 DCHECK(AreMediaDrmApisAvailable()); |
310 | 311 |
311 UUID scheme_uuid = GetKeySystemManager()->GetUUID(key_system); | 312 UUID scheme_uuid = GetKeySystemManager()->GetUUID(key_system); |
312 if (scheme_uuid.empty()) | 313 if (scheme_uuid.empty()) |
313 return nullptr; | 314 return nullptr; |
314 | 315 |
315 scoped_refptr<MediaDrmBridge> media_drm_bridge(new MediaDrmBridge( | 316 scoped_refptr<MediaDrmBridge> media_drm_bridge(new MediaDrmBridge( |
316 scheme_uuid, security_origin, security_level, create_fetcher_cb, | 317 scheme_uuid, security_origin, security_level, create_fetcher_cb, |
317 session_message_cb, session_closed_cb, session_keys_change_cb, | 318 create_storage_cb, session_message_cb, session_closed_cb, |
318 session_expiration_update_cb)); | 319 session_keys_change_cb, session_expiration_update_cb)); |
319 | 320 |
320 if (media_drm_bridge->j_media_drm_.is_null()) | 321 if (media_drm_bridge->j_media_drm_.is_null()) |
321 media_drm_bridge = nullptr; | 322 media_drm_bridge = nullptr; |
322 | 323 |
323 return media_drm_bridge; | 324 return media_drm_bridge; |
324 } | 325 } |
325 | 326 |
326 // static | 327 // static |
327 scoped_refptr<MediaDrmBridge> MediaDrmBridge::Create( | 328 scoped_refptr<MediaDrmBridge> MediaDrmBridge::Create( |
328 const std::string& key_system, | 329 const std::string& key_system, |
329 const GURL& security_origin, | 330 const GURL& security_origin, |
330 SecurityLevel security_level, | 331 SecurityLevel security_level, |
331 const CreateFetcherCB& create_fetcher_cb, | 332 const CreateFetcherCB& create_fetcher_cb, |
333 const CreateStorageCB& create_storage_cb, | |
332 const SessionMessageCB& session_message_cb, | 334 const SessionMessageCB& session_message_cb, |
333 const SessionClosedCB& session_closed_cb, | 335 const SessionClosedCB& session_closed_cb, |
334 const SessionKeysChangeCB& session_keys_change_cb, | 336 const SessionKeysChangeCB& session_keys_change_cb, |
335 const SessionExpirationUpdateCB& session_expiration_update_cb) { | 337 const SessionExpirationUpdateCB& session_expiration_update_cb) { |
336 DVLOG(1) << __func__; | 338 DVLOG(1) << __func__; |
337 | 339 |
338 if (!IsAvailable()) | 340 if (!IsAvailable()) |
339 return nullptr; | 341 return nullptr; |
340 | 342 |
341 return CreateInternal(key_system, security_origin, security_level, | 343 return CreateInternal(key_system, security_origin, security_level, |
342 create_fetcher_cb, session_message_cb, | 344 create_fetcher_cb, create_storage_cb, |
343 session_closed_cb, session_keys_change_cb, | 345 session_message_cb, session_closed_cb, |
344 session_expiration_update_cb); | 346 session_keys_change_cb, session_expiration_update_cb); |
345 } | 347 } |
346 | 348 |
347 // static | 349 // static |
348 scoped_refptr<MediaDrmBridge> MediaDrmBridge::CreateWithoutSessionSupport( | 350 scoped_refptr<MediaDrmBridge> MediaDrmBridge::CreateWithoutSessionSupport( |
349 const std::string& key_system, | 351 const std::string& key_system, |
350 SecurityLevel security_level, | 352 SecurityLevel security_level, |
351 const CreateFetcherCB& create_fetcher_cb) { | 353 const CreateFetcherCB& create_fetcher_cb) { |
352 DVLOG(1) << __func__; | 354 DVLOG(1) << __func__; |
353 | 355 |
354 // Sessions won't be used so decoding capability is not required. | 356 // Sessions won't be used so decoding capability is not required. |
355 if (!AreMediaDrmApisAvailable()) | 357 if (!AreMediaDrmApisAvailable()) |
356 return nullptr; | 358 return nullptr; |
357 | 359 |
358 return MediaDrmBridge::Create(key_system, GURL::EmptyGURL(), security_level, | 360 return MediaDrmBridge::Create( |
359 create_fetcher_cb, SessionMessageCB(), | 361 key_system, GURL::EmptyGURL(), security_level, create_fetcher_cb, |
360 SessionClosedCB(), SessionKeysChangeCB(), | 362 CreateStorageCB(), SessionMessageCB(), SessionClosedCB(), |
361 SessionExpirationUpdateCB()); | 363 SessionKeysChangeCB(), SessionExpirationUpdateCB()); |
362 } | 364 } |
363 | 365 |
364 void MediaDrmBridge::SetServerCertificate( | 366 void MediaDrmBridge::SetServerCertificate( |
365 const std::vector<uint8_t>& certificate, | 367 const std::vector<uint8_t>& certificate, |
366 std::unique_ptr<media::SimpleCdmPromise> promise) { | 368 std::unique_ptr<media::SimpleCdmPromise> promise) { |
367 DCHECK(task_runner_->BelongsToCurrentThread()); | 369 DCHECK(task_runner_->BelongsToCurrentThread()); |
368 DVLOG(2) << __func__ << "(" << certificate.size() << " bytes)"; | 370 DVLOG(2) << __func__ << "(" << certificate.size() << " bytes)"; |
369 | 371 |
370 DCHECK(!certificate.empty()); | 372 DCHECK(!certificate.empty()); |
371 | 373 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
759 } | 761 } |
760 | 762 |
761 //------------------------------------------------------------------------------ | 763 //------------------------------------------------------------------------------ |
762 // The following are private methods. | 764 // The following are private methods. |
763 | 765 |
764 MediaDrmBridge::MediaDrmBridge( | 766 MediaDrmBridge::MediaDrmBridge( |
765 const std::vector<uint8_t>& scheme_uuid, | 767 const std::vector<uint8_t>& scheme_uuid, |
766 const GURL& security_origin, | 768 const GURL& security_origin, |
767 SecurityLevel security_level, | 769 SecurityLevel security_level, |
768 const CreateFetcherCB& create_fetcher_cb, | 770 const CreateFetcherCB& create_fetcher_cb, |
771 const CreateStorageCB& create_storage_cb, | |
769 const SessionMessageCB& session_message_cb, | 772 const SessionMessageCB& session_message_cb, |
770 const SessionClosedCB& session_closed_cb, | 773 const SessionClosedCB& session_closed_cb, |
771 const SessionKeysChangeCB& session_keys_change_cb, | 774 const SessionKeysChangeCB& session_keys_change_cb, |
772 const SessionExpirationUpdateCB& session_expiration_update_cb) | 775 const SessionExpirationUpdateCB& session_expiration_update_cb) |
773 : scheme_uuid_(scheme_uuid), | 776 : scheme_uuid_(scheme_uuid), |
774 create_fetcher_cb_(create_fetcher_cb), | 777 create_fetcher_cb_(create_fetcher_cb), |
778 create_storage_cb_(create_storage_cb), | |
yucliu1
2017/03/27 19:06:41
I don't think we need this member in MediaDrmBridg
xhwang
2017/03/27 20:28:46
sgtm
| |
775 session_message_cb_(session_message_cb), | 779 session_message_cb_(session_message_cb), |
776 session_closed_cb_(session_closed_cb), | 780 session_closed_cb_(session_closed_cb), |
777 session_keys_change_cb_(session_keys_change_cb), | 781 session_keys_change_cb_(session_keys_change_cb), |
778 session_expiration_update_cb_(session_expiration_update_cb), | 782 session_expiration_update_cb_(session_expiration_update_cb), |
779 task_runner_(base::ThreadTaskRunnerHandle::Get()), | 783 task_runner_(base::ThreadTaskRunnerHandle::Get()), |
780 media_drm_bridge_cdm_context_(this), | 784 media_drm_bridge_cdm_context_(this), |
781 weak_factory_(this) { | 785 weak_factory_(this) { |
782 DVLOG(1) << __func__; | 786 DVLOG(1) << __func__; |
783 | 787 |
784 DCHECK(!create_fetcher_cb_.is_null()); | 788 DCHECK(!create_fetcher_cb_.is_null()); |
(...skipping 14 matching lines...) Expand all Loading... | |
799 base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) && | 803 base::FeatureList::IsEnabled(kMediaDrmPersistentLicense) && |
800 // MediaDrm implements origin isolated storage on M. | 804 // MediaDrm implements origin isolated storage on M. |
801 base::android::BuildInfo::GetInstance()->sdk_int() >= 23; | 805 base::android::BuildInfo::GetInstance()->sdk_int() >= 23; |
802 | 806 |
803 // TODO(yucliu): Per EME spec on individualization, implementation should not | 807 // TODO(yucliu): Per EME spec on individualization, implementation should not |
804 // expose application-specific information. Considering encode origin before | 808 // expose application-specific information. Considering encode origin before |
805 // passing to MediaDrm. | 809 // passing to MediaDrm. |
806 ScopedJavaLocalRef<jstring> j_security_origin = ConvertUTF8ToJavaString( | 810 ScopedJavaLocalRef<jstring> j_security_origin = ConvertUTF8ToJavaString( |
807 env, use_origin_isolated_storage ? security_origin.spec() : ""); | 811 env, use_origin_isolated_storage ? security_origin.spec() : ""); |
808 | 812 |
813 // TODO(yucliu): Use |create_storage_cb_| to create MediaDrmStorage which can | |
814 // be used by Java side to store/retrieve persistent data. This should only | |
815 // be used when |use_origin_isolated_storage| is true. | |
816 | |
809 // Note: OnMediaCryptoReady() could be called in this call. | 817 // Note: OnMediaCryptoReady() could be called in this call. |
810 j_media_drm_.Reset(Java_MediaDrmBridge_create( | 818 j_media_drm_.Reset(Java_MediaDrmBridge_create( |
811 env, j_scheme_uuid, j_security_origin, j_security_level, | 819 env, j_scheme_uuid, j_security_origin, j_security_level, |
812 reinterpret_cast<intptr_t>(this))); | 820 reinterpret_cast<intptr_t>(this))); |
813 } | 821 } |
814 | 822 |
815 MediaDrmBridge::~MediaDrmBridge() { | 823 MediaDrmBridge::~MediaDrmBridge() { |
816 DCHECK(task_runner_->BelongsToCurrentThread()); | 824 DCHECK(task_runner_->BelongsToCurrentThread()); |
817 DVLOG(1) << __func__; | 825 DVLOG(1) << __func__; |
818 | 826 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
910 } | 918 } |
911 | 919 |
912 void MediaDrmBridge::OnHasAdditionalUsableKey() { | 920 void MediaDrmBridge::OnHasAdditionalUsableKey() { |
913 DCHECK(task_runner_->BelongsToCurrentThread()); | 921 DCHECK(task_runner_->BelongsToCurrentThread()); |
914 DVLOG(1) << __func__; | 922 DVLOG(1) << __func__; |
915 | 923 |
916 player_tracker_.NotifyNewKey(); | 924 player_tracker_.NotifyNewKey(); |
917 } | 925 } |
918 | 926 |
919 } // namespace media | 927 } // namespace media |
OLD | NEW |