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