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

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

Issue 2658513003: [Cleanup] Rename Hidden to Background in WMPI.
Patch Set: More renames in the comments etc Created 3 years, 11 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 | « no previous file | 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 <memory> 10 #include <memory>
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 322
323 // Inspects the current playback state and: 323 // Inspects the current playback state and:
324 // - notifies |delegate_|, 324 // - notifies |delegate_|,
325 // - toggles the memory usage reporting timer, and 325 // - toggles the memory usage reporting timer, and
326 // - toggles suspend/resume as necessary. 326 // - toggles suspend/resume as necessary.
327 // 327 //
328 // This method should be called any time its dependent values change. These 328 // This method should be called any time its dependent values change. These
329 // are: 329 // are:
330 // - isRemote(), 330 // - isRemote(),
331 // - hasVideo(), 331 // - hasVideo(),
332 // - delegate_->IsHidden(), 332 // - delegate_->IsFrameHidden(),
333 // - network_state_, ready_state_, 333 // - network_state_, ready_state_,
334 // - is_idle_, must_suspend_, 334 // - is_idle_, must_suspend_,
335 // - paused_, ended_, 335 // - paused_, ended_,
336 // - pending_suspend_resume_cycle_, 336 // - pending_suspend_resume_cycle_,
337 void UpdatePlayState(); 337 void UpdatePlayState();
338 338
339 // Methods internal to UpdatePlayState(). 339 // Methods internal to UpdatePlayState().
340 PlayState UpdatePlayState_ComputePlayState(bool is_remote, 340 PlayState UpdatePlayState_ComputePlayState(bool is_remote,
341 bool is_streaming, 341 bool is_streaming,
342 bool is_suspended, 342 bool is_suspended,
343 bool is_backgrounded); 343 bool is_backgrounded);
344 void SetDelegateState(DelegateState new_state, bool is_idle); 344 void SetDelegateState(DelegateState new_state, bool is_idle);
345 void SetMemoryReportingState(bool is_memory_reporting_enabled); 345 void SetMemoryReportingState(bool is_memory_reporting_enabled);
346 void SetSuspendState(bool is_suspended); 346 void SetSuspendState(bool is_suspended);
347 347
348 // Called at low frequency to tell external observers how much memory we're 348 // Called at low frequency to tell external observers how much memory we're
349 // using for video playback. Called by |memory_usage_reporting_timer_|. 349 // using for video playback. Called by |memory_usage_reporting_timer_|.
350 // Memory usage reporting is done in two steps, because |demuxer_| must be 350 // Memory usage reporting is done in two steps, because |demuxer_| must be
351 // accessed on the media thread. 351 // accessed on the media thread.
352 void ReportMemoryUsage(); 352 void ReportMemoryUsage();
353 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); 353 void FinishMemoryUsageReport(int64_t demuxer_memory_usage);
354 354
355 // Called during OnHidden() when we want a suspended player to enter the 355 // Called during OnFrameHidden() when we want a suspended player to enter the
356 // paused state after some idle timeout. 356 // paused state after some idle timeout.
357 void ScheduleIdlePauseTimer(); 357 void ScheduleIdlePauseTimer();
358 358
359 // Returns |true| before HaveFutureData whenever there has been loading 359 // Returns |true| before HaveFutureData whenever there has been loading
360 // progress and we have not been resumed for at least kLoadingToIdleTimeout 360 // progress and we have not been resumed for at least kLoadingToIdleTimeout
361 // since then. 361 // since then.
362 // 362 //
363 // This is used to delay suspension long enough for preroll to complete, which 363 // This is used to delay suspension long enough for preroll to complete, which
364 // is necessay because play() will not be called before HaveFutureData (and 364 // is necessay because play() will not be called before HaveFutureData (and
365 // thus we think we are idle forever). 365 // thus we think we are idle forever).
366 bool IsPrerollAttemptNeeded(); 366 bool IsPrerollAttemptNeeded();
367 367
368 void CreateWatchTimeReporter(); 368 void CreateWatchTimeReporter();
369 369
370 // Returns true if the player is hidden. 370 // Returns true if the player is in the background.
371 bool IsHidden() const; 371 bool IsBackgrounded() const;
372 372
373 // Returns true if the player's source is streaming. 373 // Returns true if the player's source is streaming.
374 bool IsStreaming() const; 374 bool IsStreaming() const;
375 375
376 // Return whether |pipeline_metadata_| is compatible with an overlay. This 376 // Return whether |pipeline_metadata_| is compatible with an overlay. This
377 // is intended for android. 377 // is intended for android.
378 bool DoesOverlaySupportMetadata() const; 378 bool DoesOverlaySupportMetadata() const;
379 379
380 // Whether the video should be paused when hidden. Uses metadata so has 380 // Whether the video should be paused when in the background. Uses metadata so
381 // meaning only after the pipeline has started, otherwise returns false. 381 // has meaning only after the pipeline has started, otherwise returns false.
382 // Doesn't check if the video can actually be paused depending on the 382 // Doesn't check if the video can actually be paused depending on the
383 // pipeline's state. 383 // pipeline's state.
384 bool ShouldPauseVideoWhenHidden() const; 384 bool ShouldPauseVideoWhenBackground() const;
385 385
386 // Whether the video track should be disabled when hidden. Uses metadata so 386 // Whether the video track should be disabled when in the background. Uses
387 // has meaning only after the pipeline has started, otherwise returns false. 387 // metadata so has meaning only after the pipeline has started, otherwise
388 // Doesn't check if the video track can actually be disabled depending on the 388 // returns false. Doesn't check if the video track can actually be disabled
389 // pipeline's state. 389 // depending on the pipeline's state.
390 bool ShouldDisableVideoWhenHidden() const; 390 bool ShouldDisableVideoWhenBackground() const;
391 391
392 // Whether the video is suitable for background playback optimizations (either 392 // Whether the video is suitable for background playback optimizations (either
393 // pausing it or disabling the video track). Uses metadata so has meaning only 393 // pausing it or disabling the video track). Uses metadata so has meaning only
394 // after the pipeline has started, otherwise returns false. 394 // after the pipeline has started, otherwise returns false.
395 // The logical OR between the two methods above that is also used as their 395 // The logical OR between the two methods above that is also used as their
396 // common implementation. 396 // common implementation.
397 bool IsBackgroundOptimizationCandidate() const; 397 bool IsBackgroundOptimizationCandidate() const;
398 398
399 // If enabling or disabling background video optimization has been delayed, 399 // If enabling or disabling background video optimization has been delayed,
400 // because of the pipeline not running, seeking or resuming, this method 400 // because of the pipeline not running, seeking or resuming, this method
401 // needs to be called to update the optimization state. 401 // needs to be called to update the optimization state.
402 void UpdateBackgroundVideoOptimizationState(); 402 void UpdateBackgroundVideoOptimizationState();
403 403
404 // Pauses a hidden video only player to save power if possible. 404 // Pauses a background video only player to save power if possible.
405 // Must be called when either of the following happens: 405 // Must be called when either of the following happens:
406 // - right after the video was hidden, 406 // - right after the video was backgrounded,
407 // - right ater the pipeline has resumed if the video is hidden. 407 // - right ater the pipeline has resumed if the video is in the background.
408 void PauseVideoIfNeeded(); 408 void PauseVideoIfNeeded();
409 409
410 // Disables the video track to save power if possible. 410 // Disables the video track to save power if possible.
411 // Must be called when either of the following happens: 411 // Must be called when either of the following happens:
412 // - right after the video was hidden, 412 // - right after the video was backgrounded,
413 // - right after the pipeline has started (|seeking_| is used to detect the 413 // - right after the pipeline has started (|seeking_| is used to detect the
414 // when pipeline started) if the video is hidden, 414 // when pipeline started) if the video is in the background,
415 // - right ater the pipeline has resumed if the video is hidden. 415 // - right ater the pipeline has resumed if the video is in the background.
416 void DisableVideoTrackIfNeeded(); 416 void DisableVideoTrackIfNeeded();
417 417
418 // Enables the video track if it was disabled before to save power. 418 // Enables the video track if it was disabled before to save power.
419 // Must be called when either of the following happens: 419 // Must be called when either of the following happens:
420 // - right after the video was shown, 420 // - right after the video was put in the foreground,
421 // - right before the pipeline is requested to resume 421 // - right before the pipeline is requested to resume
422 // (see https://crbug.com/678374), 422 // (see https://crbug.com/678374),
423 // - right after the pipeline has resumed if the video is not hidden. 423 // - right after the pipeline has resumed if the video is not in the
424 // background.
424 void EnableVideoTrackIfNeeded(); 425 void EnableVideoTrackIfNeeded();
425 426
426 // Overrides the pipeline statistics returned by GetPiplineStatistics() for 427 // Overrides the pipeline statistics returned by GetPiplineStatistics() for
427 // tests. 428 // tests.
428 void SetPipelineStatisticsForTest(const PipelineStatistics& stats); 429 void SetPipelineStatisticsForTest(const PipelineStatistics& stats);
429 430
430 // Returns the pipeline statistics or the value overridden by tests. 431 // Returns the pipeline statistics or the value overridden by tests.
431 PipelineStatistics GetPipelineStatistics() const; 432 PipelineStatistics GetPipelineStatistics() const;
432 433
433 // Overrides the pipeline media duration returned by 434 // Overrides the pipeline media duration returned by
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // to hang the render thread during pause(), we record the time at the same 493 // to hang the render thread during pause(), we record the time at the same
493 // time we pause and then return that value in currentTime(). Otherwise our 494 // time we pause and then return that value in currentTime(). Otherwise our
494 // clock can creep forward a little bit while the asynchronous 495 // clock can creep forward a little bit while the asynchronous
495 // SetPlaybackRate(0) is being executed. 496 // SetPlaybackRate(0) is being executed.
496 double playback_rate_; 497 double playback_rate_;
497 498
498 // Set while paused. |paused_time_| is only valid when |paused_| is true. 499 // Set while paused. |paused_time_| is only valid when |paused_| is true.
499 bool paused_; 500 bool paused_;
500 base::TimeDelta paused_time_; 501 base::TimeDelta paused_time_;
501 502
502 // Set if paused automatically when hidden and need to resume when visible. 503 // Set if paused automatically when backgrounded and need to resume when
503 // Reset if paused for any other reason. 504 // foregrounded. Reset if paused for any other reason.
504 bool paused_when_hidden_; 505 bool paused_when_background_;
505 506
506 // Set when starting, seeking, and resuming (all of which require a Pipeline 507 // Set when starting, seeking, and resuming (all of which require a Pipeline
507 // seek). |seek_time_| is only valid when |seeking_| is true. 508 // seek). |seek_time_| is only valid when |seeking_| is true.
508 bool seeking_; 509 bool seeking_;
509 base::TimeDelta seek_time_; 510 base::TimeDelta seek_time_;
510 511
511 // Set when doing a restart (a suspend and resume in sequence) of the pipeline 512 // Set when doing a restart (a suspend and resume in sequence) of the pipeline
512 // in order to destruct and reinitialize the decoders. This is separate from 513 // in order to destruct and reinitialize the decoders. This is separate from
513 // |pending_resume_| and |pending_suspend_| because they can be elided in 514 // |pending_resume_| and |pending_suspend_| because they can be elided in
514 // certain cases, whereas for a restart they must happen. 515 // certain cases, whereas for a restart they must happen.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 687
687 // Pipeline media duration overridden by tests. 688 // Pipeline media duration overridden by tests.
688 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_; 689 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_;
689 690
690 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 691 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
691 }; 692 };
692 693
693 } // namespace media 694 } // namespace media
694 695
695 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 696 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698