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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/android/content_view_core_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
9 #include "content/browser/media/android/browser_demuxer_android.h" | 9 #include "content/browser/media/android/browser_demuxer_android.h" |
10 #include "content/browser/media/android/media_resource_getter_impl.h" | 10 #include "content/browser/media/android/media_resource_getter_impl.h" |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 | 599 |
600 AddDrmBridge(media_keys_id, uuid, frame_url); | 600 AddDrmBridge(media_keys_id, uuid, frame_url); |
601 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id| | 601 // In EME v0.1b MediaKeys lives in the media element. So the |media_keys_id| |
602 // is the same as the |player_id|. | 602 // is the same as the |player_id|. |
603 OnSetMediaKeys(media_keys_id, media_keys_id); | 603 OnSetMediaKeys(media_keys_id, media_keys_id); |
604 } | 604 } |
605 | 605 |
606 void BrowserMediaPlayerManager::OnCreateSession( | 606 void BrowserMediaPlayerManager::OnCreateSession( |
607 int media_keys_id, | 607 int media_keys_id, |
608 uint32 session_id, | 608 uint32 session_id, |
609 MediaKeysHostMsg_CreateSession_Type type, | 609 MediaKeysHostMsg_CreateSession_Type content_type, |
610 const std::vector<uint8>& init_data) { | 610 const std::vector<uint8>& init_data) { |
611 if (init_data.size() > kEmeInitDataMaximum) { | 611 if (init_data.size() > kEmeInitDataMaximum) { |
612 LOG(WARNING) << "InitData for ID: " << media_keys_id | 612 LOG(WARNING) << "InitData for ID: " << media_keys_id |
613 << " too long: " << init_data.size(); | 613 << " too long: " << init_data.size(); |
614 OnSessionError( | 614 OnSessionError( |
615 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); | 615 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); |
616 return; | 616 return; |
617 } | 617 } |
618 | 618 |
619 // Convert the session type into a MIME type. "audio" and "video" don't | 619 // Convert the session content type into a MIME type. "audio" and "video" |
620 // matter, so using "video" for the MIME type. | 620 // don't matter, so using "video" for the MIME type. |
621 // Ref: https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypt ed-media.html#dom-createsession | 621 // Ref: |
622 // https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-me dia.html#dom-createsession | |
ddorwin
2014/02/10 19:05:25
s/tip/default/ wherever you see it.
xhwang
2014/02/10 22:30:55
Done.
| |
622 std::string mime_type; | 623 std::string mime_type; |
623 switch (type) { | 624 switch (content_type) { |
624 case CREATE_SESSION_TYPE_WEBM: | 625 case CREATE_SESSION_TYPE_WEBM: |
625 mime_type = "video/webm"; | 626 mime_type = "video/webm"; |
626 break; | 627 break; |
627 case CREATE_SESSION_TYPE_MP4: | 628 case CREATE_SESSION_TYPE_MP4: |
628 mime_type = "video/mp4"; | 629 mime_type = "video/mp4"; |
629 break; | 630 break; |
630 default: | 631 default: |
631 NOTREACHED(); | 632 NOTREACHED(); |
632 return; | 633 return; |
633 } | 634 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
815 return; | 816 return; |
816 } | 817 } |
817 // TODO(qinmin): add the logic to decide whether we should create the | 818 // TODO(qinmin): add the logic to decide whether we should create the |
818 // fullscreen surface for EME lv1. | 819 // fullscreen surface for EME lv1. |
819 player->SetDrmBridge(drm_bridge); | 820 player->SetDrmBridge(drm_bridge); |
820 } | 821 } |
821 | 822 |
822 void BrowserMediaPlayerManager::CreateSessionIfPermitted( | 823 void BrowserMediaPlayerManager::CreateSessionIfPermitted( |
823 int media_keys_id, | 824 int media_keys_id, |
824 uint32 session_id, | 825 uint32 session_id, |
825 const std::string& type, | 826 const std::string& content_type, |
826 const std::vector<uint8>& init_data, | 827 const std::vector<uint8>& init_data, |
827 bool permitted) { | 828 bool permitted) { |
828 if (!permitted) { | 829 if (!permitted) { |
829 OnSessionError( | 830 OnSessionError( |
830 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); | 831 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); |
831 return; | 832 return; |
832 } | 833 } |
833 | 834 |
834 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); | 835 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); |
835 if (!drm_bridge) { | 836 if (!drm_bridge) { |
836 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; | 837 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; |
837 OnSessionError( | 838 OnSessionError( |
838 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); | 839 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); |
839 return; | 840 return; |
840 } | 841 } |
841 media_keys_ids_pending_approval_.erase(media_keys_id); | 842 media_keys_ids_pending_approval_.erase(media_keys_id); |
842 media_keys_ids_approved_.insert(media_keys_id); | 843 media_keys_ids_approved_.insert(media_keys_id); |
843 drm_bridge->CreateSession(session_id, type, &init_data[0], init_data.size()); | 844 |
845 if (!drm_bridge->CreateSession( | |
846 session_id, content_type, &init_data[0], init_data.size())) { | |
847 OnSessionError( | |
848 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); | |
849 return; | |
850 } | |
851 | |
852 // TODO(xhwang): Move the following code to OnSessionReady. | |
844 | 853 |
845 // TODO(qinmin): currently |media_keys_id| and player ID are identical. | 854 // TODO(qinmin): currently |media_keys_id| and player ID are identical. |
846 // This might not be true in the future. | 855 // This might not be true in the future. |
847 if (pending_fullscreen_player_id_ != media_keys_id) | 856 if (pending_fullscreen_player_id_ != media_keys_id) |
848 return; | 857 return; |
849 | 858 |
850 pending_fullscreen_player_id_ = -1; | 859 pending_fullscreen_player_id_ = -1; |
851 MediaPlayerAndroid* player = GetPlayer(media_keys_id); | 860 MediaPlayerAndroid* player = GetPlayer(media_keys_id); |
852 if (player->IsPlaying()) | 861 if (player->IsPlaying()) |
853 OnProtectedSurfaceRequested(media_keys_id); | 862 OnProtectedSurfaceRequested(media_keys_id); |
854 } | 863 } |
855 | 864 |
856 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( | 865 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( |
857 MediaPlayerAndroid* player) { | 866 MediaPlayerAndroid* player) { |
858 player->Release(); | 867 player->Release(); |
859 } | 868 } |
860 | 869 |
861 } // namespace content | 870 } // namespace content |
OLD | NEW |