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_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 PosterDownloadedCallback = base::Callback<void(const SkBitmap& bitmap)>; | |
46 using DownloadPosterCallback = | |
47 base::Callback<void(const GURL& url, const PosterDownloadedCallback& cb)>; | |
48 void SetDownloadPosterCallback(const DownloadPosterCallback& cb); | |
49 | |
43 base::WeakPtr<RemotingRendererController> GetWeakPtr() { | 50 base::WeakPtr<RemotingRendererController> GetWeakPtr() { |
44 return weak_factory_.GetWeakPtr(); | 51 return weak_factory_.GetWeakPtr(); |
45 } | 52 } |
46 | 53 |
47 // Used by RemotingRendererFactory to query whether to create Media Remoting | 54 // Used by RemotingRendererFactory to query whether to create Media Remoting |
48 // Renderer. | 55 // Renderer. |
49 bool remote_rendering_started() const { | 56 bool remote_rendering_started() const { |
50 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
51 return remote_rendering_started_; | 58 return remote_rendering_started_; |
52 } | 59 } |
53 | 60 |
54 void StartDataPipe( | 61 void StartDataPipe( |
55 std::unique_ptr<mojo::DataPipe> audio_data_pipe, | 62 std::unique_ptr<mojo::DataPipe> audio_data_pipe, |
56 std::unique_ptr<mojo::DataPipe> video_data_pipe, | 63 std::unique_ptr<mojo::DataPipe> video_data_pipe, |
57 const RemotingSourceImpl::DataPipeStartCallback& done_callback); | 64 const RemotingSourceImpl::DataPipeStartCallback& done_callback); |
58 | 65 |
59 // Used by RemotingRendererImpl to query the session state. | 66 // Used by RemotingRendererImpl to query the session state. |
60 RemotingSourceImpl* remoting_source() const { | 67 RemotingSourceImpl* remoting_source() const { |
61 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
62 return remoting_source_.get(); | 69 return remoting_source_.get(); |
63 } | 70 } |
64 | 71 |
65 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; | 72 base::WeakPtr<remoting::RpcBroker> GetRpcBroker() const; |
66 | 73 |
67 PipelineMetadata pipeline_metadata() const { | 74 PipelineMetadata pipeline_metadata() const { |
68 DCHECK(thread_checker_.CalledOnValidThread()); | 75 DCHECK(thread_checker_.CalledOnValidThread()); |
69 return pipeline_metadata_; | 76 return pipeline_metadata_; |
70 } | 77 } |
71 | 78 |
79 GURL poster() const { | |
miu
2016/11/29 22:56:09
Rather than exposing poster() and download_poster_
xjz
2016/12/02 19:23:11
Done.
| |
80 DCHECK(thread_checker_.CalledOnValidThread()); | |
81 return poster_; | |
82 } | |
83 | |
84 DownloadPosterCallback download_poster_cb() const { | |
85 DCHECK(thread_checker_.CalledOnValidThread()); | |
86 return download_poster_cb_; | |
87 } | |
88 | |
72 private: | 89 private: |
73 bool has_audio() const { | 90 bool has_audio() const { |
74 return pipeline_metadata_.has_audio && | 91 return pipeline_metadata_.has_audio && |
75 pipeline_metadata_.audio_decoder_config.IsValidConfig(); | 92 pipeline_metadata_.audio_decoder_config.IsValidConfig(); |
76 } | 93 } |
77 | 94 |
78 bool has_video() const { | 95 bool has_video() const { |
79 return pipeline_metadata_.has_video && | 96 return pipeline_metadata_.has_video && |
80 pipeline_metadata_.video_decoder_config.IsValidConfig(); | 97 pipeline_metadata_.video_decoder_config.IsValidConfig(); |
81 } | 98 } |
(...skipping 27 matching lines...) Expand all Loading... | |
109 // This is initially the RemotingSourceImpl passed to the ctor, and might be | 126 // This is initially the RemotingSourceImpl passed to the ctor, and might be |
110 // replaced with a different instance later if OnSetCdm() is called. | 127 // replaced with a different instance later if OnSetCdm() is called. |
111 scoped_refptr<RemotingSourceImpl> remoting_source_; | 128 scoped_refptr<RemotingSourceImpl> remoting_source_; |
112 | 129 |
113 // This is used to check all the methods are called on the current thread in | 130 // This is used to check all the methods are called on the current thread in |
114 // debug builds. | 131 // debug builds. |
115 base::ThreadChecker thread_checker_; | 132 base::ThreadChecker thread_checker_; |
116 | 133 |
117 PipelineMetadata pipeline_metadata_; | 134 PipelineMetadata pipeline_metadata_; |
118 | 135 |
136 GURL poster_; | |
137 | |
138 DownloadPosterCallback download_poster_cb_; | |
139 | |
119 base::WeakPtrFactory<RemotingRendererController> weak_factory_; | 140 base::WeakPtrFactory<RemotingRendererController> weak_factory_; |
120 | 141 |
121 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); | 142 DISALLOW_COPY_AND_ASSIGN(RemotingRendererController); |
122 }; | 143 }; |
123 | 144 |
124 } // namespace media | 145 } // namespace media |
125 | 146 |
126 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ | 147 #endif // MEDIA_REMOTING_REMOTING_RENDERER_CONTROLLER_H_ |
OLD | NEW |