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

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

Issue 2605993002: Experiment with more aggressive MSE GC on memory pressure (Closed)
Patch Set: Improve feature handling (CR feedback) 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
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 674
669 std::unique_ptr<base::TickClock> tick_clock_; 675 std::unique_ptr<base::TickClock> tick_clock_;
670 676
671 // Monitors the player events. 677 // Monitors the player events.
672 base::WeakPtr<MediaObserver> observer_; 678 base::WeakPtr<MediaObserver> observer_;
673 679
674 // The maximum video keyframe distance that allows triggering background 680 // The maximum video keyframe distance that allows triggering background
675 // playback optimizations. 681 // playback optimizations.
676 base::TimeDelta max_keyframe_distance_to_disable_background_video_; 682 base::TimeDelta max_keyframe_distance_to_disable_background_video_;
677 683
684 // When MSE garbage-collection on memory pressure is enabled, the
685 // |mse_force_gc_on_memory_pressure| controls whether the GC is done
686 // immediately on memory pressure notification or during the next SourceBuffer
687 // append (slower, but more MSE-spec compliant).
688 bool mse_force_gc_on_memory_pressure_;
689
678 // Whether disabled the video track as an optimization. 690 // Whether disabled the video track as an optimization.
679 bool video_track_disabled_ = false; 691 bool video_track_disabled_ = false;
680 692
681 // Whether the pipeline is being resumed at the moment. 693 // Whether the pipeline is being resumed at the moment.
682 bool is_pipeline_resuming_ = false; 694 bool is_pipeline_resuming_ = false;
683 695
684 // Pipeline statistics overridden by tests. 696 // Pipeline statistics overridden by tests.
685 base::Optional<PipelineStatistics> pipeline_statistics_for_test_; 697 base::Optional<PipelineStatistics> pipeline_statistics_for_test_;
686 698
687 // Pipeline media duration overridden by tests. 699 // Pipeline media duration overridden by tests.
688 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_; 700 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_;
689 701
690 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 702 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
691 }; 703 };
692 704
693 } // namespace media 705 } // namespace media
694 706
695 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 707 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698