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/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "cc/layers/video_layer.h" | 15 #include "cc/layers/video_layer.h" |
16 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
17 #include "content/renderer/media/android/proxy_media_keys.h" | 17 #include "content/renderer/media/android/proxy_media_keys.h" |
18 #include "content/renderer/media/android/renderer_demuxer_android.h" | 18 #include "content/renderer/media/android/renderer_demuxer_android.h" |
19 #include "content/renderer/media/android/renderer_media_player_manager.h" | 19 #include "content/renderer/media/android/renderer_media_player_manager.h" |
20 #include "content/renderer/media/crypto/key_systems.h" | 20 #include "content/renderer/media/crypto/key_systems.h" |
21 #include "content/renderer/media/webmediaplayer_delegate.h" | 21 #include "content/renderer/media/webmediaplayer_delegate.h" |
22 #include "content/renderer/media/webmediaplayer_util.h" | 22 #include "content/renderer/media/webmediaplayer_util.h" |
23 #include "content/renderer/render_thread_impl.h" | 23 #include "content/renderer/render_thread_impl.h" |
24 #include "gpu/GLES2/gl2extchromium.h" | 24 #include "gpu/GLES2/gl2extchromium.h" |
25 #include "gpu/command_buffer/client/gles2_interface.h" | 25 #include "gpu/command_buffer/client/gles2_interface.h" |
| 26 #include "gpu/command_buffer/common/mailbox_holder.h" |
26 #include "grit/content_resources.h" | 27 #include "grit/content_resources.h" |
27 #include "media/base/android/media_player_android.h" | 28 #include "media/base/android/media_player_android.h" |
28 #include "media/base/bind_to_current_loop.h" | 29 #include "media/base/bind_to_current_loop.h" |
29 #include "media/base/media_switches.h" | 30 #include "media/base/media_switches.h" |
30 #include "media/base/video_frame.h" | 31 #include "media/base/video_frame.h" |
31 #include "net/base/mime_util.h" | 32 #include "net/base/mime_util.h" |
32 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 33 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
33 #include "third_party/WebKit/public/platform/WebString.h" | 34 #include "third_party/WebKit/public/platform/WebString.h" |
34 #include "third_party/WebKit/public/web/WebDocument.h" | 35 #include "third_party/WebKit/public/web/WebDocument.h" |
35 #include "third_party/WebKit/public/web/WebFrame.h" | 36 #include "third_party/WebKit/public/web/WebFrame.h" |
(...skipping 20 matching lines...) Expand all Loading... |
56 // Prefix for histograms related to Encrypted Media Extensions. | 57 // Prefix for histograms related to Encrypted Media Extensions. |
57 const char* kMediaEme = "Media.EME."; | 58 const char* kMediaEme = "Media.EME."; |
58 } // namespace | 59 } // namespace |
59 | 60 |
60 namespace content { | 61 namespace content { |
61 | 62 |
62 // static | 63 // static |
63 void WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture( | 64 void WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture( |
64 const scoped_refptr<base::MessageLoopProxy>& main_loop, | 65 const scoped_refptr<base::MessageLoopProxy>& main_loop, |
65 const base::WeakPtr<WebMediaPlayerAndroid>& player, | 66 const base::WeakPtr<WebMediaPlayerAndroid>& player, |
66 uint32 sync_point) { | 67 const gpu::MailboxHolder* mailbox_holder) { |
67 main_loop->PostTask( | 68 main_loop->PostTask( |
68 FROM_HERE, | 69 FROM_HERE, |
69 base::Bind(&WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture, | 70 base::Bind(&WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture, |
70 player, | 71 player, |
71 sync_point)); | 72 mailbox_holder->sync_point)); |
72 } | 73 } |
73 | 74 |
74 WebMediaPlayerAndroid::WebMediaPlayerAndroid( | 75 WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
75 blink::WebFrame* frame, | 76 blink::WebFrame* frame, |
76 blink::WebMediaPlayerClient* client, | 77 blink::WebMediaPlayerClient* client, |
77 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 78 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
78 RendererMediaPlayerManager* manager, | 79 RendererMediaPlayerManager* manager, |
79 StreamTextureFactory* factory, | 80 StreamTextureFactory* factory, |
80 const scoped_refptr<base::MessageLoopProxy>& media_loop, | 81 const scoped_refptr<base::MessageLoopProxy>& media_loop, |
81 media::MediaLog* media_log) | 82 media::MediaLog* media_log) |
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 bitmap.getPixels()); | 928 bitmap.getPixels()); |
928 } | 929 } |
929 | 930 |
930 gpu::Mailbox texture_mailbox; | 931 gpu::Mailbox texture_mailbox; |
931 gl->GenMailboxCHROMIUM(texture_mailbox.name); | 932 gl->GenMailboxCHROMIUM(texture_mailbox.name); |
932 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); | 933 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); |
933 gl->Flush(); | 934 gl->Flush(); |
934 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 935 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
935 | 936 |
936 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 937 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
937 make_scoped_ptr(new VideoFrame::MailboxHolder( | 938 make_scoped_ptr(new gpu::MailboxHolder( |
938 texture_mailbox, | 939 texture_mailbox, texture_target, texture_mailbox_sync_point)), |
939 texture_mailbox_sync_point, | 940 base::Bind(&WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture, |
940 base::Bind(&WebMediaPlayerAndroid::OnReleaseRemotePlaybackTexture, | 941 main_loop_, |
941 main_loop_, | 942 weak_factory_.GetWeakPtr()), |
942 weak_factory_.GetWeakPtr()))), | |
943 texture_target, | |
944 canvas_size /* coded_size */, | 943 canvas_size /* coded_size */, |
945 gfx::Rect(canvas_size) /* visible_rect */, | 944 gfx::Rect(canvas_size) /* visible_rect */, |
946 canvas_size /* natural_size */, | 945 canvas_size /* natural_size */, |
947 base::TimeDelta() /* timestamp */, | 946 base::TimeDelta() /* timestamp */, |
948 VideoFrame::ReadPixelsCB(), | 947 VideoFrame::ReadPixelsCB()); |
949 base::Closure() /* no_longer_needed_cb */); | |
950 SetCurrentFrameInternal(new_frame); | 948 SetCurrentFrameInternal(new_frame); |
951 } | 949 } |
952 | 950 |
953 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 951 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
954 if (needs_external_surface_) { | 952 if (needs_external_surface_) { |
955 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. | 953 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. |
956 #if defined(VIDEO_HOLE) | 954 #if defined(VIDEO_HOLE) |
957 if (!natural_size_.isEmpty()) { | 955 if (!natural_size_.isEmpty()) { |
958 scoped_refptr<VideoFrame> new_frame = | 956 scoped_refptr<VideoFrame> new_frame = |
959 VideoFrame::CreateHoleFrame(natural_size_); | 957 VideoFrame::CreateHoleFrame(natural_size_); |
960 SetCurrentFrameInternal(new_frame); | 958 SetCurrentFrameInternal(new_frame); |
961 // Force the client to grab the hole frame. | 959 // Force the client to grab the hole frame. |
962 client_->repaint(); | 960 client_->repaint(); |
963 } | 961 } |
964 #else | 962 #else |
965 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; | 963 NOTIMPLEMENTED() << "Hole punching not supported without VIDEO_HOLE flag"; |
966 #endif // defined(VIDEO_HOLE) | 964 #endif // defined(VIDEO_HOLE) |
967 } else if (!is_remote_ && texture_id_) { | 965 } else if (!is_remote_ && texture_id_) { |
968 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 966 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
969 make_scoped_ptr(new VideoFrame::MailboxHolder( | 967 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox_, |
970 texture_mailbox_, | 968 kGLTextureExternalOES, |
971 texture_mailbox_sync_point_, | 969 texture_mailbox_sync_point_)), |
972 VideoFrame::MailboxHolder::TextureNoLongerNeededCallback())), | 970 media::VideoFrame::ReleaseMailboxCB(), |
973 kGLTextureExternalOES, | |
974 natural_size_, | 971 natural_size_, |
975 gfx::Rect(natural_size_), | 972 gfx::Rect(natural_size_), |
976 natural_size_, | 973 natural_size_, |
977 base::TimeDelta(), | 974 base::TimeDelta(), |
978 VideoFrame::ReadPixelsCB(), | 975 VideoFrame::ReadPixelsCB()); |
979 base::Closure()); | |
980 SetCurrentFrameInternal(new_frame); | 976 SetCurrentFrameInternal(new_frame); |
981 } | 977 } |
982 } | 978 } |
983 | 979 |
984 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 980 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
985 cc::VideoFrameProvider::Client* client) { | 981 cc::VideoFrameProvider::Client* client) { |
986 // This is called from both the main renderer thread and the compositor | 982 // This is called from both the main renderer thread and the compositor |
987 // thread (when the main thread is blocked). | 983 // thread (when the main thread is blocked). |
988 if (video_frame_provider_client_) | 984 if (video_frame_provider_client_) |
989 video_frame_provider_client_->StopUsingProvider(); | 985 video_frame_provider_client_->StopUsingProvider(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 | 1366 |
1371 void WebMediaPlayerAndroid::exitFullscreen() { | 1367 void WebMediaPlayerAndroid::exitFullscreen() { |
1372 manager_->ExitFullscreen(player_id_); | 1368 manager_->ExitFullscreen(player_id_); |
1373 } | 1369 } |
1374 | 1370 |
1375 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1371 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
1376 return manager_->CanEnterFullscreen(frame_); | 1372 return manager_->CanEnterFullscreen(frame_); |
1377 } | 1373 } |
1378 | 1374 |
1379 } // namespace content | 1375 } // namespace content |
OLD | NEW |