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

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

Issue 2849043002: Send AndroidOverlay routing token from WMPI to AVDA. (Closed)
Patch Set: maybe fixed macos 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
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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 bool is_suspended; 246 bool is_suspended;
246 }; 247 };
247 248
248 private: 249 private:
249 friend class WebMediaPlayerImplTest; 250 friend class WebMediaPlayerImplTest;
250 friend class WebMediaPlayerImplBackgroundBehaviorTest; 251 friend class WebMediaPlayerImplBackgroundBehaviorTest;
251 252
252 void EnableOverlay(); 253 void EnableOverlay();
253 void DisableOverlay(); 254 void DisableOverlay();
254 255
256 // Do we have overlay information? For CVV, this is a surface id. For
257 // AndroidOverlay, this is the routing token.
258 bool HaveOverlayInfo();
259
260 // Send the overlay's SurfaceID or routing token. If the decoder didn't
261 // supply a callback for it, then do nothing.
262 void SendOverlayInfoToDecoder();
263
255 void OnPipelineSuspended(); 264 void OnPipelineSuspended();
256 void OnBeforePipelineResume(); 265 void OnBeforePipelineResume();
257 void OnPipelineResumed(); 266 void OnPipelineResumed();
258 void OnDemuxerOpened(); 267 void OnDemuxerOpened();
259 268
260 // Pipeline::Client overrides. 269 // Pipeline::Client overrides.
261 void OnError(PipelineStatus status) override; 270 void OnError(PipelineStatus status) override;
262 void OnEnded() override; 271 void OnEnded() override;
263 void OnMetadata(PipelineMetadata metadata) override; 272 void OnMetadata(PipelineMetadata metadata) override;
264 void OnBufferingStateChange(BufferingState state) override; 273 void OnBufferingStateChange(BufferingState state) override;
(...skipping 17 matching lines...) Expand all
282 291
283 // Called after asynchronous initialization of a data source completed. 292 // Called after asynchronous initialization of a data source completed.
284 void DataSourceInitialized(bool success); 293 void DataSourceInitialized(bool success);
285 294
286 // Called when the data source is downloading or paused. 295 // Called when the data source is downloading or paused.
287 void NotifyDownloading(bool is_downloading); 296 void NotifyDownloading(bool is_downloading);
288 297
289 // Called by SurfaceManager when a surface is created. 298 // Called by SurfaceManager when a surface is created.
290 void OnSurfaceCreated(int surface_id); 299 void OnSurfaceCreated(int surface_id);
291 300
301 // Called by RenderFrameImpl with the overlay routing token, if we request it.
302 void OnOverlayRoutingToken(const base::UnguessableToken& token);
303
292 // Called by GpuVideoDecoder on Android to request a surface to render to (if 304 // Called by GpuVideoDecoder on Android to request a surface to render to (if
293 // necessary). 305 // necessary).
294 void OnSurfaceRequested(bool decoder_requires_restart_for_overlay, 306 void OnOverlayInfoRequested(
295 const SurfaceCreatedCB& surface_created_cb); 307 bool decoder_requires_restart_for_overlay,
308 const ProvideOverlayInfoCB& provide_overlay_info_cb);
296 309
297 // Creates a Renderer via the |renderer_factory_selector_|. 310 // Creates a Renderer via the |renderer_factory_selector_|.
298 std::unique_ptr<Renderer> CreateRenderer(); 311 std::unique_ptr<Renderer> CreateRenderer();
299 312
300 // Finishes starting the pipeline due to a call to load(). 313 // Finishes starting the pipeline due to a call to load().
301 void StartPipeline(); 314 void StartPipeline();
302 315
303 // Restart the player/pipeline as soon as possible. This will destroy the 316 // Restart the player/pipeline as soon as possible. This will destroy the
304 // current renderer, if any, and create a new one via the RendererFactory; and 317 // current renderer, if any, and create a new one via the RendererFactory; and
305 // then seek to resume playback at the current position. 318 // then seek to resume playback at the current position.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 SurfaceManager* surface_manager_; 650 SurfaceManager* surface_manager_;
638 651
639 // For canceling ongoing surface creation requests when exiting fullscreen. 652 // For canceling ongoing surface creation requests when exiting fullscreen.
640 base::CancelableCallback<void(int)> surface_created_cb_; 653 base::CancelableCallback<void(int)> surface_created_cb_;
641 654
642 // The current overlay surface id. Populated, possibly with kNoSurfaceID if 655 // The current overlay surface id. Populated, possibly with kNoSurfaceID if
643 // we're not supposed to use an overlay, unless we have an outstanding surface 656 // we're not supposed to use an overlay, unless we have an outstanding surface
644 // request to the SurfaceManager. 657 // request to the SurfaceManager.
645 base::Optional<int> overlay_surface_id_; 658 base::Optional<int> overlay_surface_id_;
646 659
647 // If a surface is requested before it's finished being created, the request 660 // For canceling AndroidOverlay routing token requests.
648 // is saved and satisfied once the surface is available. If the decoder does 661 base::CancelableCallback<void(const base::UnguessableToken&)>
649 // not require restart to change surfaces, this is callback is kept until 662 token_available_cb_;
650 // cleared by the decoder. 663
651 SurfaceCreatedCB set_surface_cb_; 664 // If overlay info is requested before we have it, then the request is saved
665 // and satisfied once the overlay info is available. If the decoder does not
666 // require restart to change surfaces, this is callback is kept until cleared
667 // by the decoder.
668 ProvideOverlayInfoCB provide_overlay_info_cb_;
652 669
653 // On Android an overlay surface means using 670 // On Android an overlay surface means using
654 // SurfaceView instead of SurfaceTexture. 671 // SurfaceView instead of SurfaceTexture.
655 672
656 // Use overlays for all video. 673 // Use overlays for all video.
657 bool force_video_overlays_; 674 bool force_video_overlays_;
658 675
659 // Use overlays for fullscreen video.
660 // (Implied if |force_video_overlays_| is true.)
661 bool enable_fullscreen_video_overlays_;
662
663 // Suppresses calls to OnPipelineError() after destruction / shutdown has been 676 // Suppresses calls to OnPipelineError() after destruction / shutdown has been
664 // started; prevents us from spuriously logging errors that are transient or 677 // started; prevents us from spuriously logging errors that are transient or
665 // unimportant. 678 // unimportant.
666 bool suppress_destruction_errors_; 679 bool suppress_destruction_errors_;
667 680
668 // If true, the media pipeline can be suspended. 681 // If true, the media pipeline can be suspended.
669 const bool suspend_enabled_; 682 const bool suspend_enabled_;
670 683
671 // Used for HLS playback and in certain fallback paths (e.g. on older devices 684 // Used for HLS playback and in certain fallback paths (e.g. on older devices
672 // that can't support the unified media pipeline). 685 // that can't support the unified media pipeline).
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // Whether embedded media experience is currently enabled. 750 // Whether embedded media experience is currently enabled.
738 bool embedded_media_experience_enabled_ = false; 751 bool embedded_media_experience_enabled_ = false;
739 752
740 gfx::Size last_uploaded_frame_size_; 753 gfx::Size last_uploaded_frame_size_;
741 base::TimeDelta last_uploaded_frame_timestamp_; 754 base::TimeDelta last_uploaded_frame_timestamp_;
742 755
743 base::CancelableCallback<void(base::TimeTicks)> frame_time_report_cb_; 756 base::CancelableCallback<void(base::TimeTicks)> frame_time_report_cb_;
744 757
745 bool initial_video_height_recorded_ = false; 758 bool initial_video_height_recorded_ = false;
746 759
760 enum class OverlayMode {
761 // All overlays are turned off.
762 kNoOverlays,
763
764 // Use ContentVideoView for overlays.
765 kUseContentVideoView,
766
767 // Use AndroidOverlay for overlays.
768 kUseAndroidOverlay,
769 };
770
771 OverlayMode overlay_mode_ = OverlayMode::kNoOverlays;
772
773 // Optional callback to request the routing token for AndroidOverlay.
774 RequestRoutingTokenCallback request_routing_token_cb_;
775
776 // Routing token, if we have one. No value if we have a request pending to
777 // get it via |request_routing_token_cb_|. A null token indicates that we
778 // have no token, which can't be sent via IPC.
tguilbert 2017/05/08 23:10:29 Can you clarify the states in this comment? IIUC,
liberato (no reviews please) 2017/05/09 16:55:37 s/null/empty/: Done for has_value && is_empty, we
779 base::Optional<base::UnguessableToken> overlay_routing_token_;
780
747 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 781 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
748 }; 782 };
749 783
750 } // namespace media 784 } // namespace media
751 785
752 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 786 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698