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