Chromium Code Reviews| 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 "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/common/content_export.h" | |
| 12 #include "media/blink/skcanvas_video_renderer.h" | 13 #include "media/blink/skcanvas_video_renderer.h" |
| 13 #include "media/blink/webmediaplayer_util.h" | 14 #include "media/blink/webmediaplayer_util.h" |
| 14 #include "media/renderers/gpu_video_accelerator_factories.h" | 15 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 15 | 16 |
| 16 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 17 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 class WebFrame; | 20 class WebFrame; |
| 20 class WebGraphicsContext3D; | 21 class WebGraphicsContext3D; |
| 21 class WebMediaPlayerClient; | 22 class WebMediaPlayerClient; |
| 22 } | 23 } |
| 23 | 24 |
| 25 namespace cc { | |
| 26 class VideoFrameProvider; | |
| 27 } | |
| 28 | |
| 24 namespace media { | 29 namespace media { |
| 25 class MediaLog; | 30 class MediaLog; |
| 26 class WebMediaPlayerDelegate; | 31 class WebMediaPlayerDelegate; |
| 27 class VideoFrame; | 32 class VideoFrame; |
| 28 } | 33 } |
| 29 | 34 |
| 30 namespace cc_blink { | 35 namespace cc_blink { |
| 31 class WebLayerImpl; | 36 class WebLayerImpl; |
| 32 } | 37 } |
| 33 | 38 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 47 // | 52 // |
| 48 // VideoFrameProvider | 53 // VideoFrameProvider |
| 49 // provides video frames for rendering. | 54 // provides video frames for rendering. |
| 50 // | 55 // |
| 51 // TODO(wjia): add AudioPlayer. | 56 // TODO(wjia): add AudioPlayer. |
| 52 // AudioPlayer | 57 // AudioPlayer |
| 53 // plays audio streams. | 58 // plays audio streams. |
| 54 // | 59 // |
| 55 // blink::WebMediaPlayerClient | 60 // blink::WebMediaPlayerClient |
| 56 // WebKit client of this media player object. | 61 // WebKit client of this media player object. |
| 57 class WebMediaPlayerMS | 62 class CONTENT_EXPORT WebMediaPlayerMS |
| 58 : public blink::WebMediaPlayer, | 63 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), |
| 59 public base::SupportsWeakPtr<WebMediaPlayerMS> { | 64 public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) { |
| 60 public: | 65 public: |
| 61 // Construct a WebMediaPlayerMS with reference to the client, and | 66 // Construct a WebMediaPlayerMS with reference to the client, and |
| 62 // a MediaStreamClient which provides VideoFrameProvider. | 67 // a MediaStreamClient which provides VideoFrameProvider. |
| 63 WebMediaPlayerMS( | 68 WebMediaPlayerMS( |
| 64 blink::WebFrame* frame, | 69 blink::WebFrame* frame, |
| 65 blink::WebMediaPlayerClient* client, | 70 blink::WebMediaPlayerClient* client, |
| 66 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 71 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
| 67 media::MediaLog* media_log, | 72 media::MediaLog* media_log, |
| 68 scoped_ptr<MediaStreamRendererFactory> factory, | 73 scoped_ptr<MediaStreamRendererFactory> factory, |
| 69 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, | 74 const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 132 |
| 128 bool copyVideoTextureToPlatformTexture( | 133 bool copyVideoTextureToPlatformTexture( |
| 129 blink::WebGraphicsContext3D* web_graphics_context, | 134 blink::WebGraphicsContext3D* web_graphics_context, |
| 130 unsigned int texture, | 135 unsigned int texture, |
| 131 unsigned int internal_format, | 136 unsigned int internal_format, |
| 132 unsigned int type, | 137 unsigned int type, |
| 133 bool premultiply_alpha, | 138 bool premultiply_alpha, |
| 134 bool flip_y) override; | 139 bool flip_y) override; |
| 135 | 140 |
| 136 private: | 141 private: |
| 142 friend class WebMediaPlayerMSTest; | |
| 143 | |
| 137 // The callback for VideoFrameProvider to signal a new frame is available. | 144 // The callback for VideoFrameProvider to signal a new frame is available. |
| 138 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); | 145 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); |
| 139 // Need repaint due to state change. | 146 // Need repaint due to state change. |
| 140 void RepaintInternal(); | 147 void RepaintInternal(); |
| 141 | 148 |
| 142 // The callback for source to report error. | 149 // The callback for source to report error. |
| 143 void OnSourceError(); | 150 void OnSourceError(); |
| 144 | 151 |
| 145 // Helpers that set the network/ready state and notifies the client if | 152 // Helpers that set the network/ready state and notifies the client if |
| 146 // they've changed. | 153 // they've changed. |
| 147 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 154 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
| 148 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 155 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
| 149 | 156 |
| 150 // Getter method to |client_|. | 157 // Getter method to |client_|. |
| 151 blink::WebMediaPlayerClient* get_client() { return client_; } | 158 blink::WebMediaPlayerClient* get_client() { return client_; } |
| 152 | 159 |
| 160 // Correspondence of load(), for unit test use only. | |
| 161 cc::VideoFrameProvider* LoadForTesting(bool algorithm_enabled); | |
|
mcasas
2015/10/21 19:54:02
Load what exactly?
Write a more significant commen
qiangchen
2015/10/22 17:22:58
Done.
| |
| 162 | |
| 153 blink::WebFrame* const frame_; | 163 blink::WebFrame* const frame_; |
| 154 | 164 |
| 155 blink::WebMediaPlayer::NetworkState network_state_; | 165 blink::WebMediaPlayer::NetworkState network_state_; |
| 156 blink::WebMediaPlayer::ReadyState ready_state_; | 166 blink::WebMediaPlayer::ReadyState ready_state_; |
| 157 | 167 |
| 158 const blink::WebTimeRanges buffered_; | 168 const blink::WebTimeRanges buffered_; |
| 159 | 169 |
| 160 blink::WebMediaPlayerClient* const client_; | 170 blink::WebMediaPlayerClient* const client_; |
| 161 | 171 |
| 162 const base::WeakPtr<media::WebMediaPlayerDelegate> delegate_; | 172 const base::WeakPtr<media::WebMediaPlayerDelegate> delegate_; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 188 scoped_ptr<WebMediaPlayerMSCompositor> compositor_; | 198 scoped_ptr<WebMediaPlayerMSCompositor> compositor_; |
| 189 | 199 |
| 190 const scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 200 const scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; |
| 191 | 201 |
| 192 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 202 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
| 193 }; | 203 }; |
| 194 | 204 |
| 195 } // namespace content | 205 } // namespace content |
| 196 | 206 |
| 197 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 207 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
| OLD | NEW |