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

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

Issue 10855051: Use enum instead of string in MessageLoopFactory::GetMessageLoop* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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/movie.cc ('k') | media/tools/seek_tester/seek_tester.cc » ('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"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 scoped_refptr<media::VideoFrame> video_frame; 93 scoped_refptr<media::VideoFrame> video_frame;
94 g_video_renderer->GetCurrentFrame(&video_frame); 94 g_video_renderer->GetCurrentFrame(&video_frame);
95 if (video_frame) 95 if (video_frame)
96 paint_cb.Run(video_frame); 96 paint_cb.Run(video_frame);
97 g_video_renderer->PutCurrentFrame(video_frame); 97 g_video_renderer->PutCurrentFrame(video_frame);
98 } 98 }
99 99
100 // TODO(vrk): Re-enabled audio. (crbug.com/112159) 100 // TODO(vrk): Re-enabled audio. (crbug.com/112159)
101 bool InitPipeline(MessageLoop* message_loop, 101 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop,
102 const scoped_refptr<media::DataSource>& data_source, 102 const scoped_refptr<media::DataSource>& data_source,
103 const PaintCB& paint_cb, 103 const PaintCB& paint_cb,
104 bool /* enable_audio */, 104 bool /* enable_audio */,
105 scoped_refptr<media::Pipeline>* pipeline, 105 scoped_refptr<media::Pipeline>* pipeline,
106 MessageLoop* paint_message_loop, 106 MessageLoop* paint_message_loop,
107 media::MessageLoopFactory* message_loop_factory) { 107 media::MessageLoopFactory* message_loop_factory) {
108 // Load media libraries. 108 // Load media libraries.
109 if (!media::InitializeMediaLibrary(FilePath())) { 109 if (!media::InitializeMediaLibrary(FilePath())) {
110 std::cout << "Unable to initialize the media library." << std::endl; 110 std::cout << "Unable to initialize the media library." << std::endl;
111 return false; 111 return false;
112 } 112 }
113 113
114 // Create our filter factories. 114 // Create our filter factories.
115 scoped_ptr<media::FilterCollection> collection( 115 scoped_ptr<media::FilterCollection> collection(
116 new media::FilterCollection()); 116 new media::FilterCollection());
117 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source)); 117 collection->SetDemuxer(new media::FFmpegDemuxer(message_loop, data_source));
118 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( 118 collection->AddAudioDecoder(new media::FFmpegAudioDecoder(
119 base::Bind(&media::MessageLoopFactory::GetMessageLoop, 119 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
120 base::Unretained(message_loop_factory), 120 base::Unretained(message_loop_factory),
121 "AudioDecoderThread"))); 121 media::MessageLoopFactory::kAudioDecoder)));
122 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder( 122 collection->GetVideoDecoders()->push_back(new media::FFmpegVideoDecoder(
123 base::Bind(&media::MessageLoopFactory::GetMessageLoop, 123 base::Bind(&media::MessageLoopFactory::GetMessageLoop,
124 base::Unretained(message_loop_factory), 124 base::Unretained(message_loop_factory),
125 "VideoDecoderThread"), 125 media::MessageLoopFactory::kVideoDecoder),
126 NULL)); 126 NULL));
127 127
128 // Create our video renderer and save a reference to it for painting. 128 // Create our video renderer and save a reference to it for painting.
129 g_video_renderer = new media::VideoRendererBase( 129 g_video_renderer = new media::VideoRendererBase(
130 base::Bind(&Paint, paint_message_loop, paint_cb), 130 base::Bind(&Paint, paint_message_loop, paint_cb),
131 base::Bind(&SetOpaque), 131 base::Bind(&SetOpaque),
132 true); 132 true);
133 collection->AddVideoRenderer(g_video_renderer); 133 collection->AddVideoRenderer(g_video_renderer);
134 134
135 collection->AddAudioRenderer( 135 collection->AddAudioRenderer(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 &GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window)); 276 &GlVideoRenderer::Paint, new GlVideoRenderer(g_display, g_window));
277 } else { 277 } else {
278 paint_cb = base::Bind( 278 paint_cb = base::Bind(
279 &X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window)); 279 &X11VideoRenderer::Paint, new X11VideoRenderer(g_display, g_window));
280 } 280 }
281 281
282 scoped_refptr<media::DataSource> data_source( 282 scoped_refptr<media::DataSource> data_source(
283 new DataSourceLogger(CreateFileDataSource(filename), 283 new DataSourceLogger(CreateFileDataSource(filename),
284 command_line->HasSwitch("streaming"))); 284 command_line->HasSwitch("streaming")));
285 285
286 if (InitPipeline(thread->message_loop(), data_source, 286 if (InitPipeline(thread->message_loop_proxy(), data_source,
287 paint_cb, command_line->HasSwitch("audio"), 287 paint_cb, command_line->HasSwitch("audio"),
288 &pipeline, &message_loop, message_loop_factory.get())) { 288 &pipeline, &message_loop, message_loop_factory.get())) {
289 // Main loop of the application. 289 // Main loop of the application.
290 g_running = true; 290 g_running = true;
291 291
292 message_loop.PostTask(FROM_HERE, base::Bind( 292 message_loop.PostTask(FROM_HERE, base::Bind(
293 &PeriodicalUpdate, pipeline, &message_loop, !pipeline->HasVideo())); 293 &PeriodicalUpdate, pipeline, &message_loop, !pipeline->HasVideo()));
294 message_loop.Run(); 294 message_loop.Run();
295 } else { 295 } else {
296 std::cout << "Pipeline initialization failed..." << std::endl; 296 std::cout << "Pipeline initialization failed..." << std::endl;
297 } 297 }
298 298
299 // Cleanup tasks. 299 // Cleanup tasks.
300 message_loop_factory.reset(); 300 message_loop_factory.reset();
301 301
302 thread->Stop(); 302 thread->Stop();
303 303
304 // Release callback which releases video renderer. Do this before cleaning up 304 // Release callback which releases video renderer. Do this before cleaning up
305 // X below since the video renderer has some X cleanup duties as well. 305 // X below since the video renderer has some X cleanup duties as well.
306 paint_cb.Reset(); 306 paint_cb.Reset();
307 307
308 XDestroyWindow(g_display, g_window); 308 XDestroyWindow(g_display, g_window);
309 XCloseDisplay(g_display); 309 XCloseDisplay(g_display);
310 g_audio_manager = NULL; 310 g_audio_manager = NULL;
311 311
312 return 0; 312 return 0;
313 } 313 }
OLDNEW
« no previous file with comments | « media/tools/player_wtl/movie.cc ('k') | media/tools/seek_tester/seek_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698