OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 17 #include "content/renderer/media/media_stream.h" |
17 #include "media/blink/webmediaplayer_delegate.h" | 18 #include "media/blink/webmediaplayer_delegate.h" |
18 #include "media/blink/webmediaplayer_util.h" | 19 #include "media/blink/webmediaplayer_util.h" |
19 #include "media/renderers/gpu_video_accelerator_factories.h" | 20 #include "media/renderers/gpu_video_accelerator_factories.h" |
20 #include "media/renderers/skcanvas_video_renderer.h" | 21 #include "media/renderers/skcanvas_video_renderer.h" |
21 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 22 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
22 #include "url/origin.h" | 23 #include "url/origin.h" |
23 | 24 |
24 namespace blink { | 25 namespace blink { |
25 class WebLocalFrame; | 26 class WebLocalFrame; |
26 class WebMediaPlayerClient; | 27 class WebMediaPlayerClient; |
(...skipping 28 matching lines...) Expand all Loading... |
55 // Renderer process. | 56 // Renderer process. |
56 // | 57 // |
57 // WebMediaPlayerMS works with multiple objects, the most important ones are: | 58 // WebMediaPlayerMS works with multiple objects, the most important ones are: |
58 // | 59 // |
59 // MediaStreamVideoRenderer | 60 // MediaStreamVideoRenderer |
60 // provides video frames for rendering. | 61 // provides video frames for rendering. |
61 // | 62 // |
62 // blink::WebMediaPlayerClient | 63 // blink::WebMediaPlayerClient |
63 // WebKit client of this media player object. | 64 // WebKit client of this media player object. |
64 class CONTENT_EXPORT WebMediaPlayerMS | 65 class CONTENT_EXPORT WebMediaPlayerMS |
65 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), | 66 : public NON_EXPORTED_BASE(MediaStreamObserver), |
| 67 public NON_EXPORTED_BASE(blink::WebMediaPlayer), |
66 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer), | 68 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer), |
67 public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) { | 69 public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) { |
68 public: | 70 public: |
69 // Construct a WebMediaPlayerMS with reference to the client, and | 71 // Construct a WebMediaPlayerMS with reference to the client, and |
70 // a MediaStreamClient which provides MediaStreamVideoRenderer. | 72 // a MediaStreamClient which provides MediaStreamVideoRenderer. |
71 // |delegate| must not be null. | 73 // |delegate| must not be null. |
72 WebMediaPlayerMS( | 74 WebMediaPlayerMS( |
73 blink::WebLocalFrame* frame, | 75 blink::WebLocalFrame* frame, |
74 blink::WebMediaPlayerClient* client, | 76 blink::WebMediaPlayerClient* client, |
75 media::WebMediaPlayerDelegate* delegate, | 77 media::WebMediaPlayerDelegate* delegate, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 int level, | 172 int level, |
171 int internalformat, | 173 int internalformat, |
172 unsigned format, | 174 unsigned format, |
173 unsigned type, | 175 unsigned type, |
174 int xoffset, | 176 int xoffset, |
175 int yoffset, | 177 int yoffset, |
176 int zoffset, | 178 int zoffset, |
177 bool flip_y, | 179 bool flip_y, |
178 bool premultiply_alpha) override; | 180 bool premultiply_alpha) override; |
179 | 181 |
| 182 // MediaStreamObserver implementation |
| 183 void TrackAdded(const blink::WebMediaStreamTrack& track) override; |
| 184 void TrackRemoved(const blink::WebMediaStreamTrack& track) override; |
| 185 |
180 private: | 186 private: |
181 friend class WebMediaPlayerMSTest; | 187 friend class WebMediaPlayerMSTest; |
182 | 188 |
183 void OnFirstFrameReceived(media::VideoRotation video_rotation, | 189 void OnFirstFrameReceived(media::VideoRotation video_rotation, |
184 bool is_opaque); | 190 bool is_opaque); |
185 void OnOpacityChanged(bool is_opaque); | 191 void OnOpacityChanged(bool is_opaque); |
186 void OnRotationChanged(media::VideoRotation video_rotation, bool is_opaque); | 192 void OnRotationChanged(media::VideoRotation video_rotation, bool is_opaque); |
187 | 193 |
188 // Need repaint due to state change. | 194 // Need repaint due to state change. |
189 void RepaintInternal(); | 195 void RepaintInternal(); |
190 | 196 |
191 // The callback for source to report error. | 197 // The callback for source to report error. |
192 void OnSourceError(); | 198 void OnSourceError(); |
193 | 199 |
194 // Helpers that set the network/ready state and notifies the client if | 200 // Helpers that set the network/ready state and notifies the client if |
195 // they've changed. | 201 // they've changed. |
196 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 202 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
197 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 203 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
198 | 204 |
199 // Getter method to |client_|. | 205 // Getter method to |client_|. |
200 blink::WebMediaPlayerClient* get_client() { return client_; } | 206 blink::WebMediaPlayerClient* get_client() { return client_; } |
201 | 207 |
| 208 // To be run when tracks are added or removed. |
| 209 void Reload(); |
| 210 |
202 blink::WebLocalFrame* const frame_; | 211 blink::WebLocalFrame* const frame_; |
203 | 212 |
204 blink::WebMediaPlayer::NetworkState network_state_; | 213 blink::WebMediaPlayer::NetworkState network_state_; |
205 blink::WebMediaPlayer::ReadyState ready_state_; | 214 blink::WebMediaPlayer::ReadyState ready_state_; |
206 | 215 |
207 const blink::WebTimeRanges buffered_; | 216 const blink::WebTimeRanges buffered_; |
208 | 217 |
209 blink::WebMediaPlayerClient* const client_; | 218 blink::WebMediaPlayerClient* const client_; |
210 | 219 |
211 // WebMediaPlayer notifies the |delegate_| of playback state changes using | 220 // WebMediaPlayer notifies the |delegate_| of playback state changes using |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // The last volume received by setVolume() and the last volume multiplier from | 266 // The last volume received by setVolume() and the last volume multiplier from |
258 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less | 267 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less |
259 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) | 268 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) |
260 // for a transient sound. Playout volume is derived by volume * multiplier. | 269 // for a transient sound. Playout volume is derived by volume * multiplier. |
261 double volume_; | 270 double volume_; |
262 double volume_multiplier_; | 271 double volume_multiplier_; |
263 | 272 |
264 // True if playback should be started upon the next call to OnShown(). Only | 273 // True if playback should be started upon the next call to OnShown(). Only |
265 // used on Android. | 274 // used on Android. |
266 bool should_play_upon_shown_; | 275 bool should_play_upon_shown_; |
| 276 blink::WebMediaStream web_stream_; |
267 | 277 |
268 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 278 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
269 }; | 279 }; |
270 | 280 |
271 } // namespace content | 281 } // namespace content |
272 | 282 |
273 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 283 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
OLD | NEW |