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

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

Issue 2611333003: [Video] Disable bg optimization if avg keyframe distance is >10s (Closed)
Patch Set: Unittest 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
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>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/cancelable_callback.h" 14 #include "base/cancelable_callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/optional.h"
20 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
21 #include "base/time/default_tick_clock.h" 22 #include "base/time/default_tick_clock.h"
23 #include "base/time/time.h"
22 #include "base/timer/elapsed_timer.h" 24 #include "base/timer/elapsed_timer.h"
23 #include "base/timer/timer.h" 25 #include "base/timer/timer.h"
24 #include "build/build_config.h" 26 #include "build/build_config.h"
25 #include "media/base/media_observer.h" 27 #include "media/base/media_observer.h"
26 #include "media/base/media_tracks.h" 28 #include "media/base/media_tracks.h"
27 #include "media/base/pipeline_impl.h" 29 #include "media/base/pipeline_impl.h"
28 #include "media/base/renderer_factory.h" 30 #include "media/base/renderer_factory.h"
29 #include "media/base/surface_manager.h" 31 #include "media/base/surface_manager.h"
30 #include "media/base/text_track.h" 32 #include "media/base/text_track.h"
31 #include "media/blink/buffered_data_source_host_impl.h" 33 #include "media/blink/buffered_data_source_host_impl.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 void DisableVideoTrackIfNeeded(); 392 void DisableVideoTrackIfNeeded();
391 393
392 // Enables the video track if it was disabled before to save power. 394 // Enables the video track if it was disabled before to save power.
393 // Must be called when either of the following happens: 395 // Must be called when either of the following happens:
394 // - right after the video was shown, 396 // - right after the video was shown,
395 // - right before the pipeline is requested to resume 397 // - right before the pipeline is requested to resume
396 // (see https://crbug.com/678374), 398 // (see https://crbug.com/678374),
397 // - right after the pipeline has resumed if the video is not hidden. 399 // - right after the pipeline has resumed if the video is not hidden.
398 void EnableVideoTrackIfNeeded(); 400 void EnableVideoTrackIfNeeded();
399 401
402 // Overrides the pipeline statistics returned by GetStatistics() for tests.
403 void SetPipelineStatisticsForTest(const PipelineStatistics& stats);
404
405 // Returns the pipeline statistics or the value overridden by tests.
406 PipelineStatistics GetPipelineStatistics() const;
407
400 blink::WebLocalFrame* frame_; 408 blink::WebLocalFrame* frame_;
401 409
402 // The playback state last reported to |delegate_|, to avoid setting duplicate 410 // The playback state last reported to |delegate_|, to avoid setting duplicate
403 // states. (Which can have undesired effects like resetting the idle timer.) 411 // states. (Which can have undesired effects like resetting the idle timer.)
404 DelegateState delegate_state_; 412 DelegateState delegate_state_;
405 413
406 // Set when OnSuspendRequested() is called with |must_suspend| unset. 414 // Set when OnSuspendRequested() is called with |must_suspend| unset.
407 bool is_idle_; 415 bool is_idle_;
408 416
409 // Set when OnSuspendRequested() is called with |must_suspend| set. 417 // Set when OnSuspendRequested() is called with |must_suspend| set.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 base::TimeTicks last_time_loading_progressed_; 626 base::TimeTicks last_time_loading_progressed_;
619 627
620 std::unique_ptr<base::TickClock> tick_clock_; 628 std::unique_ptr<base::TickClock> tick_clock_;
621 629
622 // Monitors the player events. 630 // Monitors the player events.
623 base::WeakPtr<MediaObserver> observer_; 631 base::WeakPtr<MediaObserver> observer_;
624 632
625 // Whether the player is currently in autoplay muted state. 633 // Whether the player is currently in autoplay muted state.
626 bool autoplay_muted_ = false; 634 bool autoplay_muted_ = false;
627 635
636 // The maximum video keyframe distance that allows triggering background
637 // playback optimizations.
638 // 10 seconds by default but can be overridden by a Finch experiment.
639 base::TimeDelta max_keyframe_distance_to_disable_background_video_ =
640 base::TimeDelta::FromSeconds(10);
641
628 // Whether disabled the video track as an optimization. 642 // Whether disabled the video track as an optimization.
629 bool video_track_disabled_ = false; 643 bool video_track_disabled_ = false;
630 644
631 // Whether the pipeline is being resumed at the moment. 645 // Whether the pipeline is being resumed at the moment.
632 bool is_pipeline_resuming_ = false; 646 bool is_pipeline_resuming_ = false;
633 647
648 // Pipeline statistics overridden by tests.
649 base::Optional<PipelineStatistics> pipeline_statistics_for_test_;
650
634 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 651 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
635 }; 652 };
636 653
637 } // namespace media 654 } // namespace media
638 655
639 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 656 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698