Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1117423002: media: Let VideoFrame carry more than one native texture. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reveman's comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 655
656 scoped_refptr<VideoFrame> video_frame; 656 scoped_refptr<VideoFrame> video_frame;
657 { 657 {
658 base::AutoLock auto_lock(current_frame_lock_); 658 base::AutoLock auto_lock(current_frame_lock_);
659 video_frame = current_frame_; 659 video_frame = current_frame_;
660 } 660 }
661 661
662 if (!video_frame.get() || 662 if (!video_frame.get() ||
663 video_frame->format() != media::VideoFrame::NATIVE_TEXTURE) 663 video_frame->format() != media::VideoFrame::NATIVE_TEXTURE)
664 return false; 664 return false;
665 const gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder(); 665 DCHECK_EQ(1u, media::VideoFrame::NumTextures(video_frame->texture_format()));
666 const gpu::MailboxHolder& mailbox_holder = video_frame->mailbox_holder(0);
666 DCHECK((!is_remote_ && 667 DCHECK((!is_remote_ &&
667 mailbox_holder->texture_target == GL_TEXTURE_EXTERNAL_OES) || 668 mailbox_holder.texture_target == GL_TEXTURE_EXTERNAL_OES) ||
668 (is_remote_ && mailbox_holder->texture_target == GL_TEXTURE_2D)); 669 (is_remote_ && mailbox_holder.texture_target == GL_TEXTURE_2D));
669 670
670 web_graphics_context->waitSyncPoint(mailbox_holder->sync_point); 671 web_graphics_context->waitSyncPoint(mailbox_holder.sync_point);
671 672
672 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise 673 // Ensure the target of texture is set before copyTextureCHROMIUM, otherwise
673 // an invalid texture target may be used for copy texture. 674 // an invalid texture target may be used for copy texture.
674 uint32 src_texture = web_graphics_context->createAndConsumeTextureCHROMIUM( 675 uint32 src_texture = web_graphics_context->createAndConsumeTextureCHROMIUM(
675 mailbox_holder->texture_target, mailbox_holder->mailbox.name); 676 mailbox_holder.texture_target, mailbox_holder.mailbox.name);
676 677
677 // The video is stored in an unmultiplied format, so premultiply if 678 // The video is stored in an unmultiplied format, so premultiply if
678 // necessary. 679 // necessary.
679 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, 680 web_graphics_context->pixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM,
680 premultiply_alpha); 681 premultiply_alpha);
681 682
682 // Application itself needs to take care of setting the right flip_y 683 // Application itself needs to take care of setting the right flip_y
683 // value down to get the expected result. 684 // value down to get the expected result.
684 // flip_y==true means to reverse the video orientation while 685 // flip_y==true means to reverse the video orientation while
685 // flip_y==false means to keep the intrinsic orientation. 686 // flip_y==false means to keep the intrinsic orientation.
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 bitmap.getPixels()); 1196 bitmap.getPixels());
1196 } 1197 }
1197 1198
1198 gpu::Mailbox texture_mailbox; 1199 gpu::Mailbox texture_mailbox;
1199 gl->GenMailboxCHROMIUM(texture_mailbox.name); 1200 gl->GenMailboxCHROMIUM(texture_mailbox.name);
1200 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); 1201 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name);
1201 gl->Flush(); 1202 gl->Flush();
1202 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); 1203 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM();
1203 1204
1204 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( 1205 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture(
1205 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox, texture_target, 1206 gpu::MailboxHolder(texture_mailbox, texture_target,
1206 texture_mailbox_sync_point)), 1207 texture_mailbox_sync_point),
1207 media::BindToCurrentLoop(base::Bind(&OnReleaseTexture, 1208 media::BindToCurrentLoop(base::Bind(&OnReleaseTexture,
1208 stream_texture_factory_, 1209 stream_texture_factory_,
1209 remote_playback_texture_id)), 1210 remote_playback_texture_id)),
1210 canvas_size /* coded_size */, gfx::Rect(canvas_size) /* visible_rect */, 1211 canvas_size /* coded_size */, gfx::Rect(canvas_size) /* visible_rect */,
1211 canvas_size /* natural_size */, base::TimeDelta() /* timestamp */, 1212 canvas_size /* natural_size */, base::TimeDelta() /* timestamp */,
1212 false /* allow overlay */); 1213 false /* allow overlay */);
1213 SetCurrentFrameInternal(new_frame); 1214 SetCurrentFrameInternal(new_frame);
1214 } 1215 }
1215 1216
1216 void WebMediaPlayerAndroid::ReallocateVideoFrame() { 1217 void WebMediaPlayerAndroid::ReallocateVideoFrame() {
(...skipping 16 matching lines...) Expand all
1233 #endif // defined(VIDEO_HOLE) 1234 #endif // defined(VIDEO_HOLE)
1234 } else if (!is_remote_ && texture_id_) { 1235 } else if (!is_remote_ && texture_id_) {
1235 GLES2Interface* gl = stream_texture_factory_->ContextGL(); 1236 GLES2Interface* gl = stream_texture_factory_->ContextGL();
1236 GLuint texture_target = kGLTextureExternalOES; 1237 GLuint texture_target = kGLTextureExternalOES;
1237 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( 1238 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM(
1238 texture_target, texture_mailbox_.name); 1239 texture_target, texture_mailbox_.name);
1239 gl->Flush(); 1240 gl->Flush();
1240 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); 1241 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM();
1241 1242
1242 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( 1243 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture(
1243 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox_, texture_target, 1244 gpu::MailboxHolder(texture_mailbox_, texture_target,
1244 texture_mailbox_sync_point)), 1245 texture_mailbox_sync_point),
1245 media::BindToCurrentLoop(base::Bind( 1246 media::BindToCurrentLoop(base::Bind(
1246 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), 1247 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)),
1247 natural_size_, gfx::Rect(natural_size_), natural_size_, 1248 natural_size_, gfx::Rect(natural_size_), natural_size_,
1248 base::TimeDelta(), false); 1249 base::TimeDelta(), false);
1249 SetCurrentFrameInternal(new_frame); 1250 SetCurrentFrameInternal(new_frame);
1250 } 1251 }
1251 } 1252 }
1252 1253
1253 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( 1254 void WebMediaPlayerAndroid::SetVideoFrameProviderClient(
1254 cc::VideoFrameProvider::Client* client) { 1255 cc::VideoFrameProvider::Client* client) {
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 1855
1855 bool WebMediaPlayerAndroid::IsHLSStream() const { 1856 bool WebMediaPlayerAndroid::IsHLSStream() const {
1856 std::string mime; 1857 std::string mime;
1857 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; 1858 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_;
1858 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) 1859 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime))
1859 return false; 1860 return false;
1860 return !mime.compare("application/x-mpegurl"); 1861 return !mime.compare("application/x-mpegurl");
1861 } 1862 }
1862 1863
1863 } // namespace content 1864 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698