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

Side by Side Diff: media/tools/player_x11/player_x11.cc

Issue 12096081: Replace VideoRendererBase Get/PutCurrentFrame() with a VideoFrame-containing callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <signal.h> 5 #include <signal.h>
6 6
7 #include <iostream> // NOLINT 7 #include <iostream> // NOLINT
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 26 matching lines...) Expand all
37 #include <X11/Xlib.h> 37 #include <X11/Xlib.h>
38 #include "media/tools/player_x11/gl_video_renderer.h" 38 #include "media/tools/player_x11/gl_video_renderer.h"
39 #include "media/tools/player_x11/x11_video_renderer.h" 39 #include "media/tools/player_x11/x11_video_renderer.h"
40 40
41 static Display* g_display = NULL; 41 static Display* g_display = NULL;
42 static Window g_window = 0; 42 static Window g_window = 0;
43 static bool g_running = false; 43 static bool g_running = false;
44 44
45 media::AudioManager* g_audio_manager = NULL; 45 media::AudioManager* g_audio_manager = NULL;
46 46
47 media::VideoRendererBase* g_video_renderer = NULL;
48
49 scoped_refptr<media::FileDataSource> CreateFileDataSource( 47 scoped_refptr<media::FileDataSource> CreateFileDataSource(
50 const std::string& file_path) { 48 const std::string& file_path) {
51 scoped_refptr<media::FileDataSource> file_data_source( 49 scoped_refptr<media::FileDataSource> file_data_source(
52 new media::FileDataSource()); 50 new media::FileDataSource());
53 CHECK(file_data_source->Initialize(FilePath(file_path))); 51 CHECK(file_data_source->Initialize(FilePath(file_path)));
54 return file_data_source; 52 return file_data_source;
55 } 53 }
56 54
57 // Initialize X11. Returns true if successful. This method creates the X11 55 // Initialize X11. Returns true if successful. This method creates the X11
58 // window. Further initialization is done in X11VideoRenderer. 56 // window. Further initialization is done in X11VideoRenderer.
(...skipping 17 matching lines...) Expand all
76 XSelectInput(g_display, g_window, 74 XSelectInput(g_display, g_window,
77 ExposureMask | ButtonPressMask | KeyPressMask); 75 ExposureMask | ButtonPressMask | KeyPressMask);
78 XMapWindow(g_display, g_window); 76 XMapWindow(g_display, g_window);
79 return true; 77 return true;
80 } 78 }
81 79
82 void SetOpaque(bool /*opaque*/) { 80 void SetOpaque(bool /*opaque*/) {
83 } 81 }
84 82
85 typedef base::Callback<void(media::VideoFrame*)> PaintCB; 83 typedef base::Callback<void(media::VideoFrame*)> PaintCB;
86 void Paint(MessageLoop* message_loop, const PaintCB& paint_cb) { 84 void Paint(MessageLoop* message_loop, const PaintCB& paint_cb,
85 const scoped_refptr<media::VideoFrame>& video_frame) {
87 if (message_loop != MessageLoop::current()) { 86 if (message_loop != MessageLoop::current()) {
88 message_loop->PostTask(FROM_HERE, base::Bind( 87 message_loop->PostTask(FROM_HERE, base::Bind(
89 &Paint, message_loop, paint_cb)); 88 &Paint, message_loop, paint_cb, video_frame));
90 return; 89 return;
91 } 90 }
92 91
93 scoped_refptr<media::VideoFrame> video_frame; 92 paint_cb.Run(video_frame);
94 g_video_renderer->GetCurrentFrame(&video_frame);
95 if (video_frame)
96 paint_cb.Run(video_frame);
97 g_video_renderer->PutCurrentFrame(video_frame);
98 } 93 }
99 94
100 static void OnBufferingState(media::Pipeline::BufferingState buffering_state) {} 95 static void OnBufferingState(media::Pipeline::BufferingState buffering_state) {}
101 96
102 // TODO(vrk): Re-enabled audio. (crbug.com/112159) 97 // TODO(vrk): Re-enabled audio. (crbug.com/112159)
103 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, 98 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
104 const scoped_refptr<media::DataSource>& data_source, 99 const scoped_refptr<media::DataSource>& data_source,
105 const PaintCB& paint_cb, 100 const PaintCB& paint_cb,
106 bool /* enable_audio */, 101 bool /* enable_audio */,
107 scoped_refptr<media::Pipeline>* pipeline, 102 scoped_refptr<media::Pipeline>* pipeline,
108 MessageLoop* paint_message_loop) { 103 MessageLoop* paint_message_loop) {
109 // Create our filter factories. 104 // Create our filter factories.
110 scoped_ptr<media::FilterCollection> collection( 105 scoped_ptr<media::FilterCollection> collection(
111 new media::FilterCollection()); 106 new media::FilterCollection());
112 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source)); 107 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source));
113 collection->GetAudioDecoders()->push_back(new media::FFmpegAudioDecoder( 108 collection->GetAudioDecoders()->push_back(new media::FFmpegAudioDecoder(
114 message_loop)); 109 message_loop));
115 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder( 110 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder(
116 message_loop)); 111 message_loop));
117 112
118 // Create our video renderer and save a reference to it for painting. 113 // Create our video renderer and save a reference to it for painting.
119 g_video_renderer = new media::VideoRendererBase( 114 collection->AddVideoRenderer(new media::VideoRendererBase(
120 message_loop, 115 message_loop,
121 media::SetDecryptorReadyCB(), 116 media::SetDecryptorReadyCB(),
122 base::Bind(&Paint, paint_message_loop, paint_cb), 117 base::Bind(&Paint, paint_message_loop, paint_cb),
123 base::Bind(&SetOpaque), 118 base::Bind(&SetOpaque),
124 true); 119 true));
125 collection->AddVideoRenderer(g_video_renderer);
126 120
127 collection->AddAudioRenderer(new media::AudioRendererImpl( 121 collection->AddAudioRenderer(new media::AudioRendererImpl(
128 message_loop, 122 message_loop,
129 new media::NullAudioSink(), 123 new media::NullAudioSink(),
130 media::SetDecryptorReadyCB())); 124 media::SetDecryptorReadyCB()));
131 125
132 // Create the pipeline and start it. 126 // Create the pipeline and start it.
133 *pipeline = new media::Pipeline(message_loop, new media::MediaLog()); 127 *pipeline = new media::Pipeline(message_loop, new media::MediaLog());
134 media::PipelineStatusNotification note; 128 media::PipelineStatusNotification note;
135 (*pipeline)->Start( 129 (*pipeline)->Start(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // Release callback which releases video renderer. Do this before cleaning up 289 // Release callback which releases video renderer. Do this before cleaning up
296 // X below since the video renderer has some X cleanup duties as well. 290 // X below since the video renderer has some X cleanup duties as well.
297 paint_cb.Reset(); 291 paint_cb.Reset();
298 292
299 XDestroyWindow(g_display, g_window); 293 XDestroyWindow(g_display, g_window);
300 XCloseDisplay(g_display); 294 XCloseDisplay(g_display);
301 g_audio_manager = NULL; 295 g_audio_manager = NULL;
302 296
303 return 0; 297 return 0;
304 } 298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698