| 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 "webkit/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "cc/layers/video_layer.h" | 13 #include "cc/layers/video_layer.h" |
| 14 #include "content/renderer/media/android/proxy_media_keys.h" |
| 15 #include "content/renderer/media/android/webmediaplayer_manager_android.h" |
| 16 #include "content/renderer/media/android/webmediaplayer_proxy_android.h" |
| 14 #include "gpu/GLES2/gl2extchromium.h" | 17 #include "gpu/GLES2/gl2extchromium.h" |
| 15 #include "media/base/android/media_player_android.h" | 18 #include "media/base/android/media_player_android.h" |
| 16 #include "media/base/bind_to_loop.h" | 19 #include "media/base/bind_to_loop.h" |
| 17 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 18 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 19 #include "net/base/mime_util.h" | 22 #include "net/base/mime_util.h" |
| 20 #include "third_party/WebKit/public/platform/WebString.h" | 23 #include "third_party/WebKit/public/platform/WebString.h" |
| 21 #include "third_party/WebKit/public/web/WebDocument.h" | 24 #include "third_party/WebKit/public/web/WebDocument.h" |
| 22 #include "third_party/WebKit/public/web/WebFrame.h" | 25 #include "third_party/WebKit/public/web/WebFrame.h" |
| 23 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" | 26 #include "third_party/WebKit/public/web/WebMediaPlayerClient.h" |
| 24 #include "third_party/WebKit/public/web/WebMediaSource.h" | 27 #include "third_party/WebKit/public/web/WebMediaSource.h" |
| 25 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 28 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 26 #include "third_party/WebKit/public/web/WebView.h" | 29 #include "third_party/WebKit/public/web/WebView.h" |
| 27 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 30 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| 28 #include "webkit/renderer/media/android/webmediaplayer_manager_android.h" | |
| 29 #include "webkit/renderer/media/android/webmediaplayer_proxy_android.h" | |
| 30 #include "webkit/renderer/media/crypto/key_systems.h" | 31 #include "webkit/renderer/media/crypto/key_systems.h" |
| 31 #include "webkit/renderer/media/webmediaplayer_delegate.h" | 32 #include "webkit/renderer/media/webmediaplayer_delegate.h" |
| 32 #include "webkit/renderer/media/webmediaplayer_util.h" | 33 #include "webkit/renderer/media/webmediaplayer_util.h" |
| 33 | 34 |
| 34 #if defined(GOOGLE_TV) | 35 #if defined(GOOGLE_TV) |
| 35 #include "webkit/renderer/media/media_stream_audio_renderer.h" | 36 #include "content/renderer/media/media_stream_audio_renderer.h" |
| 36 #include "webkit/renderer/media/media_stream_client.h" | 37 #include "content/renderer/media/media_stream_client.h" |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 static const uint32 kGLTextureExternalOES = 0x8D65; | 40 static const uint32 kGLTextureExternalOES = 0x8D65; |
| 40 | 41 |
| 41 using WebKit::WebMediaPlayer; | 42 using WebKit::WebMediaPlayer; |
| 42 using WebKit::WebMediaSource; | 43 using WebKit::WebMediaSource; |
| 43 using WebKit::WebSize; | 44 using WebKit::WebSize; |
| 44 using WebKit::WebString; | 45 using WebKit::WebString; |
| 45 using WebKit::WebTimeRanges; | 46 using WebKit::WebTimeRanges; |
| 46 using WebKit::WebURL; | 47 using WebKit::WebURL; |
| 47 using media::MediaPlayerAndroid; | 48 using media::MediaPlayerAndroid; |
| 48 using media::VideoFrame; | 49 using media::VideoFrame; |
| 50 using webkit_media::ConvertSecondsToTimestamp; |
| 51 using webkit_media::IsSupportedKeySystem; |
| 52 using webkit_media::KeySystemNameForUMA; |
| 53 using webkit_media::ProxyDecryptor; |
| 54 using webkit_media::WebMediaPlayerDelegate; |
| 49 | 55 |
| 50 namespace { | 56 namespace { |
| 51 // Prefix for histograms related to Encrypted Media Extensions. | 57 // Prefix for histograms related to Encrypted Media Extensions. |
| 52 const char* kMediaEme = "Media.EME."; | 58 const char* kMediaEme = "Media.EME."; |
| 53 } // namespace | 59 } // namespace |
| 54 | 60 |
| 55 namespace webkit_media { | 61 namespace content { |
| 56 | 62 |
| 57 #define BIND_TO_RENDER_LOOP(function) \ | 63 #define BIND_TO_RENDER_LOOP(function) \ |
| 58 media::BindToLoop(main_loop_, base::Bind(function, AsWeakPtr())) | 64 media::BindToLoop(main_loop_, base::Bind(function, AsWeakPtr())) |
| 59 | 65 |
| 60 WebMediaPlayerAndroid::WebMediaPlayerAndroid( | 66 WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
| 61 WebKit::WebFrame* frame, | 67 WebKit::WebFrame* frame, |
| 62 WebKit::WebMediaPlayerClient* client, | 68 WebKit::WebMediaPlayerClient* client, |
| 63 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 69 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 64 WebMediaPlayerManagerAndroid* manager, | 70 WebMediaPlayerManagerAndroid* manager, |
| 65 WebMediaPlayerProxyAndroid* proxy, | 71 WebMediaPlayerProxyAndroid* proxy, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 115 } |
| 110 | 116 |
| 111 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) { | 117 if (WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) { |
| 112 // |decryptor_| is owned, so Unretained() is safe here. | 118 // |decryptor_| is owned, so Unretained() is safe here. |
| 113 decryptor_.reset(new ProxyDecryptor( | 119 decryptor_.reset(new ProxyDecryptor( |
| 114 #if defined(ENABLE_PEPPER_CDMS) | 120 #if defined(ENABLE_PEPPER_CDMS) |
| 115 client, | 121 client, |
| 116 frame, | 122 frame, |
| 117 #endif // defined(ENABLE_PEPPER_CDMS) | 123 #endif // defined(ENABLE_PEPPER_CDMS) |
| 118 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) | 124 #if defined(OS_ANDROID) && !defined(GOOGLE_TV) |
| 119 proxy_, | 125 // TODO(xhwang): Use media_keys_id when MediaKeys are separated from |
| 120 player_id_, // TODO(xhwang): Use media_keys_id when MediaKeys are | 126 // WebMediaPlayer. |
| 121 // separated from WebMediaPlayer. | 127 scoped_ptr<media::MediaKeys>(new ProxyMediaKeys(proxy_, player_id_)), |
| 122 #endif // defined(OS_ANDROID) && !defined(GOOGLE_TV) | 128 #endif // defined(OS_ANDROID) && !defined(GOOGLE_TV) |
| 123 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)), | 129 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, base::Unretained(this)), |
| 124 base::Bind(&WebMediaPlayerAndroid::OnKeyError, base::Unretained(this)), | 130 base::Bind(&WebMediaPlayerAndroid::OnKeyError, base::Unretained(this)), |
| 125 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, | 131 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, |
| 126 base::Unretained(this)))); | 132 base::Unretained(this)))); |
| 127 } | 133 } |
| 128 } | 134 } |
| 129 | 135 |
| 130 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 136 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| 131 SetVideoFrameProviderClient(NULL); | 137 SetVideoFrameProviderClient(NULL); |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 } | 1109 } |
| 1104 | 1110 |
| 1105 void WebMediaPlayerAndroid::exitFullscreen() { | 1111 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1106 proxy_->ExitFullscreen(player_id_); | 1112 proxy_->ExitFullscreen(player_id_); |
| 1107 } | 1113 } |
| 1108 | 1114 |
| 1109 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1115 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1110 return manager_->CanEnterFullscreen(frame_); | 1116 return manager_->CanEnterFullscreen(frame_); |
| 1111 } | 1117 } |
| 1112 | 1118 |
| 1113 } // namespace webkit_media | 1119 } // namespace content |
| OLD | NEW |