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

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

Issue 6171009: Remove MessageLoop methods from Filter interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied more CR suggestions & removed message_loop() methods where possible. Created 9 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/tools/player_wtl/view.h ('k') | media/tools/player_x11/x11_video_renderer.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <iostream> 5 #include <iostream>
6 #include <signal.h> 6 #include <signal.h>
7 #include <X11/keysym.h> 7 #include <X11/keysym.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.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/scoped_ptr.h" 13 #include "base/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/base/callback.h" 16 #include "media/base/callback.h"
17 #include "media/base/filter_collection.h" 17 #include "media/base/filter_collection.h"
18 #include "media/base/media.h" 18 #include "media/base/media.h"
19 #include "media/base/media_switches.h" 19 #include "media/base/media_switches.h"
20 #include "media/base/message_loop_factory_impl.h"
20 #include "media/base/pipeline_impl.h" 21 #include "media/base/pipeline_impl.h"
21 #include "media/filters/audio_renderer_impl.h" 22 #include "media/filters/audio_renderer_impl.h"
22 #include "media/filters/ffmpeg_audio_decoder.h" 23 #include "media/filters/ffmpeg_audio_decoder.h"
23 #include "media/filters/ffmpeg_demuxer.h" 24 #include "media/filters/ffmpeg_demuxer.h"
24 #include "media/filters/ffmpeg_video_decoder.h" 25 #include "media/filters/ffmpeg_video_decoder.h"
25 #include "media/filters/file_data_source.h" 26 #include "media/filters/file_data_source.h"
26 #include "media/filters/null_audio_renderer.h" 27 #include "media/filters/null_audio_renderer.h"
27 #include "media/filters/omx_video_decoder.h" 28 #include "media/filters/omx_video_decoder.h"
28 29
29 // TODO(jiesun): implement different video decode contexts according to 30 // TODO(jiesun): implement different video decode contexts according to
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 XSelectInput(g_display, g_window, 78 XSelectInput(g_display, g_window,
78 ExposureMask | ButtonPressMask | KeyPressMask); 79 ExposureMask | ButtonPressMask | KeyPressMask);
79 XMapWindow(g_display, g_window); 80 XMapWindow(g_display, g_window);
80 return true; 81 return true;
81 } 82 }
82 83
83 bool InitPipeline(MessageLoop* message_loop, 84 bool InitPipeline(MessageLoop* message_loop,
84 const char* filename, bool enable_audio, 85 const char* filename, bool enable_audio,
85 scoped_refptr<media::PipelineImpl>* pipeline, 86 scoped_refptr<media::PipelineImpl>* pipeline,
86 MessageLoop* paint_message_loop) { 87 MessageLoop* paint_message_loop,
88 media::MessageLoopFactory* message_loop_factory) {
87 // Initialize OpenMAX. 89 // Initialize OpenMAX.
88 if (CommandLine::ForCurrentProcess()->HasSwitch( 90 if (CommandLine::ForCurrentProcess()->HasSwitch(
89 switches::kEnableOpenMax) && 91 switches::kEnableOpenMax) &&
90 !media::InitializeOpenMaxLibrary(FilePath())) { 92 !media::InitializeOpenMaxLibrary(FilePath())) {
91 std::cout << "Unable to initialize OpenMAX library."<< std::endl; 93 std::cout << "Unable to initialize OpenMAX library."<< std::endl;
92 return false; 94 return false;
93 } 95 }
94 96
95 // Load media libraries. 97 // Load media libraries.
96 if (!media::InitializeMediaLibrary(FilePath())) { 98 if (!media::InitializeMediaLibrary(FilePath())) {
97 std::cout << "Unable to initialize the media library." << std::endl; 99 std::cout << "Unable to initialize the media library." << std::endl;
98 return false; 100 return false;
99 } 101 }
100 102
101 // Create our filter factories. 103 // Create our filter factories.
102 scoped_ptr<media::FilterCollection> collection( 104 scoped_ptr<media::FilterCollection> collection(
103 new media::FilterCollection()); 105 new media::FilterCollection());
104 collection->AddDataSource(new media::FileDataSource()); 106 collection->AddDataSource(new media::FileDataSource());
105 collection->AddDemuxer(new media::FFmpegDemuxer()); 107 collection->AddDemuxer(new media::FFmpegDemuxer(
106 collection->AddAudioDecoder(new media::FFmpegAudioDecoder()); 108 message_loop_factory->GetMessageLoop("DemuxThread")));
109 collection->AddAudioDecoder(new media::FFmpegAudioDecoder(
110 message_loop_factory->GetMessageLoop("AudioDecoderThread")));
107 if (CommandLine::ForCurrentProcess()->HasSwitch( 111 if (CommandLine::ForCurrentProcess()->HasSwitch(
108 switches::kEnableOpenMax)) { 112 switches::kEnableOpenMax)) {
109 collection->AddVideoDecoder(new media::OmxVideoDecoder(NULL)); 113 collection->AddVideoDecoder(new media::OmxVideoDecoder(
114 message_loop_factory->GetMessageLoop("VideoDecoderThread"),
115 NULL));
110 } else { 116 } else {
111 collection->AddVideoDecoder(new media::FFmpegVideoDecoder(NULL)); 117 collection->AddVideoDecoder(new media::FFmpegVideoDecoder(
118 message_loop_factory->GetMessageLoop("VideoDecoderThread"),
119 NULL));
112 } 120 }
113 collection->AddVideoRenderer(new Renderer(g_display, 121 collection->AddVideoRenderer(new Renderer(g_display,
114 g_window, 122 g_window,
115 paint_message_loop)); 123 paint_message_loop));
116 124
117 if (enable_audio) 125 if (enable_audio)
118 collection->AddAudioRenderer(new media::AudioRendererImpl()); 126 collection->AddAudioRenderer(new media::AudioRendererImpl());
119 else 127 else
120 collection->AddAudioRenderer(new media::NullAudioRenderer()); 128 collection->AddAudioRenderer(new media::NullAudioRenderer());
121 129
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Install the signal handler. 245 // Install the signal handler.
238 signal(SIGTERM, &TerminateHandler); 246 signal(SIGTERM, &TerminateHandler);
239 signal(SIGINT, &TerminateHandler); 247 signal(SIGINT, &TerminateHandler);
240 248
241 // Initialize X11. 249 // Initialize X11.
242 if (!InitX11()) 250 if (!InitX11())
243 return 1; 251 return 1;
244 252
245 // Initialize the pipeline thread and the pipeline. 253 // Initialize the pipeline thread and the pipeline.
246 base::AtExitManager at_exit; 254 base::AtExitManager at_exit;
255 scoped_ptr<media::MessageLoopFactory> message_loop_factory(
256 new media::MessageLoopFactoryImpl());
247 scoped_ptr<base::Thread> thread; 257 scoped_ptr<base::Thread> thread;
248 scoped_refptr<media::PipelineImpl> pipeline; 258 scoped_refptr<media::PipelineImpl> pipeline;
249 MessageLoop message_loop; 259 MessageLoop message_loop;
250 thread.reset(new base::Thread("PipelineThread")); 260 thread.reset(new base::Thread("PipelineThread"));
251 thread->Start(); 261 thread->Start();
252 if (InitPipeline(thread->message_loop(), filename.c_str(), 262 if (InitPipeline(thread->message_loop(), filename.c_str(),
253 enable_audio, &pipeline, &message_loop)) { 263 enable_audio, &pipeline, &message_loop,
264 message_loop_factory.get())) {
254 // Main loop of the application. 265 // Main loop of the application.
255 g_running = true; 266 g_running = true;
256 267
257 // Check if video is present. 268 // Check if video is present.
258 audio_only = !pipeline->IsRendered(media::mime_type::kMajorTypeVideo); 269 audio_only = !pipeline->IsRendered(media::mime_type::kMajorTypeVideo);
259 270
260 message_loop.PostTask(FROM_HERE, 271 message_loop.PostTask(FROM_HERE,
261 NewRunnableFunction(PeriodicalUpdate, pipeline, 272 NewRunnableFunction(PeriodicalUpdate, pipeline,
262 &message_loop, audio_only)); 273 &message_loop, audio_only));
263 message_loop.Run(); 274 message_loop.Run();
264 } else{ 275 } else{
265 std::cout << "Pipeline initialization failed..." << std::endl; 276 std::cout << "Pipeline initialization failed..." << std::endl;
266 } 277 }
267 278
268 // Cleanup tasks. 279 // Cleanup tasks.
280 message_loop_factory.reset();
281
269 thread->Stop(); 282 thread->Stop();
270 XDestroyWindow(g_display, g_window); 283 XDestroyWindow(g_display, g_window);
271 XCloseDisplay(g_display); 284 XCloseDisplay(g_display);
272 return 0; 285 return 0;
273 } 286 }
OLDNEW
« no previous file with comments | « media/tools/player_wtl/view.h ('k') | media/tools/player_x11/x11_video_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698