| OLD | NEW |
| 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_interstitial_ui.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; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 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; |
| 40 | 41 |
| 41 void SetSwitchRendererCallback(const base::Closure& cb); | 42 void SetSwitchRendererCallback(const base::Closure& cb); |
| 42 | 43 |
| 44 using ShowInterstitialCallback = base::Callback< |
| 45 void(const SkBitmap&, const gfx::Size&, RemotingInterstitialType type)>; |
| 46 // Called by RemoteRendererImpl constructor to set the callback to draw and |
| 47 // show remoting interstial. |
| 48 void SetShowInterstitialCallback(const ShowInterstitialCallback& cb); |
| 49 |
| 50 // Called when any of the following happens: |
| 51 // 1. SetShowInterstitialCallback() is called (RemoteRendererImpl is |
| 52 // constructed); |
| 53 // 2. The remoting session is shut down (to update the status message in the |
| 54 // interstitial). |
| 55 // 3. The size of the canvas is changed (to update the background image and |
| 56 // the position of the status message). |
| 57 // TODO(xjz): Call this when poster url is set/changed. Download poster image |
| 58 // when available, and draw interstitial on it. |
| 59 void UpdateAndMaybeShowInterstitial(); |
| 60 |
| 43 base::WeakPtr<RemotingRendererController> GetWeakPtr() { | 61 base::WeakPtr<RemotingRendererController> GetWeakPtr() { |
| 44 return weak_factory_.GetWeakPtr(); | 62 return weak_factory_.GetWeakPtr(); |
| 45 } | 63 } |
| 46 | 64 |
| 47 // Used by RemotingRendererFactory to query whether to create Media Remoting | 65 // Used by RemotingRendererFactory to query whether to create Media Remoting |
| 48 // Renderer. | 66 // Renderer. |
| 49 bool remote_rendering_started() const { | 67 bool remote_rendering_started() const { |
| 50 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
| 51 return remote_rendering_started_; | 69 return remote_rendering_started_; |
| 52 } | 70 } |
| 53 | 71 |
| 54 void StartDataPipe( | 72 void StartDataPipe( |
| 55 std::unique_ptr<mojo::DataPipe> audio_data_pipe, | 73 std::unique_ptr<mojo::DataPipe> audio_data_pipe, |
| 56 std::unique_ptr<mojo::DataPipe> video_data_pipe, | 74 std::unique_ptr<mojo::DataPipe> video_data_pipe, |
| 57 const RemotingSourceImpl::DataPipeStartCallback& done_callback); | 75 const RemotingSourceImpl::DataPipeStartCallback& done_callback); |
| 58 | 76 |
| 59 // Used by RemotingRendererImpl to query the session state. | 77 // Used by RemotingRendererImpl to query the session state. |
| 60 RemotingSourceImpl* remoting_source() const { | 78 RemotingSourceImpl* remoting_source() const { |
| 61 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 return remoting_source_.get(); | 80 return remoting_source_.get(); |
| 63 } | 81 } |
| 64 | 82 |
| 65 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; | 83 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; |
| 66 | 84 |
| 67 PipelineMetadata pipeline_metadata() const { | |
| 68 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 69 return pipeline_metadata_; | |
| 70 } | |
| 71 | |
| 72 private: | 85 private: |
| 73 bool has_audio() const { | 86 bool has_audio() const { |
| 74 return pipeline_metadata_.has_audio && | 87 return pipeline_metadata_.has_audio && |
| 75 pipeline_metadata_.audio_decoder_config.IsValidConfig(); | 88 pipeline_metadata_.audio_decoder_config.IsValidConfig(); |
| 76 } | 89 } |
| 77 | 90 |
| 78 bool has_video() const { | 91 bool has_video() const { |
| 79 return pipeline_metadata_.has_video && | 92 return pipeline_metadata_.has_video && |
| 80 pipeline_metadata_.video_decoder_config.IsValidConfig(); | 93 pipeline_metadata_.video_decoder_config.IsValidConfig(); |
| 81 } | 94 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 92 | 105 |
| 93 // Indicates whether this media element or its ancestor is in full screen. | 106 // Indicates whether this media element or its ancestor is in full screen. |
| 94 bool is_fullscreen_ = false; | 107 bool is_fullscreen_ = false; |
| 95 | 108 |
| 96 // Indicates whether remoting is started. | 109 // Indicates whether remoting is started. |
| 97 bool remote_rendering_started_ = false; | 110 bool remote_rendering_started_ = false; |
| 98 | 111 |
| 99 // Indicates whether audio or video is encrypted. | 112 // Indicates whether audio or video is encrypted. |
| 100 bool is_encrypted_ = false; | 113 bool is_encrypted_ = false; |
| 101 | 114 |
| 102 // Current audio/video config. | |
| 103 VideoDecoderConfig video_decoder_config_; | |
| 104 AudioDecoderConfig audio_decoder_config_; | |
| 105 | |
| 106 // The callback to switch the media renderer. | 115 // The callback to switch the media renderer. |
| 107 base::Closure switch_renderer_cb_; | 116 base::Closure switch_renderer_cb_; |
| 108 | 117 |
| 109 // This is initially the RemotingSourceImpl passed to the ctor, and might be | 118 // This is initially the RemotingSourceImpl passed to the ctor, and might be |
| 110 // replaced with a different instance later if OnSetCdm() is called. | 119 // replaced with a different instance later if OnSetCdm() is called. |
| 111 scoped_refptr<RemotingSourceImpl> remoting_source_; | 120 scoped_refptr<RemotingSourceImpl> remoting_source_; |
| 112 | 121 |
| 113 // This is used to check all the methods are called on the current thread in | 122 // This is used to check all the methods are called on the current thread in |
| 114 // debug builds. | 123 // debug builds. |
| 115 base::ThreadChecker thread_checker_; | 124 base::ThreadChecker thread_checker_; |
| 116 | 125 |
| 117 PipelineMetadata pipeline_metadata_; | 126 PipelineMetadata pipeline_metadata_; |
| 118 | 127 |
| 128 // The callback to show remoting interstitial. It is set when entering the |
| 129 // remoting mode (RemotingRendererImpl is constructed) by calling |
| 130 // SetShowInterstitialCallback(), and is reset when leaving the remoting mode. |
| 131 ShowInterstitialCallback show_interstitial_cb_; |
| 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_ |
| OLD | NEW |