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

Side by Side Diff: media/blink/webmediaplayer_impl.h

Issue 1759123003: Revert of Extract state management from WebMediaPlayerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/blink/webmediaplayer_cast_android.cc ('k') | media/blink/webmediaplayer_impl.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 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 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 12 matching lines...) Expand all
23 #include "media/base/surface_manager.h" 23 #include "media/base/surface_manager.h"
24 #include "media/base/text_track.h" 24 #include "media/base/text_track.h"
25 #include "media/blink/buffered_data_source.h" 25 #include "media/blink/buffered_data_source.h"
26 #include "media/blink/buffered_data_source_host_impl.h" 26 #include "media/blink/buffered_data_source_host_impl.h"
27 #include "media/blink/media_blink_export.h" 27 #include "media/blink/media_blink_export.h"
28 #include "media/blink/multibuffer_data_source.h" 28 #include "media/blink/multibuffer_data_source.h"
29 #include "media/blink/video_frame_compositor.h" 29 #include "media/blink/video_frame_compositor.h"
30 #include "media/blink/webmediaplayer_delegate.h" 30 #include "media/blink/webmediaplayer_delegate.h"
31 #include "media/blink/webmediaplayer_params.h" 31 #include "media/blink/webmediaplayer_params.h"
32 #include "media/blink/webmediaplayer_util.h" 32 #include "media/blink/webmediaplayer_util.h"
33 #include "media/filters/pipeline_controller.h"
34 #include "media/renderers/skcanvas_video_renderer.h" 33 #include "media/renderers/skcanvas_video_renderer.h"
35 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
36 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
37 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
38 #include "url/gurl.h" 37 #include "url/gurl.h"
39 38
40 #if defined(OS_ANDROID) // WMPI_CAST 39 #if defined(OS_ANDROID) // WMPI_CAST
41 // Delete this file when WMPI_CAST is no longer needed. 40 // Delete this file when WMPI_CAST is no longer needed.
42 #include "media/blink/webmediaplayer_cast_android.h" 41 #include "media/blink/webmediaplayer_cast_android.h"
43 #endif 42 #endif
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 158
160 blink::WebAudioSourceProvider* audioSourceProvider() override; 159 blink::WebAudioSourceProvider* audioSourceProvider() override;
161 160
162 void setContentDecryptionModule( 161 void setContentDecryptionModule(
163 blink::WebContentDecryptionModule* cdm, 162 blink::WebContentDecryptionModule* cdm,
164 blink::WebContentDecryptionModuleResult result) override; 163 blink::WebContentDecryptionModuleResult result) override;
165 164
166 void enteredFullscreen() override; 165 void enteredFullscreen() override;
167 void exitedFullscreen() override; 166 void exitedFullscreen() override;
168 167
168 void OnPipelineSeeked(bool time_changed, PipelineStatus status);
169 void OnPipelineSuspended(PipelineStatus status);
170 void OnPipelineEnded();
171 void OnPipelineError(PipelineStatus error);
172 void OnPipelineMetadata(PipelineMetadata metadata);
173 void OnPipelineBufferingStateChanged(BufferingState buffering_state);
174 void OnDemuxerOpened();
175 void OnAddTextTrack(const TextTrackConfig& config,
176 const AddTextTrackDoneCB& done_cb);
177
169 // WebMediaPlayerDelegate::Observer implementation. 178 // WebMediaPlayerDelegate::Observer implementation.
170 void OnHidden(bool must_suspend) override; 179 void OnHidden(bool must_suspend) override;
171 void OnShown() override; 180 void OnShown() override;
172 void OnPlay() override; 181 void OnPlay() override;
173 void OnPause() override; 182 void OnPause() override;
174 void OnVolumeMultiplierUpdate(double multiplier) override; 183 void OnVolumeMultiplierUpdate(double multiplier) override;
175 184
176 #if defined(OS_ANDROID) // WMPI_CAST 185 #if defined(OS_ANDROID) // WMPI_CAST
177 bool isRemote() const override; 186 bool isRemote() const override;
178 void requestRemotePlayback() override; 187 void requestRemotePlayback() override;
179 void requestRemotePlaybackControl() override; 188 void requestRemotePlaybackControl() override;
180 189
181 void SetMediaPlayerManager( 190 void SetMediaPlayerManager(
182 RendererMediaPlayerManagerInterface* media_player_manager); 191 RendererMediaPlayerManagerInterface* media_player_manager);
183 void OnRemotePlaybackEnded(); 192 void OnRemotePlaybackEnded();
184 void OnDisconnectedFromRemoteDevice(double t); 193 void OnDisconnectedFromRemoteDevice(double t);
185 void SuspendForRemote(); 194 void SuspendForRemote();
186 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, 195 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame,
187 PipelineStatus status); 196 PipelineStatus status);
188 gfx::Size GetCanvasSize() const; 197 gfx::Size GetCanvasSize() const;
189 void SetDeviceScaleFactor(float scale_factor); 198 void SetDeviceScaleFactor(float scale_factor);
190 #endif 199 #endif
191 200
192 // Called from WebMediaPlayerCast. 201 private:
193 // TODO(hubbe): WMPI_CAST make private. 202 // Ask for the pipeline to be suspended, will call Suspend() when ready.
194 void OnPipelineSeeked(bool time_updated); 203 // (Possibly immediately.)
204 void ScheduleSuspend();
195 205
196 private: 206 // Initiate suspending the pipeline.
197 void OnPipelineSuspended(); 207 void Suspend();
198 void OnPipelineResumed();
199 void OnPipelineEnded();
200 void OnPipelineError(PipelineStatus error);
201 void OnPipelineMetadata(PipelineMetadata metadata);
202 void OnPipelineBufferingStateChanged(BufferingState buffering_state);
203 void OnDemuxerOpened();
204 void OnAddTextTrack(const TextTrackConfig& config,
205 const AddTextTrackDoneCB& done_cb);
206 208
207 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when 209 // Ask for the pipeline to be resumed, will call Resume() when ready.
208 // |time_updated| is false. 210 // (Possibly immediately.)
209 void DoSeek(base::TimeDelta time, bool time_updated); 211 void ScheduleResume();
212
213 // Initiate resuming the pipeline.
214 void Resume();
210 215
211 // Ask for the renderer to be restarted (destructed and recreated). 216 // Ask for the renderer to be restarted (destructed and recreated).
212 void ScheduleRestart(); 217 void ScheduleRestart();
213 218
214 // Called after |defer_load_cb_| has decided to allow the load. If 219 // Called after |defer_load_cb_| has decided to allow the load. If
215 // |defer_load_cb_| is null this is called immediately. 220 // |defer_load_cb_| is null this is called immediately.
216 void DoLoad(LoadType load_type, 221 void DoLoad(LoadType load_type,
217 const blink::WebURL& url, 222 const blink::WebURL& url,
218 CORSMode cors_mode); 223 CORSMode cors_mode);
219 224
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // is not available. 265 // is not available.
261 void OnWaitingForDecryptionKey(); 266 void OnWaitingForDecryptionKey();
262 267
263 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. 268 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done.
264 // Parameter order is reversed for easy binding. 269 // Parameter order is reversed for easy binding.
265 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); 270 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context);
266 271
267 // Called when a CDM has been attached to the |pipeline_|. 272 // Called when a CDM has been attached to the |pipeline_|.
268 void OnCdmAttached(bool success); 273 void OnCdmAttached(bool success);
269 274
275 // Updates |paused_time_| to the current media time with consideration for the
276 // |ended_| state by clamping current time to duration upon |ended_|.
277 void UpdatePausedTime();
278
270 // Notifies |delegate_| that playback has started or was paused; also starts 279 // Notifies |delegate_| that playback has started or was paused; also starts
271 // or stops the memory usage reporting timer respectively. 280 // or stops the memory usage reporting timer respectively.
272 void NotifyPlaybackStarted(); 281 void NotifyPlaybackStarted();
273 void NotifyPlaybackPaused(); 282 void NotifyPlaybackPaused();
274 283
275 // Called at low frequency to tell external observers how much memory we're 284 // Called at low frequency to tell external observers how much memory we're
276 // using for video playback. Called by |memory_usage_reporting_timer_|. 285 // using for video playback. Called by |memory_usage_reporting_timer_|.
277 // Memory usage reporting is done in two steps, because |demuxer_| must be 286 // Memory usage reporting is done in two steps, because |demuxer_| must be
278 // accessed on the media thread. 287 // accessed on the media thread.
279 void ReportMemoryUsage(); 288 void ReportMemoryUsage();
(...skipping 12 matching lines...) Expand all
292 // setBufferingStrategy(). 301 // setBufferingStrategy().
293 BufferedDataSource::BufferingStrategy buffering_strategy_; 302 BufferedDataSource::BufferingStrategy buffering_strategy_;
294 303
295 // Task runner for posting tasks on Chrome's main thread. Also used 304 // Task runner for posting tasks on Chrome's main thread. Also used
296 // for DCHECKs so methods calls won't execute in the wrong thread. 305 // for DCHECKs so methods calls won't execute in the wrong thread.
297 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 306 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
298 307
299 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_; 308 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner_;
300 scoped_refptr<base::TaskRunner> worker_task_runner_; 309 scoped_refptr<base::TaskRunner> worker_task_runner_;
301 scoped_refptr<MediaLog> media_log_; 310 scoped_refptr<MediaLog> media_log_;
302
303 // |pipeline_controller_| references |pipeline_| and therefore must be
304 // constructed after and destructed before |pipeline_|.
305 PipelineImpl pipeline_; 311 PipelineImpl pipeline_;
306 PipelineController pipeline_controller_;
307 312
308 // The LoadType passed in the |load_type| parameter of the load() call. 313 // The LoadType passed in the |load_type| parameter of the load() call.
309 LoadType load_type_; 314 LoadType load_type_;
310 315
311 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize(). 316 // Cache of metadata for answering hasAudio(), hasVideo(), and naturalSize().
312 PipelineMetadata pipeline_metadata_; 317 PipelineMetadata pipeline_metadata_;
313 318
314 // Whether the video is known to be opaque or not. 319 // Whether the video is known to be opaque or not.
315 bool opaque_; 320 bool opaque_;
316 321
317 // Playback state. 322 // Playback state.
318 // 323 //
319 // TODO(scherkus): we have these because Pipeline favours the simplicity of a 324 // TODO(scherkus): we have these because Pipeline favours the simplicity of a
320 // single "playback rate" over worrying about paused/stopped etc... It forces 325 // single "playback rate" over worrying about paused/stopped etc... It forces
321 // all clients to manage the pause+playback rate externally, but is that 326 // all clients to manage the pause+playback rate externally, but is that
322 // really a bad thing? 327 // really a bad thing?
323 // 328 //
324 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want 329 // TODO(scherkus): since SetPlaybackRate(0) is asynchronous and we don't want
325 // to hang the render thread during pause(), we record the time at the same 330 // to hang the render thread during pause(), we record the time at the same
326 // time we pause and then return that value in currentTime(). Otherwise our 331 // time we pause and then return that value in currentTime(). Otherwise our
327 // clock can creep forward a little bit while the asynchronous 332 // clock can creep forward a little bit while the asynchronous
328 // SetPlaybackRate(0) is being executed. 333 // SetPlaybackRate(0) is being executed.
329 double playback_rate_; 334 double playback_rate_;
330
331 // Set while paused. |paused_time_| is only valid when |paused_| is true.
332 bool paused_; 335 bool paused_;
333 base::TimeDelta paused_time_; 336 base::TimeDelta paused_time_;
337 bool seeking_;
334 338
335 // Set when starting, seeking, and resuming (all of which require a Pipeline 339 // Set when seeking (|seeking_| is true) or resuming.
336 // seek). |seek_time_| is only valid when |seeking_| is true.
337 bool seeking_;
338 base::TimeDelta seek_time_; 340 base::TimeDelta seek_time_;
339 341
342 // Set when a suspend is required but another suspend or seek is in progress.
343 bool pending_suspend_;
344
345 // Set when suspending immediately after a seek. The time change will happen
346 // after Resume().
347 bool pending_time_change_;
348
349 // Set when a resume is required but suspending is in progress.
350 bool pending_resume_;
351
352 // Set for the entire period between suspend starting and resume completing.
353 bool suspending_;
354
355 // Set while suspending to detect double-suspend.
356 bool suspended_;
357
358 // Set while resuming to detect double-resume.
359 bool resuming_;
360
340 // Set when doing a restart (a suspend and resume in sequence) of the pipeline 361 // Set when doing a restart (a suspend and resume in sequence) of the pipeline
341 // in order to destruct and reinitialize the decoders. This is separate from 362 // in order to destruct and reinitialize the decoders. This is separate from
342 // |pending_resume_| and |pending_suspend_| because they can be elided in 363 // |pending_resume_| and |pending_suspend_| because they can be elided in
343 // certain cases, whereas for a restart they must happen. 364 // certain cases, whereas for a restart they must happen.
344 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart. 365 // TODO(sandersd,watk): Create a simpler interface for a pipeline restart.
345 bool pending_suspend_resume_cycle_; 366 bool pending_suspend_resume_cycle_;
346 367
347 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement, 368 // TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement,
348 // see http://crbug.com/409280 369 // see http://crbug.com/409280
349 bool ended_; 370 bool ended_;
350 371
372 // Indicates that a seek is queued after the current seek completes or, if the
373 // pipeline is suspended, after it resumes. Only the last queued seek will
374 // have any effect.
375 bool pending_seek_;
376
377 // |pending_seek_time_| is meaningless when |pending_seek_| is false.
378 base::TimeDelta pending_seek_time_;
379
351 // Tracks whether to issue time changed notifications during buffering state 380 // Tracks whether to issue time changed notifications during buffering state
352 // changes. 381 // changes.
353 bool should_notify_time_changed_; 382 bool should_notify_time_changed_;
354 383
355 bool fullscreen_; 384 bool fullscreen_;
356 385
357 // Whether the current decoder requires a restart on fullscreen transitions. 386 // Whether the current decoder requires a restart on fullscreen transitions.
358 bool decoder_requires_restart_for_fullscreen_; 387 bool decoder_requires_restart_for_fullscreen_;
359 388
360 blink::WebMediaPlayerClient* client_; 389 blink::WebMediaPlayerClient* client_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // started; prevents us from spuriously logging errors that are transient or 458 // started; prevents us from spuriously logging errors that are transient or
430 // unimportant. 459 // unimportant.
431 bool suppress_destruction_errors_; 460 bool suppress_destruction_errors_;
432 461
433 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 462 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
434 }; 463 };
435 464
436 } // namespace media 465 } // namespace media
437 466
438 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 467 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_cast_android.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698