Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_BLINK_RENDERER_MEDIA_PLAYER_INTERFACE_H_ | |
| 6 #define MEDIA_BLINK_RENDERER_MEDIA_PLAYER_INTERFACE_H_ | |
| 7 | |
| 8 // This file contains interfaces modeled after classes in | |
| 9 // content/renderer/media/android for the purposes of letting clases in | |
| 10 // this directory implement and/or interact with those classes. | |
| 11 // It's a stop-gap used to support cast on android until a better solution | |
| 12 // is implemented: crbug/575276 | |
| 13 | |
| 14 #include <string> | |
| 15 #include "base/time/time.h" | |
| 16 #include "ui/gfx/geometry/rect_f.h" | |
| 17 #include "url/gurl.h" | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class RendererMediaPlayerInterface { | |
| 22 public: | |
| 23 virtual void OnMediaMetadataChanged(base::TimeDelta duration, | |
| 24 int width, | |
| 25 int height, | |
| 26 bool success) = 0; | |
| 27 virtual void OnPlaybackComplete() = 0; | |
| 28 virtual void OnBufferingUpdate(int percentage) = 0; | |
| 29 virtual void OnSeekRequest(const base::TimeDelta& time_to_seek) = 0; | |
| 30 virtual void OnSeekComplete(const base::TimeDelta& current_time) = 0; | |
| 31 virtual void OnMediaError(int error_type) = 0; | |
| 32 virtual void OnVideoSizeChanged(int width, int height) = 0; | |
| 33 | |
| 34 // Called to update the current time. | |
| 35 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, | |
| 36 base::TimeTicks current_time_ticks) = 0; | |
| 37 | |
| 38 virtual void OnWaitingForDecryptionKey() = 0; | |
| 39 virtual void OnPlayerReleased() = 0; | |
| 40 | |
| 41 // Functions called when media player status changes. | |
| 42 virtual void OnConnectedToRemoteDevice( | |
| 43 const std::string& remote_playback_message) = 0; | |
| 44 virtual void OnDisconnectedFromRemoteDevice() = 0; | |
| 45 virtual void OnDidExitFullscreen() = 0; | |
| 46 virtual void OnMediaPlayerPlay() = 0; | |
| 47 virtual void OnMediaPlayerPause() = 0; | |
| 48 virtual void OnRemoteRouteAvailabilityChanged(bool routes_available) = 0; | |
| 49 | |
| 50 // Getters of playback state. | |
| 51 virtual bool paused() const = 0; | |
| 52 | |
| 53 // True if the loaded media has a playable video track. | |
| 54 virtual bool hasVideo() const = 0; | |
| 55 | |
| 56 // This function is called by the RendererMediaPlayerManager to pause the | |
| 57 // video and release the media player and surface texture when we switch tabs. | |
| 58 // However, the actual GlTexture is not released to keep the video screenshot. | |
| 59 virtual void ReleaseMediaResources() = 0; | |
| 60 | |
| 61 #if defined(VIDEO_HOLE) | |
| 62 // Calculate the boundary rectangle of the media player (i.e. location and | |
| 63 // size of the video frame). | |
| 64 // Returns true if the geometry has been changed since the last call. | |
| 65 virtual bool UpdateBoundaryRectangle() = 0; | |
| 66 | |
| 67 virtual const gfx::RectF GetBoundaryRectangle() = 0; | |
| 68 #endif | |
| 69 }; | |
| 70 | |
| 71 // Dictates which type of media playback is being initialized. | |
| 72 // Must match content/common/media/media_player_messages_enums_android.h | |
| 73 enum MediaPlayerHostMsg_Initialize_Type { | |
|
DaleCurtis
2016/01/12 23:21:53
Why not include this file in content/common/media/
hubbe
2016/01/13 00:11:56
Thought that would end up causing dependency probl
| |
| 74 MEDIA_PLAYER_TYPE_URL, | |
| 75 MEDIA_PLAYER_TYPE_MEDIA_SOURCE, | |
| 76 MEDIA_PLAYER_TYPE_REMOTE_ONLY, | |
| 77 MEDIA_PLAYER_TYPE_LAST = MEDIA_PLAYER_TYPE_MEDIA_SOURCE | |
| 78 }; | |
| 79 | |
| 80 class RendererMediaPlayerManagerInterface { | |
| 81 public: | |
| 82 // Initializes a MediaPlayerAndroid object in browser process. | |
| 83 virtual void Initialize(MediaPlayerHostMsg_Initialize_Type type, | |
| 84 int player_id, | |
| 85 const GURL& url, | |
| 86 const GURL& first_party_for_cookies, | |
| 87 int demuxer_client_id, | |
| 88 const GURL& frame_url, | |
| 89 bool allow_credentials) = 0; | |
| 90 | |
| 91 // Starts the player. | |
| 92 virtual void Start(int player_id) = 0; | |
| 93 | |
| 94 // Pauses the player. | |
| 95 // is_media_related_action should be true if this pause is coming from an | |
| 96 // an action that explicitly pauses the video (user pressing pause, JS, etc.) | |
| 97 // Otherwise it should be false if Pause is being called due to other reasons | |
| 98 // (cleanup, freeing resources, etc.) | |
| 99 virtual void Pause(int player_id, bool is_media_related_action) = 0; | |
| 100 | |
| 101 // Performs seek on the player. | |
| 102 virtual void Seek(int player_id, const base::TimeDelta& time) = 0; | |
| 103 | |
| 104 // Sets the player volume. | |
| 105 virtual void SetVolume(int player_id, double volume) = 0; | |
| 106 | |
| 107 // Sets the poster image. | |
| 108 virtual void SetPoster(int player_id, const GURL& poster) = 0; | |
| 109 | |
| 110 // Releases resources for the player. | |
| 111 virtual void ReleaseResources(int player_id) = 0; | |
| 112 | |
| 113 // Destroys the player in the browser process | |
| 114 virtual void DestroyPlayer(int player_id) = 0; | |
| 115 | |
| 116 // Requests remote playback if possible | |
| 117 virtual void RequestRemotePlayback(int player_id) = 0; | |
| 118 | |
| 119 // Requests control of remote playback | |
| 120 virtual void RequestRemotePlaybackControl(int player_id) = 0; | |
| 121 | |
| 122 // Registers and unregisters a RendererMediaPlayerInterface object. | |
| 123 virtual int RegisterMediaPlayer(RendererMediaPlayerInterface* player) = 0; | |
| 124 virtual void UnregisterMediaPlayer(int player_id) = 0; | |
| 125 }; | |
| 126 | |
| 127 } // namespace media | |
| 128 | |
| 129 #endif // MEDIA_BLINK_RENDERER_MEDIA_PLAYER_INTERFACE_H_ | |
| OLD | NEW |