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 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 bitmap.getPixels()); | 1175 bitmap.getPixels()); |
1176 } | 1176 } |
1177 | 1177 |
1178 gpu::Mailbox texture_mailbox; | 1178 gpu::Mailbox texture_mailbox; |
1179 gl->GenMailboxCHROMIUM(texture_mailbox.name); | 1179 gl->GenMailboxCHROMIUM(texture_mailbox.name); |
1180 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); | 1180 gl->ProduceTextureCHROMIUM(texture_target, texture_mailbox.name); |
1181 gl->Flush(); | 1181 gl->Flush(); |
1182 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 1182 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
1183 | 1183 |
1184 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 1184 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
1185 make_scoped_ptr(new gpu::MailboxHolder( | 1185 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox, texture_target, |
1186 texture_mailbox, texture_target, texture_mailbox_sync_point)), | 1186 texture_mailbox_sync_point)), |
1187 media::BindToCurrentLoop(base::Bind(&OnReleaseTexture, | 1187 media::BindToCurrentLoop(base::Bind(&OnReleaseTexture, |
1188 stream_texture_factory_, | 1188 stream_texture_factory_, |
1189 remote_playback_texture_id)), | 1189 remote_playback_texture_id)), |
1190 canvas_size /* coded_size */, | 1190 canvas_size /* coded_size */, gfx::Rect(canvas_size) /* visible_rect */, |
1191 gfx::Rect(canvas_size) /* visible_rect */, | 1191 canvas_size /* natural_size */, base::TimeDelta() /* timestamp */, |
1192 canvas_size /* natural_size */, | 1192 VideoFrame::ReadPixelsCB(), false /* allow overlay */); |
1193 base::TimeDelta() /* timestamp */, | |
1194 VideoFrame::ReadPixelsCB()); | |
1195 SetCurrentFrameInternal(new_frame); | 1193 SetCurrentFrameInternal(new_frame); |
1196 } | 1194 } |
1197 | 1195 |
1198 void WebMediaPlayerAndroid::ReallocateVideoFrame() { | 1196 void WebMediaPlayerAndroid::ReallocateVideoFrame() { |
1199 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1197 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1200 if (needs_external_surface_) { | 1198 if (needs_external_surface_) { |
1201 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. | 1199 // VideoFrame::CreateHoleFrame is only defined under VIDEO_HOLE. |
1202 #if defined(VIDEO_HOLE) | 1200 #if defined(VIDEO_HOLE) |
1203 if (!natural_size_.isEmpty()) { | 1201 if (!natural_size_.isEmpty()) { |
1204 // Now we finally know that "stream texture" and "video frame" won't | 1202 // Now we finally know that "stream texture" and "video frame" won't |
(...skipping 10 matching lines...) Expand all Loading... |
1215 #endif // defined(VIDEO_HOLE) | 1213 #endif // defined(VIDEO_HOLE) |
1216 } else if (!is_remote_ && texture_id_) { | 1214 } else if (!is_remote_ && texture_id_) { |
1217 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1215 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
1218 GLuint texture_target = kGLTextureExternalOES; | 1216 GLuint texture_target = kGLTextureExternalOES; |
1219 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( | 1217 GLuint texture_id_ref = gl->CreateAndConsumeTextureCHROMIUM( |
1220 texture_target, texture_mailbox_.name); | 1218 texture_target, texture_mailbox_.name); |
1221 gl->Flush(); | 1219 gl->Flush(); |
1222 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); | 1220 GLuint texture_mailbox_sync_point = gl->InsertSyncPointCHROMIUM(); |
1223 | 1221 |
1224 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( | 1222 scoped_refptr<VideoFrame> new_frame = VideoFrame::WrapNativeTexture( |
1225 make_scoped_ptr(new gpu::MailboxHolder( | 1223 make_scoped_ptr(new gpu::MailboxHolder(texture_mailbox_, texture_target, |
1226 texture_mailbox_, texture_target, texture_mailbox_sync_point)), | 1224 texture_mailbox_sync_point)), |
1227 media::BindToCurrentLoop(base::Bind( | 1225 media::BindToCurrentLoop(base::Bind( |
1228 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), | 1226 &OnReleaseTexture, stream_texture_factory_, texture_id_ref)), |
1229 natural_size_, | 1227 natural_size_, gfx::Rect(natural_size_), natural_size_, |
1230 gfx::Rect(natural_size_), | 1228 base::TimeDelta(), VideoFrame::ReadPixelsCB(), false); |
1231 natural_size_, | |
1232 base::TimeDelta(), | |
1233 VideoFrame::ReadPixelsCB()); | |
1234 SetCurrentFrameInternal(new_frame); | 1229 SetCurrentFrameInternal(new_frame); |
1235 } | 1230 } |
1236 } | 1231 } |
1237 | 1232 |
1238 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( | 1233 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( |
1239 cc::VideoFrameProvider::Client* client) { | 1234 cc::VideoFrameProvider::Client* client) { |
1240 // This is called from both the main renderer thread and the compositor | 1235 // This is called from both the main renderer thread and the compositor |
1241 // thread (when the main thread is blocked). | 1236 // thread (when the main thread is blocked). |
1242 | 1237 |
1243 // Set the callback target when a frame is produced. Need to do this before | 1238 // Set the callback target when a frame is produced. Need to do this before |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 | 1794 |
1800 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1795 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1801 std::string mime; | 1796 std::string mime; |
1802 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1797 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1803 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1798 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1804 return false; | 1799 return false; |
1805 return !mime.compare("application/x-mpegurl"); | 1800 return !mime.compare("application/x-mpegurl"); |
1806 } | 1801 } |
1807 | 1802 |
1808 } // namespace content | 1803 } // namespace content |
OLD | NEW |