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

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

Issue 2849043002: Send AndroidOverlay routing token from WMPI to AVDA. (Closed)
Patch Set: rebased Created 3 years, 7 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
« no previous file with comments | « media/base/routing_token_callback.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/cancelable_callback.h" 14 #include "base/cancelable_callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/linked_ptr.h" 17 #include "base/memory/linked_ptr.h"
18 #include "base/memory/memory_pressure_listener.h" 18 #include "base/memory/memory_pressure_listener.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "base/optional.h" 21 #include "base/optional.h"
22 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
23 #include "base/time/default_tick_clock.h" 23 #include "base/time/default_tick_clock.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "base/timer/elapsed_timer.h" 25 #include "base/timer/elapsed_timer.h"
26 #include "base/timer/timer.h" 26 #include "base/timer/timer.h"
27 #include "build/build_config.h" 27 #include "build/build_config.h"
28 #include "media/base/media_observer.h" 28 #include "media/base/media_observer.h"
29 #include "media/base/media_tracks.h" 29 #include "media/base/media_tracks.h"
30 #include "media/base/overlay_info.h"
30 #include "media/base/pipeline_impl.h" 31 #include "media/base/pipeline_impl.h"
31 #include "media/base/renderer_factory_selector.h" 32 #include "media/base/renderer_factory_selector.h"
32 #include "media/base/surface_manager.h" 33 #include "media/base/surface_manager.h"
33 #include "media/base/text_track.h" 34 #include "media/base/text_track.h"
34 #include "media/blink/buffered_data_source_host_impl.h" 35 #include "media/blink/buffered_data_source_host_impl.h"
35 #include "media/blink/media_blink_export.h" 36 #include "media/blink/media_blink_export.h"
36 #include "media/blink/multibuffer_data_source.h" 37 #include "media/blink/multibuffer_data_source.h"
37 #include "media/blink/video_frame_compositor.h" 38 #include "media/blink/video_frame_compositor.h"
38 #include "media/blink/webmediaplayer_delegate.h" 39 #include "media/blink/webmediaplayer_delegate.h"
39 #include "media/blink/webmediaplayer_params.h" 40 #include "media/blink/webmediaplayer_params.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 bool is_suspended; 248 bool is_suspended;
248 }; 249 };
249 250
250 private: 251 private:
251 friend class WebMediaPlayerImplTest; 252 friend class WebMediaPlayerImplTest;
252 friend class WebMediaPlayerImplBackgroundBehaviorTest; 253 friend class WebMediaPlayerImplBackgroundBehaviorTest;
253 254
254 void EnableOverlay(); 255 void EnableOverlay();
255 void DisableOverlay(); 256 void DisableOverlay();
256 257
258 // Do we have overlay information? For CVV, this is a surface id. For
259 // AndroidOverlay, this is the routing token.
260 bool HaveOverlayInfo();
261
262 // Send the overlay surface ID / routing token to the decoder if we have it
263 // and if it has been requested.
264 void MaybeSendOverlayInfoToDecoder();
265
257 void OnPipelineSuspended(); 266 void OnPipelineSuspended();
258 void OnBeforePipelineResume(); 267 void OnBeforePipelineResume();
259 void OnPipelineResumed(); 268 void OnPipelineResumed();
260 void OnDemuxerOpened(); 269 void OnDemuxerOpened();
261 270
262 // Pipeline::Client overrides. 271 // Pipeline::Client overrides.
263 void OnError(PipelineStatus status) override; 272 void OnError(PipelineStatus status) override;
264 void OnEnded() override; 273 void OnEnded() override;
265 void OnMetadata(PipelineMetadata metadata) override; 274 void OnMetadata(PipelineMetadata metadata) override;
266 void OnBufferingStateChange(BufferingState state) override; 275 void OnBufferingStateChange(BufferingState state) override;
(...skipping 17 matching lines...) Expand all
284 293
285 // Called after asynchronous initialization of a data source completed. 294 // Called after asynchronous initialization of a data source completed.
286 void DataSourceInitialized(bool success); 295 void DataSourceInitialized(bool success);
287 296
288 // Called when the data source is downloading or paused. 297 // Called when the data source is downloading or paused.
289 void NotifyDownloading(bool is_downloading); 298 void NotifyDownloading(bool is_downloading);
290 299
291 // Called by SurfaceManager when a surface is created. 300 // Called by SurfaceManager when a surface is created.
292 void OnSurfaceCreated(int surface_id); 301 void OnSurfaceCreated(int surface_id);
293 302
303 // Called by RenderFrameImpl with the overlay routing token, if we request it.
304 void OnOverlayRoutingToken(const base::UnguessableToken& token);
305
294 // Called by GpuVideoDecoder on Android to request a surface to render to (if 306 // Called by GpuVideoDecoder on Android to request a surface to render to (if
295 // necessary). 307 // necessary).
296 void OnSurfaceRequested(bool decoder_requires_restart_for_overlay, 308 void OnOverlayInfoRequested(
297 const SurfaceCreatedCB& surface_created_cb); 309 bool decoder_requires_restart_for_overlay,
310 const ProvideOverlayInfoCB& provide_overlay_info_cb);
298 311
299 // Creates a Renderer via the |renderer_factory_selector_|. 312 // Creates a Renderer via the |renderer_factory_selector_|.
300 std::unique_ptr<Renderer> CreateRenderer(); 313 std::unique_ptr<Renderer> CreateRenderer();
301 314
302 // Finishes starting the pipeline due to a call to load(). 315 // Finishes starting the pipeline due to a call to load().
303 void StartPipeline(); 316 void StartPipeline();
304 317
305 // Restart the player/pipeline as soon as possible. This will destroy the 318 // Restart the player/pipeline as soon as possible. This will destroy the
306 // current renderer, if any, and create a new one via the RendererFactory; and 319 // current renderer, if any, and create a new one via the RendererFactory; and
307 // then seek to resume playback at the current position. 320 // then seek to resume playback at the current position.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 SurfaceManager* surface_manager_; 652 SurfaceManager* surface_manager_;
640 653
641 // For canceling ongoing surface creation requests when exiting fullscreen. 654 // For canceling ongoing surface creation requests when exiting fullscreen.
642 base::CancelableCallback<void(int)> surface_created_cb_; 655 base::CancelableCallback<void(int)> surface_created_cb_;
643 656
644 // The current overlay surface id. Populated, possibly with kNoSurfaceID if 657 // The current overlay surface id. Populated, possibly with kNoSurfaceID if
645 // we're not supposed to use an overlay, unless we have an outstanding surface 658 // we're not supposed to use an overlay, unless we have an outstanding surface
646 // request to the SurfaceManager. 659 // request to the SurfaceManager.
647 base::Optional<int> overlay_surface_id_; 660 base::Optional<int> overlay_surface_id_;
648 661
649 // If a surface is requested before it's finished being created, the request 662 // For canceling AndroidOverlay routing token requests.
650 // is saved and satisfied once the surface is available. If the decoder does 663 base::CancelableCallback<void(const base::UnguessableToken&)>
651 // not require restart to change surfaces, this is callback is kept until 664 token_available_cb_;
652 // cleared by the decoder. 665
653 SurfaceCreatedCB set_surface_cb_; 666 // If overlay info is requested before we have it, then the request is saved
667 // and satisfied once the overlay info is available. If the decoder does not
668 // require restart to change surfaces, this is callback is kept until cleared
669 // by the decoder.
670 ProvideOverlayInfoCB provide_overlay_info_cb_;
654 671
655 // On Android an overlay surface means using 672 // On Android an overlay surface means using
656 // SurfaceView instead of SurfaceTexture. 673 // SurfaceView instead of SurfaceTexture.
657 674
658 // Use overlays for all video. 675 // Use overlays for all video.
659 bool force_video_overlays_; 676 bool force_video_overlays_;
660 677
661 // Use overlays for fullscreen video.
662 // (Implied if |force_video_overlays_| is true.)
663 bool enable_fullscreen_video_overlays_;
664
665 // Suppresses calls to OnPipelineError() after destruction / shutdown has been 678 // Suppresses calls to OnPipelineError() after destruction / shutdown has been
666 // started; prevents us from spuriously logging errors that are transient or 679 // started; prevents us from spuriously logging errors that are transient or
667 // unimportant. 680 // unimportant.
668 bool suppress_destruction_errors_; 681 bool suppress_destruction_errors_;
669 682
670 // If true, the media pipeline can be suspended. 683 // If true, the media pipeline can be suspended.
671 const bool suspend_enabled_; 684 const bool suspend_enabled_;
672 685
673 // Used for HLS playback and in certain fallback paths (e.g. on older devices 686 // Used for HLS playback and in certain fallback paths (e.g. on older devices
674 // that can't support the unified media pipeline). 687 // that can't support the unified media pipeline).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 // Whether embedded media experience is currently enabled. 752 // Whether embedded media experience is currently enabled.
740 bool embedded_media_experience_enabled_ = false; 753 bool embedded_media_experience_enabled_ = false;
741 754
742 gfx::Size last_uploaded_frame_size_; 755 gfx::Size last_uploaded_frame_size_;
743 base::TimeDelta last_uploaded_frame_timestamp_; 756 base::TimeDelta last_uploaded_frame_timestamp_;
744 757
745 base::CancelableCallback<void(base::TimeTicks)> frame_time_report_cb_; 758 base::CancelableCallback<void(base::TimeTicks)> frame_time_report_cb_;
746 759
747 bool initial_video_height_recorded_ = false; 760 bool initial_video_height_recorded_ = false;
748 761
762 enum class OverlayMode {
763 // All overlays are turned off.
764 kNoOverlays,
765
766 // Use ContentVideoView for overlays.
767 kUseContentVideoView,
768
769 // Use AndroidOverlay for overlays.
770 kUseAndroidOverlay,
771 };
772
773 OverlayMode overlay_mode_ = OverlayMode::kNoOverlays;
774
775 // Optional callback to request the routing token for AndroidOverlay.
776 RequestRoutingTokenCallback request_routing_token_cb_;
777
778 // Routing token, if we have one. No value if we have a request pending to
779 // get it via |request_routing_token_cb_|. A has_value() is_empty() token
780 // indicates that we requested and received an empty token. Note that we
781 // can't send an empty token via IPC, so we handle that specially.
782 base::Optional<base::UnguessableToken> overlay_routing_token_;
783
749 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 784 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
750 }; 785 };
751 786
752 } // namespace media 787 } // namespace media
753 788
754 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 789 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « media/base/routing_token_callback.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698