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

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

Issue 2538853002: Media Remoting: Draw remoting interstitial on poster image. (Closed)
Patch Set: Addressed xhwang's comment. 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
51 // Download the poster image if available, and show remoting interstitial.
52 // Called when the poster URL is changed (to update the background image).
53 // TODO(xjz): https://codereview.chromium.org/2566223005/
54 // Call this when:
55 // 1. SetShowInterstitialCallback() is called (RemoteRendererImpl is created).
56 // 2. The remoting session is shut down (to update the status message in the
57 // interstitial).
58 // 3. The size of the canvas is changed (to update the background image and
59 // the position of the status message).
60 void UpdateAndMaybeShowInterstitial();
61
43 base::WeakPtr<RemotingRendererController> GetWeakPtr() { 62 base::WeakPtr<RemotingRendererController> GetWeakPtr() {
44 return weak_factory_.GetWeakPtr(); 63 return weak_factory_.GetWeakPtr();
45 } 64 }
46 65
47 // Used by RemotingRendererFactory to query whether to create Media Remoting 66 // Used by RemotingRendererFactory to query whether to create Media Remoting
48 // Renderer. 67 // Renderer.
49 bool remote_rendering_started() const { 68 bool remote_rendering_started() const {
50 DCHECK(thread_checker_.CalledOnValidThread()); 69 DCHECK(thread_checker_.CalledOnValidThread());
51 return remote_rendering_started_; 70 return remote_rendering_started_;
52 } 71 }
(...skipping 30 matching lines...) Expand all
83 bool IsVideoCodecSupported(); 102 bool IsVideoCodecSupported();
84 bool IsAudioCodecSupported(); 103 bool IsAudioCodecSupported();
85 104
86 // Helper to decide whether to enter or leave Remoting mode. 105 // Helper to decide whether to enter or leave Remoting mode.
87 bool ShouldBeRemoting(); 106 bool ShouldBeRemoting();
88 107
89 // Determines whether to enter or leave Remoting mode and switches if 108 // Determines whether to enter or leave Remoting mode and switches if
90 // necessary. 109 // necessary.
91 void UpdateAndMaybeSwitch(); 110 void UpdateAndMaybeSwitch();
92 111
112 // Called when poster image is downloaded.
113 void PosterImageDownloaded(const SkBitmap& image);
114
93 // Indicates whether this media element or its ancestor is in full screen. 115 // Indicates whether this media element or its ancestor is in full screen.
94 bool is_fullscreen_ = false; 116 bool is_fullscreen_ = false;
95 117
96 // Indicates whether remoting is started. 118 // Indicates whether remoting is started.
97 bool remote_rendering_started_ = false; 119 bool remote_rendering_started_ = false;
98 120
99 // Indicates whether audio or video is encrypted. 121 // Indicates whether audio or video is encrypted.
100 bool is_encrypted_ = false; 122 bool is_encrypted_ = false;
101 123
102 // Current audio/video config. 124 // Current audio/video config.
103 VideoDecoderConfig video_decoder_config_; 125 VideoDecoderConfig video_decoder_config_;
104 AudioDecoderConfig audio_decoder_config_; 126 AudioDecoderConfig audio_decoder_config_;
105 127
106 // The callback to switch the media renderer. 128 // The callback to switch the media renderer.
107 base::Closure switch_renderer_cb_; 129 base::Closure switch_renderer_cb_;
108 130
109 // This is initially the RemotingSourceImpl passed to the ctor, and might be 131 // This is initially the RemotingSourceImpl passed to the ctor, and might be
110 // replaced with a different instance later if OnSetCdm() is called. 132 // replaced with a different instance later if OnSetCdm() is called.
111 scoped_refptr<RemotingSourceImpl> remoting_source_; 133 scoped_refptr<RemotingSourceImpl> remoting_source_;
112 134
113 // This is used to check all the methods are called on the current thread in 135 // This is used to check all the methods are called on the current thread in
114 // debug builds. 136 // debug builds.
115 base::ThreadChecker thread_checker_; 137 base::ThreadChecker thread_checker_;
116 138
117 PipelineMetadata pipeline_metadata_; 139 PipelineMetadata pipeline_metadata_;
118 140
141 GURL poster_url_;
miu 2016/12/20 00:48:07 nit: Needs comment ("Current poster URL, whose ima
xjz 2016/12/20 21:46:25 Done.
142
143 DownloadPosterCallback download_poster_cb_;
miu 2016/12/20 00:48:06 ditto: Short comment, please.
xjz 2016/12/20 21:46:25 Done.
144
119 base::WeakPtrFactory<RemotingRendererController> weak_factory_; 145 base::WeakPtrFactory<RemotingRendererController> weak_factory_;
120 146
121 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); 147 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController);
122 }; 148 };
123 149
124 } // namespace media 150 } // namespace media
125 151
126 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ 152 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698