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

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

Issue 2611333003: [Video] Disable bg optimization if avg keyframe distance is >10s (Closed)
Patch Set: Rebase the test 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 | « media/base/pipeline_status.h ('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 <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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 void DisableVideoTrackIfNeeded(); 390 void DisableVideoTrackIfNeeded();
389 391
390 // Enables the video track if it was disabled before to save power. 392 // Enables the video track if it was disabled before to save power.
391 // Must be called when either of the following happens: 393 // Must be called when either of the following happens:
392 // - right after the video was shown, 394 // - right after the video was shown,
393 // - right before the pipeline is requested to resume 395 // - right before the pipeline is requested to resume
394 // (see https://crbug.com/678374), 396 // (see https://crbug.com/678374),
395 // - right after the pipeline has resumed if the video is not hidden. 397 // - right after the pipeline has resumed if the video is not hidden.
396 void EnableVideoTrackIfNeeded(); 398 void EnableVideoTrackIfNeeded();
397 399
400 // Overrides the pipeline statistics returned by GetStatistics() for tests.
401 void SetPipelineStatisticsForTest(const PipelineStatistics& stats);
402
403 // Returns the pipeline statistics or the value overridden by tests.
404 PipelineStatistics GetPipelineStatistics() const;
405
398 blink::WebLocalFrame* frame_; 406 blink::WebLocalFrame* frame_;
399 407
400 // The playback state last reported to |delegate_|, to avoid setting duplicate 408 // The playback state last reported to |delegate_|, to avoid setting duplicate
401 // states. (Which can have undesired effects like resetting the idle timer.) 409 // states. (Which can have undesired effects like resetting the idle timer.)
402 DelegateState delegate_state_; 410 DelegateState delegate_state_;
403 411
404 // Set when OnSuspendRequested() is called with |must_suspend| unset. 412 // Set when OnSuspendRequested() is called with |must_suspend| unset.
405 bool is_idle_; 413 bool is_idle_;
406 414
407 // Set when OnSuspendRequested() is called with |must_suspend| set. 415 // Set when OnSuspendRequested() is called with |must_suspend| set.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 base::TimeTicks last_time_loading_progressed_; 624 base::TimeTicks last_time_loading_progressed_;
617 625
618 std::unique_ptr<base::TickClock> tick_clock_; 626 std::unique_ptr<base::TickClock> tick_clock_;
619 627
620 // Monitors the player events. 628 // Monitors the player events.
621 base::WeakPtr<MediaObserver> observer_; 629 base::WeakPtr<MediaObserver> observer_;
622 630
623 // Whether the player is currently in autoplay muted state. 631 // Whether the player is currently in autoplay muted state.
624 bool autoplay_muted_ = false; 632 bool autoplay_muted_ = false;
625 633
634 // The maximum video keyframe distance that allows triggering background
635 // playback optimizations.
636 // 10 seconds by default but can be overridden by a Finch experiment.
637 base::TimeDelta max_keyframe_distance_to_disable_background_video_ =
638 base::TimeDelta::FromSeconds(10);
639
626 // Whether disabled the video track as an optimization. 640 // Whether disabled the video track as an optimization.
627 bool video_track_disabled_ = false; 641 bool video_track_disabled_ = false;
628 642
629 // Whether the pipeline is being resumed at the moment. 643 // Whether the pipeline is being resumed at the moment.
630 bool is_pipeline_resuming_ = false; 644 bool is_pipeline_resuming_ = false;
631 645
646 // Pipeline statistics overridden by tests.
647 base::Optional<PipelineStatistics> pipeline_statistics_for_test_;
648
632 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 649 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
633 }; 650 };
634 651
635 } // namespace media 652 } // namespace media
636 653
637 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 654 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/pipeline_status.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698