summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 21:47:17 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 21:47:17 +0000
commit3bb08606c22e357896714764731a7af21e04377d (patch)
tree9d459e951749c408fad9e490d547d2da352c20cb /chrome/renderer
parente570464a01253a25520171f967fa3e7a97c70cb6 (diff)
downloadchromium_src-3bb08606c22e357896714764731a7af21e04377d.zip
chromium_src-3bb08606c22e357896714764731a7af21e04377d.tar.gz
chromium_src-3bb08606c22e357896714764731a7af21e04377d.tar.bz2
Make FakeGlVideoDecodeEngine works in the hardware video decoding architecture
Add Preroll IPC message for finishing the initialiation of FakeGlVideoDecodeEngine. Also defined methods in WebVideoFrameImpl to access video frame textures. This change depend on a WebKit change to succesfully display the textures. BUG=53714 TEST=Tree is green. This still needs WebKit changes to work. Review URL: http://codereview.chromium.org/3472016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61853 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/ggl/ggl.cc13
-rw-r--r--chrome/renderer/ggl/ggl.h4
-rw-r--r--chrome/renderer/gpu_video_decoder_host.cc21
-rw-r--r--chrome/renderer/gpu_video_decoder_host.h1
-rw-r--r--chrome/renderer/gpu_video_service_host.cc3
-rw-r--r--chrome/renderer/media/gles2_video_decode_context.cc9
-rw-r--r--chrome/renderer/media/ipc_video_decoder.cc12
-rw-r--r--chrome/renderer/media/ipc_video_decoder.h2
-rw-r--r--chrome/renderer/render_view.cc15
9 files changed, 62 insertions, 18 deletions
diff --git a/chrome/renderer/ggl/ggl.cc b/chrome/renderer/ggl/ggl.cc
index efe2072..1a0e6e9 100644
--- a/chrome/renderer/ggl/ggl.cc
+++ b/chrome/renderer/ggl/ggl.cc
@@ -13,7 +13,6 @@
#include "chrome/renderer/gpu_channel_host.h"
#include "chrome/renderer/gpu_video_service_host.h"
#include "chrome/renderer/media/gles2_video_decode_context.h"
-#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/render_widget.h"
#include "ipc/ipc_channel_handle.h"
@@ -105,7 +104,8 @@ class Context : public base::SupportsWeakPtr<Context> {
media::VideoDecodeEngine* CreateVideoDecodeEngine();
// Create a hardware video decode context associated with this context.
- media::VideoDecodeContext* CreateVideoDecodeContext(bool hardware_decoder);
+ media::VideoDecodeContext* CreateVideoDecodeContext(MessageLoop* message_loop,
+ bool hardware_decoder);
// Get the current error code. Clears context's error code afterwards.
Error GetError();
@@ -372,9 +372,8 @@ media::VideoDecodeEngine* Context::CreateVideoDecodeEngine() {
}
media::VideoDecodeContext* Context::CreateVideoDecodeContext(
- bool hardware_decoder) {
- return new Gles2VideoDecodeContext(
- RenderThread::current()->message_loop(), hardware_decoder, this);
+ MessageLoop* message_loop, bool hardware_decoder) {
+ return new Gles2VideoDecodeContext(message_loop, hardware_decoder, this);
}
Error Context::GetError() {
@@ -526,8 +525,8 @@ media::VideoDecodeEngine* CreateVideoDecodeEngine(Context* context) {
}
media::VideoDecodeContext* CreateVideoDecodeContext(
- Context* context, bool hardware_decoder) {
- return context->CreateVideoDecodeContext(hardware_decoder);
+ Context* context, MessageLoop* message_loop, bool hardware_decoder) {
+ return context->CreateVideoDecodeContext(message_loop, hardware_decoder);
}
Error GetError() {
diff --git a/chrome/renderer/ggl/ggl.h b/chrome/renderer/ggl/ggl.h
index 8368ab3..b535306 100644
--- a/chrome/renderer/ggl/ggl.h
+++ b/chrome/renderer/ggl/ggl.h
@@ -16,6 +16,7 @@
#include "gfx/size.h"
class GpuChannelHost;
+class MessageLoop;
namespace media {
@@ -144,8 +145,9 @@ media::VideoDecodeEngine* CreateVideoDecodeEngine(Context* context);
// decode engine. It can also be used with a software decode engine.
//
// Set |hardware_decoder| to true if this context is for a hardware video
-// engine.
+// engine. |message_loop| is where the decode context should run on.
media::VideoDecodeContext* CreateVideoDecodeContext(Context* context,
+ MessageLoop* message_loop,
bool hardware_decoder);
// TODO(gman): Remove this
diff --git a/chrome/renderer/gpu_video_decoder_host.cc b/chrome/renderer/gpu_video_decoder_host.cc
index 4a97702..ad81004 100644
--- a/chrome/renderer/gpu_video_decoder_host.cc
+++ b/chrome/renderer/gpu_video_decoder_host.cc
@@ -40,6 +40,8 @@ void GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) {
OnUninitializeDone)
IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK,
OnFlushDone)
+ IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_PrerollDone,
+ OnPrerollDone)
IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK,
OnEmptyThisBufferACK)
IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone,
@@ -169,7 +171,17 @@ void GpuVideoDecoderHost::Flush() {
}
void GpuVideoDecoderHost::Seek() {
- // TODO(hclam): Implement.
+ if (MessageLoop::current() != message_loop_) {
+ message_loop_->PostTask(
+ FROM_HERE, NewRunnableMethod(this, &GpuVideoDecoderHost::Seek));
+ return;
+ }
+
+ if (!ipc_sender_->Send(new GpuVideoDecoderMsg_Preroll(decoder_id_))) {
+ LOG(ERROR) << "GpuVideoDecoderMsg_Preroll failed";
+ event_handler_->OnError();
+ return;
+ }
}
void GpuVideoDecoderHost::OnCreateVideoDecoderDone(int32 decoder_id) {
@@ -228,6 +240,13 @@ void GpuVideoDecoderHost::OnFlushDone() {
event_handler_->OnFlushComplete();
}
+void GpuVideoDecoderHost::OnPrerollDone() {
+ DCHECK_EQ(message_loop_, MessageLoop::current());
+
+ state_ = kStateNormal;
+ event_handler_->OnSeekComplete();
+}
+
void GpuVideoDecoderHost::OnEmptyThisBufferACK() {
DCHECK_EQ(message_loop_, MessageLoop::current());
diff --git a/chrome/renderer/gpu_video_decoder_host.h b/chrome/renderer/gpu_video_decoder_host.h
index e5a26fd..5ca520e 100644
--- a/chrome/renderer/gpu_video_decoder_host.h
+++ b/chrome/renderer/gpu_video_decoder_host.h
@@ -75,6 +75,7 @@ class GpuVideoDecoderHost : public media::VideoDecodeEngine,
void OnInitializeDone(const GpuVideoDecoderInitDoneParam& param);
void OnUninitializeDone();
void OnFlushDone();
+ void OnPrerollDone();
void OnEmptyThisBufferACK();
void OnProduceVideoSample();
void OnConsumeVideoFrame(int32 frame_id, int64 timestamp,
diff --git a/chrome/renderer/gpu_video_service_host.cc b/chrome/renderer/gpu_video_service_host.cc
index d47e309..9c4f433 100644
--- a/chrome/renderer/gpu_video_service_host.cc
+++ b/chrome/renderer/gpu_video_service_host.cc
@@ -54,11 +54,10 @@ void GpuVideoServiceHost::OnGpuChannelConnected(
GpuVideoDecoderHost* GpuVideoServiceHost::CreateVideoDecoder(
int context_route_id) {
- DCHECK(RenderThread::current());
-
GpuVideoDecoderHost* host = new GpuVideoDecoderHost(router_, channel_host_,
context_route_id,
next_decoder_host_id_);
+ // TODO(hclam): Handle thread safety of incrementing the ID.
++next_decoder_host_id_;
return host;
}
diff --git a/chrome/renderer/media/gles2_video_decode_context.cc b/chrome/renderer/media/gles2_video_decode_context.cc
index 1ae31f2..bd60ea1 100644
--- a/chrome/renderer/media/gles2_video_decode_context.cc
+++ b/chrome/renderer/media/gles2_video_decode_context.cc
@@ -25,14 +25,14 @@ void* Gles2VideoDecodeContext::GetDevice() {
}
void Gles2VideoDecodeContext::AllocateVideoFrames(
- int frames_num, size_t width, size_t height,
+ int num_frames, size_t width, size_t height,
media::VideoFrame::Format format,
std::vector<scoped_refptr<media::VideoFrame> >* frames_out, Task* task) {
if (MessageLoop::current() != message_loop_) {
message_loop_->PostTask(
FROM_HERE,
NewRunnableMethod(this, &Gles2VideoDecodeContext::AllocateVideoFrames,
- frames_num, width, height, format, frames_out,
+ num_frames, width, height, format, frames_out,
task));
return;
}
@@ -43,8 +43,8 @@ void Gles2VideoDecodeContext::AllocateVideoFrames(
bool ret = ggl::MakeCurrent(context_);
CHECK(ret) << "Failed to switch context";
- frames_.resize(frames_num);
- for (int i = 0; i < frames_num; ++i) {
+ frames_.resize(num_frames);
+ for (int i = 0; i < num_frames; ++i) {
int planes = media::VideoFrame::GetNumberOfPlanes(format);
media::VideoFrame::GlTexture textures[media::VideoFrame::kMaxPlanes];
@@ -61,6 +61,7 @@ void Gles2VideoDecodeContext::AllocateVideoFrames(
glTexImage2D(GL_TEXTURE_2D, 0, gl_format, width, height, 0, gl_format,
GL_UNSIGNED_BYTE, NULL);
}
+ glFlush();
scoped_refptr<media::VideoFrame> frame;
media::VideoFrame::CreateFrameGlTexture(format, width, height, textures,
diff --git a/chrome/renderer/media/ipc_video_decoder.cc b/chrome/renderer/media/ipc_video_decoder.cc
index 57a7dde..c8f8096 100644
--- a/chrome/renderer/media/ipc_video_decoder.cc
+++ b/chrome/renderer/media/ipc_video_decoder.cc
@@ -56,7 +56,10 @@ void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream,
// Create a video decode context that assocates with the graphics
// context.
- decode_context_.reset(ggl::CreateVideoDecodeContext(ggl_context_, true));
+ // TODO(hclam): Need to define a message loop that hosts decode context.
+ decode_context_.reset(
+ ggl::CreateVideoDecodeContext(
+ ggl_context_, decode_engine_message_loop_, true));
// Create a hardware video decoder handle.
decode_engine_.reset(ggl::CreateVideoDecodeEngine(ggl_context_));
@@ -104,6 +107,10 @@ void IpcVideoDecoder::OnInitializeComplete(const media::VideoCodecInfo& info) {
if (info.success) {
media_format_.SetAsString(media::MediaFormat::kMimeType,
media::mime_type::kUncompressedVideo);
+ media_format_.SetAsInteger(media::MediaFormat::kSurfaceType,
+ media::VideoFrame::TYPE_GL_TEXTURE);
+ media_format_.SetAsInteger(media::MediaFormat::kSurfaceFormat,
+ info.stream_info.surface_format);
media_format_.SetAsInteger(media::MediaFormat::kWidth,
info.stream_info.surface_width);
media_format_.SetAsInteger(media::MediaFormat::kHeight,
@@ -201,6 +208,5 @@ bool IpcVideoDecoder::IsMediaFormatSupported(const media::MediaFormat& format) {
// TODO(jiesun): Although we current only support H264 hardware decoding,
// in the future, we should query GpuVideoService for capabilities.
int codec_id;
- return format.GetAsInteger(media::MediaFormat::kFFmpegCodecID, &codec_id) &&
- codec_id == CODEC_ID_H264;
+ return format.GetAsInteger(media::MediaFormat::kFFmpegCodecID, &codec_id);
}
diff --git a/chrome/renderer/media/ipc_video_decoder.h b/chrome/renderer/media/ipc_video_decoder.h
index b47e1ab..d0aba70 100644
--- a/chrome/renderer/media/ipc_video_decoder.h
+++ b/chrome/renderer/media/ipc_video_decoder.h
@@ -50,6 +50,8 @@ class IpcVideoDecoder : public media::VideoDecoder,
virtual void OnFlushComplete();
virtual void OnSeekComplete();
virtual void OnError();
+
+ // TODO(hclam): Remove this method.
virtual void OnFormatChange(media::VideoStreamInfo stream_info) {}
virtual void ProduceVideoSample(scoped_refptr<media::Buffer> buffer);
virtual void ConsumeVideoFrame(scoped_refptr<media::VideoFrame> frame);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 9c078661..b164a39 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -62,6 +62,7 @@
#include "chrome/renderer/extensions/renderer_extension_bindings.h"
#include "chrome/renderer/external_host_bindings.h"
#include "chrome/renderer/geolocation_dispatcher.h"
+#include "chrome/renderer/ggl/ggl.h"
#include "chrome/renderer/localized_error.h"
#include "chrome/renderer/media/audio_renderer_impl.h"
#include "chrome/renderer/media/ipc_video_decoder.h"
@@ -116,6 +117,7 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebGraphicsContext3D.h"
#include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h"
#include "third_party/WebKit/WebKit/chromium/public/WebImage.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h"
@@ -2465,6 +2467,19 @@ WebMediaPlayer* RenderView::createMediaPlayer(
AudioRendererImpl::CreateFactory(audio_message_filter()));
}
+ if (cmd_line->HasSwitch(switches::kEnableAcceleratedDecoding) &&
+ !cmd_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
+ // Add the hardware video decoder factory.
+ // TODO(hclam): This assumes that ggl::Context is set to current
+ // internally. I need to make it more explicit to get the context.
+ bool ret = frame->view()->graphicsContext3D()->makeContextCurrent();
+ CHECK(ret) << "Failed to switch context";
+
+ factory->AddFactory(IpcVideoDecoder::CreateFactory(
+ MessageLoop::current(),
+ ggl::GetCurrentContext()));
+ }
+
WebApplicationCacheHostImpl* appcache_host =
WebApplicationCacheHostImpl::FromFrame(frame);