OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Delete this file when WMPI_CAST is no longer needed. |
| 6 |
| 7 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_CAST_H_ |
| 8 #define MEDIA_BLINK_WEBMEDIAPLAYER_CAST_H_ |
| 9 |
| 10 #include "media/blink/renderer_media_player_interface.h" |
| 11 #include "media/blink/webmediaplayer_params.h" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 #if defined(OS_ANDROID) |
| 15 |
| 16 namespace blink { |
| 17 class WebLocalFrame; |
| 18 class WebMediaPlayerClient; |
| 19 } |
| 20 |
| 21 namespace media { |
| 22 |
| 23 class WebMediaPlayerImpl; |
| 24 |
| 25 // This shim allows WebMediaPlayer to act sufficiently similar to |
| 26 // WebMediaPlayerAndroid (by extending RendererMediaPlayerInterface) |
| 27 // to implement cast functionality. |
| 28 class WebMediaPlayerCast : public RendererMediaPlayerInterface { |
| 29 public: |
| 30 WebMediaPlayerCast(WebMediaPlayerImpl* impl, |
| 31 blink::WebMediaPlayerClient* client, |
| 32 const WebMediaPlayerParams::Context3DCB& context_3d_cb); |
| 33 ~WebMediaPlayerCast(); |
| 34 |
| 35 void Initialize(const GURL& url, blink::WebLocalFrame* frame); |
| 36 |
| 37 void requestRemotePlayback(); |
| 38 void requestRemotePlaybackControl(); |
| 39 |
| 40 void set_media_player_manager( |
| 41 RendererMediaPlayerManagerInterface* media_player_manager); |
| 42 bool isRemote() const { return is_remote_; } |
| 43 |
| 44 double currentTime() const; |
| 45 void play(); |
| 46 void pause(); |
| 47 void seek(base::TimeDelta t); |
| 48 |
| 49 // RendererMediaPlayerInterface implementation |
| 50 void OnMediaMetadataChanged(base::TimeDelta duration, |
| 51 int width, |
| 52 int height, |
| 53 bool success) override; |
| 54 void OnPlaybackComplete() override; |
| 55 void OnBufferingUpdate(int percentage) override; |
| 56 void OnSeekRequest(const base::TimeDelta& time_to_seek) override; |
| 57 void OnSeekComplete(const base::TimeDelta& current_time) override; |
| 58 void OnMediaError(int error_type) override; |
| 59 void OnVideoSizeChanged(int width, int height) override; |
| 60 |
| 61 // Called to update the current time. |
| 62 void OnTimeUpdate(base::TimeDelta current_timestamp, |
| 63 base::TimeTicks current_time_ticks) override; |
| 64 |
| 65 // void OnWaitingForDecryptionKey() override; |
| 66 void OnPlayerReleased() override; |
| 67 |
| 68 // Functions called when media player status changes. |
| 69 void OnConnectedToRemoteDevice( |
| 70 const std::string& remote_playback_message) override; |
| 71 void OnDisconnectedFromRemoteDevice() override; |
| 72 void OnDidExitFullscreen() override; |
| 73 void OnMediaPlayerPlay() override; |
| 74 void OnMediaPlayerPause() override; |
| 75 void OnRemoteRouteAvailabilityChanged(bool routes_available) override; |
| 76 |
| 77 // Getters of playback state. |
| 78 // bool paused() const override; |
| 79 |
| 80 // True if the loaded media has a playable video track. |
| 81 // bool hasVideo() const override; |
| 82 |
| 83 // This function is called by the RendererMediaPlayerManager to pause the |
| 84 // video and release the media player and surface texture when we switch tabs. |
| 85 // However, the actual GlTexture is not released to keep the video screenshot. |
| 86 void ReleaseMediaResources() override; |
| 87 |
| 88 #if defined(VIDEO_HOLE) |
| 89 // Calculate the boundary rectangle of the media player (i.e. location and |
| 90 // size of the video frame). |
| 91 // Returns true if the geometry has been changed since the last call. |
| 92 bool UpdateBoundaryRectangle() override; |
| 93 |
| 94 const gfx::RectF GetBoundaryRectangle() override; |
| 95 #endif |
| 96 |
| 97 void OnWaitingForDecryptionKey() override; |
| 98 |
| 99 void DrawRemotePlaybackText(const std::string& remote_playback_message); |
| 100 bool paused() const override; |
| 101 bool hasVideo() const override; |
| 102 |
| 103 private: |
| 104 WebMediaPlayerImpl* webmediaplayer_; |
| 105 blink::WebMediaPlayerClient* client_; |
| 106 WebMediaPlayerParams::Context3DCB context_3d_cb_; |
| 107 |
| 108 // Manages this object and delegates player calls to the browser process. |
| 109 // Owned by RenderFrameImpl. |
| 110 RendererMediaPlayerManagerInterface* player_manager_ = nullptr; |
| 111 |
| 112 // Player ID assigned by the |player_manager_|. |
| 113 int player_id_; |
| 114 |
| 115 // Whether the browser is currently connected to a remote media player. |
| 116 bool is_remote_ = false; |
| 117 |
| 118 bool paused_ = true; |
| 119 bool should_notify_time_changed_ = false; |
| 120 |
| 121 // Last reported playout time. |
| 122 base::TimeDelta remote_time_; |
| 123 base::TimeTicks remote_time_at_; |
| 124 |
| 125 // Whether the media player has been initialized. |
| 126 bool is_player_initialized_ = false; |
| 127 }; |
| 128 |
| 129 } // namespace media |
| 130 |
| 131 #endif // OS_ANDROID |
| 132 |
| 133 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_CAST_H_ |
OLD | NEW |