| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/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/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/adaptive_demuxer.h" | 22 #include "media/filters/adaptive_demuxer.h" |
| 23 #include "media/filters/audio_renderer_impl.h" | 23 #include "media/filters/audio_renderer_impl.h" |
| 24 #include "media/filters/ffmpeg_audio_decoder.h" | 24 #include "media/filters/ffmpeg_audio_decoder.h" |
| 25 #include "media/filters/ffmpeg_demuxer_factory.h" | 25 #include "media/filters/ffmpeg_demuxer_factory.h" |
| 26 #include "media/filters/ffmpeg_video_decoder.h" | 26 #include "media/filters/ffmpeg_video_decoder.h" |
| 27 #include "media/filters/file_data_source_factory.h" | 27 #include "media/filters/file_data_source_factory.h" |
| 28 #include "media/filters/null_audio_renderer.h" | 28 #include "media/filters/null_audio_renderer.h" |
| 29 #include "media/filters/omx_video_decoder.h" |
| 29 | 30 |
| 30 // TODO(jiesun): implement different video decode contexts according to | 31 // TODO(jiesun): implement different video decode contexts according to |
| 31 // these flags. e.g. | 32 // these flags. e.g. |
| 32 // 1. system memory video decode context for x11 | 33 // 1. system memory video decode context for x11 |
| 33 // 2. gl texture video decode context for OpenGL. | 34 // 2. gl texture video decode context for OpenGL. |
| 34 // 3. gles texture video decode context for OpenGLES. | 35 // 3. gles texture video decode context for OpenGLES. |
| 35 // TODO(jiesun): add an uniform video renderer which take the video | 36 // TODO(jiesun): add an uniform video renderer which take the video |
| 36 // decode context object and delegate renderer request to these | 37 // decode context object and delegate renderer request to these |
| 37 // objects. i.e. Seperate "painter" and "pts scheduler". | 38 // objects. i.e. Seperate "painter" and "pts scheduler". |
| 38 #if defined(RENDERER_GL) | 39 #if defined(RENDERER_GL) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 ExposureMask | ButtonPressMask | KeyPressMask); | 88 ExposureMask | ButtonPressMask | KeyPressMask); |
| 88 XMapWindow(g_display, g_window); | 89 XMapWindow(g_display, g_window); |
| 89 return true; | 90 return true; |
| 90 } | 91 } |
| 91 | 92 |
| 92 bool InitPipeline(MessageLoop* message_loop, | 93 bool InitPipeline(MessageLoop* message_loop, |
| 93 const char* filename, bool enable_audio, | 94 const char* filename, bool enable_audio, |
| 94 scoped_refptr<media::PipelineImpl>* pipeline, | 95 scoped_refptr<media::PipelineImpl>* pipeline, |
| 95 MessageLoop* paint_message_loop, | 96 MessageLoop* paint_message_loop, |
| 96 media::MessageLoopFactory* message_loop_factory) { | 97 media::MessageLoopFactory* message_loop_factory) { |
| 98 // Initialize OpenMAX. |
| 99 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 100 switches::kEnableOpenMax) && |
| 101 !media::InitializeOpenMaxLibrary(FilePath())) { |
| 102 std::cout << "Unable to initialize OpenMAX library."<< std::endl; |
| 103 return false; |
| 104 } |
| 105 |
| 97 // Load media libraries. | 106 // Load media libraries. |
| 98 if (!media::InitializeMediaLibrary(FilePath())) { | 107 if (!media::InitializeMediaLibrary(FilePath())) { |
| 99 std::cout << "Unable to initialize the media library." << std::endl; | 108 std::cout << "Unable to initialize the media library." << std::endl; |
| 100 return false; | 109 return false; |
| 101 } | 110 } |
| 102 | 111 |
| 103 // Create our filter factories. | 112 // Create our filter factories. |
| 104 scoped_ptr<media::FilterCollection> collection( | 113 scoped_ptr<media::FilterCollection> collection( |
| 105 new media::FilterCollection()); | 114 new media::FilterCollection()); |
| 106 collection->SetDemuxerFactory( | 115 collection->SetDemuxerFactory( |
| 107 new media::AdaptiveDemuxerFactory( | 116 new media::AdaptiveDemuxerFactory( |
| 108 new media::FFmpegDemuxerFactory( | 117 new media::FFmpegDemuxerFactory( |
| 109 new media::FileDataSourceFactory(), message_loop))); | 118 new media::FileDataSourceFactory(), message_loop))); |
| 110 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( | 119 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 111 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); | 120 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); |
| 112 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( | 121 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 113 message_loop_factory->GetMessageLoop("VideoDecoderThread"), | 122 switches::kEnableOpenMax)) { |
| 114 NULL)); | 123 collection->AddVideoDecoder(new media::OmxVideoDecoder( |
| 124 message_loop_factory->GetMessageLoop("VideoDecoderThread"), |
| 125 NULL)); |
| 126 } else { |
| 127 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 128 message_loop_factory->GetMessageLoop("VideoDecoderThread"), |
| 129 NULL)); |
| 130 } |
| 115 collection->AddVideoRenderer(new Renderer(g_display, | 131 collection->AddVideoRenderer(new Renderer(g_display, |
| 116 g_window, | 132 g_window, |
| 117 paint_message_loop)); | 133 paint_message_loop)); |
| 118 | 134 |
| 119 if (enable_audio) | 135 if (enable_audio) |
| 120 collection->AddAudioRenderer(new media::AudioRendererImpl()); | 136 collection->AddAudioRenderer(new media::AudioRendererImpl()); |
| 121 else | 137 else |
| 122 collection->AddAudioRenderer(new media::NullAudioRenderer()); | 138 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
| 123 | 139 |
| 124 // Create the pipeline and start it. | 140 // Create the pipeline and start it. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 NewRunnableFunction(PeriodicalUpdate, make_scoped_refptr(pipeline), | 227 NewRunnableFunction(PeriodicalUpdate, make_scoped_refptr(pipeline), |
| 212 message_loop, audio_only), 10); | 228 message_loop, audio_only), 10); |
| 213 } | 229 } |
| 214 | 230 |
| 215 int main(int argc, char** argv) { | 231 int main(int argc, char** argv) { |
| 216 // Read arguments. | 232 // Read arguments. |
| 217 if (argc == 1) { | 233 if (argc == 1) { |
| 218 std::cout << "Usage: " << argv[0] << " --file=FILE" << std::endl | 234 std::cout << "Usage: " << argv[0] << " --file=FILE" << std::endl |
| 219 << std::endl | 235 << std::endl |
| 220 << "Optional arguments:" << std::endl | 236 << "Optional arguments:" << std::endl |
| 237 << " [--enable-openmax]" |
| 221 << " [--audio]" | 238 << " [--audio]" |
| 222 << " [--alsa-device=DEVICE]" << std::endl | 239 << " [--alsa-device=DEVICE]" << std::endl |
| 223 << " Press [ESC] to stop" << std::endl | 240 << " Press [ESC] to stop" << std::endl |
| 224 << " Press [SPACE] to toggle pause/play" << std::endl | 241 << " Press [SPACE] to toggle pause/play" << std::endl |
| 225 << " Press mouse left button to seek" << std::endl; | 242 << " Press mouse left button to seek" << std::endl; |
| 226 return 1; | 243 return 1; |
| 227 } | 244 } |
| 228 | 245 |
| 229 // Read command line. | 246 // Read command line. |
| 230 CommandLine::Init(argc, argv); | 247 CommandLine::Init(argc, argv); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 292 } |
| 276 | 293 |
| 277 // Cleanup tasks. | 294 // Cleanup tasks. |
| 278 message_loop_factory.reset(); | 295 message_loop_factory.reset(); |
| 279 | 296 |
| 280 thread->Stop(); | 297 thread->Stop(); |
| 281 XDestroyWindow(g_display, g_window); | 298 XDestroyWindow(g_display, g_window); |
| 282 XCloseDisplay(g_display); | 299 XCloseDisplay(g_display); |
| 283 return 0; | 300 return 0; |
| 284 } | 301 } |
| OLD | NEW |