Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.h

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
6 #define CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 6 #define CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 18 matching lines...) Expand all
29 #include "third_party/WebKit/public/platform/WebSize.h" 29 #include "third_party/WebKit/public/platform/WebSize.h"
30 #include "third_party/WebKit/public/platform/WebURL.h" 30 #include "third_party/WebKit/public/platform/WebURL.h"
31 #include "third_party/WebKit/public/web/WebMediaPlayer.h" 31 #include "third_party/WebKit/public/web/WebMediaPlayer.h"
32 #include "ui/gfx/rect_f.h" 32 #include "ui/gfx/rect_f.h"
33 33
34 namespace media { 34 namespace media {
35 class Demuxer; 35 class Demuxer;
36 class MediaLog; 36 class MediaLog;
37 } 37 }
38 38
39 namespace WebKit { 39 namespace blink {
40 class WebFrame; 40 class WebFrame;
41 } 41 }
42 42
43 namespace webkit { 43 namespace webkit {
44 class WebLayerImpl; 44 class WebLayerImpl;
45 } 45 }
46 46
47 namespace content { 47 namespace content {
48 class WebMediaPlayerDelegate; 48 class WebMediaPlayerDelegate;
49 class RendererMediaPlayerManager; 49 class RendererMediaPlayerManager;
50 50
51 #if defined(GOOGLE_TV) 51 #if defined(GOOGLE_TV)
52 class MediaStreamAudioRenderer; 52 class MediaStreamAudioRenderer;
53 class MediaStreamClient; 53 class MediaStreamClient;
54 #endif 54 #endif
55 55
56 // This class implements WebKit::WebMediaPlayer by keeping the android 56 // This class implements blink::WebMediaPlayer by keeping the android
57 // media player in the browser process. It listens to all the status changes 57 // media player in the browser process. It listens to all the status changes
58 // sent from the browser process and sends playback controls to the media 58 // sent from the browser process and sends playback controls to the media
59 // player. 59 // player.
60 class WebMediaPlayerAndroid 60 class WebMediaPlayerAndroid
61 : public WebKit::WebMediaPlayer, 61 : public blink::WebMediaPlayer,
62 public cc::VideoFrameProvider, 62 public cc::VideoFrameProvider,
63 public base::MessageLoop::DestructionObserver, 63 public base::MessageLoop::DestructionObserver,
64 public base::SupportsWeakPtr<WebMediaPlayerAndroid> { 64 public base::SupportsWeakPtr<WebMediaPlayerAndroid> {
65 public: 65 public:
66 // Construct a WebMediaPlayerAndroid object. This class communicates 66 // Construct a WebMediaPlayerAndroid object. This class communicates
67 // with the MediaPlayerAndroid object in the browser process through 67 // with the MediaPlayerAndroid object in the browser process through
68 // |proxy|. 68 // |proxy|.
69 // TODO(qinmin): |frame| argument is used to determine whether the current 69 // TODO(qinmin): |frame| argument is used to determine whether the current
70 // player can enter fullscreen. This logic should probably be moved into 70 // player can enter fullscreen. This logic should probably be moved into
71 // blink, so that enterFullscreen() will not be called if another video is 71 // blink, so that enterFullscreen() will not be called if another video is
72 // already in fullscreen. 72 // already in fullscreen.
73 WebMediaPlayerAndroid( 73 WebMediaPlayerAndroid(
74 WebKit::WebFrame* frame, 74 blink::WebFrame* frame,
75 WebKit::WebMediaPlayerClient* client, 75 blink::WebMediaPlayerClient* client,
76 base::WeakPtr<WebMediaPlayerDelegate> delegate, 76 base::WeakPtr<WebMediaPlayerDelegate> delegate,
77 RendererMediaPlayerManager* manager, 77 RendererMediaPlayerManager* manager,
78 StreamTextureFactory* factory, 78 StreamTextureFactory* factory,
79 const scoped_refptr<base::MessageLoopProxy>& media_loop, 79 const scoped_refptr<base::MessageLoopProxy>& media_loop,
80 media::MediaLog* media_log); 80 media::MediaLog* media_log);
81 virtual ~WebMediaPlayerAndroid(); 81 virtual ~WebMediaPlayerAndroid();
82 82
83 // WebKit::WebMediaPlayer implementation. 83 // blink::WebMediaPlayer implementation.
84 virtual void enterFullscreen(); 84 virtual void enterFullscreen();
85 virtual void exitFullscreen(); 85 virtual void exitFullscreen();
86 virtual bool canEnterFullscreen() const; 86 virtual bool canEnterFullscreen() const;
87 87
88 // Resource loading. 88 // Resource loading.
89 virtual void load(LoadType load_type, 89 virtual void load(LoadType load_type,
90 const WebKit::WebURL& url, 90 const blink::WebURL& url,
91 CORSMode cors_mode) OVERRIDE; 91 CORSMode cors_mode) OVERRIDE;
92 92
93 // Playback controls. 93 // Playback controls.
94 virtual void play(); 94 virtual void play();
95 virtual void pause(); 95 virtual void pause();
96 virtual void pause(bool is_media_related_action); 96 virtual void pause(bool is_media_related_action);
97 virtual void seek(double seconds); 97 virtual void seek(double seconds);
98 virtual bool supportsFullscreen() const; 98 virtual bool supportsFullscreen() const;
99 virtual bool supportsSave() const; 99 virtual bool supportsSave() const;
100 virtual void setRate(double rate); 100 virtual void setRate(double rate);
101 virtual void setVolume(double volume); 101 virtual void setVolume(double volume);
102 virtual const WebKit::WebTimeRanges& buffered(); 102 virtual const blink::WebTimeRanges& buffered();
103 virtual double maxTimeSeekable() const; 103 virtual double maxTimeSeekable() const;
104 104
105 // Methods for painting. 105 // Methods for painting.
106 virtual void paint(WebKit::WebCanvas* canvas, 106 virtual void paint(blink::WebCanvas* canvas,
107 const WebKit::WebRect& rect, 107 const blink::WebRect& rect,
108 unsigned char alpha); 108 unsigned char alpha);
109 109
110 virtual bool copyVideoTextureToPlatformTexture( 110 virtual bool copyVideoTextureToPlatformTexture(
111 WebKit::WebGraphicsContext3D* web_graphics_context, 111 blink::WebGraphicsContext3D* web_graphics_context,
112 unsigned int texture, 112 unsigned int texture,
113 unsigned int level, 113 unsigned int level,
114 unsigned int internal_format, 114 unsigned int internal_format,
115 unsigned int type, 115 unsigned int type,
116 bool premultiply_alpha, 116 bool premultiply_alpha,
117 bool flip_y); 117 bool flip_y);
118 118
119 // True if the loaded media has a playable video/audio track. 119 // True if the loaded media has a playable video/audio track.
120 virtual bool hasVideo() const; 120 virtual bool hasVideo() const;
121 virtual bool hasAudio() const; 121 virtual bool hasAudio() const;
122 122
123 // Dimensions of the video. 123 // Dimensions of the video.
124 virtual WebKit::WebSize naturalSize() const; 124 virtual blink::WebSize naturalSize() const;
125 125
126 // Getters of playback state. 126 // Getters of playback state.
127 virtual bool paused() const; 127 virtual bool paused() const;
128 virtual bool seeking() const; 128 virtual bool seeking() const;
129 virtual double duration() const; 129 virtual double duration() const;
130 virtual double currentTime() const; 130 virtual double currentTime() const;
131 131
132 virtual bool didLoadingProgress() const; 132 virtual bool didLoadingProgress() const;
133 133
134 // Internal states of loading and network. 134 // Internal states of loading and network.
135 virtual WebKit::WebMediaPlayer::NetworkState networkState() const; 135 virtual blink::WebMediaPlayer::NetworkState networkState() const;
136 virtual WebKit::WebMediaPlayer::ReadyState readyState() const; 136 virtual blink::WebMediaPlayer::ReadyState readyState() const;
137 137
138 virtual bool hasSingleSecurityOrigin() const; 138 virtual bool hasSingleSecurityOrigin() const;
139 virtual bool didPassCORSAccessCheck() const; 139 virtual bool didPassCORSAccessCheck() const;
140 140
141 virtual double mediaTimeForTimeValue(double timeValue) const; 141 virtual double mediaTimeForTimeValue(double timeValue) const;
142 142
143 // Provide statistics. 143 // Provide statistics.
144 virtual unsigned decodedFrameCount() const; 144 virtual unsigned decodedFrameCount() const;
145 virtual unsigned droppedFrameCount() const; 145 virtual unsigned droppedFrameCount() const;
146 virtual unsigned audioDecodedByteCount() const; 146 virtual unsigned audioDecodedByteCount() const;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 void Detach(); 191 void Detach();
192 192
193 #if defined(GOOGLE_TV) 193 #if defined(GOOGLE_TV)
194 // Retrieve geometry of the media player (i.e. location and size of the video 194 // Retrieve geometry of the media player (i.e. location and size of the video
195 // frame) if changed. Returns true only if the geometry has been changed since 195 // frame) if changed. Returns true only if the geometry has been changed since
196 // the last call. 196 // the last call.
197 bool RetrieveGeometryChange(gfx::RectF* rect); 197 bool RetrieveGeometryChange(gfx::RectF* rect);
198 #endif 198 #endif
199 199
200 virtual MediaKeyException generateKeyRequest( 200 virtual MediaKeyException generateKeyRequest(
201 const WebKit::WebString& key_system, 201 const blink::WebString& key_system,
202 const unsigned char* init_data, 202 const unsigned char* init_data,
203 unsigned init_data_length) OVERRIDE; 203 unsigned init_data_length) OVERRIDE;
204 virtual MediaKeyException addKey( 204 virtual MediaKeyException addKey(
205 const WebKit::WebString& key_system, 205 const blink::WebString& key_system,
206 const unsigned char* key, 206 const unsigned char* key,
207 unsigned key_length, 207 unsigned key_length,
208 const unsigned char* init_data, 208 const unsigned char* init_data,
209 unsigned init_data_length, 209 unsigned init_data_length,
210 const WebKit::WebString& session_id) OVERRIDE; 210 const blink::WebString& session_id) OVERRIDE;
211 virtual MediaKeyException cancelKeyRequest( 211 virtual MediaKeyException cancelKeyRequest(
212 const WebKit::WebString& key_system, 212 const blink::WebString& key_system,
213 const WebKit::WebString& session_id) OVERRIDE; 213 const blink::WebString& session_id) OVERRIDE;
214 214
215 void OnKeyAdded(const std::string& session_id); 215 void OnKeyAdded(const std::string& session_id);
216 void OnKeyError(const std::string& session_id, 216 void OnKeyError(const std::string& session_id,
217 media::MediaKeys::KeyError error_code, 217 media::MediaKeys::KeyError error_code,
218 int system_code); 218 int system_code);
219 void OnKeyMessage(const std::string& session_id, 219 void OnKeyMessage(const std::string& session_id,
220 const std::vector<uint8>& message, 220 const std::vector<uint8>& message,
221 const std::string& destination_url); 221 const std::string& destination_url);
222 222
223 void OnMediaSourceOpened(WebKit::WebMediaSource* web_media_source); 223 void OnMediaSourceOpened(blink::WebMediaSource* web_media_source);
224 224
225 void OnNeedKey(const std::string& type, 225 void OnNeedKey(const std::string& type,
226 const std::vector<uint8>& init_data); 226 const std::vector<uint8>& init_data);
227 227
228 #if defined(GOOGLE_TV) 228 #if defined(GOOGLE_TV)
229 bool InjectMediaStream(MediaStreamClient* media_stream_client, 229 bool InjectMediaStream(MediaStreamClient* media_stream_client,
230 media::Demuxer* demuxer, 230 media::Demuxer* demuxer,
231 const base::Closure& destroy_demuxer_cb); 231 const base::Closure& destroy_demuxer_cb);
232 #endif 232 #endif
233 233
234 // Can be called on any thread. 234 // Can be called on any thread.
235 static void OnReleaseRemotePlaybackTexture( 235 static void OnReleaseRemotePlaybackTexture(
236 const scoped_refptr<base::MessageLoopProxy>& main_loop, 236 const scoped_refptr<base::MessageLoopProxy>& main_loop,
237 const base::WeakPtr<WebMediaPlayerAndroid>& player, 237 const base::WeakPtr<WebMediaPlayerAndroid>& player,
238 uint32 sync_point); 238 uint32 sync_point);
239 239
240 protected: 240 protected:
241 // Helper method to update the playing state. 241 // Helper method to update the playing state.
242 void UpdatePlayingState(bool is_playing_); 242 void UpdatePlayingState(bool is_playing_);
243 243
244 // Helper methods for posting task for setting states and update WebKit. 244 // Helper methods for posting task for setting states and update WebKit.
245 void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state); 245 void UpdateNetworkState(blink::WebMediaPlayer::NetworkState state);
246 void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state); 246 void UpdateReadyState(blink::WebMediaPlayer::ReadyState state);
247 void TryCreateStreamTextureProxyIfNeeded(); 247 void TryCreateStreamTextureProxyIfNeeded();
248 void DoCreateStreamTexture(); 248 void DoCreateStreamTexture();
249 249
250 250
251 // Helper method to reestablish the surface texture peer for android 251 // Helper method to reestablish the surface texture peer for android
252 // media player. 252 // media player.
253 void EstablishSurfaceTexturePeer(); 253 void EstablishSurfaceTexturePeer();
254 254
255 // Requesting whether the surface texture peer needs to be reestablished. 255 // Requesting whether the surface texture peer needs to be reestablished.
256 void SetNeedsEstablishPeer(bool needs_establish_peer); 256 void SetNeedsEstablishPeer(bool needs_establish_peer);
257 257
258 #if defined(GOOGLE_TV) 258 #if defined(GOOGLE_TV)
259 // Request external surface for out-of-band composition. 259 // Request external surface for out-of-band composition.
260 void RequestExternalSurface(); 260 void RequestExternalSurface();
261 #endif 261 #endif
262 262
263 private: 263 private:
264 void DrawRemotePlaybackIcon(); 264 void DrawRemotePlaybackIcon();
265 void ReallocateVideoFrame(); 265 void ReallocateVideoFrame();
266 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame); 266 void SetCurrentFrameInternal(scoped_refptr<media::VideoFrame>& frame);
267 void DidLoadMediaInfo(MediaInfoLoader::Status status); 267 void DidLoadMediaInfo(MediaInfoLoader::Status status);
268 void DoReleaseRemotePlaybackTexture(uint32 sync_point); 268 void DoReleaseRemotePlaybackTexture(uint32 sync_point);
269 269
270 // Actually do the work for generateKeyRequest/addKey so they can easily 270 // Actually do the work for generateKeyRequest/addKey so they can easily
271 // report results to UMA. 271 // report results to UMA.
272 MediaKeyException GenerateKeyRequestInternal( 272 MediaKeyException GenerateKeyRequestInternal(
273 const WebKit::WebString& key_system, 273 const blink::WebString& key_system,
274 const unsigned char* init_data, 274 const unsigned char* init_data,
275 unsigned init_data_length); 275 unsigned init_data_length);
276 MediaKeyException AddKeyInternal(const WebKit::WebString& key_system, 276 MediaKeyException AddKeyInternal(const blink::WebString& key_system,
277 const unsigned char* key, 277 const unsigned char* key,
278 unsigned key_length, 278 unsigned key_length,
279 const unsigned char* init_data, 279 const unsigned char* init_data,
280 unsigned init_data_length, 280 unsigned init_data_length,
281 const WebKit::WebString& session_id); 281 const blink::WebString& session_id);
282 MediaKeyException CancelKeyRequestInternal( 282 MediaKeyException CancelKeyRequestInternal(
283 const WebKit::WebString& key_system, 283 const blink::WebString& key_system,
284 const WebKit::WebString& session_id); 284 const blink::WebString& session_id);
285 285
286 WebKit::WebFrame* const frame_; 286 blink::WebFrame* const frame_;
287 287
288 WebKit::WebMediaPlayerClient* const client_; 288 blink::WebMediaPlayerClient* const client_;
289 289
290 // |delegate_| is used to notify the browser process of the player status, so 290 // |delegate_| is used to notify the browser process of the player status, so
291 // that the browser process can control screen locks. 291 // that the browser process can control screen locks.
292 // TODO(qinmin): Currently android mediaplayer takes care of the screen 292 // TODO(qinmin): Currently android mediaplayer takes care of the screen
293 // lock. So this is only used for media source. Will apply this to regular 293 // lock. So this is only used for media source. Will apply this to regular
294 // media tag once http://crbug.com/247892 is fixed. 294 // media tag once http://crbug.com/247892 is fixed.
295 base::WeakPtr<WebMediaPlayerDelegate> delegate_; 295 base::WeakPtr<WebMediaPlayerDelegate> delegate_;
296 296
297 // Save the list of buffered time ranges. 297 // Save the list of buffered time ranges.
298 WebKit::WebTimeRanges buffered_; 298 blink::WebTimeRanges buffered_;
299 299
300 // Size of the video. 300 // Size of the video.
301 WebKit::WebSize natural_size_; 301 blink::WebSize natural_size_;
302 302
303 // Size that has been sent to StreamTexture. 303 // Size that has been sent to StreamTexture.
304 WebKit::WebSize cached_stream_texture_size_; 304 blink::WebSize cached_stream_texture_size_;
305 305
306 // The video frame object used for rendering by the compositor. 306 // The video frame object used for rendering by the compositor.
307 scoped_refptr<media::VideoFrame> current_frame_; 307 scoped_refptr<media::VideoFrame> current_frame_;
308 base::Lock current_frame_lock_; 308 base::Lock current_frame_lock_;
309 309
310 base::ThreadChecker main_thread_checker_; 310 base::ThreadChecker main_thread_checker_;
311 311
312 // Message loop for main renderer thread. 312 // Message loop for main renderer thread.
313 const scoped_refptr<base::MessageLoopProxy> main_loop_; 313 const scoped_refptr<base::MessageLoopProxy> main_loop_;
314 314
(...skipping 24 matching lines...) Expand all
339 mutable bool did_loading_progress_; 339 mutable bool did_loading_progress_;
340 340
341 // Manager for managing this object and for delegating method calls on 341 // Manager for managing this object and for delegating method calls on
342 // Render Thread. 342 // Render Thread.
343 RendererMediaPlayerManager* manager_; 343 RendererMediaPlayerManager* manager_;
344 344
345 // Player ID assigned by the |manager_|. 345 // Player ID assigned by the |manager_|.
346 int player_id_; 346 int player_id_;
347 347
348 // Current player states. 348 // Current player states.
349 WebKit::WebMediaPlayer::NetworkState network_state_; 349 blink::WebMediaPlayer::NetworkState network_state_;
350 WebKit::WebMediaPlayer::ReadyState ready_state_; 350 blink::WebMediaPlayer::ReadyState ready_state_;
351 351
352 // GL texture ID used to show the remote playback icon. 352 // GL texture ID used to show the remote playback icon.
353 unsigned int remote_playback_texture_id_; 353 unsigned int remote_playback_texture_id_;
354 354
355 // GL texture ID allocated to the video. 355 // GL texture ID allocated to the video.
356 unsigned int texture_id_; 356 unsigned int texture_id_;
357 357
358 // GL texture mailbox for texture_id_ to provide in the VideoFrame, and sync 358 // GL texture mailbox for texture_id_ to provide in the VideoFrame, and sync
359 // point for when the mailbox was produced. 359 // point for when the mailbox was produced.
360 gpu::Mailbox texture_mailbox_; 360 gpu::Mailbox texture_mailbox_;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 // Whether the browser is currently connected to a remote media player. 431 // Whether the browser is currently connected to a remote media player.
432 bool is_remote_; 432 bool is_remote_;
433 433
434 media::MediaLog* media_log_; 434 media::MediaLog* media_log_;
435 435
436 scoped_ptr<MediaInfoLoader> info_loader_; 436 scoped_ptr<MediaInfoLoader> info_loader_;
437 437
438 // The currently selected key system. Empty string means that no key system 438 // The currently selected key system. Empty string means that no key system
439 // has been selected. 439 // has been selected.
440 WebKit::WebString current_key_system_; 440 blink::WebString current_key_system_;
441 441
442 // Temporary for EME v0.1. In the future the init data type should be passed 442 // Temporary for EME v0.1. In the future the init data type should be passed
443 // through GenerateKeyRequest() directly from WebKit. 443 // through GenerateKeyRequest() directly from WebKit.
444 std::string init_data_type_; 444 std::string init_data_type_;
445 445
446 // The decryptor that manages decryption keys and decrypts encrypted frames. 446 // The decryptor that manages decryption keys and decrypts encrypted frames.
447 scoped_ptr<ProxyDecryptor> decryptor_; 447 scoped_ptr<ProxyDecryptor> decryptor_;
448 448
449 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; 449 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_;
450 450
451 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); 451 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
452 }; 452 };
453 453
454 } // namespace content 454 } // namespace content
455 455
456 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 456 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698