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/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_to_current_loop.h" |
11 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "cc/blink/web_layer_impl.h" | 20 #include "cc/blink/web_layer_impl.h" |
20 #include "cc/layers/video_layer.h" | 21 #include "cc/layers/video_layer.h" |
21 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
22 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
23 #include "content/public/common/renderer_preferences.h" | 24 #include "content/public/common/renderer_preferences.h" |
24 #include "content/public/renderer/render_frame.h" | 25 #include "content/public/renderer/render_frame.h" |
25 #include "content/renderer/media/android/renderer_demuxer_android.h" | 26 #include "content/renderer/media/android/renderer_demuxer_android.h" |
26 #include "content/renderer/media/android/renderer_media_player_manager.h" | 27 #include "content/renderer/media/android/renderer_media_player_manager.h" |
27 #include "content/renderer/media/crypto/render_cdm_factory.h" | 28 #include "content/renderer/media/crypto/render_cdm_factory.h" |
28 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 29 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
29 #include "content/renderer/render_frame_impl.h" | 30 #include "content/renderer/render_frame_impl.h" |
30 #include "content/renderer/render_thread_impl.h" | 31 #include "content/renderer/render_thread_impl.h" |
31 #include "content/renderer/render_view_impl.h" | 32 #include "content/renderer/render_view_impl.h" |
32 #include "gpu/GLES2/gl2extchromium.h" | 33 #include "gpu/GLES2/gl2extchromium.h" |
33 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
34 #include "gpu/command_buffer/common/mailbox_holder.h" | 35 #include "gpu/command_buffer/common/mailbox_holder.h" |
35 #include "media/base/android/media_common_android.h" | 36 #include "media/base/android/media_common_android.h" |
36 #include "media/base/android/media_player_android.h" | 37 #include "media/base/android/media_player_android.h" |
37 #include "media/base/bind_to_current_loop.h" | |
38 #include "media/base/cdm_context.h" | 38 #include "media/base/cdm_context.h" |
39 #include "media/base/key_systems.h" | 39 #include "media/base/key_systems.h" |
40 #include "media/base/media_keys.h" | 40 #include "media/base/media_keys.h" |
41 #include "media/base/media_log.h" | 41 #include "media/base/media_log.h" |
42 #include "media/base/media_switches.h" | 42 #include "media/base/media_switches.h" |
43 #include "media/base/video_frame.h" | 43 #include "media/base/video_frame.h" |
44 #include "media/blink/webcontentdecryptionmodule_impl.h" | 44 #include "media/blink/webcontentdecryptionmodule_impl.h" |
45 #include "media/blink/webmediaplayer_delegate.h" | 45 #include "media/blink/webmediaplayer_delegate.h" |
46 #include "media/blink/webmediaplayer_util.h" | 46 #include "media/blink/webmediaplayer_util.h" |
47 #include "net/base/mime_util.h" | 47 #include "net/base/mime_util.h" |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 | 1197 |
1198 gpu::Mailbox texture_mailbox; | 1198 gpu::Mailbox texture_mailbox; |
1199 gl->GenMailboxCHROMIUM(texture_mailbox.name); | 1199 gl->GenMailboxCHROMIUM(texture_mailbox.name); |
1200 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); | 1200 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); |
1201 gl->Flush(); | 1201 gl->Flush(); |
1202 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 1202 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
1203 | 1203 |
1204 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 1204 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
1205 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox, texture_target, | 1205 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox, texture_target, |
1206 texture_mailbox_sync_point)), | 1206 texture_mailbox_sync_point)), |
1207 media::BindToCurrentLoop(base::Bind(&OnReleaseTexture, | 1207 base::BindToCurrentLoop(base::Bind(&OnReleaseTexture, |
1208 stream_texture_factory_, | 1208 stream_texture_factory_, |
1209 remote_playback_texture_id)), | 1209 remote_playback_texture_id)), |
1210 canvas_size /* coded_size */, gfx::Rect(canvas_size) /* visible_rect */, | 1210 canvas_size /* coded_size */, gfx::Rect(canvas_size) /* visible_rect */, |
1211 canvas_size /* natural_size */, base::TimeDelta() /* timestamp */, | 1211 canvas_size /* natural_size */, base::TimeDelta() /* timestamp */, |
1212 false /* allow overlay */); | 1212 false /* allow overlay */); |
1213 SetCurrentFrameInternal(new_frame); | 1213 SetCurrentFrameInternal(new_frame); |
1214 } | 1214 } |
1215 | 1215 |
1216 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 1216 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
1217 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1217 DCHECK(main_thread_checker_.CalledOnValidThread()); |
(...skipping 17 matching lines...) Expand all Loading... |
1235 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1235 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
1236 GLuint texture_target = kGLTextureExternalOES; | 1236 GLuint texture_target = kGLTextureExternalOES; |
1237 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( | 1237 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( |
1238 texture_target, texture_mailbox_.name); | 1238 texture_target, texture_mailbox_.name); |
1239 gl->Flush(); | 1239 gl->Flush(); |
1240 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 1240 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
1241 | 1241 |
1242 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 1242 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
1243 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox_, texture_target, | 1243 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox_, texture_target, |
1244 texture_mailbox_sync_point)), | 1244 texture_mailbox_sync_point)), |
1245 media::BindToCurrentLoop(base::Bind( | 1245 base::BindToCurrentLoop(base::Bind( |
1246 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), | 1246 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), |
1247 natural_size_, gfx::Rect(natural_size_), natural_size_, | 1247 natural_size_, gfx::Rect(natural_size_), natural_size_, |
1248 base::TimeDelta(), false); | 1248 base::TimeDelta(), false); |
1249 SetCurrentFrameInternal(new_frame); | 1249 SetCurrentFrameInternal(new_frame); |
1250 } | 1250 } |
1251 } | 1251 } |
1252 | 1252 |
1253 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 1253 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
1254 cc::VideoFrameProvider::Client* client) { | 1254 cc::VideoFrameProvider::Client* client) { |
1255 // This is called from both the main renderer thread and the compositor | 1255 // This is called from both the main renderer thread and the compositor |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 result.completeWithError( | 1653 result.completeWithError( |
1654 blink::WebContentDecryptionModuleExceptionNotSupportedError, | 1654 blink::WebContentDecryptionModuleExceptionNotSupportedError, |
1655 0, | 1655 0, |
1656 "Null MediaKeys object is not supported."); | 1656 "Null MediaKeys object is not supported."); |
1657 return; | 1657 return; |
1658 } | 1658 } |
1659 | 1659 |
1660 cdm_context_ = media::ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(); | 1660 cdm_context_ = media::ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(); |
1661 | 1661 |
1662 if (is_player_initialized_) { | 1662 if (is_player_initialized_) { |
1663 SetCdmInternal(media::BindToCurrentLoop( | 1663 SetCdmInternal(base::BindToCurrentLoop( |
1664 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, | 1664 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, |
1665 weak_factory_.GetWeakPtr(), result))); | 1665 weak_factory_.GetWeakPtr(), result))); |
1666 } else { | 1666 } else { |
1667 // No pipeline/decoder connected, so resolve the promise. When something | 1667 // No pipeline/decoder connected, so resolve the promise. When something |
1668 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). | 1668 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). |
1669 ContentDecryptionModuleAttached(result, true); | 1669 ContentDecryptionModuleAttached(result, true); |
1670 } | 1670 } |
1671 } | 1671 } |
1672 | 1672 |
1673 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( | 1673 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1854 | 1854 |
1855 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1855 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1856 std::string mime; | 1856 std::string mime; |
1857 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1857 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1858 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1858 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1859 return false; | 1859 return false; |
1860 return !mime.compare("application/x-mpegurl"); | 1860 return !mime.compare("application/x-mpegurl"); |
1861 } | 1861 } |
1862 | 1862 |
1863 } // namespace content | 1863 } // namespace content |
OLD | NEW |