Chromium Code Reviews| 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 "content/browser/media/android/browser_media_player_manager.h" | 5 #include "content/browser/media/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include "base/android/scoped_java_ref.h" | 7 #include "base/android/scoped_java_ref.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/browser/web_contents_delegate.h" | 26 #include "content/public/browser/web_contents_delegate.h" |
| 27 #include "content/public/common/content_client.h" | 27 #include "content/public/common/content_client.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "media/base/android/media_player_bridge.h" | 29 #include "media/base/android/media_player_bridge.h" |
| 30 #include "media/base/android/media_source_player.h" | 30 #include "media/base/android/media_source_player.h" |
| 31 #include "media/base/cdm_factory.h" | 31 #include "media/base/browser_cdm.h" |
| 32 #include "media/base/browser_cdm_factory.h" | |
| 32 #include "media/base/media_switches.h" | 33 #include "media/base/media_switches.h" |
| 33 | 34 |
| 35 using media::BrowserCdm; | |
| 34 using media::MediaKeys; | 36 using media::MediaKeys; |
| 35 using media::MediaPlayerAndroid; | 37 using media::MediaPlayerAndroid; |
| 36 using media::MediaPlayerBridge; | 38 using media::MediaPlayerBridge; |
| 37 using media::MediaPlayerManager; | 39 using media::MediaPlayerManager; |
| 38 using media::MediaSourcePlayer; | 40 using media::MediaSourcePlayer; |
| 39 | 41 |
| 40 namespace content { | 42 namespace content { |
| 41 | 43 |
| 42 // Threshold on the number of media players per renderer before we start | 44 // Threshold on the number of media players per renderer before we start |
| 43 // attempting to release inactive media players. | 45 // attempting to release inactive media players. |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 | 312 |
| 311 MediaPlayerAndroid* BrowserMediaPlayerManager::GetPlayer(int player_id) { | 313 MediaPlayerAndroid* BrowserMediaPlayerManager::GetPlayer(int player_id) { |
| 312 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 314 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
| 313 it != players_.end(); ++it) { | 315 it != players_.end(); ++it) { |
| 314 if ((*it)->player_id() == player_id) | 316 if ((*it)->player_id() == player_id) |
| 315 return *it; | 317 return *it; |
| 316 } | 318 } |
| 317 return NULL; | 319 return NULL; |
| 318 } | 320 } |
| 319 | 321 |
| 320 MediaKeys* BrowserMediaPlayerManager::GetCdm(int cdm_id) { | 322 BrowserCdm* BrowserMediaPlayerManager::GetCdm(int cdm_id) { |
| 321 CdmMap::const_iterator iter = cdm_map_.find(cdm_id); | 323 CdmMap::const_iterator iter = cdm_map_.find(cdm_id); |
| 322 return (iter == cdm_map_.end()) ? NULL : iter->second; | 324 return (iter == cdm_map_.end()) ? NULL : iter->second; |
| 323 } | 325 } |
| 324 | 326 |
| 325 void BrowserMediaPlayerManager::DestroyAllMediaPlayers() { | 327 void BrowserMediaPlayerManager::DestroyAllMediaPlayers() { |
| 326 players_.clear(); | 328 players_.clear(); |
| 327 STLDeleteValues(&cdm_map_); | 329 STLDeleteValues(&cdm_map_); |
| 328 if (fullscreen_player_id_ != -1) { | 330 if (fullscreen_player_id_ != -1) { |
| 329 video_view_.reset(); | 331 video_view_.reset(); |
| 330 fullscreen_player_id_ = -1; | 332 fullscreen_player_id_ = -1; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 } | 371 } |
| 370 | 372 |
| 371 void BrowserMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { | 373 void BrowserMediaPlayerManager::OnSessionReady(int cdm_id, uint32 session_id) { |
| 372 Send(new CdmMsg_SessionReady(RoutingID(), cdm_id, session_id)); | 374 Send(new CdmMsg_SessionReady(RoutingID(), cdm_id, session_id)); |
| 373 } | 375 } |
| 374 | 376 |
| 375 void BrowserMediaPlayerManager::OnSessionClosed(int cdm_id, uint32 session_id) { | 377 void BrowserMediaPlayerManager::OnSessionClosed(int cdm_id, uint32 session_id) { |
| 376 Send(new CdmMsg_SessionClosed(RoutingID(), cdm_id, session_id)); | 378 Send(new CdmMsg_SessionClosed(RoutingID(), cdm_id, session_id)); |
| 377 } | 379 } |
| 378 | 380 |
| 379 void BrowserMediaPlayerManager::OnSessionError( | 381 void BrowserMediaPlayerManager::OnSessionError(int cdm_id, |
| 380 int cdm_id, | 382 uint32 session_id, |
| 381 uint32 session_id, | 383 MediaKeys::KeyError error_code, |
|
ddorwin
2014/05/30 20:50:05
When BrowserCdm no longer inherits from MediaKeys,
xhwang
2014/06/02 20:11:43
Shall we put those errors in a common place? e.g.
ddorwin
2014/06/02 20:20:29
Maybe. That's how jrummel has them in the Blink CL
| |
| 382 media::MediaKeys::KeyError error_code, | 384 uint32 system_code) { |
| 383 uint32 system_code) { | |
| 384 Send(new CdmMsg_SessionError( | 385 Send(new CdmMsg_SessionError( |
| 385 RoutingID(), cdm_id, session_id, error_code, system_code)); | 386 RoutingID(), cdm_id, session_id, error_code, system_code)); |
| 386 } | 387 } |
| 387 | 388 |
| 388 #if defined(VIDEO_HOLE) | 389 #if defined(VIDEO_HOLE) |
| 389 void BrowserMediaPlayerManager::AttachExternalVideoSurface(int player_id, | 390 void BrowserMediaPlayerManager::AttachExternalVideoSurface(int player_id, |
| 390 jobject surface) { | 391 jobject surface) { |
| 391 MediaPlayerAndroid* player = GetPlayer(player_id); | 392 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 392 if (player) { | 393 if (player) { |
| 393 player->SetVideoSurface( | 394 player->SetVideoSurface( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 } | 570 } |
| 570 | 571 |
| 571 void BrowserMediaPlayerManager::OnCreateSession( | 572 void BrowserMediaPlayerManager::OnCreateSession( |
| 572 int cdm_id, | 573 int cdm_id, |
| 573 uint32 session_id, | 574 uint32 session_id, |
| 574 CdmHostMsg_CreateSession_ContentType content_type, | 575 CdmHostMsg_CreateSession_ContentType content_type, |
| 575 const std::vector<uint8>& init_data) { | 576 const std::vector<uint8>& init_data) { |
| 576 if (init_data.size() > kMaxInitDataLength) { | 577 if (init_data.size() > kMaxInitDataLength) { |
| 577 LOG(WARNING) << "InitData for ID: " << cdm_id | 578 LOG(WARNING) << "InitData for ID: " << cdm_id |
| 578 << " too long: " << init_data.size(); | 579 << " too long: " << init_data.size(); |
| 579 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 580 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 580 return; | 581 return; |
| 581 } | 582 } |
| 582 | 583 |
| 583 // Convert the session content type into a MIME type. "audio" and "video" | 584 // Convert the session content type into a MIME type. "audio" and "video" |
| 584 // don't matter, so using "video" for the MIME type. | 585 // don't matter, so using "video" for the MIME type. |
| 585 // Ref: | 586 // Ref: |
| 586 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#dom-createsession | 587 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#dom-createsession |
| 587 std::string mime_type; | 588 std::string mime_type; |
| 588 switch (content_type) { | 589 switch (content_type) { |
| 589 case CREATE_SESSION_TYPE_WEBM: | 590 case CREATE_SESSION_TYPE_WEBM: |
| 590 mime_type = "video/webm"; | 591 mime_type = "video/webm"; |
| 591 break; | 592 break; |
| 592 case CREATE_SESSION_TYPE_MP4: | 593 case CREATE_SESSION_TYPE_MP4: |
| 593 mime_type = "video/mp4"; | 594 mime_type = "video/mp4"; |
| 594 break; | 595 break; |
| 595 default: | 596 default: |
| 596 NOTREACHED(); | 597 NOTREACHED(); |
| 597 return; | 598 return; |
| 598 } | 599 } |
| 599 | 600 |
| 600 if (CommandLine::ForCurrentProcess() | 601 if (CommandLine::ForCurrentProcess() |
| 601 ->HasSwitch(switches::kDisableInfobarForProtectedMediaIdentifier)) { | 602 ->HasSwitch(switches::kDisableInfobarForProtectedMediaIdentifier)) { |
| 602 CreateSessionIfPermitted(cdm_id, session_id, mime_type, init_data, true); | 603 CreateSessionIfPermitted(cdm_id, session_id, mime_type, init_data, true); |
| 603 return; | 604 return; |
| 604 } | 605 } |
| 605 | 606 |
| 606 MediaKeys* cdm = GetCdm(cdm_id); | 607 BrowserCdm* cdm = GetCdm(cdm_id); |
| 607 if (!cdm) { | 608 if (!cdm) { |
| 608 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; | 609 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; |
| 609 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 610 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 610 return; | 611 return; |
| 611 } | 612 } |
| 612 | 613 |
| 613 BrowserContext* context = | 614 BrowserContext* context = |
| 614 web_contents()->GetRenderProcessHost()->GetBrowserContext(); | 615 web_contents()->GetRenderProcessHost()->GetBrowserContext(); |
| 615 | 616 |
| 616 std::map<int, GURL>::const_iterator iter = | 617 std::map<int, GURL>::const_iterator iter = |
| 617 cdm_security_origin_map_.find(cdm_id); | 618 cdm_security_origin_map_.find(cdm_id); |
| 618 if (iter == cdm_security_origin_map_.end()) { | 619 if (iter == cdm_security_origin_map_.end()) { |
| 619 NOTREACHED(); | 620 NOTREACHED(); |
| 620 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 621 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 621 return; | 622 return; |
| 622 } | 623 } |
| 623 | 624 |
| 624 context->RequestProtectedMediaIdentifierPermission( | 625 context->RequestProtectedMediaIdentifierPermission( |
| 625 web_contents()->GetRenderProcessHost()->GetID(), | 626 web_contents()->GetRenderProcessHost()->GetID(), |
| 626 web_contents()->GetRenderViewHost()->GetRoutingID(), | 627 web_contents()->GetRenderViewHost()->GetRoutingID(), |
| 627 iter->second, | 628 iter->second, |
| 628 base::Bind(&BrowserMediaPlayerManager::CreateSessionIfPermitted, | 629 base::Bind(&BrowserMediaPlayerManager::CreateSessionIfPermitted, |
| 629 weak_ptr_factory_.GetWeakPtr(), | 630 weak_ptr_factory_.GetWeakPtr(), |
| 630 cdm_id, | 631 cdm_id, |
| 631 session_id, | 632 session_id, |
| 632 mime_type, | 633 mime_type, |
| 633 init_data)); | 634 init_data)); |
| 634 } | 635 } |
| 635 | 636 |
| 636 void BrowserMediaPlayerManager::OnUpdateSession( | 637 void BrowserMediaPlayerManager::OnUpdateSession( |
| 637 int cdm_id, | 638 int cdm_id, |
| 638 uint32 session_id, | 639 uint32 session_id, |
| 639 const std::vector<uint8>& response) { | 640 const std::vector<uint8>& response) { |
| 640 MediaKeys* cdm = GetCdm(cdm_id); | 641 BrowserCdm* cdm = GetCdm(cdm_id); |
| 641 if (!cdm) { | 642 if (!cdm) { |
| 642 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; | 643 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; |
| 643 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 644 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 644 return; | 645 return; |
| 645 } | 646 } |
| 646 | 647 |
| 647 if (response.size() > kMaxSessionResponseLength) { | 648 if (response.size() > kMaxSessionResponseLength) { |
| 648 LOG(WARNING) << "Response for ID " << cdm_id | 649 LOG(WARNING) << "Response for ID " << cdm_id |
| 649 << " is too long: " << response.size(); | 650 << " is too long: " << response.size(); |
| 650 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 651 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 651 return; | 652 return; |
| 652 } | 653 } |
| 653 | 654 |
| 654 cdm->UpdateSession(session_id, &response[0], response.size()); | 655 cdm->UpdateSession(session_id, &response[0], response.size()); |
| 655 | |
| 656 CdmToPlayerMap::const_iterator iter = cdm_to_player_map_.find(cdm_id); | |
| 657 if (iter == cdm_to_player_map_.end()) | |
| 658 return; | |
| 659 | |
| 660 int player_id = iter->second; | |
| 661 MediaPlayerAndroid* player = GetPlayer(player_id); | |
| 662 if (player) | |
| 663 player->OnKeyAdded(); | |
| 664 } | 656 } |
| 665 | 657 |
| 666 void BrowserMediaPlayerManager::OnReleaseSession(int cdm_id, | 658 void BrowserMediaPlayerManager::OnReleaseSession(int cdm_id, |
| 667 uint32 session_id) { | 659 uint32 session_id) { |
| 668 MediaKeys* cdm = GetCdm(cdm_id); | 660 BrowserCdm* cdm = GetCdm(cdm_id); |
| 669 if (!cdm) { | 661 if (!cdm) { |
| 670 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; | 662 DLOG(WARNING) << "No CDM for ID " << cdm_id << " found"; |
| 671 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 663 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 672 return; | 664 return; |
| 673 } | 665 } |
| 674 | 666 |
| 675 cdm->ReleaseSession(session_id); | 667 cdm->ReleaseSession(session_id); |
| 676 } | 668 } |
| 677 | 669 |
| 678 void BrowserMediaPlayerManager::OnDestroyCdm(int cdm_id) { | 670 void BrowserMediaPlayerManager::OnDestroyCdm(int cdm_id) { |
| 679 MediaKeys* cdm = GetCdm(cdm_id); | 671 BrowserCdm* cdm = GetCdm(cdm_id); |
| 680 if (!cdm) | 672 if (!cdm) |
| 681 return; | 673 return; |
| 682 | 674 |
| 683 CancelAllPendingSessionCreations(cdm_id); | 675 CancelAllPendingSessionCreations(cdm_id); |
| 684 RemoveCdm(cdm_id); | 676 RemoveCdm(cdm_id); |
| 685 } | 677 } |
| 686 | 678 |
| 687 void BrowserMediaPlayerManager::CancelAllPendingSessionCreations(int cdm_id) { | 679 void BrowserMediaPlayerManager::CancelAllPendingSessionCreations(int cdm_id) { |
| 688 BrowserContext* context = | 680 BrowserContext* context = |
| 689 web_contents()->GetRenderProcessHost()->GetBrowserContext(); | 681 web_contents()->GetRenderProcessHost()->GetBrowserContext(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 704 | 696 |
| 705 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { | 697 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { |
| 706 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 698 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
| 707 it != players_.end(); ++it) { | 699 it != players_.end(); ++it) { |
| 708 MediaPlayerAndroid* player = *it; | 700 MediaPlayerAndroid* player = *it; |
| 709 if (player->player_id() == player_id) { | 701 if (player->player_id() == player_id) { |
| 710 players_.erase(it); | 702 players_.erase(it); |
| 711 break; | 703 break; |
| 712 } | 704 } |
| 713 } | 705 } |
| 714 | |
| 715 for (CdmToPlayerMap::iterator it = cdm_to_player_map_.begin(); | |
| 716 it != cdm_to_player_map_.end(); | |
| 717 ++it) { | |
| 718 if (it->second == player_id) { | |
| 719 cdm_to_player_map_.erase(it); | |
| 720 break; | |
| 721 } | |
| 722 } | |
| 723 } | 706 } |
| 724 | 707 |
| 725 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer( | 708 scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer( |
| 726 int player_id, media::MediaPlayerAndroid* player) { | 709 int player_id, media::MediaPlayerAndroid* player) { |
| 727 media::MediaPlayerAndroid* previous_player = NULL; | 710 media::MediaPlayerAndroid* previous_player = NULL; |
| 728 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); | 711 for (ScopedVector<MediaPlayerAndroid>::iterator it = players_.begin(); |
| 729 it != players_.end(); ++it) { | 712 it != players_.end(); ++it) { |
| 730 if ((*it)->player_id() == player_id) { | 713 if ((*it)->player_id() == player_id) { |
| 731 previous_player = *it; | 714 previous_player = *it; |
| 732 players_.weak_erase(it); | 715 players_.weak_erase(it); |
| 733 players_.push_back(player); | 716 players_.push_back(player); |
| 734 break; | 717 break; |
| 735 } | 718 } |
| 736 } | 719 } |
| 737 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); | 720 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); |
| 738 } | 721 } |
| 739 | 722 |
| 740 void BrowserMediaPlayerManager::AddCdm(int cdm_id, | 723 void BrowserMediaPlayerManager::AddCdm(int cdm_id, |
| 741 const std::string& key_system, | 724 const std::string& key_system, |
| 742 const GURL& security_origin) { | 725 const GURL& security_origin) { |
| 743 DCHECK(!GetCdm(cdm_id)); | 726 DCHECK(!GetCdm(cdm_id)); |
| 744 base::WeakPtr<BrowserMediaPlayerManager> weak_this = | 727 base::WeakPtr<BrowserMediaPlayerManager> weak_this = |
| 745 weak_ptr_factory_.GetWeakPtr(); | 728 weak_ptr_factory_.GetWeakPtr(); |
| 746 | 729 |
| 747 scoped_ptr<MediaKeys> cdm(media::CreateBrowserCdm( | 730 const int& id = cdm_id; |
|
ddorwin
2014/05/30 20:50:05
nit: I think we usually just copy the value. The c
xhwang
2014/06/02 20:11:43
Done.
| |
| 731 scoped_ptr<BrowserCdm> cdm(media::CreateBrowserCdm( | |
| 748 key_system, | 732 key_system, |
| 749 base::Bind( | 733 base::Bind(&BrowserMediaPlayerManager::OnSessionCreated, weak_this, id), |
| 750 &BrowserMediaPlayerManager::OnSessionCreated, weak_this, cdm_id), | 734 base::Bind(&BrowserMediaPlayerManager::OnSessionMessage, weak_this, id), |
| 751 base::Bind( | 735 base::Bind(&BrowserMediaPlayerManager::OnSessionReady, weak_this, id), |
| 752 &BrowserMediaPlayerManager::OnSessionMessage, weak_this, cdm_id), | 736 base::Bind(&BrowserMediaPlayerManager::OnSessionClosed, weak_this, id), |
| 753 base::Bind( | 737 base::Bind(&BrowserMediaPlayerManager::OnSessionError, weak_this, id))); |
| 754 &BrowserMediaPlayerManager::OnSessionReady, weak_this, cdm_id), | |
| 755 base::Bind( | |
| 756 &BrowserMediaPlayerManager::OnSessionClosed, weak_this, cdm_id), | |
| 757 base::Bind( | |
| 758 &BrowserMediaPlayerManager::OnSessionError, weak_this, cdm_id))); | |
| 759 | 738 |
| 760 if (!cdm) { | 739 if (!cdm) { |
| 761 // This failure will be discovered and reported by OnCreateSession() | 740 // This failure will be discovered and reported by OnCreateSession() |
| 762 // as GetCdm() will return null. | 741 // as GetCdm() will return null. |
| 763 DVLOG(1) << "failed to create CDM."; | 742 DVLOG(1) << "failed to create CDM."; |
| 764 return; | 743 return; |
| 765 } | 744 } |
| 766 | 745 |
| 767 cdm_map_[cdm_id] = cdm.release(); | 746 cdm_map_[cdm_id] = cdm.release(); |
| 768 cdm_security_origin_map_[cdm_id] = security_origin; | 747 cdm_security_origin_map_[cdm_id] = security_origin; |
| 769 } | 748 } |
| 770 | 749 |
| 771 void BrowserMediaPlayerManager::RemoveCdm(int cdm_id) { | 750 void BrowserMediaPlayerManager::RemoveCdm(int cdm_id) { |
| 772 // TODO(xhwang): Detach CDM from the player it's set to. In prefixed | 751 // TODO(xhwang): Detach CDM from the player it's set to. In prefixed |
| 773 // EME implementation the current code is fine because we always destroy the | 752 // EME implementation the current code is fine because we always destroy the |
| 774 // player before we destroy the DrmBridge. This will not always be the case | 753 // player before we destroy the DrmBridge. This will not always be the case |
| 775 // in unprefixed EME implementation. | 754 // in unprefixed EME implementation. |
| 776 CdmMap::iterator iter = cdm_map_.find(cdm_id); | 755 CdmMap::iterator iter = cdm_map_.find(cdm_id); |
| 777 if (iter != cdm_map_.end()) { | 756 if (iter != cdm_map_.end()) { |
| 778 delete iter->second; | 757 delete iter->second; |
| 779 cdm_map_.erase(iter); | 758 cdm_map_.erase(iter); |
| 780 } | 759 } |
| 781 cdm_to_player_map_.erase(cdm_id); | |
| 782 cdm_security_origin_map_.erase(cdm_id); | 760 cdm_security_origin_map_.erase(cdm_id); |
| 783 } | 761 } |
| 784 | 762 |
| 785 void BrowserMediaPlayerManager::OnSetCdm(int player_id, int cdm_id) { | 763 void BrowserMediaPlayerManager::OnSetCdm(int player_id, int cdm_id) { |
| 786 MediaPlayerAndroid* player = GetPlayer(player_id); | 764 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 787 MediaKeys* cdm = GetCdm(cdm_id); | 765 BrowserCdm* cdm = GetCdm(cdm_id); |
| 766 // Currently we do not support detaching CDM from a player. | |
|
ddorwin
2014/05/30 20:50:05
Is this prevented by Blink? If so, DCHECK()? If no
xhwang
2014/06/02 20:11:43
This is prevented by the WMPA. Added NOT_REACHED.
| |
| 788 if (!cdm || !player) { | 767 if (!cdm || !player) { |
| 789 DVLOG(1) << "Cannot set CDM on the specified player."; | 768 DVLOG(1) << "Cannot set CDM on the specified player."; |
| 790 return; | 769 return; |
| 791 } | 770 } |
| 792 | 771 |
| 793 // TODO(qinmin): add the logic to decide whether we should create the | 772 // TODO(qinmin): add the logic to decide whether we should create the |
| 794 // fullscreen surface for EME lv1. | 773 // fullscreen surface for EME lv1. |
| 795 player->SetCdm(cdm); | 774 player->SetCdm(cdm); |
| 796 // Do now support setting one CDM on multiple players. | |
| 797 | |
| 798 if (ContainsKey(cdm_to_player_map_, cdm_id)) { | |
| 799 DVLOG(1) << "CDM is already set on another player."; | |
| 800 return; | |
| 801 } | |
| 802 | |
| 803 cdm_to_player_map_[cdm_id] = player_id; | |
| 804 } | 775 } |
| 805 | 776 |
| 806 int BrowserMediaPlayerManager::RoutingID() { | 777 int BrowserMediaPlayerManager::RoutingID() { |
| 807 return render_frame_host_->GetRoutingID(); | 778 return render_frame_host_->GetRoutingID(); |
| 808 } | 779 } |
| 809 | 780 |
| 810 bool BrowserMediaPlayerManager::Send(IPC::Message* msg) { | 781 bool BrowserMediaPlayerManager::Send(IPC::Message* msg) { |
| 811 return render_frame_host_->Send(msg); | 782 return render_frame_host_->Send(msg); |
| 812 } | 783 } |
| 813 | 784 |
| 814 void BrowserMediaPlayerManager::CreateSessionIfPermitted( | 785 void BrowserMediaPlayerManager::CreateSessionIfPermitted( |
| 815 int cdm_id, | 786 int cdm_id, |
| 816 uint32 session_id, | 787 uint32 session_id, |
| 817 const std::string& content_type, | 788 const std::string& content_type, |
| 818 const std::vector<uint8>& init_data, | 789 const std::vector<uint8>& init_data, |
| 819 bool permitted) { | 790 bool permitted) { |
| 820 if (!permitted) { | 791 if (!permitted) { |
| 821 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 792 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 822 return; | 793 return; |
| 823 } | 794 } |
| 824 | 795 |
| 825 MediaKeys* cdm = GetCdm(cdm_id); | 796 BrowserCdm* cdm = GetCdm(cdm_id); |
| 826 if (!cdm) { | 797 if (!cdm) { |
| 827 DLOG(WARNING) << "No CDM for ID: " << cdm_id << " found"; | 798 DLOG(WARNING) << "No CDM for ID: " << cdm_id << " found"; |
| 828 OnSessionError(cdm_id, session_id, media::MediaKeys::kUnknownError, 0); | 799 OnSessionError(cdm_id, session_id, MediaKeys::kUnknownError, 0); |
| 829 return; | 800 return; |
| 830 } | 801 } |
| 831 | 802 |
| 832 // This could fail, in which case a SessionError will be fired. | 803 // This could fail, in which case a SessionError will be fired. |
| 833 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size()); | 804 cdm->CreateSession(session_id, content_type, &init_data[0], init_data.size()); |
| 834 } | 805 } |
| 835 | 806 |
| 836 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( | 807 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( |
| 837 MediaPlayerAndroid* player) { | 808 MediaPlayerAndroid* player) { |
| 838 player->Release(); | 809 player->Release(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 870 #if defined(VIDEO_HOLE) | 841 #if defined(VIDEO_HOLE) |
| 871 MediaPlayerAndroid* player = GetPlayer(player_id); | 842 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 872 if (player && player->IsSurfaceInUse()) | 843 if (player && player->IsSurfaceInUse()) |
| 873 return; | 844 return; |
| 874 if (external_video_surface_container_) | 845 if (external_video_surface_container_) |
| 875 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); | 846 external_video_surface_container_->ReleaseExternalVideoSurface(player_id); |
| 876 #endif // defined(VIDEO_HOLE) | 847 #endif // defined(VIDEO_HOLE) |
| 877 } | 848 } |
| 878 | 849 |
| 879 } // namespace content | 850 } // namespace content |
| OLD | NEW |