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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 scoped_refptr<media::VideoFrame> video_frame; | 92 scoped_refptr<media::VideoFrame> video_frame; |
93 g_video_renderer->GetCurrentFrame(&video_frame); | 93 g_video_renderer->GetCurrentFrame(&video_frame); |
94 if (video_frame) | 94 if (video_frame) |
95 paint_cb.Run(video_frame); | 95 paint_cb.Run(video_frame); |
96 g_video_renderer->PutCurrentFrame(video_frame); | 96 g_video_renderer->PutCurrentFrame(video_frame); |
97 } | 97 } |
98 | 98 |
99 bool InitPipeline(MessageLoop* message_loop, | 99 bool InitPipeline(MessageLoop* message_loop, |
100 const char* filename, | 100 const char* filename, |
101 const PaintCB& paint_cb, | 101 const PaintCB& paint_cb, |
102 bool enable_audio, | 102 bool /* enable_audio */, |
scherkus (not reviewing)
2012/01/28 02:12:52
can we TODO for adding audio back in w/ bug?
vrk (LEFT CHROMIUM)
2012/01/31 23:53:08
Done.
| |
103 scoped_refptr<media::Pipeline>* pipeline, | 103 scoped_refptr<media::Pipeline>* pipeline, |
104 MessageLoop* paint_message_loop, | 104 MessageLoop* paint_message_loop, |
105 media::MessageLoopFactory* message_loop_factory) { | 105 media::MessageLoopFactory* message_loop_factory) { |
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 // Open the file. | 112 // Open the file. |
(...skipping 12 matching lines...) Expand all Loading... | |
125 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); | 125 message_loop_factory->GetMessageLoop("AudioDecoderThread"))); |
126 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( | 126 collection->AddVideoDecoder(new media::FFmpegVideoDecoder( |
127 message_loop_factory->GetMessageLoop("VideoDecoderThread"))); | 127 message_loop_factory->GetMessageLoop("VideoDecoderThread"))); |
128 | 128 |
129 // Create our video renderer and save a reference to it for painting. | 129 // Create our video renderer and save a reference to it for painting. |
130 g_video_renderer = new media::VideoRendererBase( | 130 g_video_renderer = new media::VideoRendererBase( |
131 base::Bind(&Paint, paint_message_loop, paint_cb), | 131 base::Bind(&Paint, paint_message_loop, paint_cb), |
132 base::Bind(&SetOpaque)); | 132 base::Bind(&SetOpaque)); |
133 collection->AddVideoRenderer(g_video_renderer); | 133 collection->AddVideoRenderer(g_video_renderer); |
134 | 134 |
135 if (enable_audio) { | 135 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
136 collection->AddAudioRenderer( | |
137 new media::ReferenceAudioRenderer(g_audio_manager)); | |
138 } else { | |
139 collection->AddAudioRenderer(new media::NullAudioRenderer()); | |
140 } | |
141 | 136 |
142 // Create the pipeline and start it. | 137 // Create the pipeline and start it. |
143 *pipeline = new media::Pipeline(message_loop, new media::MediaLog()); | 138 *pipeline = new media::Pipeline(message_loop, new media::MediaLog()); |
144 media::PipelineStatusNotification note; | 139 media::PipelineStatusNotification note; |
145 (*pipeline)->Start(collection.Pass(), filename, note.Callback()); | 140 (*pipeline)->Start(collection.Pass(), filename, note.Callback()); |
146 | 141 |
147 // Wait until the pipeline is fully initialized. | 142 // Wait until the pipeline is fully initialized. |
148 note.Wait(); | 143 note.Wait(); |
149 if (note.status() != media::PIPELINE_OK) { | 144 if (note.status() != media::PIPELINE_OK) { |
150 std::cout << "InitPipeline: " << note.status() << std::endl; | 145 std::cout << "InitPipeline: " << note.status() << std::endl; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 // Release callback which releases video renderer. Do this before cleaning up | 305 // Release callback which releases video renderer. Do this before cleaning up |
311 // 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. |
312 paint_cb.Reset(); | 307 paint_cb.Reset(); |
313 | 308 |
314 XDestroyWindow(g_display, g_window); | 309 XDestroyWindow(g_display, g_window); |
315 XCloseDisplay(g_display); | 310 XCloseDisplay(g_display); |
316 g_audio_manager = NULL; | 311 g_audio_manager = NULL; |
317 | 312 |
318 return 0; | 313 return 0; |
319 } | 314 } |
OLD | NEW |