OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/webmediaplayer_ms.h" | 5 #include "content/renderer/media/webmediaplayer_ms.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 WebMediaPlayerMS::WebMediaPlayerMS( | 80 WebMediaPlayerMS::WebMediaPlayerMS( |
81 blink::WebFrame* frame, | 81 blink::WebFrame* frame, |
82 blink::WebMediaPlayerClient* client, | 82 blink::WebMediaPlayerClient* client, |
83 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 83 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
84 media::MediaLog* media_log, | 84 media::MediaLog* media_log, |
85 scoped_ptr<MediaStreamRendererFactory> factory) | 85 scoped_ptr<MediaStreamRendererFactory> factory) |
86 : frame_(frame), | 86 : frame_(frame), |
87 network_state_(WebMediaPlayer::NetworkStateEmpty), | 87 network_state_(WebMediaPlayer::NetworkStateEmpty), |
88 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 88 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
89 buffered_(static_cast<size_t>(1)), | 89 buffered_(static_cast<size_t>(1)), |
| 90 volume_(1.0f), |
90 client_(client), | 91 client_(client), |
91 delegate_(delegate), | 92 delegate_(delegate), |
92 paused_(true), | 93 paused_(true), |
93 current_frame_used_(false), | 94 current_frame_used_(false), |
94 pending_repaint_(false), | 95 pending_repaint_(false), |
95 video_frame_provider_client_(NULL), | 96 video_frame_provider_client_(NULL), |
96 received_first_frame_(false), | 97 received_first_frame_(false), |
97 total_frame_count_(0), | 98 total_frame_count_(0), |
98 dropped_frame_count_(0), | 99 dropped_frame_count_(0), |
99 media_log_(media_log), | 100 media_log_(media_log), |
(...skipping 28 matching lines...) Expand all Loading... |
128 CORSMode cors_mode) { | 129 CORSMode cors_mode) { |
129 DVLOG(1) << "WebMediaPlayerMS::load"; | 130 DVLOG(1) << "WebMediaPlayerMS::load"; |
130 DCHECK(thread_checker_.CalledOnValidThread()); | 131 DCHECK(thread_checker_.CalledOnValidThread()); |
131 | 132 |
132 // TODO(acolwell): Change this to DCHECK_EQ(load_type, | 133 // TODO(acolwell): Change this to DCHECK_EQ(load_type, |
133 // LoadTypeMediaStream) once Blink-side changes land. | 134 // LoadTypeMediaStream) once Blink-side changes land. |
134 DCHECK_NE(load_type, LoadTypeMediaSource); | 135 DCHECK_NE(load_type, LoadTypeMediaSource); |
135 | 136 |
136 GURL gurl(url); | 137 GURL gurl(url); |
137 | 138 |
138 setVolume(GetClient()->volume()); | |
139 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 139 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
140 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 140 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
141 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 141 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
142 | 142 |
143 video_frame_provider_ = renderer_factory_->GetVideoFrameProvider( | 143 video_frame_provider_ = renderer_factory_->GetVideoFrameProvider( |
144 url, | 144 url, |
145 base::Bind(&WebMediaPlayerMS::OnSourceError, AsWeakPtr()), | 145 base::Bind(&WebMediaPlayerMS::OnSourceError, AsWeakPtr()), |
146 base::Bind(&WebMediaPlayerMS::OnFrameAvailable, AsWeakPtr())); | 146 base::Bind(&WebMediaPlayerMS::OnFrameAvailable, AsWeakPtr())); |
147 | 147 |
148 RenderFrame* frame = RenderFrame::FromWebFrame(frame_); | 148 RenderFrame* frame = RenderFrame::FromWebFrame(frame_); |
149 audio_renderer_ = renderer_factory_->GetAudioRenderer( | 149 audio_renderer_ = renderer_factory_->GetAudioRenderer( |
150 url, | 150 url, |
151 frame->GetRenderView()->GetRoutingID(), | 151 frame->GetRenderView()->GetRoutingID(), |
152 frame->GetRoutingID()); | 152 frame->GetRoutingID()); |
153 | 153 |
154 if (video_frame_provider_.get() || audio_renderer_.get()) { | 154 if (video_frame_provider_.get() || audio_renderer_.get()) { |
155 if (audio_renderer_.get()) | 155 if (audio_renderer_.get()) { |
| 156 audio_renderer_->SetVolume(volume_); |
156 audio_renderer_->Start(); | 157 audio_renderer_->Start(); |
| 158 } |
157 | 159 |
158 if (video_frame_provider_.get()) { | 160 if (video_frame_provider_.get()) { |
159 video_frame_provider_->Start(); | 161 video_frame_provider_->Start(); |
160 } else { | 162 } else { |
161 // This is audio-only mode. | 163 // This is audio-only mode. |
162 DCHECK(audio_renderer_.get()); | 164 DCHECK(audio_renderer_.get()); |
163 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 165 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
164 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); | 166 SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); |
165 } | 167 } |
166 } else { | 168 } else { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 void WebMediaPlayerMS::seek(double seconds) { | 229 void WebMediaPlayerMS::seek(double seconds) { |
228 DCHECK(thread_checker_.CalledOnValidThread()); | 230 DCHECK(thread_checker_.CalledOnValidThread()); |
229 } | 231 } |
230 | 232 |
231 void WebMediaPlayerMS::setRate(double rate) { | 233 void WebMediaPlayerMS::setRate(double rate) { |
232 DCHECK(thread_checker_.CalledOnValidThread()); | 234 DCHECK(thread_checker_.CalledOnValidThread()); |
233 } | 235 } |
234 | 236 |
235 void WebMediaPlayerMS::setVolume(double volume) { | 237 void WebMediaPlayerMS::setVolume(double volume) { |
236 DCHECK(thread_checker_.CalledOnValidThread()); | 238 DCHECK(thread_checker_.CalledOnValidThread()); |
237 if (!audio_renderer_.get()) | |
238 return; | |
239 DVLOG(1) << "WebMediaPlayerMS::setVolume(volume=" << volume << ")"; | 239 DVLOG(1) << "WebMediaPlayerMS::setVolume(volume=" << volume << ")"; |
240 audio_renderer_->SetVolume(volume); | 240 volume_ = volume; |
| 241 if (audio_renderer_.get()) |
| 242 audio_renderer_->SetVolume(volume_); |
241 } | 243 } |
242 | 244 |
243 void WebMediaPlayerMS::setPreload(WebMediaPlayer::Preload preload) { | 245 void WebMediaPlayerMS::setPreload(WebMediaPlayer::Preload preload) { |
244 DCHECK(thread_checker_.CalledOnValidThread()); | 246 DCHECK(thread_checker_.CalledOnValidThread()); |
245 } | 247 } |
246 | 248 |
247 bool WebMediaPlayerMS::hasVideo() const { | 249 bool WebMediaPlayerMS::hasVideo() const { |
248 DCHECK(thread_checker_.CalledOnValidThread()); | 250 DCHECK(thread_checker_.CalledOnValidThread()); |
249 return (video_frame_provider_.get() != NULL); | 251 return (video_frame_provider_.get() != NULL); |
250 } | 252 } |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 GetClient()->readyStateChanged(); | 471 GetClient()->readyStateChanged(); |
470 } | 472 } |
471 | 473 |
472 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { | 474 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { |
473 DCHECK(thread_checker_.CalledOnValidThread()); | 475 DCHECK(thread_checker_.CalledOnValidThread()); |
474 DCHECK(client_); | 476 DCHECK(client_); |
475 return client_; | 477 return client_; |
476 } | 478 } |
477 | 479 |
478 } // namespace content | 480 } // namespace content |
OLD | NEW |