Commit 4b06d9be authored by scherkus@chromium.org's avatar scherkus@chromium.org

Clean up paint callbacks in player_x11 to use media::BindToCurrentLoop().

Review URL: https://codereview.chromium.org/252703006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266480 0039d316-1c4b-4281-b951-d872f2087c98
parent c53b9b3a
......@@ -111,7 +111,8 @@ GlVideoRenderer::~GlVideoRenderer() {
glXDestroyContext(display_, gl_context_);
}
void GlVideoRenderer::Paint(media::VideoFrame* video_frame) {
void GlVideoRenderer::Paint(
const scoped_refptr<media::VideoFrame>& video_frame) {
if (!gl_context_)
Initialize(video_frame->coded_size(), video_frame->visible_rect());
......
......@@ -19,7 +19,7 @@ class GlVideoRenderer : public base::RefCountedThreadSafe<GlVideoRenderer> {
public:
GlVideoRenderer(Display* display, Window window);
void Paint(media::VideoFrame* video_frame);
void Paint(const scoped_refptr<media::VideoFrame>& video_frame);
private:
friend class base::RefCountedThreadSafe<GlVideoRenderer>;
......
......@@ -17,6 +17,7 @@
#include "media/audio/audio_manager.h"
#include "media/audio/null_audio_sink.h"
#include "media/base/audio_hardware_config.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/decryptor.h"
#include "media/base/filter_collection.h"
#include "media/base/media.h"
......@@ -79,18 +80,6 @@ bool InitX11() {
return true;
}
typedef base::Callback<void(media::VideoFrame*)> PaintCB;
void Paint(base::MessageLoop* message_loop, const PaintCB& paint_cb,
const scoped_refptr<media::VideoFrame>& video_frame) {
if (message_loop != base::MessageLoop::current()) {
message_loop->PostTask(FROM_HERE, base::Bind(
&Paint, message_loop, paint_cb, video_frame));
return;
}
paint_cb.Run(video_frame.get());
}
static void DoNothing() {}
static void OnStatus(media::PipelineStatus status) {}
......@@ -114,9 +103,8 @@ void InitPipeline(
media::Pipeline* pipeline,
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
media::Demuxer* demuxer,
const PaintCB& paint_cb,
bool /* enable_audio */,
base::MessageLoop* paint_message_loop) {
const media::VideoRendererImpl::PaintCB& paint_cb,
bool /* enable_audio */) {
// Create our filter factories.
scoped_ptr<media::FilterCollection> collection(
new media::FilterCollection());
......@@ -128,7 +116,7 @@ void InitPipeline(
task_runner,
video_decoders.Pass(),
media::SetDecryptorReadyCB(),
base::Bind(&Paint, paint_message_loop, paint_cb),
paint_cb,
true));
collection->SetVideoRenderer(video_renderer.Pass());
......@@ -277,13 +265,13 @@ int main(int argc, char** argv) {
base::Thread media_thread("MediaThread");
media_thread.Start();
PaintCB paint_cb;
media::VideoRendererImpl::PaintCB paint_cb;
if (command_line->HasSwitch("use-gl")) {
paint_cb = base::Bind(
&GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window));
paint_cb = media::BindToCurrentLoop(base::Bind(
&GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window)));
} else {
paint_cb = base::Bind(
&X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window));
paint_cb = media::BindToCurrentLoop(base::Bind(
&X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window)));
}
scoped_ptr<media::DataSource> data_source(new DataSourceLogger(
......@@ -295,7 +283,7 @@ int main(int argc, char** argv) {
media::Pipeline pipeline(media_thread.message_loop_proxy(),
new media::MediaLog());
InitPipeline(&pipeline, media_thread.message_loop_proxy(), demuxer.get(),
paint_cb, command_line->HasSwitch("audio"), &message_loop);
paint_cb, command_line->HasSwitch("audio"));
// Main loop of the application.
g_running = true;
......
......@@ -83,7 +83,8 @@ X11VideoRenderer::~X11VideoRenderer() {
XRenderFreePicture(display_, picture_);
}
void X11VideoRenderer::Paint(media::VideoFrame* video_frame) {
void X11VideoRenderer::Paint(
const scoped_refptr<media::VideoFrame>& video_frame) {
if (!image_)
Initialize(video_frame->coded_size(), video_frame->visible_rect());
......
......@@ -20,7 +20,7 @@ class X11VideoRenderer : public base::RefCountedThreadSafe<X11VideoRenderer> {
public:
X11VideoRenderer(Display* display, Window window);
void Paint(media::VideoFrame* video_frame);
void Paint(const scoped_refptr<media::VideoFrame>& video_frame);
private:
friend class base::RefCountedThreadSafe<X11VideoRenderer>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment