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 <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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return; | 90 return; |
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 static void OnBufferingState(media::Pipeline::BufferingState buffering_state) {} |
| 101 |
100 // TODO(vrk): Re-enabled audio. (crbug.com/112159) | 102 // TODO(vrk): Re-enabled audio. (crbug.com/112159) |
101 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 103 bool InitPipeline(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
102 const scoped_refptr<media::DataSource>& data_source, | 104 const scoped_refptr<media::DataSource>& data_source, |
103 const PaintCB& paint_cb, | 105 const PaintCB& paint_cb, |
104 bool /* enable_audio */, | 106 bool /* enable_audio */, |
105 scoped_refptr<media::Pipeline>* pipeline, | 107 scoped_refptr<media::Pipeline>* pipeline, |
106 MessageLoop* paint_message_loop, | 108 MessageLoop* paint_message_loop, |
107 media::MessageLoopFactory* message_loop_factory) { | 109 media::MessageLoopFactory* message_loop_factory) { |
108 // Load media libraries. | 110 // Load media libraries. |
109 if (!media::InitializeMediaLibrary(FilePath())) { | 111 if (!media::InitializeMediaLibrary(FilePath())) { |
(...skipping 23 matching lines...) Expand all Loading... |
133 collection->AddVideoRenderer(g_video_renderer); | 135 collection->AddVideoRenderer(g_video_renderer); |
134 | 136 |
135 collection->AddAudioRenderer( | 137 collection->AddAudioRenderer( |
136 new media::AudioRendererImpl(new media::NullAudioSink())); | 138 new media::AudioRendererImpl(new media::NullAudioSink())); |
137 | 139 |
138 // Create the pipeline and start it. | 140 // Create the pipeline and start it. |
139 *pipeline = new media::Pipeline(message_loop, new media::MediaLog()); | 141 *pipeline = new media::Pipeline(message_loop, new media::MediaLog()); |
140 media::PipelineStatusNotification note; | 142 media::PipelineStatusNotification note; |
141 (*pipeline)->Start( | 143 (*pipeline)->Start( |
142 collection.Pass(), media::PipelineStatusCB(), media::PipelineStatusCB(), | 144 collection.Pass(), media::PipelineStatusCB(), media::PipelineStatusCB(), |
143 note.Callback()); | 145 note.Callback(), base::Bind(&OnBufferingState)); |
144 | 146 |
145 // Wait until the pipeline is fully initialized. | 147 // Wait until the pipeline is fully initialized. |
146 note.Wait(); | 148 note.Wait(); |
147 if (note.status() != media::PIPELINE_OK) { | 149 if (note.status() != media::PIPELINE_OK) { |
148 std::cout << "InitPipeline: " << note.status() << std::endl; | 150 std::cout << "InitPipeline: " << note.status() << std::endl; |
149 (*pipeline)->Stop(base::Closure()); | 151 (*pipeline)->Stop(base::Closure()); |
150 return false; | 152 return false; |
151 } | 153 } |
152 | 154 |
153 // And start the playback. | 155 // And start the playback. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // Release callback which releases video renderer. Do this before cleaning up | 306 // 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. | 307 // X below since the video renderer has some X cleanup duties as well. |
306 paint_cb.Reset(); | 308 paint_cb.Reset(); |
307 | 309 |
308 XDestroyWindow(g_display, g_window); | 310 XDestroyWindow(g_display, g_window); |
309 XCloseDisplay(g_display); | 311 XCloseDisplay(g_display); |
310 g_audio_manager = NULL; | 312 g_audio_manager = NULL; |
311 | 313 |
312 return 0; | 314 return 0; |
313 } | 315 } |
OLD | NEW |