Add an TrackSelector base interface

This will allow Player to move in common without
trackSelector and all its many dependency.

Currently all users of `getTrackSelector` are
downcasting it in `DefaultTrackSelector`, this change
thus does not break them.

Track selection API is intended to be reworked, methods
will be added to the currently empty interface.

#player-to-common

PiperOrigin-RevId: 346159765
This commit is contained in:
krocard 2020-12-07 20:55:36 +00:00 committed by Ian Baker
parent b5f0379ba0
commit 42f5e53def
4 changed files with 34 additions and 3 deletions

View File

@ -468,6 +468,10 @@ public interface ExoPlayer extends Player {
}
}
@Override
@Nullable
TrackSelector getTrackSelector();
/** Returns the {@link Looper} associated with the playback thread. */
Looper getPlaybackLooper();

View File

@ -34,7 +34,7 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelectorInterface;
import com.google.android.exoplayer2.util.MutableFlags;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoDecoderOutputBufferRenderer;
@ -1441,7 +1441,7 @@ public interface Player {
* Returns the track selector that this player uses, or null if track selection is not supported.
*/
@Nullable
TrackSelector getTrackSelector();
TrackSelectorInterface getTrackSelector();
/** Returns the available track groups. */
TrackGroupArray getCurrentTrackGroups();

View File

@ -83,7 +83,7 @@ import com.google.android.exoplayer2.util.Assertions;
* thread. The track selector may call {@link InvalidationListener#onTrackSelectionsInvalidated()}
* from any thread.
*/
public abstract class TrackSelector {
public abstract class TrackSelector implements TrackSelectorInterface {
/**
* Notified when selections previously made by a {@link TrackSelector} are no longer valid.

View File

@ -0,0 +1,27 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.trackselection;
import com.google.android.exoplayer2.Player;
/**
* The component of a {@link Player} responsible for selecting tracks to be played.
*
* <p>No Player agnostic track selection is currently supported. Clients should downcast to the
* implementation's track selection.
*/
// TODO(b/172315872) Define an interface for track selection.
public interface TrackSelectorInterface {}