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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java

Issue 1403703005: Refactor Clank cast connect logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybot detected error. Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
index 858001ed796a8861b907849abdb68197b9316155..d2eaa6f2acd09a37d01b02ff686215e9c3257e22 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
@@ -27,49 +27,87 @@ public interface MediaRouteController extends TransportControl.Listener {
* is removed.
* @param available whether routes are available.
*/
- public void onRouteAvailabilityChanged(boolean available);
+ void onRouteAvailabilityChanged(boolean available);
/**
* Called when an error is detected by the media route controller
*/
- public void onError();
+ void onError();
/**
* Called when a seek completes on the current route
*/
- public void onSeekCompleted();
+ void onSeekCompleted();
/**
- * Called when the current route is ready to be used
+ * Called when the current route is unselected
+ */
+ void onRouteUnselected();
+
+ /**
+ * Called when the playback state changes (e.g. from Playing to Paused)
+ * @param newState the new playback state
*/
- public void onPrepared();
+ void onPlaybackStateChanged(PlayerState newState);
+
+ String getTitle();
+
+ Bitmap getPosterBitmap();
+
+ void pauseLocal();
+
+ int getLocalPosition();
/**
- * Called when a new route has been selected for Cast
- * @param name the name of the route
+ * Tells the rest of Chrome that we are starting to cast, so that user inputs control cast
+ * in place of local playback
*/
- public void onRouteSelected(String name);
+ void onCastStarting(String routeName);
/**
- * Called when the current route is unselected
+ * Tells the rest of Chrome that we are no longer casting the video.
*/
- public void onRouteUnselected();
+ void onCastStopping();
/**
- * Called when the playback state changes (e.g. from Playing to Paused)
- * @param newState the new playback state
+ * @return the source URL
+ */
+ String getSourceUrl();
+
+ /**
+ * @return the Cookies
+ */
+ String getCookies();
+
+ /**
+ * @return the User Agent string
+ */
+ String getUserAgent();
+
+ /**
+ * @return the frame URL
+ */
+ String getFrameUrl();
+
+ /**
+ * @return the start position
+ */
+ long getStartPositionMillis();
+
+ /**
+ * @return true if the user has pressed the pause button (or requested pause some other way)
*/
- public void onPlaybackStateChanged(PlayerState newState);
+ boolean isPauseRequested();
/**
- * @return the title of the video
+ * @return true if the user has requested a seek
*/
- public String getTitle();
+ boolean isSeekRequested();
/**
- * @return the poster bitmap
+ * @return the requested seek location. Only meaningful if isSeekRequested is true.
*/
- public Bitmap getPosterBitmap();
+ int getSeekLocation();
}
/**
@@ -137,7 +175,7 @@ public interface MediaRouteController extends TransportControl.Listener {
*
* @return false if device doesn't support cast, true otherwise.
*/
- public boolean initialize();
+ boolean initialize();
/**
* Can this mediaRouteController handle a media element?
@@ -145,28 +183,28 @@ public interface MediaRouteController extends TransportControl.Listener {
* @param frameUrl
* @return true if it can, false if it can't.
*/
- public boolean canPlayMedia(String sourceUrl, String frameUrl);
+ boolean canPlayMedia(String sourceUrl, String frameUrl);
/**
* @return A new MediaRouteSelector filtering the remote playback devices from all the routes.
*/
- public MediaRouteSelector buildMediaRouteSelector();
+ MediaRouteSelector buildMediaRouteSelector();
/**
* @return Whether there're remote playback devices available.
*/
- public boolean isRemotePlaybackAvailable();
+ boolean isRemotePlaybackAvailable();
/**
* @return Whether the currently selected device supports remote playback
*/
- public boolean currentRouteSupportsRemotePlayback();
+ boolean currentRouteSupportsRemotePlayback();
/**
* Checks if we want to reconnect, and if so starts trying to do so. Otherwise clears out the
* persistent request to reconnect.
*/
- public boolean reconnectAnyExistingRoute();
+ boolean reconnectAnyExistingRoute();
/**
* Sets the video URL when it becomes known.
@@ -177,36 +215,36 @@ public interface MediaRouteController extends TransportControl.Listener {
* @param uri The video URL.
* @param userAgent The browser user agent.
*/
- public void setDataSource(Uri uri, String cookies, String userAgent);
+ void setDataSource(Uri uri, String cookies, String userAgent);
/**
* Setup this object to discover new routes and register the necessary players.
*/
- public void prepareMediaRoute();
+ void prepareMediaRoute();
/**
* Add a Listener that will listen to events from this object
*
* @param listener the Listener that will receive the events
*/
- public void addUiListener(UiListener listener);
+ void addUiListener(UiListener listener);
/**
* Removes a Listener from this object
*
* @param listener the Listener to remove
*/
- public void removeUiListener(UiListener listener);
+ void removeUiListener(UiListener listener);
/**
* @return The currently selected route's friendly name, or null if there is none selected
*/
- public String getRouteName();
+ String getRouteName();
/**
* @return true if this is currently using the default route, false if not.
*/
- public boolean routeIsDefaultRoute();
+ boolean routeIsDefaultRoute();
/**
* Called to prepare the remote playback asyncronously. onPrepared() of the current remote media
@@ -214,24 +252,24 @@ public interface MediaRouteController extends TransportControl.Listener {
*
* @param startPositionMillis indicates where in the stream to start playing
*/
- public void prepareAsync(String frameUrl, long startPositionMillis);
+ void prepareAsync(String frameUrl, long startPositionMillis);
/**
* Sets the remote volume of the current route.
*
* @param delta The delta value in arbitrary "Android Volume Units".
*/
- public void setRemoteVolume(int delta);
+ void setRemoteVolume(int delta);
/**
* Resume paused playback of the current video.
*/
- public void resume();
+ void resume();
/**
* Pauses the currently playing video if any.
*/
- public void pause();
+ void pause();
/**
* Returns the current remote playback position. Estimates the current position by using the
@@ -242,68 +280,77 @@ public interface MediaRouteController extends TransportControl.Listener {
*
* @return The current position of the remote playback in milliseconds.
*/
- public int getPosition();
+ int getPosition();
/**
* @return The stream duration in milliseconds.
*/
- public int getDuration();
+ int getDuration();
/**
* @return Whether the video is currently being played.
*/
- public boolean isPlaying();
+ boolean isPlaying();
/**
* @return Whether the video is being cast (any of playing/paused/loading/stopped).
*/
- public boolean isBeingCast();
+ boolean isBeingCast();
/**
* Initiates a seek request for the remote playback device to the specified position.
*
* @param msec The position to seek to, in milliseconds.
*/
- public void seekTo(int msec);
+ void seekTo(int msec);
/**
* Stop the current remote playback completely and release all resources.
*/
- public void release();
+ void release();
/**
* @param player - the current player using this media route controller.
*/
- public void setMediaStateListener(MediaStateListener listener);
+ void setMediaStateListener(MediaStateListener listener);
/**
* @return the current VideoStateListener
*/
- public MediaStateListener getMediaStateListener();
+ MediaStateListener getMediaStateListener();
/**
* @return true if the video is new
*/
- public boolean shouldResetState(MediaStateListener newListener);
+ boolean shouldResetState(MediaStateListener newListener);
- @VisibleForTesting
- public PlayerState getPlayerState();
+ @VisibleForTesting PlayerState getPlayerState();
/**
* Remove an existing media state listener
* @param listener
*/
- public void removeMediaStateListener(MediaStateListener listener);
+ void removeMediaStateListener(MediaStateListener listener);
/**
* Add a media state listener
* @param listener
*/
- public void addMediaStateListener(MediaStateListener listener);
+ void addMediaStateListener(MediaStateListener listener);
/**
* Get the poster for the video, if any
* @return the poster bitmap, or Null.
*/
- public Bitmap getPoster();
+ Bitmap getPoster();
+
+ /**
+ * Used to switch video or audio streams when already casting.
+ * If the mediaRouteController not casting does nothing.
+ * If the mediaRouteController is already casting, then the calling RemoteMediaPlayerBridge
+ * takes over the cast device and starts casting its stream.
+ * @param mMediaStateListener
+ * @return true if the new stream has been cast, false if not.
+ */
+ boolean playerTakesOverCastDevice(MediaStateListener mediaStateListener);
}

Powered by Google App Engine
This is Rietveld 408576698