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

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

Issue 11468033: Vanquish the remnants of media::MessageLoopFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comment Created 7 years, 11 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
« no previous file with comments | « media/media.gyp ('k') | webkit/media/webkit_media.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/platform_thread.h" 14 #include "base/threading/platform_thread.h"
15 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
16 #include "media/audio/audio_manager.h" 16 #include "media/audio/audio_manager.h"
17 #include "media/audio/null_audio_sink.h" 17 #include "media/audio/null_audio_sink.h"
18 #include "media/base/decryptor.h" 18 #include "media/base/decryptor.h"
19 #include "media/base/filter_collection.h" 19 #include "media/base/filter_collection.h"
20 #include "media/base/media.h" 20 #include "media/base/media.h"
21 #include "media/base/media_log.h" 21 #include "media/base/media_log.h"
22 #include "media/base/media_switches.h" 22 #include "media/base/media_switches.h"
23 #include "media/base/message_loop_factory.h"
24 #include "media/base/pipeline.h" 23 #include "media/base/pipeline.h"
25 #include "media/base/video_frame.h" 24 #include "media/base/video_frame.h"
26 #include "media/filters/audio_renderer_impl.h" 25 #include "media/filters/audio_renderer_impl.h"
27 #include "media/filters/ffmpeg_audio_decoder.h" 26 #include "media/filters/ffmpeg_audio_decoder.h"
28 #include "media/filters/ffmpeg_demuxer.h" 27 #include "media/filters/ffmpeg_demuxer.h"
29 #include "media/filters/ffmpeg_video_decoder.h" 28 #include "media/filters/ffmpeg_video_decoder.h"
30 #include "media/filters/file_data_source.h" 29 #include "media/filters/file_data_source.h"
31 #include "media/filters/video_renderer_base.h" 30 #include "media/filters/video_renderer_base.h"
32 #include "media/tools/player_x11/data_source_logger.h" 31 #include "media/tools/player_x11/data_source_logger.h"
33 32
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 98 }
100 99
101 static void OnBufferingState(media::Pipeline::BufferingState buffering_state) {} 100 static void OnBufferingState(media::Pipeline::BufferingState buffering_state) {}
102 101
103 // TODO(vrk): Re-enabled audio. (crbug.com/112159) 102 // TODO(vrk): Re-enabled audio. (crbug.com/112159)
104 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, 103 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
105 const scoped_refptr<media::DataSource>& data_source, 104 const scoped_refptr<media::DataSource>& data_source,
106 const PaintCB& paint_cb, 105 const PaintCB& paint_cb,
107 bool /* enable_audio */, 106 bool /* enable_audio */,
108 scoped_refptr<media::Pipeline>* pipeline, 107 scoped_refptr<media::Pipeline>* pipeline,
109 MessageLoop* paint_message_loop, 108 MessageLoop* paint_message_loop) {
110 media::MessageLoopFactory* message_loop_factory) {
111 // Create our filter factories. 109 // Create our filter factories.
112 scoped_ptr<media::FilterCollection> collection( 110 scoped_ptr<media::FilterCollection> collection(
113 new media::FilterCollection()); 111 new media::FilterCollection());
114 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source)); 112 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source));
115 collection->GetAudioDecoders()->push_back(new media::FFmpegAudioDecoder( 113 collection->GetAudioDecoders()->push_back(new media::FFmpegAudioDecoder(
116 message_loop)); 114 message_loop));
117 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder( 115 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder(
118 message_loop)); 116 message_loop));
119 117
120 // Create our video renderer and save a reference to it for painting. 118 // Create our video renderer and save a reference to it for painting.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 250
253 // Install the signal handler. 251 // Install the signal handler.
254 signal(SIGTERM, &TerminateHandler); 252 signal(SIGTERM, &TerminateHandler);
255 signal(SIGINT, &TerminateHandler); 253 signal(SIGINT, &TerminateHandler);
256 254
257 // Initialize X11. 255 // Initialize X11.
258 if (!InitX11()) 256 if (!InitX11())
259 return 1; 257 return 1;
260 258
261 // Initialize the pipeline thread and the pipeline. 259 // Initialize the pipeline thread and the pipeline.
262 scoped_ptr<media::MessageLoopFactory> message_loop_factory( 260 MessageLoop message_loop;
263 new media::MessageLoopFactory()); 261 base::Thread media_thread("MediaThread");
264 scoped_ptr<base::Thread> thread; 262 media_thread.Start();
265 scoped_refptr<media::Pipeline> pipeline; 263 scoped_refptr<media::Pipeline> pipeline;
266 MessageLoop message_loop;
267 thread.reset(new base::Thread("PipelineThread"));
268 thread->Start();
269 264
270 PaintCB paint_cb; 265 PaintCB paint_cb;
271 if (command_line->HasSwitch("use-gl")) { 266 if (command_line->HasSwitch("use-gl")) {
272 paint_cb = base::Bind( 267 paint_cb = base::Bind(
273 &GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window)); 268 &GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window));
274 } else { 269 } else {
275 paint_cb = base::Bind( 270 paint_cb = base::Bind(
276 &X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window)); 271 &X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window));
277 } 272 }
278 273
279 scoped_refptr<media::DataSource> data_source( 274 scoped_refptr<media::DataSource> data_source(
280 new DataSourceLogger(CreateFileDataSource(filename), 275 new DataSourceLogger(CreateFileDataSource(filename),
281 command_line->HasSwitch("streaming"))); 276 command_line->HasSwitch("streaming")));
282 277
283 if (InitPipeline(thread->message_loop_proxy(), data_source, 278 if (InitPipeline(media_thread.message_loop_proxy(), data_source,
284 paint_cb, command_line->HasSwitch("audio"), 279 paint_cb, command_line->HasSwitch("audio"),
285 &pipeline, &message_loop, message_loop_factory.get())) { 280 &pipeline, &message_loop)) {
286 // Main loop of the application. 281 // Main loop of the application.
287 g_running = true; 282 g_running = true;
288 283
289 message_loop.PostTask(FROM_HERE, base::Bind( 284 message_loop.PostTask(FROM_HERE, base::Bind(
290 &PeriodicalUpdate, pipeline, &message_loop, !pipeline->HasVideo())); 285 &PeriodicalUpdate, pipeline, &message_loop, !pipeline->HasVideo()));
291 message_loop.Run(); 286 message_loop.Run();
292 } else { 287 } else {
293 std::cout << "Pipeline initialization failed..." << std::endl; 288 std::cout << "Pipeline initialization failed..." << std::endl;
294 } 289 }
295 290
296 // Cleanup tasks. 291 // Cleanup tasks.
297 message_loop_factory.reset(); 292 media_thread.Stop();
298
299 thread->Stop();
300 293
301 // Release callback which releases video renderer. Do this before cleaning up 294 // Release callback which releases video renderer. Do this before cleaning up
302 // X below since the video renderer has some X cleanup duties as well. 295 // X below since the video renderer has some X cleanup duties as well.
303 paint_cb.Reset(); 296 paint_cb.Reset();
304 297
305 XDestroyWindow(g_display, g_window); 298 XDestroyWindow(g_display, g_window);
306 XCloseDisplay(g_display); 299 XCloseDisplay(g_display);
307 g_audio_manager = NULL; 300 g_audio_manager = NULL;
308 301
309 return 0; 302 return 0;
310 } 303 }
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | webkit/media/webkit_media.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698