| 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 <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" | 
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" | 
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" | 
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" | 
|  | 14 #include "content/common/content_export.h" | 
| 14 #include "media/blink/webmediaplayer_util.h" | 15 #include "media/blink/webmediaplayer_util.h" | 
| 15 #include "media/renderers/gpu_video_accelerator_factories.h" | 16 #include "media/renderers/gpu_video_accelerator_factories.h" | 
| 16 #include "media/renderers/skcanvas_video_renderer.h" | 17 #include "media/renderers/skcanvas_video_renderer.h" | 
| 17 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 18 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 
| 18 #include "url/origin.h" | 19 #include "url/origin.h" | 
| 19 | 20 | 
| 20 namespace blink { | 21 namespace blink { | 
| 21 class WebFrame; | 22 class WebFrame; | 
| 22 class WebGraphicsContext3D; | 23 class WebGraphicsContext3D; | 
| 23 class WebMediaPlayerClient; | 24 class WebMediaPlayerClient; | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 51 // | 52 // | 
| 52 // VideoFrameProvider | 53 // VideoFrameProvider | 
| 53 //   provides video frames for rendering. | 54 //   provides video frames for rendering. | 
| 54 // | 55 // | 
| 55 // TODO(wjia): add AudioPlayer. | 56 // TODO(wjia): add AudioPlayer. | 
| 56 // AudioPlayer | 57 // AudioPlayer | 
| 57 //   plays audio streams. | 58 //   plays audio streams. | 
| 58 // | 59 // | 
| 59 // blink::WebMediaPlayerClient | 60 // blink::WebMediaPlayerClient | 
| 60 //   WebKit client of this media player object. | 61 //   WebKit client of this media player object. | 
| 61 class WebMediaPlayerMS | 62 class CONTENT_EXPORT WebMediaPlayerMS | 
| 62     : public blink::WebMediaPlayer, | 63     : public NON_EXPORTED_BASE(blink::WebMediaPlayer), | 
| 63       public base::SupportsWeakPtr<WebMediaPlayerMS> { | 64       public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) { | 
| 64  public: | 65  public: | 
| 65   // Construct a WebMediaPlayerMS with reference to the client, and | 66   // Construct a WebMediaPlayerMS with reference to the client, and | 
| 66   // a MediaStreamClient which provides VideoFrameProvider. | 67   // a MediaStreamClient which provides VideoFrameProvider. | 
| 67   WebMediaPlayerMS( | 68   WebMediaPlayerMS( | 
| 68       blink::WebFrame* frame, | 69       blink::WebFrame* frame, | 
| 69       blink::WebMediaPlayerClient* client, | 70       blink::WebMediaPlayerClient* client, | 
| 70       base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 71       base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 
| 71       media::MediaLog* media_log, | 72       media::MediaLog* media_log, | 
| 72       scoped_ptr<MediaStreamRendererFactory> factory, | 73       scoped_ptr<MediaStreamRendererFactory> factory, | 
| 73       const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, | 74       const scoped_refptr<base::SingleThreadTaskRunner>& compositor_task_runner, | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 136 | 137 | 
| 137   bool copyVideoTextureToPlatformTexture( | 138   bool copyVideoTextureToPlatformTexture( | 
| 138       blink::WebGraphicsContext3D* web_graphics_context, | 139       blink::WebGraphicsContext3D* web_graphics_context, | 
| 139       unsigned int texture, | 140       unsigned int texture, | 
| 140       unsigned int internal_format, | 141       unsigned int internal_format, | 
| 141       unsigned int type, | 142       unsigned int type, | 
| 142       bool premultiply_alpha, | 143       bool premultiply_alpha, | 
| 143       bool flip_y) override; | 144       bool flip_y) override; | 
| 144 | 145 | 
| 145  private: | 146  private: | 
|  | 147   friend class WebMediaPlayerMSTest; | 
|  | 148 | 
| 146   // The callback for VideoFrameProvider to signal a new frame is available. | 149   // The callback for VideoFrameProvider to signal a new frame is available. | 
| 147   void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); | 150   void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); | 
| 148   // Need repaint due to state change. | 151   // Need repaint due to state change. | 
| 149   void RepaintInternal(); | 152   void RepaintInternal(); | 
| 150 | 153 | 
| 151   // The callback for source to report error. | 154   // The callback for source to report error. | 
| 152   void OnSourceError(); | 155   void OnSourceError(); | 
| 153 | 156 | 
| 154   // Helpers that set the network/ready state and notifies the client if | 157   // Helpers that set the network/ready state and notifies the client if | 
| 155   // they've changed. | 158   // they've changed. | 
| 156   void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 159   void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 
| 157   void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 160   void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 
| 158 | 161 | 
| 159   // Getter method to |client_|. | 162   // Getter method to |client_|. | 
| 160   blink::WebMediaPlayerClient* get_client() { return client_; } | 163   blink::WebMediaPlayerClient* get_client() { return client_; } | 
| 161 | 164 | 
|  | 165   // For unit test use only. | 
|  | 166   // Returns the pointer to the WebMediaPlayerMSCompositor. | 
|  | 167   WebMediaPlayerMSCompositor* GetCompositorForTesting(); | 
|  | 168 | 
| 162   blink::WebFrame* const frame_; | 169   blink::WebFrame* const frame_; | 
| 163 | 170 | 
| 164   blink::WebMediaPlayer::NetworkState network_state_; | 171   blink::WebMediaPlayer::NetworkState network_state_; | 
| 165   blink::WebMediaPlayer::ReadyState ready_state_; | 172   blink::WebMediaPlayer::ReadyState ready_state_; | 
| 166 | 173 | 
| 167   const blink::WebTimeRanges buffered_; | 174   const blink::WebTimeRanges buffered_; | 
| 168 | 175 | 
| 169   blink::WebMediaPlayerClient* const client_; | 176   blink::WebMediaPlayerClient* const client_; | 
| 170 | 177 | 
| 171   const base::WeakPtr<media::WebMediaPlayerDelegate> delegate_; | 178   const base::WeakPtr<media::WebMediaPlayerDelegate> delegate_; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 192   // Used for DCHECKs to ensure methods calls executed in the correct thread. | 199   // Used for DCHECKs to ensure methods calls executed in the correct thread. | 
| 193   base::ThreadChecker thread_checker_; | 200   base::ThreadChecker thread_checker_; | 
| 194 | 201 | 
| 195   // WebMediaPlayerMS owns |compositor_| and destroys it on | 202   // WebMediaPlayerMS owns |compositor_| and destroys it on | 
| 196   // |compositor_task_runner_|. | 203   // |compositor_task_runner_|. | 
| 197   scoped_ptr<WebMediaPlayerMSCompositor> compositor_; | 204   scoped_ptr<WebMediaPlayerMSCompositor> compositor_; | 
| 198 | 205 | 
| 199   const scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 206   const scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_; | 
| 200 | 207 | 
| 201   const std::string initial_audio_output_device_id_; | 208   const std::string initial_audio_output_device_id_; | 
| 202   const url::Origin initial_security_origin_; | 209   url::Origin initial_security_origin_; | 
| 203 | 210 | 
| 204   DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 211   DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 
| 205 }; | 212 }; | 
| 206 | 213 | 
| 207 }  // namespace content | 214 }  // namespace content | 
| 208 | 215 | 
| 209 #endif  // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 216 #endif  // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 
| OLD | NEW | 
|---|