| OLD | NEW |
| 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 <X11/keysym.h> | 5 #include <X11/keysym.h> |
| 6 #include <X11/Xlib.h> | 6 #include <X11/Xlib.h> |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <iostream> // NOLINT | 9 #include <iostream> // NOLINT |
| 10 | 10 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Load media libraries. | 106 // Load media libraries. |
| 107 if (!media::InitializeMediaLibrary(FilePath())) { | 107 if (!media::InitializeMediaLibrary(FilePath())) { |
| 108 std::cout << "Unable to initialize the media library." << std::endl; | 108 std::cout << "Unable to initialize the media library." << std::endl; |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // Create our filter factories. | 112 // Create our filter factories. |
| 113 scoped_ptr<media::FilterCollection> collection( | 113 scoped_ptr<media::FilterCollection> collection( |
| 114 new media::FilterCollection()); | 114 new media::FilterCollection()); |
| 115 collection->SetDemuxerFactory( | 115 collection->SetDemuxerFactory( |
| 116 new media::FFmpegDemuxerFactory( | 116 scoped_ptr<media::DemuxerFactory>( |
| 117 new media::FileDataSourceFactory(), message_loop)); | 117 new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>( |
| 118 new media::FileDataSourceFactory()), message_loop))); |
| 118 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( | 119 collection->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 119 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); | 120 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); |
| 120 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( | 121 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 121 message_loop_factory->GetMessageLoop("VideoDecoderThread"))); | 122 message_loop_factory->GetMessageLoop("VideoDecoderThread"))); |
| 122 | 123 |
| 123 // Create our video renderer and save a reference to it for painting. | 124 // Create our video renderer and save a reference to it for painting. |
| 124 g_video_renderer = new media::VideoRendererBase( | 125 g_video_renderer = new media::VideoRendererBase( |
| 125 base::Bind(&Paint, paint_message_loop, paint_cb), | 126 base::Bind(&Paint, paint_message_loop, paint_cb), |
| 126 base::Bind(&SetOpaque)); | 127 base::Bind(&SetOpaque)); |
| 127 collection->AddVideoRenderer(g_video_renderer); | 128 collection->AddVideoRenderer(g_video_renderer); |
| 128 | 129 |
| 129 if (enable_audio) { | 130 if (enable_audio) { |
| 130 collection->AddAudioRenderer( | 131 collection->AddAudioRenderer( |
| 131 new media::ReferenceAudioRenderer(g_audio_manager)); | 132 new media::ReferenceAudioRenderer(g_audio_manager)); |
| 132 } else { | 133 } else { |
| 133 collection->AddAudioRenderer(new media::NullAudioRenderer()); | 134 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
| 134 } | 135 } |
| 135 | 136 |
| 136 // Create the pipeline and start it. | 137 // Create the pipeline and start it. |
| 137 *pipeline = new media::PipelineImpl(message_loop, new media::MediaLog()); | 138 *pipeline = new media::PipelineImpl(message_loop, new media::MediaLog()); |
| 138 media::PipelineStatusNotification note; | 139 media::PipelineStatusNotification note; |
| 139 (*pipeline)->Start(collection.release(), filename, note.Callback()); | 140 (*pipeline)->Start(collection.Pass(), filename, note.Callback()); |
| 140 | 141 |
| 141 // Wait until the pipeline is fully initialized. | 142 // Wait until the pipeline is fully initialized. |
| 142 note.Wait(); | 143 note.Wait(); |
| 143 if (note.status() != media::PIPELINE_OK) { | 144 if (note.status() != media::PIPELINE_OK) { |
| 144 std::cout << "InitPipeline: " << note.status() << std::endl; | 145 std::cout << "InitPipeline: " << note.status() << std::endl; |
| 145 (*pipeline)->Stop(media::PipelineStatusCB()); | 146 (*pipeline)->Stop(media::PipelineStatusCB()); |
| 146 return false; | 147 return false; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // And start the playback. | 150 // And start the playback. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // Release callback which releases video renderer. Do this before cleaning up | 305 // 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. | 306 // X below since the video renderer has some X cleanup duties as well. |
| 306 paint_cb.Reset(); | 307 paint_cb.Reset(); |
| 307 | 308 |
| 308 XDestroyWindow(g_display, g_window); | 309 XDestroyWindow(g_display, g_window); |
| 309 XCloseDisplay(g_display); | 310 XCloseDisplay(g_display); |
| 310 g_audio_manager = NULL; | 311 g_audio_manager = NULL; |
| 311 | 312 |
| 312 return 0; | 313 return 0; |
| 313 } | 314 } |
| OLD | NEW |