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

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

Issue 6648004: DemuxerFactory is born! (Closed)
Patch Set: Created 9 years, 9 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
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/message_loop_factory_impl.h"
21 #include "media/base/pipeline_impl.h" 21 #include "media/base/pipeline_impl.h"
22 #include "media/filters/audio_renderer_impl.h" 22 #include "media/filters/audio_renderer_impl.h"
23 #include "media/filters/ffmpeg_audio_decoder.h" 23 #include "media/filters/ffmpeg_audio_decoder.h"
24 #include "media/filters/ffmpeg_demuxer.h" 24 #include "media/filters/ffmpeg_demuxer_factory.h"
25 #include "media/filters/ffmpeg_video_decoder.h" 25 #include "media/filters/ffmpeg_video_decoder.h"
26 #include "media/filters/file_data_source_factory.h" 26 #include "media/filters/file_data_source_factory.h"
27 #include "media/filters/null_audio_renderer.h" 27 #include "media/filters/null_audio_renderer.h"
28 #include "media/filters/omx_video_decoder.h" 28 #include "media/filters/omx_video_decoder.h"
29 29
30 // TODO(jiesun): implement different video decode contexts according to 30 // TODO(jiesun): implement different video decode contexts according to
31 // these flags. e.g. 31 // these flags. e.g.
32 // 1. system memory video decode context for x11 32 // 1. system memory video decode context for x11
33 // 2. gl texture video decode context for OpenGL. 33 // 2. gl texture video decode context for OpenGL.
34 // 3. gles texture video decode context for OpenGLES. 34 // 3. gles texture video decode context for OpenGLES.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 std::cout << "Unable to initialize OpenMAX library."<< std::endl; 93 std::cout << "Unable to initialize OpenMAX library."<< std::endl;
94 return false; 94 return false;
95 } 95 }
96 96
97 // Load media libraries. 97 // Load media libraries.
98 if (!media::InitializeMediaLibrary(FilePath())) { 98 if (!media::InitializeMediaLibrary(FilePath())) {
99 std::cout << "Unable to initialize the media library." << std::endl; 99 std::cout << "Unable to initialize the media library." << std::endl;
100 return false; 100 return false;
101 } 101 }
102 102
103 // Create the pipeline.
104 *pipeline = new media::PipelineImpl(message_loop);
acolwell GONE FROM CHROMIUM 2011/03/08 21:48:09 Move back if FFmpegDemuxerFactory doesn't need Fil
Ami GONE FROM CHROMIUM 2011/03/08 22:44:48 Done.
105
103 // Create our filter factories. 106 // Create our filter factories.
104 scoped_ptr<media::FilterCollection> collection( 107 scoped_ptr<media::FilterCollection> collection(
105 new media::FilterCollection()); 108 new media::FilterCollection());
106 collection->SetDataSourceFactory(new media::FileDataSourceFactory()); 109 collection->SetDemuxerFactory(
107 collection->AddDemuxer(new media::FFmpegDemuxer( 110 new media::FFmpegDemuxerFactory(
108 message_loop_factory->GetMessageLoop("DemuxThread"))); 111 new media::FileDataSourceFactory(), message_loop, pipeline->get()));
109 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( 112 collection->AddAudioDecoder(new media::FFmpegAudioDecoder(
110 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); 113 message_loop_factory->GetMessageLoop("AudioDecoderThread")));
111 if (CommandLine::ForCurrentProcess()->HasSwitch( 114 if (CommandLine::ForCurrentProcess()->HasSwitch(
112 switches::kEnableOpenMax)) { 115 switches::kEnableOpenMax)) {
113 collection->AddVideoDecoder(new media::OmxVideoDecoder( 116 collection->AddVideoDecoder(new media::OmxVideoDecoder(
114 message_loop_factory->GetMessageLoop("VideoDecoderThread"), 117 message_loop_factory->GetMessageLoop("VideoDecoderThread"),
115 NULL)); 118 NULL));
116 } else { 119 } else {
117 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( 120 collection->AddVideoDecoder(new media::FFmpegVideoDecoder(
118 message_loop_factory->GetMessageLoop("VideoDecoderThread"), 121 message_loop_factory->GetMessageLoop("VideoDecoderThread"),
119 NULL)); 122 NULL));
120 } 123 }
121 collection->AddVideoRenderer(new Renderer(g_display, 124 collection->AddVideoRenderer(new Renderer(g_display,
122 g_window, 125 g_window,
123 paint_message_loop)); 126 paint_message_loop));
124 127
125 if (enable_audio) 128 if (enable_audio)
126 collection->AddAudioRenderer(new media::AudioRendererImpl()); 129 collection->AddAudioRenderer(new media::AudioRendererImpl());
127 else 130 else
128 collection->AddAudioRenderer(new media::NullAudioRenderer()); 131 collection->AddAudioRenderer(new media::NullAudioRenderer());
129 132
130 // Creates the pipeline and start it. 133 // Start the pipeline.
131 *pipeline = new media::PipelineImpl(message_loop);
132 (*pipeline)->Start(collection.release(), filename, NULL); 134 (*pipeline)->Start(collection.release(), filename, NULL);
133 135
134 // Wait until the pipeline is fully initialized. 136 // Wait until the pipeline is fully initialized.
135 while (true) { 137 while (true) {
136 base::PlatformThread::Sleep(100); 138 base::PlatformThread::Sleep(100);
137 if ((*pipeline)->IsInitialized()) 139 if ((*pipeline)->IsInitialized())
138 break; 140 break;
139 if ((*pipeline)->GetError() != media::PIPELINE_OK) { 141 if ((*pipeline)->GetError() != media::PIPELINE_OK) {
142 std::cout << "InitPipeline: " << (*pipeline)->GetError() << std::endl;
acolwell GONE FROM CHROMIUM 2011/03/08 21:48:09 remove
Ami GONE FROM CHROMIUM 2011/03/08 22:44:48 Keeping; it's useful for figuring out what went wr
acolwell GONE FROM CHROMIUM 2011/03/08 23:19:00 Sounds good to me.
140 (*pipeline)->Stop(NULL); 143 (*pipeline)->Stop(NULL);
141 return false; 144 return false;
142 } 145 }
143 } 146 }
144 147
145 // And starts the playback. 148 // And starts the playback.
146 (*pipeline)->SetPlaybackRate(1.0f); 149 (*pipeline)->SetPlaybackRate(1.0f);
147 return true; 150 return true;
148 } 151 }
149 152
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 280 }
278 281
279 // Cleanup tasks. 282 // Cleanup tasks.
280 message_loop_factory.reset(); 283 message_loop_factory.reset();
281 284
282 thread->Stop(); 285 thread->Stop();
283 XDestroyWindow(g_display, g_window); 286 XDestroyWindow(g_display, g_window);
284 XCloseDisplay(g_display); 287 XCloseDisplay(g_display);
285 return 0; 288 return 0;
286 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698