summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
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/gpu
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/gpu')
-rw-r--r--chrome/gpu/gpu_video_decoder.cc17
-rw-r--r--chrome/gpu/gpu_video_decoder.h2
-rw-r--r--chrome/gpu/media/fake_gl_video_decode_engine.cc45
-rw-r--r--chrome/gpu/media/fake_gl_video_decode_engine.h5
4 files changed, 54 insertions, 15 deletions
diff --git a/chrome/gpu/gpu_video_decoder.cc b/chrome/gpu/gpu_video_decoder.cc
index b316253..86bcd04 100644
--- a/chrome/gpu/gpu_video_decoder.cc
+++ b/chrome/gpu/gpu_video_decoder.cc
@@ -26,6 +26,8 @@ void GpuVideoDecoder::OnMessageReceived(const IPC::Message& msg) {
OnUninitialize)
IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Flush,
OnFlush)
+ IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Preroll,
+ OnPreroll)
IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_EmptyThisBuffer,
OnEmptyThisBuffer)
IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_ProduceVideoFrame,
@@ -87,7 +89,7 @@ void GpuVideoDecoder::OnFlushComplete() {
}
void GpuVideoDecoder::OnSeekComplete() {
- NOTIMPLEMENTED();
+ SendPrerollDone();
}
void GpuVideoDecoder::OnError() {
@@ -200,7 +202,7 @@ void GpuVideoDecoder::Destroy(Task* task) {
}
void GpuVideoDecoder::SetVideoDecodeEngine(media::VideoDecodeEngine* engine) {
- decode_engine_.reset(engine);
+ decode_engine_.reset(engine);
}
void GpuVideoDecoder::SetGpuVideoDevice(GpuVideoDevice* device) {
@@ -244,6 +246,10 @@ void GpuVideoDecoder::OnFlush() {
decode_engine_->Flush();
}
+void GpuVideoDecoder::OnPreroll() {
+ decode_engine_->Seek();
+}
+
void GpuVideoDecoder::OnEmptyThisBuffer(
const GpuVideoDecoderInputBufferParam& buffer) {
DCHECK(input_transfer_buffer_->memory());
@@ -328,6 +334,13 @@ void GpuVideoDecoder::SendFlushDone() {
}
}
+void GpuVideoDecoder::SendPrerollDone() {
+ if (!sender_->Send(new GpuVideoDecoderHostMsg_PrerollDone(
+ decoder_host_id()))) {
+ LOG(ERROR) << "GpuVideoDecoderMsg_PrerollDone failed";
+ }
+}
+
void GpuVideoDecoder::SendEmptyBufferDone() {
if (!sender_->Send(
new GpuVideoDecoderHostMsg_EmptyThisBufferDone(decoder_host_id()))) {
diff --git a/chrome/gpu/gpu_video_decoder.h b/chrome/gpu/gpu_video_decoder.h
index 786e0de..9a339e1 100644
--- a/chrome/gpu/gpu_video_decoder.h
+++ b/chrome/gpu/gpu_video_decoder.h
@@ -149,6 +149,7 @@ class GpuVideoDecoder
void OnInitialize(const GpuVideoDecoderInitParam& param);
void OnUninitialize();
void OnFlush();
+ void OnPreroll();
void OnEmptyThisBuffer(const GpuVideoDecoderInputBufferParam& buffer);
void OnProduceVideoFrame(int32 frame_id);
void OnVideoFrameAllocated(int32 frame_id, std::vector<uint32> textures);
@@ -157,6 +158,7 @@ class GpuVideoDecoder
void SendInitializeDone(const GpuVideoDecoderInitDoneParam& param);
void SendUninitializeDone();
void SendFlushDone();
+ void SendPrerollDone();
void SendEmptyBufferDone();
void SendEmptyBufferACK();
void SendConsumeVideoFrame(int32 frame_id, int64 timestamp, int64 duration,
diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.cc b/chrome/gpu/media/fake_gl_video_decode_engine.cc
index 4badc0e..532434b 100644
--- a/chrome/gpu/media/fake_gl_video_decode_engine.cc
+++ b/chrome/gpu/media/fake_gl_video_decode_engine.cc
@@ -4,6 +4,7 @@
#include "chrome/gpu/media/fake_gl_video_decode_engine.h"
+#include "media/base/limits.h"
#include "media/base/video_frame.h"
#include "media/video/video_decode_context.h"
@@ -37,14 +38,18 @@ void FakeGlVideoDecodeEngine::Initialize(
// Use VideoDecodeContext to allocate VideoFrame that can be consumed by
// external body.
+ // TODO(hclam): It is horrible to use constants everywhere in the code!
+ // The number of frames come from VideoRendererBase in the renderer, this is
+ // horrible!
context_->AllocateVideoFrames(
- 1, width_, height_, media::VideoFrame::RGBA, &external_frames_,
+ media::Limits::kMaxVideoFrames, width_, height_, media::VideoFrame::RGBA,
+ &external_frames_,
NewRunnableMethod(this,
&FakeGlVideoDecodeEngine::AllocationCompleteTask));
}
void FakeGlVideoDecodeEngine::AllocationCompleteTask() {
- DCHECK_EQ(1u, external_frames_.size());
+ DCHECK(media::Limits::kMaxVideoFrames == external_frames_.size());
DCHECK_EQ(media::VideoFrame::TYPE_GL_TEXTURE, external_frames_[0]->type());
media::VideoCodecInfo info;
@@ -66,22 +71,27 @@ void FakeGlVideoDecodeEngine::Flush() {
}
void FakeGlVideoDecodeEngine::Seek() {
+ // TODO(hclam): This is a big hack to continue playing because we need to
+ // *push* decoded frames to downstream. The model used in VideoRendererBase
+ // to wait for *push* is flawed.
+ for (size_t i = 0; i < external_frames_.size(); ++i)
+ handler_->ConsumeVideoFrame(external_frames_[i]);
handler_->OnSeekComplete();
}
void FakeGlVideoDecodeEngine::ConsumeVideoSample(
- scoped_refptr<media::Buffer> buffer) {
- // Don't care.
-}
+ scoped_refptr<media::Buffer> sample) {
+ DCHECK(!pending_frames_.empty());
+ scoped_refptr<media::VideoFrame> frame = pending_frames_.front();
+ pending_frames_.pop();
-void FakeGlVideoDecodeEngine::ProduceVideoFrame(
- scoped_refptr<media::VideoFrame> frame) {
- // Fake that we need some buffer.
- handler_->ProduceVideoSample(NULL);
+ frame->SetDuration(sample->GetDuration());
+ frame->SetTimestamp(sample->GetTimestamp());
+ // Generate a pattern to the internal frame and then uploads it.
int size = width_ * height_ * 4;
scoped_array<uint8> buffer(new uint8[size]);
- memset(buffer.get(), 0, size);
+ memset(buffer.get(), 255, size);
uint8* row = internal_frame_->data(media::VideoFrame::kRGBPlane);
static int seed = 0;
@@ -89,7 +99,7 @@ void FakeGlVideoDecodeEngine::ProduceVideoFrame(
for (int y = 0; y < height_; ++y) {
int offset = y % 3;
for (int x = 0; x < width_; ++x) {
- row[x * 4 + offset] = seed++;
+ row[x * 4 + offset + 1] = seed++;
seed &= 255;
}
row += width_ * 4;
@@ -99,9 +109,18 @@ void FakeGlVideoDecodeEngine::ProduceVideoFrame(
// After we have filled the content upload the internal frame to the
// VideoFrame allocated through VideoDecodeContext.
context_->UploadToVideoFrame(
- internal_frame_, external_frames_[0],
+ internal_frame_, frame,
NewRunnableMethod(this, &FakeGlVideoDecodeEngine::UploadCompleteTask,
- external_frames_[0]));
+ frame));
+}
+
+void FakeGlVideoDecodeEngine::ProduceVideoFrame(
+ scoped_refptr<media::VideoFrame> frame) {
+ // Enqueue the frame to the pending queue.
+ pending_frames_.push(frame);
+
+ // Fake that we need some buffer.
+ handler_->ProduceVideoSample(NULL);
}
void FakeGlVideoDecodeEngine::UploadCompleteTask(
diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.h b/chrome/gpu/media/fake_gl_video_decode_engine.h
index 164c8c4..24d3b33 100644
--- a/chrome/gpu/media/fake_gl_video_decode_engine.h
+++ b/chrome/gpu/media/fake_gl_video_decode_engine.h
@@ -5,6 +5,7 @@
#ifndef CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
#define CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
+#include <queue>
#include <vector>
#include "base/scoped_ptr.h"
@@ -53,6 +54,10 @@ class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine {
// opaque to us. And we need an extra upload step.
std::vector<scoped_refptr<media::VideoFrame> > external_frames_;
+ // These are the video frames that are waiting for input buffer to generate
+ // fake pattern in them.
+ std::queue<scoped_refptr<media::VideoFrame> > pending_frames_;
+
DISALLOW_COPY_AND_ASSIGN(FakeGlVideoDecodeEngine);
};