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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "content/public/common/renderer_preferences.h" | 23 #include "content/public/common/renderer_preferences.h" |
24 #include "content/public/renderer/render_frame.h" | 24 #include "content/public/renderer/render_frame.h" |
25 #include "content/renderer/media/android/renderer_demuxer_android.h" | 25 #include "content/renderer/media/android/renderer_demuxer_android.h" |
26 #include "content/renderer/media/android/renderer_media_player_manager.h" | 26 #include "content/renderer/media/android/renderer_media_player_manager.h" |
27 #include "content/renderer/media/crypto/render_cdm_factory.h" | 27 #include "content/renderer/media/crypto/render_cdm_factory.h" |
28 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 28 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
29 #include "content/renderer/render_frame_impl.h" | 29 #include "content/renderer/render_frame_impl.h" |
30 #include "content/renderer/render_thread_impl.h" | 30 #include "content/renderer/render_thread_impl.h" |
31 #include "content/renderer/render_view_impl.h" | 31 #include "content/renderer/render_view_impl.h" |
32 #include "gpu/blink/webgraphicscontext3d_impl.h" | |
33 #include "gpu/GLES2/gl2extchromium.h" | 32 #include "gpu/GLES2/gl2extchromium.h" |
34 #include "gpu/command_buffer/client/gles2_interface.h" | 33 #include "gpu/command_buffer/client/gles2_interface.h" |
35 #include "gpu/command_buffer/common/mailbox_holder.h" | 34 #include "gpu/command_buffer/common/mailbox_holder.h" |
36 #include "media/base/android/media_common_android.h" | 35 #include "media/base/android/media_common_android.h" |
37 #include "media/base/android/media_player_android.h" | 36 #include "media/base/android/media_player_android.h" |
38 #include "media/base/bind_to_current_loop.h" | 37 #include "media/base/bind_to_current_loop.h" |
39 #include "media/base/cdm_context.h" | 38 #include "media/base/cdm_context.h" |
40 #include "media/base/key_systems.h" | 39 #include "media/base/key_systems.h" |
41 #include "media/base/media_keys.h" | 40 #include "media/base/media_keys.h" |
42 #include "media/base/media_log.h" | 41 #include "media/base/media_log.h" |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 unsigned int texture, | 643 unsigned int texture, |
645 unsigned int internal_format, | 644 unsigned int internal_format, |
646 unsigned int type, | 645 unsigned int type, |
647 bool premultiply_alpha, | 646 bool premultiply_alpha, |
648 bool flip_y) { | 647 bool flip_y) { |
649 DCHECK(main_thread_checker_.CalledOnValidThread()); | 648 DCHECK(main_thread_checker_.CalledOnValidThread()); |
650 // Don't allow clients to copy an encrypted video frame. | 649 // Don't allow clients to copy an encrypted video frame. |
651 if (needs_external_surface_) | 650 if (needs_external_surface_) |
652 return false; | 651 return false; |
653 | 652 |
654 // TODO(zmo): Remove the casting once Copy{Sub}TextureCHROMIUM API | |
655 // signatures are switched over in blink. | |
656 gpu_blink::WebGraphicsContext3DImpl* web_graphics_context_impl = | |
657 reinterpret_cast<gpu_blink::WebGraphicsContext3DImpl*>( | |
658 web_graphics_context); | |
659 | |
660 scoped_refptr<VideoFrame> video_frame; | 653 scoped_refptr<VideoFrame> video_frame; |
661 { | 654 { |
662 base::AutoLock auto_lock(current_frame_lock_); | 655 base::AutoLock auto_lock(current_frame_lock_); |
663 video_frame = current_frame_; | 656 video_frame = current_frame_; |
664 } | 657 } |
665 | 658 |
666 if (!video_frame.get() || !video_frame->HasTextures()) | 659 if (!video_frame.get() || !video_frame->HasTextures()) |
667 return false; | 660 return false; |
668 DCHECK_EQ(1u, media::VideoFrame::NumPlanes(video_frame->format())); | 661 DCHECK_EQ(1u, media::VideoFrame::NumPlanes(video_frame->format())); |
669 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); | 662 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0); |
670 DCHECK((!is_remote_ && | 663 DCHECK((!is_remote_ && |
671 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) || | 664 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) || |
672 (is_remote_ && mailbox_holder.texture_target == GL_TEXTURE_2D)); | 665 (is_remote_ && mailbox_holder.texture_target == GL_TEXTURE_2D)); |
673 | 666 |
674 web_graphics_context_impl->waitSyncPoint(mailbox_holder.sync_point); | 667 web_graphics_context->waitSyncPoint(mailbox_holder.sync_point); |
675 | 668 |
676 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise | 669 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise |
677 // an invalid texture target may be used for copy texture. | 670 // an invalid texture target may be used for copy texture. |
678 uint32 src_texture = | 671 uint32 src_texture = |
679 web_graphics_context_impl->createAndConsumeTextureCHROMIUM( | 672 web_graphics_context->createAndConsumeTextureCHROMIUM( |
680 mailbox_holder.texture_target, mailbox_holder.mailbox.name); | 673 mailbox_holder.texture_target, mailbox_holder.mailbox.name); |
681 | 674 |
682 // The video is stored in an unmultiplied format, so premultiply if | |
683 // necessary. | |
684 web_graphics_context_impl->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | |
685 premultiply_alpha); | |
686 | |
687 // Application itself needs to take care of setting the right flip_y | 675 // Application itself needs to take care of setting the right flip_y |
688 // value down to get the expected result. | 676 // value down to get the expected result. |
689 // flip_y==true means to reverse the video orientation while | 677 // flip_y==true means to reverse the video orientation while |
690 // flip_y==false means to keep the intrinsic orientation. | 678 // flip_y==false means to keep the intrinsic orientation. |
691 web_graphics_context_impl->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, flip_y); | 679 web_graphics_context->copyTextureCHROMIUM( |
692 web_graphics_context_impl->copyTextureCHROMIUM( | |
693 GL_TEXTURE_2D, src_texture, texture, internal_format, type, | 680 GL_TEXTURE_2D, src_texture, texture, internal_format, type, |
694 flip_y, premultiply_alpha, false); | 681 flip_y, premultiply_alpha, false); |
695 web_graphics_context_impl->pixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, false); | |
696 web_graphics_context_impl->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, | |
697 false); | |
698 | 682 |
699 web_graphics_context_impl->deleteTexture(src_texture); | 683 web_graphics_context->deleteTexture(src_texture); |
700 web_graphics_context_impl->flush(); | 684 web_graphics_context->flush(); |
701 | 685 |
702 SyncPointClientImpl client(web_graphics_context); | 686 SyncPointClientImpl client(web_graphics_context); |
703 video_frame->UpdateReleaseSyncPoint(&client); | 687 video_frame->UpdateReleaseSyncPoint(&client); |
704 return true; | 688 return true; |
705 } | 689 } |
706 | 690 |
707 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { | 691 bool WebMediaPlayerAndroid::hasSingleSecurityOrigin() const { |
708 DCHECK(main_thread_checker_.CalledOnValidThread()); | 692 DCHECK(main_thread_checker_.CalledOnValidThread()); |
709 if (player_type_ != MEDIA_PLAYER_TYPE_URL) | 693 if (player_type_ != MEDIA_PLAYER_TYPE_URL) |
710 return true; | 694 return true; |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 | 1851 |
1868 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1852 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1869 std::string mime; | 1853 std::string mime; |
1870 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1854 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1871 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1855 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1872 return false; | 1856 return false; |
1873 return !mime.compare("application/x-mpegurl"); | 1857 return !mime.compare("application/x-mpegurl"); |
1874 } | 1858 } |
1875 | 1859 |
1876 } // namespace content | 1860 } // namespace content |
OLD | NEW |