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

Side by Side Diff: media/blink/webmediaplayer_impl.h

Issue 1567123002: Support CAST+WMPI on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 18 matching lines...) Expand all
29 #include "media/blink/video_frame_compositor.h" 29 #include "media/blink/video_frame_compositor.h"
30 #include "media/blink/webmediaplayer_delegate.h" 30 #include "media/blink/webmediaplayer_delegate.h"
31 #include "media/blink/webmediaplayer_params.h" 31 #include "media/blink/webmediaplayer_params.h"
32 #include "media/blink/webmediaplayer_util.h" 32 #include "media/blink/webmediaplayer_util.h"
33 #include "media/renderers/skcanvas_video_renderer.h" 33 #include "media/renderers/skcanvas_video_renderer.h"
34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 34 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 35 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 36 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
37 #include "url/gurl.h" 37 #include "url/gurl.h"
38 38
39 #if defined(OS_ANDROID)
40 // Use WIMPI_CAST instead of OS_ANDROID to clearly mark the cast implementation
41 // so that we can easily remove it later, see crbug/575276.
42 #define WIMPI_CAST
DaleCurtis 2016/01/07 19:59:32 Can we avoid setting this here. #define in header
hubbe 2016/01/07 20:31:03 Hmm, so where should it go then? I see two possib
DaleCurtis 2016/01/07 21:28:39 I'd just use OS_ANDROID with a // WMPI_CAST commen
hubbe 2016/01/11 22:47:24 Done.
43 #endif
44
45 #if defined(WIMPI_CAST)
46 // Delete this file when WIMPI_CAST is no longer needed.
47 #include "media/blink/renderer_media_player_interface.h"
48 #endif
49
39 namespace blink { 50 namespace blink {
40 class WebGraphicsContext3D; 51 class WebGraphicsContext3D;
41 class WebLocalFrame; 52 class WebLocalFrame;
42 class WebMediaPlayerClient; 53 class WebMediaPlayerClient;
43 class WebMediaPlayerEncryptedMediaClient; 54 class WebMediaPlayerEncryptedMediaClient;
44 } 55 }
45 56
46 namespace base { 57 namespace base {
47 class SingleThreadTaskRunner; 58 class SingleThreadTaskRunner;
48 class TaskRunner; 59 class TaskRunner;
(...skipping 14 matching lines...) Expand all
63 class WebAudioSourceProviderImpl; 74 class WebAudioSourceProviderImpl;
64 class WebMediaPlayerDelegate; 75 class WebMediaPlayerDelegate;
65 class WebTextTrackImpl; 76 class WebTextTrackImpl;
66 77
67 // The canonical implementation of blink::WebMediaPlayer that's backed by 78 // The canonical implementation of blink::WebMediaPlayer that's backed by
68 // Pipeline. Handles normal resource loading, Media Source, and 79 // Pipeline. Handles normal resource loading, Media Source, and
69 // Encrypted Media. 80 // Encrypted Media.
70 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl 81 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl
71 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), 82 : public NON_EXPORTED_BASE(blink::WebMediaPlayer),
72 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), 83 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer),
84 #if defined(WIMPI_CAST)
85 public RendererMediaPlayerInterface,
86 #endif
73 public base::SupportsWeakPtr<WebMediaPlayerImpl> { 87 public base::SupportsWeakPtr<WebMediaPlayerImpl> {
74 public: 88 public:
75 // Constructs a WebMediaPlayer implementation using Chromium's media stack. 89 // Constructs a WebMediaPlayer implementation using Chromium's media stack.
76 // |delegate| may be null. |renderer| may also be null, in which case an 90 // |delegate| may be null. |renderer| may also be null, in which case an
77 // internal renderer will be created. 91 // internal renderer will be created.
78 // TODO(xhwang): Drop the internal renderer path and always pass in a renderer 92 // TODO(xhwang): Drop the internal renderer path and always pass in a renderer
79 // here. 93 // here.
80 WebMediaPlayerImpl( 94 WebMediaPlayerImpl(
81 blink::WebLocalFrame* frame, 95 blink::WebLocalFrame* frame,
82 blink::WebMediaPlayerClient* client, 96 blink::WebMediaPlayerClient* client,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 void OnPipelineMetadata(PipelineMetadata metadata); 197 void OnPipelineMetadata(PipelineMetadata metadata);
184 void OnPipelineBufferingStateChanged(BufferingState buffering_state); 198 void OnPipelineBufferingStateChanged(BufferingState buffering_state);
185 void OnDemuxerOpened(); 199 void OnDemuxerOpened();
186 void OnAddTextTrack(const TextTrackConfig& config, 200 void OnAddTextTrack(const TextTrackConfig& config,
187 const AddTextTrackDoneCB& done_cb); 201 const AddTextTrackDoneCB& done_cb);
188 202
189 // WebMediaPlayerDelegate::Observer implementation. 203 // WebMediaPlayerDelegate::Observer implementation.
190 void OnHidden() override; 204 void OnHidden() override;
191 void OnShown() override; 205 void OnShown() override;
192 206
207 #if defined(WIMPI_CAST)
DaleCurtis 2016/01/07 19:59:32 Can you stick this all in another class instead th
hubbe 2016/01/07 20:31:03 It's not a simple thing to do. Some of these metho
DaleCurtis 2016/01/07 21:28:40 Please give it some more thought. You're essential
DaleCurtis 2016/01/07 21:29:09 s/900/400/
liberato (no reviews please) 2016/01/08 16:37:58 many of the operations these things perform are on
hubbe 2016/01/11 22:47:24 I think it might turn out messy, but I'm not sure.
208 void requestRemotePlayback() override;
209 void requestRemotePlaybackControl() override;
210
211 void set_media_player_manager(
212 RendererMediaPlayerManagerInterface* media_player_manager);
213
214 // RendererMediaPlayerInterface implementation
215 void OnMediaMetadataChanged(base::TimeDelta duration,
216 int width,
217 int height,
218 bool success) override;
219 void OnPlaybackComplete() override;
220 void OnBufferingUpdate(int percentage) override;
221 void OnSeekRequest(const base::TimeDelta& time_to_seek) override;
222 void OnSeekComplete(const base::TimeDelta& current_time) override;
223 void OnMediaError(int error_type) override;
224 void OnVideoSizeChanged(int width, int height) override;
225
226 // Called to update the current time.
227 void OnTimeUpdate(base::TimeDelta current_timestamp,
228 base::TimeTicks current_time_ticks) override;
229
230 // void OnWaitingForDecryptionKey() override;
231 void OnPlayerReleased() override;
232
233 // Functions called when media player status changes.
234 void OnConnectedToRemoteDevice(
235 const std::string& remote_playback_message) override;
236 void OnDisconnectedFromRemoteDevice() override;
237 void OnDidExitFullscreen() override;
238 void OnMediaPlayerPlay() override;
239 void OnMediaPlayerPause() override;
240 void OnRemoteRouteAvailabilityChanged(bool routes_available) override;
241
242 // Getters of playback state.
243 // bool paused() const override;
244
245 // True if the loaded media has a playable video track.
246 // bool hasVideo() const override;
247
248 // This function is called by the RendererMediaPlayerManager to pause the
249 // video and release the media player and surface texture when we switch tabs.
250 // However, the actual GlTexture is not released to keep the video screenshot.
251 void ReleaseMediaResources() override;
252
253 #if defined(VIDEO_HOLE)
254 // Calculate the boundary rectangle of the media player (i.e. location and
255 // size of the video frame).
256 // Returns true if the geometry has been changed since the last call.
257 bool UpdateBoundaryRectangle() override;
258
259 const gfx::RectF GetBoundaryRectangle() override;
260 #endif
261
262 void DrawRemotePlaybackText(const std::string& remote_playback_message);
263 #endif
264
193 private: 265 private:
194 // Initiate suspending the pipeline. 266 // Initiate suspending the pipeline.
195 void Suspend(); 267 void Suspend();
196 268
197 // Initiate resuming the pipeline. 269 // Initiate resuming the pipeline.
198 void Resume(); 270 void Resume();
199 271
200 // Called after |defer_load_cb_| has decided to allow the load. If 272 // Called after |defer_load_cb_| has decided to allow the load. If
201 // |defer_load_cb_| is null this is called immediately. 273 // |defer_load_cb_| is null this is called immediately.
202 void DoLoad(LoadType load_type, 274 void DoLoad(LoadType load_type,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Returns the current video frame from |compositor_|. Blocks until the 307 // Returns the current video frame from |compositor_|. Blocks until the
236 // compositor can return the frame. 308 // compositor can return the frame.
237 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); 309 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor();
238 310
239 // Called when the demuxer encounters encrypted streams. 311 // Called when the demuxer encounters encrypted streams.
240 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, 312 void OnEncryptedMediaInitData(EmeInitDataType init_data_type,
241 const std::vector<uint8_t>& init_data); 313 const std::vector<uint8_t>& init_data);
242 314
243 // Called when a decoder detects that the key needed to decrypt the stream 315 // Called when a decoder detects that the key needed to decrypt the stream
244 // is not available. 316 // is not available.
245 void OnWaitingForDecryptionKey(); 317 void OnWaitingForDecryptionKey() override;
246 318
247 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. 319 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done.
248 // Parameter order is reversed for easy binding. 320 // Parameter order is reversed for easy binding.
249 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); 321 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context);
250 322
251 // Called when a CDM has been attached to the |pipeline_|. 323 // Called when a CDM has been attached to the |pipeline_|.
252 void OnCdmAttached(bool success); 324 void OnCdmAttached(bool success);
253 325
254 // Updates |paused_time_| to the current media time with consideration for the 326 // Updates |paused_time_| to the current media time with consideration for the
255 // |ended_| state by clamping current time to duration upon |ended_|. 327 // |ended_| state by clamping current time to duration upon |ended_|.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // The compositor layer for displaying the video content when using composited 465 // The compositor layer for displaying the video content when using composited
394 // playback. 466 // playback.
395 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_; 467 scoped_ptr<cc_blink::WebLayerImpl> video_weblayer_;
396 468
397 EncryptedMediaPlayerSupport encrypted_media_support_; 469 EncryptedMediaPlayerSupport encrypted_media_support_;
398 470
399 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_; 471 scoped_ptr<blink::WebContentDecryptionModuleResult> set_cdm_result_;
400 472
401 scoped_ptr<RendererFactory> renderer_factory_; 473 scoped_ptr<RendererFactory> renderer_factory_;
402 474
475 #if defined(WIMPI_CAST)
476 // Manages this object and delegates player calls to the browser process.
477 // Owned by RenderFrameImpl.
478 RendererMediaPlayerManagerInterface* player_manager_ = nullptr;
479
480 // Player ID assigned by the |player_manager_|.
481 int player_id_;
482
483 // Whether the browser is currently connected to a remote media player.
484 bool is_remote_ = false;
485
486 // Last reported playout time.
487 base::TimeDelta remote_time_;
488 base::TimeTicks remote_time_at_;
489
490 // Whether the media player has been initialized.
491 bool is_player_initialized_ = false;
492 #endif
493
403 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 494 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
404 }; 495 };
405 496
406 } // namespace media 497 } // namespace media
407 498
408 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 499 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698