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