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

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

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed comments. Created 4 years 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 "media/base/media_observer.h" 10 #include "media/base/media_observer.h"
11 #include "media/remoting/remoting_source_impl.h" 11 #include "media/remoting/remoting_source_impl.h"
12 #include "third_party/skia/include/core/SkBitmap.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;
38 void OnSetCdm(CdmContext* cdm_context) override; 39 void OnSetCdm(CdmContext* cdm_context) override;
39 void OnMetadataChanged(const PipelineMetadata& metadata) override; 40 void OnMetadataChanged(const PipelineMetadata& metadata) override;
41 void OnSetPoster(const GURL& poster) override;
40 42
41 void SetSwitchRendererCallback(const base::Closure& cb); 43 void SetSwitchRendererCallback(const base::Closure& cb);
42 44
45 using DownloadPosterCallback =
46 base::Callback<void(const GURL&,
47 const base::Callback<void(const SkBitmap&)>&)>;
48 // Set the callback to download poster image. Can only be called once.
49 void SetDownloadPosterCallback(const DownloadPosterCallback& cb);
50
43 base::WeakPtr<RemotingRendererController> GetWeakPtr() { 51 base::WeakPtr<RemotingRendererController> GetWeakPtr() {
44 return weak_factory_.GetWeakPtr(); 52 return weak_factory_.GetWeakPtr();
45 } 53 }
46 54
47 // Used by RemotingRendererFactory to query whether to create Media Remoting 55 // Used by RemotingRendererFactory to query whether to create Media Remoting
48 // Renderer. 56 // Renderer.
49 bool remote_rendering_started() const { 57 bool remote_rendering_started() const {
50 DCHECK(thread_checker_.CalledOnValidThread()); 58 DCHECK(thread_checker_.CalledOnValidThread());
51 return remote_rendering_started_; 59 return remote_rendering_started_;
52 } 60 }
(...skipping 30 matching lines...) Expand all
83 bool IsVideoCodecSupported(); 91 bool IsVideoCodecSupported();
84 bool IsAudioCodecSupported(); 92 bool IsAudioCodecSupported();
85 93
86 // Helper to decide whether to enter or leave Remoting mode. 94 // Helper to decide whether to enter or leave Remoting mode.
87 bool ShouldBeRemoting(); 95 bool ShouldBeRemoting();
88 96
89 // Determines whether to enter or leave Remoting mode and switches if 97 // Determines whether to enter or leave Remoting mode and switches if
90 // necessary. 98 // necessary.
91 void UpdateAndMaybeSwitch(); 99 void UpdateAndMaybeSwitch();
92 100
93 // Indicates whether this media element or its ancestor is in full screen. 101 // Called when poster image is downloaded.
102 void OnPosterImageDownloaded(const GURL& download_url, const SkBitmap& image);
103
104 // Update remoting interstitial with |image|. When |image| is empty,
105 // interstitial will be drawn on previously downloaded poster image (in
106 // RemoteRendererImpl) or black background if none was downloaded before.
107 // TODO(xjz): https://codereview.chromium.org/2566223005/
108 // Call this when:
109 // 1. SetShowInterstitialCallback() is called (RemoteRendererImpl is created).
110 // 2. The remoting session is shut down (to update the status message in the
111 // interstitial).
112 // 3. The size of the canvas is changed (to update the background image and
113 // the position of the status message).
114 // 4. Poster image is downloaded (to update the background image).
115 void UpdateInterstitial(const SkBitmap& image);
116
117 // Indicates whether this media element is in full screen.
94 bool is_fullscreen_ = false; 118 bool is_fullscreen_ = false;
95 119
96 // Indicates whether remoting is started. 120 // Indicates whether remoting is started.
97 bool remote_rendering_started_ = false; 121 bool remote_rendering_started_ = false;
98 122
99 // Indicates whether audio or video is encrypted. 123 // Indicates whether audio or video is encrypted.
100 bool is_encrypted_ = false; 124 bool is_encrypted_ = false;
101 125
102 // Current audio/video config. 126 // Current audio/video config.
103 VideoDecoderConfig video_decoder_config_; 127 VideoDecoderConfig video_decoder_config_;
104 AudioDecoderConfig audio_decoder_config_; 128 AudioDecoderConfig audio_decoder_config_;
105 129
106 // The callback to switch the media renderer. 130 // The callback to switch the media renderer.
107 base::Closure switch_renderer_cb_; 131 base::Closure switch_renderer_cb_;
108 132
109 // This is initially the RemotingSourceImpl passed to the ctor, and might be 133 // This is initially the RemotingSourceImpl passed to the ctor, and might be
110 // replaced with a different instance later if OnSetCdm() is called. 134 // replaced with a different instance later if OnSetCdm() is called.
111 scoped_refptr<RemotingSourceImpl> remoting_source_; 135 scoped_refptr<RemotingSourceImpl> remoting_source_;
112 136
113 // This is used to check all the methods are called on the current thread in 137 // This is used to check all the methods are called on the current thread in
114 // debug builds. 138 // debug builds.
115 base::ThreadChecker thread_checker_; 139 base::ThreadChecker thread_checker_;
116 140
141 // Current pipeline metadata.
117 PipelineMetadata pipeline_metadata_; 142 PipelineMetadata pipeline_metadata_;
118 143
144 // Current poster URL, whose image will feed into the local UI.
145 GURL poster_url_;
146
147 // The callback to download the poster image. Called when |poster_url_|
148 // changes during a remoting session or the show interstial callback is set.
149 // OnPosterImageDownloaded() will be called when download completes.
150 DownloadPosterCallback download_poster_cb_;
151
119 base::WeakPtrFactory<RemotingRendererController> weak_factory_; 152 base::WeakPtrFactory<RemotingRendererController> weak_factory_;
120 153
121 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); 154 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController);
122 }; 155 };
123 156
124 } // namespace media 157 } // namespace media
125 158
126 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ 159 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698