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

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

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: rebase/resolve conflicts Created 3 years, 10 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/media_switches.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 <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/memory_pressure_listener.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
20 #include "base/optional.h" 21 #include "base/optional.h"
21 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
22 #include "base/time/default_tick_clock.h" 23 #include "base/time/default_tick_clock.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "base/timer/elapsed_timer.h" 25 #include "base/timer/elapsed_timer.h"
25 #include "base/timer/timer.h" 26 #include "base/timer/timer.h"
26 #include "build/build_config.h" 27 #include "build/build_config.h"
27 #include "media/base/media_observer.h" 28 #include "media/base/media_observer.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void SetMemoryReportingState(bool is_memory_reporting_enabled); 346 void SetMemoryReportingState(bool is_memory_reporting_enabled);
346 void SetSuspendState(bool is_suspended); 347 void SetSuspendState(bool is_suspended);
347 348
348 // Called at low frequency to tell external observers how much memory we're 349 // Called at low frequency to tell external observers how much memory we're
349 // using for video playback. Called by |memory_usage_reporting_timer_|. 350 // using for video playback. Called by |memory_usage_reporting_timer_|.
350 // Memory usage reporting is done in two steps, because |demuxer_| must be 351 // Memory usage reporting is done in two steps, because |demuxer_| must be
351 // accessed on the media thread. 352 // accessed on the media thread.
352 void ReportMemoryUsage(); 353 void ReportMemoryUsage();
353 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); 354 void FinishMemoryUsageReport(int64_t demuxer_memory_usage);
354 355
356 void OnMemoryPressure(
357 base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level);
358
355 // Called during OnHidden() when we want a suspended player to enter the 359 // Called during OnHidden() when we want a suspended player to enter the
356 // paused state after some idle timeout. 360 // paused state after some idle timeout.
357 void ScheduleIdlePauseTimer(); 361 void ScheduleIdlePauseTimer();
358 362
359 // Returns |true| before HaveFutureData whenever there has been loading 363 // Returns |true| before HaveFutureData whenever there has been loading
360 // progress and we have not been resumed for at least kLoadingToIdleTimeout 364 // progress and we have not been resumed for at least kLoadingToIdleTimeout
361 // since then. 365 // since then.
362 // 366 //
363 // This is used to delay suspension long enough for preroll to complete, which 367 // 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 368 // is necessay because play() will not be called before HaveFutureData (and
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 // These two are mutually exclusive: 565 // These two are mutually exclusive:
562 // |data_source_| is used for regular resource loads. 566 // |data_source_| is used for regular resource loads.
563 // |chunk_demuxer_| is used for Media Source resource loads. 567 // |chunk_demuxer_| is used for Media Source resource loads.
564 // 568 //
565 // |demuxer_| will contain the appropriate demuxer based on which resource 569 // |demuxer_| will contain the appropriate demuxer based on which resource
566 // load strategy we're using. 570 // load strategy we're using.
567 std::unique_ptr<MultibufferDataSource> data_source_; 571 std::unique_ptr<MultibufferDataSource> data_source_;
568 std::unique_ptr<Demuxer> demuxer_; 572 std::unique_ptr<Demuxer> demuxer_;
569 ChunkDemuxer* chunk_demuxer_; 573 ChunkDemuxer* chunk_demuxer_;
570 574
575 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
576
571 BufferedDataSourceHostImpl buffered_data_source_host_; 577 BufferedDataSourceHostImpl buffered_data_source_host_;
572 linked_ptr<UrlIndex> url_index_; 578 linked_ptr<UrlIndex> url_index_;
573 579
574 // Video rendering members. 580 // Video rendering members.
575 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; 581 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
576 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|. 582 VideoFrameCompositor* compositor_; // Deleted on |compositor_task_runner_|.
577 SkCanvasVideoRenderer skcanvas_video_renderer_; 583 SkCanvasVideoRenderer skcanvas_video_renderer_;
578 584
579 // The compositor layer for displaying the video content when using composited 585 // The compositor layer for displaying the video content when using composited
580 // playback. 586 // playback.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 670
665 std::unique_ptr<base::TickClock> tick_clock_; 671 std::unique_ptr<base::TickClock> tick_clock_;
666 672
667 // Monitors the player events. 673 // Monitors the player events.
668 base::WeakPtr<MediaObserver> observer_; 674 base::WeakPtr<MediaObserver> observer_;
669 675
670 // The maximum video keyframe distance that allows triggering background 676 // The maximum video keyframe distance that allows triggering background
671 // playback optimizations. 677 // playback optimizations.
672 base::TimeDelta max_keyframe_distance_to_disable_background_video_; 678 base::TimeDelta max_keyframe_distance_to_disable_background_video_;
673 679
680 // When MSE memory pressure based garbage collection is enabled, the
681 // |enable_instant_source_buffer_gc| controls whether the GC is done
682 // immediately on memory pressure notification or during the next SourceBuffer
683 // append (slower, but MSE spec compliant).
684 bool enable_instant_source_buffer_gc_ = false;
685
674 // Whether disabled the video track as an optimization. 686 // Whether disabled the video track as an optimization.
675 bool video_track_disabled_ = false; 687 bool video_track_disabled_ = false;
676 688
677 // Whether the pipeline is being resumed at the moment. 689 // Whether the pipeline is being resumed at the moment.
678 bool is_pipeline_resuming_ = false; 690 bool is_pipeline_resuming_ = false;
679 691
680 // Pipeline statistics overridden by tests. 692 // Pipeline statistics overridden by tests.
681 base::Optional<PipelineStatistics> pipeline_statistics_for_test_; 693 base::Optional<PipelineStatistics> pipeline_statistics_for_test_;
682 694
683 // Pipeline media duration overridden by tests. 695 // Pipeline media duration overridden by tests.
684 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_; 696 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_;
685 697
686 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 698 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
687 }; 699 };
688 700
689 } // namespace media 701 } // namespace media
690 702
691 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 703 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/media_switches.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698