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