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 MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "media/blink/video_frame_compositor.h" | 29 #include "media/blink/video_frame_compositor.h" |
30 #include "media/blink/webmediaplayer_delegate.h" | 30 #include "media/blink/webmediaplayer_delegate.h" |
31 #include "media/blink/webmediaplayer_params.h" | 31 #include "media/blink/webmediaplayer_params.h" |
32 #include "media/blink/webmediaplayer_util.h" | 32 #include "media/blink/webmediaplayer_util.h" |
33 #include "media/renderers/skcanvas_video_renderer.h" | 33 #include "media/renderers/skcanvas_video_renderer.h" |
34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" | 34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" |
35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
37 #include "url/gurl.h" | 37 #include "url/gurl.h" |
38 | 38 |
| 39 #if defined(OS_ANDROID) // WMPI_CAST |
| 40 // Delete this file when WMPI_CAST is no longer needed. |
| 41 #include "media/blink/renderer_media_player_interface.h" |
| 42 #endif |
| 43 |
39 namespace blink { | 44 namespace blink { |
40 class WebGraphicsContext3D; | 45 class WebGraphicsContext3D; |
41 class WebLocalFrame; | 46 class WebLocalFrame; |
42 class WebMediaPlayerClient; | 47 class WebMediaPlayerClient; |
43 class WebMediaPlayerEncryptedMediaClient; | 48 class WebMediaPlayerEncryptedMediaClient; |
44 } | 49 } |
45 | 50 |
46 namespace base { | 51 namespace base { |
47 class SingleThreadTaskRunner; | 52 class SingleThreadTaskRunner; |
48 class TaskRunner; | 53 class TaskRunner; |
(...skipping 14 matching lines...) Expand all Loading... |
63 class WebAudioSourceProviderImpl; | 68 class WebAudioSourceProviderImpl; |
64 class WebMediaPlayerDelegate; | 69 class WebMediaPlayerDelegate; |
65 class WebTextTrackImpl; | 70 class WebTextTrackImpl; |
66 | 71 |
67 // The canonical implementation of blink::WebMediaPlayer that's backed by | 72 // The canonical implementation of blink::WebMediaPlayer that's backed by |
68 // Pipeline. Handles normal resource loading, Media Source, and | 73 // Pipeline. Handles normal resource loading, Media Source, and |
69 // Encrypted Media. | 74 // Encrypted Media. |
70 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl | 75 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl |
71 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), | 76 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), |
72 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), | 77 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), |
| 78 #if defined(OS_ANDROID) // WMPI_CAST |
| 79 public RendererMediaPlayerInterface, |
| 80 #endif |
73 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 81 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
74 public: | 82 public: |
75 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 83 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
76 // |delegate| may be null. |renderer| may also be null, in which case an | 84 // |delegate| may be null. |renderer| may also be null, in which case an |
77 // internal renderer will be created. | 85 // internal renderer will be created. |
78 // TODO(xhwang): Drop the internal renderer path and always pass in a renderer | 86 // TODO(xhwang): Drop the internal renderer path and always pass in a renderer |
79 // here. | 87 // here. |
80 WebMediaPlayerImpl( | 88 WebMediaPlayerImpl( |
81 blink::WebLocalFrame* frame, | 89 blink::WebLocalFrame* frame, |
82 blink::WebMediaPlayerClient* client, | 90 blink::WebMediaPlayerClient* client, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void OnPipelineMetadata(PipelineMetadata metadata); | 191 void OnPipelineMetadata(PipelineMetadata metadata); |
184 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | 192 void OnPipelineBufferingStateChanged(BufferingState buffering_state); |
185 void OnDemuxerOpened(); | 193 void OnDemuxerOpened(); |
186 void OnAddTextTrack(const TextTrackConfig& config, | 194 void OnAddTextTrack(const TextTrackConfig& config, |
187 const AddTextTrackDoneCB& done_cb); | 195 const AddTextTrackDoneCB& done_cb); |
188 | 196 |
189 // WebMediaPlayerDelegate::Observer implementation. | 197 // WebMediaPlayerDelegate::Observer implementation. |
190 void OnHidden() override; | 198 void OnHidden() override; |
191 void OnShown() override; | 199 void OnShown() override; |
192 | 200 |
| 201 #if defined(OS_ANDROID) // WMPI_CAST |
| 202 void requestRemotePlayback() override; |
| 203 void requestRemotePlaybackControl() override; |
| 204 |
| 205 void set_media_player_manager( |
| 206 RendererMediaPlayerManagerInterface* media_player_manager); |
| 207 |
| 208 // RendererMediaPlayerInterface implementation |
| 209 void OnMediaMetadataChanged(base::TimeDelta duration, |
| 210 int width, |
| 211 int height, |
| 212 bool success) override; |
| 213 void OnPlaybackComplete() override; |
| 214 void OnBufferingUpdate(int percentage) override; |
| 215 void OnSeekRequest(const base::TimeDelta& time_to_seek) override; |
| 216 void OnSeekComplete(const base::TimeDelta& current_time) override; |
| 217 void OnMediaError(int error_type) override; |
| 218 void OnVideoSizeChanged(int width, int height) override; |
| 219 |
| 220 // Called to update the current time. |
| 221 void OnTimeUpdate(base::TimeDelta current_timestamp, |
| 222 base::TimeTicks current_time_ticks) override; |
| 223 |
| 224 // void OnWaitingForDecryptionKey() override; |
| 225 void OnPlayerReleased() override; |
| 226 |
| 227 // Functions called when media player status changes. |
| 228 void OnConnectedToRemoteDevice( |
| 229 const std::string& remote_playback_message) override; |
| 230 void OnDisconnectedFromRemoteDevice() override; |
| 231 void OnDidExitFullscreen() override; |
| 232 void OnMediaPlayerPlay() override; |
| 233 void OnMediaPlayerPause() override; |
| 234 void OnRemoteRouteAvailabilityChanged(bool routes_available) override; |
| 235 |
| 236 // Getters of playback state. |
| 237 // bool paused() const override; |
| 238 |
| 239 // True if the loaded media has a playable video track. |
| 240 // bool hasVideo() const override; |
| 241 |
| 242 // This function is called by the RendererMediaPlayerManager to pause the |
| 243 // video and release the media player and surface texture when we switch tabs. |
| 244 // However, the actual GlTexture is not released to keep the video screenshot. |
| 245 void ReleaseMediaResources() override; |
| 246 |
| 247 #if defined(VIDEO_HOLE) |
| 248 // Calculate the boundary rectangle of the media player (i.e. location and |
| 249 // size of the video frame). |
| 250 // Returns true if the geometry has been changed since the last call. |
| 251 bool UpdateBoundaryRectangle() override; |
| 252 |
| 253 const gfx::RectF GetBoundaryRectangle() override; |
| 254 #endif |
| 255 |
| 256 void DrawRemotePlaybackText(const std::string& remote_playback_message); |
| 257 #endif |
| 258 |
193 private: | 259 private: |
194 // Initiate suspending the pipeline. | 260 // Initiate suspending the pipeline. |
195 void Suspend(); | 261 void Suspend(); |
196 | 262 |
197 // Initiate resuming the pipeline. | 263 // Initiate resuming the pipeline. |
198 void Resume(); | 264 void Resume(); |
199 | 265 |
200 // Called after |defer_load_cb_| has decided to allow the load. If | 266 // Called after |defer_load_cb_| has decided to allow the load. If |
201 // |defer_load_cb_| is null this is called immediately. | 267 // |defer_load_cb_| is null this is called immediately. |
202 void DoLoad(LoadType load_type, | 268 void DoLoad(LoadType load_type, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Returns the current video frame from |compositor_|. Blocks until the | 301 // Returns the current video frame from |compositor_|. Blocks until the |
236 // compositor can return the frame. | 302 // compositor can return the frame. |
237 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); | 303 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); |
238 | 304 |
239 // Called when the demuxer encounters encrypted streams. | 305 // Called when the demuxer encounters encrypted streams. |
240 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 306 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
241 const std::vector<uint8_t>& init_data); | 307 const std::vector<uint8_t>& init_data); |
242 | 308 |
243 // Called when a decoder detects that the key needed to decrypt the stream | 309 // Called when a decoder detects that the key needed to decrypt the stream |
244 // is not available. | 310 // is not available. |
245 void OnWaitingForDecryptionKey(); | 311 void OnWaitingForDecryptionKey() override; |
246 | 312 |
247 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 313 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
248 // Parameter order is reversed for easy binding. | 314 // Parameter order is reversed for easy binding. |
249 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 315 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
250 | 316 |
251 // Called when a CDM has been attached to the |pipeline_|. | 317 // Called when a CDM has been attached to the |pipeline_|. |
252 void OnCdmAttached(bool success); | 318 void OnCdmAttached(bool success); |
253 | 319 |
254 // Updates |paused_time_| to the current media time with consideration for the | 320 // Updates |paused_time_| to the current media time with consideration for the |
255 // |ended_| state by clamping current time to duration upon |ended_|. | 321 // |ended_| state by clamping current time to duration upon |ended_|. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // The compositor layer for displaying the video content when using composited | 459 // The compositor layer for displaying the video content when using composited |
394 // playback. | 460 // playback. |
395 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; | 461 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; |
396 | 462 |
397 EncryptedMediaPlayerSupport encrypted_media_support_; | 463 EncryptedMediaPlayerSupport encrypted_media_support_; |
398 | 464 |
399 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; | 465 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; |
400 | 466 |
401 scoped_ptr<RendererFactory> renderer_factory_; | 467 scoped_ptr<RendererFactory> renderer_factory_; |
402 | 468 |
| 469 #if defined(OS_ANDROID) // WMPI_CAST |
| 470 // Manages this object and delegates player calls to the browser process. |
| 471 // Owned by RenderFrameImpl. |
| 472 RendererMediaPlayerManagerInterface* player_manager_ = nullptr; |
| 473 |
| 474 // Player ID assigned by the |player_manager_|. |
| 475 int player_id_; |
| 476 |
| 477 // Whether the browser is currently connected to a remote media player. |
| 478 bool is_remote_ = false; |
| 479 |
| 480 // Last reported playout time. |
| 481 base::TimeDelta remote_time_; |
| 482 base::TimeTicks remote_time_at_; |
| 483 |
| 484 // Whether the media player has been initialized. |
| 485 bool is_player_initialized_ = false; |
| 486 #endif |
| 487 |
403 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 488 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
404 }; | 489 }; |
405 | 490 |
406 } // namespace media | 491 } // namespace media |
407 | 492 |
408 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 493 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |