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

Side by Side Diff: media/filters/renderer_impl.cc

Issue 591203003: media: Pass DemuxerStreamProvider in Renderer::Initialize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 6 years, 2 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
« no previous file with comments | « media/filters/renderer_impl.h ('k') | media/filters/renderer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/filters/renderer_impl.h" 5 #include "media/filters/renderer_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "media/base/audio_renderer.h" 13 #include "media/base/audio_renderer.h"
14 #include "media/base/demuxer_stream_provider.h" 14 #include "media/base/demuxer_stream_provider.h"
15 #include "media/base/time_source.h" 15 #include "media/base/time_source.h"
16 #include "media/base/video_renderer.h" 16 #include "media/base/video_renderer.h"
17 #include "media/base/wall_clock_time_source.h" 17 #include "media/base/wall_clock_time_source.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 RendererImpl::RendererImpl( 21 RendererImpl::RendererImpl(
22 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 22 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
23 DemuxerStreamProvider* demuxer_stream_provider,
24 scoped_ptr<AudioRenderer> audio_renderer, 23 scoped_ptr<AudioRenderer> audio_renderer,
25 scoped_ptr<VideoRenderer> video_renderer) 24 scoped_ptr<VideoRenderer> video_renderer)
26 : state_(STATE_UNINITIALIZED), 25 : state_(STATE_UNINITIALIZED),
27 task_runner_(task_runner), 26 task_runner_(task_runner),
28 demuxer_stream_provider_(demuxer_stream_provider),
29 audio_renderer_(audio_renderer.Pass()), 27 audio_renderer_(audio_renderer.Pass()),
30 video_renderer_(video_renderer.Pass()), 28 video_renderer_(video_renderer.Pass()),
31 time_source_(NULL), 29 time_source_(NULL),
32 time_ticking_(false), 30 time_ticking_(false),
33 audio_buffering_state_(BUFFERING_HAVE_NOTHING), 31 audio_buffering_state_(BUFFERING_HAVE_NOTHING),
34 video_buffering_state_(BUFFERING_HAVE_NOTHING), 32 video_buffering_state_(BUFFERING_HAVE_NOTHING),
35 audio_ended_(false), 33 audio_ended_(false),
36 video_ended_(false), 34 video_ended_(false),
37 underflow_disabled_for_testing_(false), 35 underflow_disabled_for_testing_(false),
38 clockless_video_playback_enabled_for_testing_(false), 36 clockless_video_playback_enabled_for_testing_(false),
39 weak_factory_(this), 37 weak_factory_(this),
40 weak_this_(weak_factory_.GetWeakPtr()) { 38 weak_this_(weak_factory_.GetWeakPtr()) {
41 DVLOG(1) << __FUNCTION__; 39 DVLOG(1) << __FUNCTION__;
42 } 40 }
43 41
44 RendererImpl::~RendererImpl() { 42 RendererImpl::~RendererImpl() {
45 DVLOG(1) << __FUNCTION__; 43 DVLOG(1) << __FUNCTION__;
46 DCHECK(task_runner_->BelongsToCurrentThread()); 44 DCHECK(task_runner_->BelongsToCurrentThread());
47 45
48 // Tear down in opposite order of construction as |video_renderer_| can still 46 // Tear down in opposite order of construction as |video_renderer_| can still
49 // need |time_source_| (which can be |audio_renderer_|) to be alive. 47 // need |time_source_| (which can be |audio_renderer_|) to be alive.
50 video_renderer_.reset(); 48 video_renderer_.reset();
51 audio_renderer_.reset(); 49 audio_renderer_.reset();
52 50
53 FireAllPendingCallbacks(); 51 FireAllPendingCallbacks();
54 } 52 }
55 53
56 void RendererImpl::Initialize(const base::Closure& init_cb, 54 void RendererImpl::Initialize(DemuxerStreamProvider* demuxer_stream_provider,
55 const base::Closure& init_cb,
57 const StatisticsCB& statistics_cb, 56 const StatisticsCB& statistics_cb,
58 const base::Closure& ended_cb, 57 const base::Closure& ended_cb,
59 const PipelineStatusCB& error_cb, 58 const PipelineStatusCB& error_cb,
60 const BufferingStateCB& buffering_state_cb) { 59 const BufferingStateCB& buffering_state_cb) {
61 DVLOG(1) << __FUNCTION__; 60 DVLOG(1) << __FUNCTION__;
62 DCHECK(task_runner_->BelongsToCurrentThread()); 61 DCHECK(task_runner_->BelongsToCurrentThread());
63 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_; 62 DCHECK_EQ(state_, STATE_UNINITIALIZED) << state_;
64 DCHECK(!init_cb.is_null()); 63 DCHECK(!init_cb.is_null());
65 DCHECK(!statistics_cb.is_null()); 64 DCHECK(!statistics_cb.is_null());
66 DCHECK(!ended_cb.is_null()); 65 DCHECK(!ended_cb.is_null());
67 DCHECK(!error_cb.is_null()); 66 DCHECK(!error_cb.is_null());
68 DCHECK(!buffering_state_cb.is_null()); 67 DCHECK(!buffering_state_cb.is_null());
69 DCHECK(demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO) || 68 DCHECK(demuxer_stream_provider->GetStream(DemuxerStream::AUDIO) ||
70 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO)); 69 demuxer_stream_provider->GetStream(DemuxerStream::VIDEO));
71 70
71 demuxer_stream_provider_ = demuxer_stream_provider;
72 statistics_cb_ = statistics_cb; 72 statistics_cb_ = statistics_cb;
73 ended_cb_ = ended_cb; 73 ended_cb_ = ended_cb;
74 error_cb_ = error_cb; 74 error_cb_ = error_cb;
75 buffering_state_cb_ = buffering_state_cb; 75 buffering_state_cb_ = buffering_state_cb;
76 76
77 init_cb_ = init_cb; 77 init_cb_ = init_cb;
78 state_ = STATE_INITIALIZING; 78 state_ = STATE_INITIALIZING;
79 InitializeAudioRenderer(); 79 InitializeAudioRenderer();
80 } 80 }
81 81
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 DCHECK(task_runner_->BelongsToCurrentThread()); 496 DCHECK(task_runner_->BelongsToCurrentThread());
497 497
498 if (!init_cb_.is_null()) 498 if (!init_cb_.is_null())
499 base::ResetAndReturn(&init_cb_).Run(); 499 base::ResetAndReturn(&init_cb_).Run();
500 500
501 if (!flush_cb_.is_null()) 501 if (!flush_cb_.is_null())
502 base::ResetAndReturn(&flush_cb_).Run(); 502 base::ResetAndReturn(&flush_cb_).Run();
503 } 503 }
504 504
505 } // namespace media 505 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/renderer_impl.h ('k') | media/filters/renderer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698