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

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

Issue 1570043002: Implement MediaSession on top of the WebMediaPlayerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session
Patch Set: Merge. Cleanup. Fix RequestPlay. Created 4 years, 11 months 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
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/time/default_tick_clock.h" 18 #include "base/time/default_tick_clock.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "cc/layers/video_frame_provider.h" 20 #include "cc/layers/video_frame_provider.h"
21 #include "content/common/media/media_player_messages_enums_android.h" 21 #include "content/common/media/media_player_messages_enums_android.h"
22 #include "content/public/renderer/render_frame_observer.h"
23 #include "content/renderer/media/android/media_info_loader.h" 22 #include "content/renderer/media/android/media_info_loader.h"
24 #include "content/renderer/media/android/media_source_delegate.h" 23 #include "content/renderer/media/android/media_source_delegate.h"
25 #include "content/renderer/media/android/stream_texture_factory.h" 24 #include "content/renderer/media/android/stream_texture_factory.h"
26 #include "gpu/command_buffer/common/mailbox.h" 25 #include "gpu/command_buffer/common/mailbox.h"
27 #include "media/base/android/media_player_android.h" 26 #include "media/base/android/media_player_android.h"
28 #include "media/base/cdm_context.h" 27 #include "media/base/cdm_context.h"
29 #include "media/base/demuxer_stream.h" 28 #include "media/base/demuxer_stream.h"
30 #include "media/base/media_keys.h" 29 #include "media/base/media_keys.h"
31 #include "media/base/time_delta_interpolator.h" 30 #include "media/base/time_delta_interpolator.h"
31 #include "media/blink/webmediaplayer_delegate.h"
32 #include "media/blink/webmediaplayer_params.h" 32 #include "media/blink/webmediaplayer_params.h"
33 #include "media/cdm/proxy_decryptor.h" 33 #include "media/cdm/proxy_decryptor.h"
34 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 34 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
35 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 35 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
36 #include "third_party/WebKit/public/platform/WebSetSinkIdCallbacks.h" 36 #include "third_party/WebKit/public/platform/WebSetSinkIdCallbacks.h"
37 #include "third_party/WebKit/public/platform/WebSize.h" 37 #include "third_party/WebKit/public/platform/WebSize.h"
38 #include "third_party/WebKit/public/platform/WebURL.h" 38 #include "third_party/WebKit/public/platform/WebURL.h"
39 #include "third_party/skia/include/core/SkBitmap.h" 39 #include "third_party/skia/include/core/SkBitmap.h"
40 #include "ui/gfx/geometry/rect_f.h" 40 #include "ui/gfx/geometry/rect_f.h"
41 41
(...skipping 17 matching lines...) Expand all
59 namespace gpu { 59 namespace gpu {
60 struct MailboxHolder; 60 struct MailboxHolder;
61 } 61 }
62 62
63 namespace media { 63 namespace media {
64 class CdmContext; 64 class CdmContext;
65 class CdmFactory; 65 class CdmFactory;
66 class MediaLog; 66 class MediaLog;
67 class MediaPermission; 67 class MediaPermission;
68 class WebContentDecryptionModuleImpl; 68 class WebContentDecryptionModuleImpl;
69 class WebMediaPlayerDelegate;
70 } 69 }
71 70
72 namespace content { 71 namespace content {
73 72
74 class RendererCdmManager; 73 class RendererCdmManager;
75 class RendererMediaPlayerManager; 74 class RendererMediaPlayerManager;
76 75
77 // This class implements blink::WebMediaPlayer by keeping the android 76 // This class implements blink::WebMediaPlayer by keeping the android
78 // media player in the browser process. It listens to all the status changes 77 // media player in the browser process. It listens to all the status changes
79 // sent from the browser process and sends playback controls to the media 78 // sent from the browser process and sends playback controls to the media
80 // player. 79 // player.
81 class WebMediaPlayerAndroid : public blink::WebMediaPlayer, 80 class WebMediaPlayerAndroid
82 public cc::VideoFrameProvider, 81 : public blink::WebMediaPlayer,
83 public RenderFrameObserver, 82 public cc::VideoFrameProvider,
84 public StreamTextureFactoryContextObserver { 83 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer),
84 public StreamTextureFactoryContextObserver {
85 public: 85 public:
86 // Construct a WebMediaPlayerAndroid object. This class communicates with the 86 // Construct a WebMediaPlayerAndroid object. This class communicates with the
87 // MediaPlayerAndroid object in the browser process through |proxy|. 87 // MediaPlayerAndroid object in the browser process through |proxy|.
88 // TODO(qinmin): |frame| argument is used to determine whether the current 88 // TODO(qinmin): |frame| argument is used to determine whether the current
89 // player can enter fullscreen. This logic should probably be moved into 89 // player can enter fullscreen. This logic should probably be moved into
90 // blink, so that enterFullscreen() will not be called if another video is 90 // blink, so that enterFullscreen() will not be called if another video is
91 // already in fullscreen. 91 // already in fullscreen.
92 WebMediaPlayerAndroid( 92 WebMediaPlayerAndroid(
93 blink::WebFrame* frame, 93 blink::WebFrame* frame,
94 blink::WebMediaPlayerClient* client, 94 blink::WebMediaPlayerClient* client,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void ResetStreamTextureProxy() override; 216 void ResetStreamTextureProxy() override;
217 217
218 // Called when the player is released. 218 // Called when the player is released.
219 virtual void OnPlayerReleased(); 219 virtual void OnPlayerReleased();
220 220
221 // This function is called by the RendererMediaPlayerManager to pause the 221 // This function is called by the RendererMediaPlayerManager to pause the
222 // video and release the media player and surface texture when we switch tabs. 222 // video and release the media player and surface texture when we switch tabs.
223 // However, the actual GlTexture is not released to keep the video screenshot. 223 // However, the actual GlTexture is not released to keep the video screenshot.
224 void SuspendAndReleaseResources(); 224 void SuspendAndReleaseResources();
225 225
226 // RenderFrameObserver implementation.
227 void OnDestruct() override;
228
229 #if defined(VIDEO_HOLE) 226 #if defined(VIDEO_HOLE)
230 // Calculate the boundary rectangle of the media player (i.e. location and 227 // Calculate the boundary rectangle of the media player (i.e. location and
231 // size of the video frame). 228 // size of the video frame).
232 // Returns true if the geometry has been changed since the last call. 229 // Returns true if the geometry has been changed since the last call.
233 bool UpdateBoundaryRectangle(); 230 bool UpdateBoundaryRectangle();
234 231
235 const gfx::RectF GetBoundaryRectangle(); 232 const gfx::RectF GetBoundaryRectangle();
236 #endif // defined(VIDEO_HOLE) 233 #endif // defined(VIDEO_HOLE)
237 234
238 MediaKeyException generateKeyRequest(const blink::WebString& key_system, 235 MediaKeyException generateKeyRequest(const blink::WebString& key_system,
(...skipping 23 matching lines...) Expand all
262 259
263 void OnMediaSourceOpened(blink::WebMediaSource* web_media_source); 260 void OnMediaSourceOpened(blink::WebMediaSource* web_media_source);
264 261
265 void OnEncryptedMediaInitData(media::EmeInitDataType init_data_type, 262 void OnEncryptedMediaInitData(media::EmeInitDataType init_data_type,
266 const std::vector<uint8_t>& init_data); 263 const std::vector<uint8_t>& init_data);
267 264
268 // Called when a decoder detects that the key needed to decrypt the stream 265 // Called when a decoder detects that the key needed to decrypt the stream
269 // is not available. 266 // is not available.
270 void OnWaitingForDecryptionKey(); 267 void OnWaitingForDecryptionKey();
271 268
269 // WebMediaPlayerDelegate::Observer implementation.
270 void OnHidden() override;
271 void OnShown() override;
272 void OnPlay() override;
273 void OnPause() override;
274
272 protected: 275 protected:
273 // Helper method to update the playing state. 276 // Helper method to update the playing state.
274 void UpdatePlayingState(bool is_playing_); 277 void UpdatePlayingState(bool is_playing_);
275 278
276 // Helper methods for posting task for setting states and update WebKit. 279 // Helper methods for posting task for setting states and update WebKit.
277 void UpdateNetworkState(blink::WebMediaPlayer::NetworkState state); 280 void UpdateNetworkState(blink::WebMediaPlayer::NetworkState state);
278 void UpdateReadyState(blink::WebMediaPlayer::ReadyState state); 281 void UpdateReadyState(blink::WebMediaPlayer::ReadyState state);
279 void TryCreateStreamTextureProxyIfNeeded(); 282 void TryCreateStreamTextureProxyIfNeeded();
280 void DoCreateStreamTexture(); 283 void DoCreateStreamTexture();
281 284
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // as playback progresses. 533 // as playback progresses.
531 media::TimeDeltaInterpolator interpolator_; 534 media::TimeDeltaInterpolator interpolator_;
532 535
533 scoped_ptr<MediaSourceDelegate> media_source_delegate_; 536 scoped_ptr<MediaSourceDelegate> media_source_delegate_;
534 537
535 int frame_id_; 538 int frame_id_;
536 539
537 // Whether to delete the existing texture and re-create it. 540 // Whether to delete the existing texture and re-create it.
538 bool suppress_deleting_texture_; 541 bool suppress_deleting_texture_;
539 542
543 // Whether OnPlaybackComplete() has been called since the last playback.
544 bool playback_completed_;
545
540 // NOTE: Weak pointers must be invalidated before all other member variables. 546 // NOTE: Weak pointers must be invalidated before all other member variables.
541 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_; 547 base::WeakPtrFactory<WebMediaPlayerAndroid> weak_factory_;
542 548
543 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid); 549 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerAndroid);
544 }; 550 };
545 551
546 } // namespace content 552 } // namespace content
547 553
548 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_ 554 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698