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

Side by Side Diff: media/remoting/remoting_renderer_controller.h

Issue 2511143006: Detect change on the intersection of video and viewport. (Closed)
Patch Set: Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ 5 #ifndef MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
6 #define MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ 6 #define MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/timer/timer.h"
10 #include "media/base/media_observer.h" 11 #include "media/base/media_observer.h"
11 #include "media/remoting/remoting_source_impl.h" 12 #include "media/remoting/remoting_source_impl.h"
12 13
13 namespace media { 14 namespace media {
14 15
15 namespace remoting { 16 namespace remoting {
16 class RpcBroker; 17 class RpcBroker;
17 } 18 }
18 19
19 // This class: 20 // This class:
20 // 1) Implements the RemotingSourceImpl::Client; 21 // 1) Implements the RemotingSourceImpl::Client;
21 // 2) Monitors player events as a MediaObserver; 22 // 2) Monitors player events as a MediaObserver;
22 // 3) May trigger the switch of the media renderer between local playback 23 // 3) May trigger the switch of the media renderer between local playback
23 // and remoting. 24 // and remoting.
24 class RemotingRendererController final : public RemotingSourceImpl::Client, 25 class RemotingRendererController final : public RemotingSourceImpl::Client,
25 public MediaObserver { 26 public MediaObserver {
26 public: 27 public:
27 explicit RemotingRendererController( 28 explicit RemotingRendererController(
28 scoped_refptr<RemotingSourceImpl> remoting_source); 29 scoped_refptr<RemotingSourceImpl> remoting_source);
29 ~RemotingRendererController() override; 30 ~RemotingRendererController() override;
30 31
31 // RemotingSourceImpl::Client implemenations. 32 // RemotingSourceImpl::Client implemenations.
32 void OnStarted(bool success) override; 33 void OnStarted(bool success) override;
33 void OnSessionStateChanged() override; 34 void OnSessionStateChanged() override;
34 35
35 // MediaObserver implementations. 36 // MediaObserver implementations.
36 void OnEnteredFullscreen() override; 37 void OnEnteredFullscreen() override;
37 void OnExitedFullscreen() override; 38 void OnExitedFullscreen() override;
39 void OnVideoViewportIntersectionChanged(
40 const ViewportIntersectionInfo& info) override;
38 void OnSetCdm(CdmContext* cdm_context) override; 41 void OnSetCdm(CdmContext* cdm_context) override;
39 void OnMetadataChanged(const PipelineMetadata& metadata) override; 42 void OnMetadataChanged(const PipelineMetadata& metadata) override;
40 43
41 void SetSwitchRendererCallback(const base::Closure& cb); 44 void SetSwitchRendererCallback(const base::Closure& cb);
42 45
43 base::WeakPtr<RemotingRendererController> GetWeakPtr() { 46 base::WeakPtr<RemotingRendererController> GetWeakPtr() {
44 return weak_factory_.GetWeakPtr(); 47 return weak_factory_.GetWeakPtr();
45 } 48 }
46 49
47 // Used by RemotingRendererFactory to query whether to create Media Remoting 50 // Used by RemotingRendererFactory to query whether to create Media Remoting
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool IsVideoCodecSupported(); 86 bool IsVideoCodecSupported();
84 bool IsAudioCodecSupported(); 87 bool IsAudioCodecSupported();
85 88
86 // Helper to decide whether to enter or leave Remoting mode. 89 // Helper to decide whether to enter or leave Remoting mode.
87 bool ShouldBeRemoting(); 90 bool ShouldBeRemoting();
88 91
89 // Determines whether to enter or leave Remoting mode and switches if 92 // Determines whether to enter or leave Remoting mode and switches if
90 // necessary. 93 // necessary.
91 void UpdateAndMaybeSwitch(); 94 void UpdateAndMaybeSwitch();
92 95
96 // Callback from |viewport_fill_debouncer_timer_| when video keeps covering
97 // most of the viewport for a certain time.
98 void OnViewportMostlyFilledAndUnchanging();
99
93 // Indicates whether this media element or its ancestor is in full screen. 100 // Indicates whether this media element or its ancestor is in full screen.
94 bool is_fullscreen_ = false; 101 bool is_fullscreen_ = false;
95 102
96 // Indicates whether remoting is started. 103 // Indicates whether remoting is started.
97 bool remote_rendering_started_ = false; 104 bool remote_rendering_started_ = false;
98 105
99 // Indicates whether audio or video is encrypted. 106 // Indicates whether audio or video is encrypted.
100 bool is_encrypted_ = false; 107 bool is_encrypted_ = false;
101 108
102 // Current audio/video config. 109 // Current audio/video config.
103 VideoDecoderConfig video_decoder_config_; 110 VideoDecoderConfig video_decoder_config_;
104 AudioDecoderConfig audio_decoder_config_; 111 AudioDecoderConfig audio_decoder_config_;
105 112
113 // Indicates whether video covers most of the viewport.
114 bool is_mostly_filling_viewport_ = false;
115
116 // Video/Viewport ratio meeting/exceeding the threshold should hold steady for
117 // a certain time before attempting to start remoting.
118 base::OneShotTimer viewport_fill_debouncer_timer_;
119
106 // The callback to switch the media renderer. 120 // The callback to switch the media renderer.
107 base::Closure switch_renderer_cb_; 121 base::Closure switch_renderer_cb_;
108 122
109 // This is initially the RemotingSourceImpl passed to the ctor, and might be 123 // This is initially the RemotingSourceImpl passed to the ctor, and might be
110 // replaced with a different instance later if OnSetCdm() is called. 124 // replaced with a different instance later if OnSetCdm() is called.
111 scoped_refptr<RemotingSourceImpl> remoting_source_; 125 scoped_refptr<RemotingSourceImpl> remoting_source_;
112 126
113 // This is used to check all the methods are called on the current thread in 127 // This is used to check all the methods are called on the current thread in
114 // debug builds. 128 // debug builds.
115 base::ThreadChecker thread_checker_; 129 base::ThreadChecker thread_checker_;
116 130
117 PipelineMetadata pipeline_metadata_; 131 PipelineMetadata pipeline_metadata_;
118 132
119 base::WeakPtrFactory<RemotingRendererController> weak_factory_; 133 base::WeakPtrFactory<RemotingRendererController> weak_factory_;
120 134
121 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); 135 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController);
122 }; 136 };
123 137
124 } // namespace media 138 } // namespace media
125 139
126 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ 140 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698