Skip to content

Commit

Permalink
Try exceeding renderer capabilities by default
Browse files Browse the repository at this point in the history
Not sure what I think about this, but we're getting quite
a lot of issues reported where streams play fine but capabilities
indicate they wont. It's probably best just to cross our fingers
and hope for the best in such cases, as was the case in V1 when
using ExtractorSampleSource.

Issue: #2157
Issue: #2034
Issue: #2007

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=141758070
  • Loading branch information
ojw28 committed Dec 12, 2016
1 parent 1055c52 commit 759cb32
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,12 @@ public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray tra
updateButtonVisibilities();
MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null) {
if (mappedTrackInfo.hasOnlyUnplayableTracks(C.TRACK_TYPE_VIDEO)) {
if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_VIDEO)
== MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
showToast(R.string.error_unsupported_video);
}
if (mappedTrackInfo.hasOnlyUnplayableTracks(C.TRACK_TYPE_AUDIO)) {
if (mappedTrackInfo.getTrackTypeRendererSupport(C.TRACK_TYPE_AUDIO)
== MappedTrackInfo.RENDERER_SUPPORT_UNSUPPORTED_TRACKS) {
showToast(R.string.error_unsupported_audio);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public static final class Parameters {
* <li>Non seamless adaptation is allowed.</li>
* <li>No max limit for video width/height.</li>
* <li>Video constraints are exceeded if no supported selection can be made otherwise.</li>
* <li>Renderer capabilities are not exceeded even if no supported selection can be made.</li>
* <li>Renderer capabilities are exceeded if no supported selection can be made.</li>
* <li>No viewport width/height constraints are set.</li>
* </ul>
*/
public Parameters() {
this(null, null, false, true, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false,
this(null, null, false, true, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true,
Integer.MAX_VALUE, Integer.MAX_VALUE, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroup;
Expand Down Expand Up @@ -138,8 +139,6 @@ public final boolean getRendererDisabled(int rendererIndex) {
* @param groups The {@link TrackGroupArray} for which the override should be applied.
* @param override The override.
*/
// TODO - Don't allow overrides that select unsupported tracks, unless some flag has been
// explicitly set by the user to indicate that they want this.
public final void setSelectionOverride(int rendererIndex, TrackGroupArray groups,
SelectionOverride override) {
Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.get(rendererIndex);
Expand Down Expand Up @@ -411,13 +410,18 @@ public static final class MappedTrackInfo {
*/
public static final int RENDERER_SUPPORT_NO_TRACKS = 0;
/**
* The renderer has associated tracks, but cannot play any of them.
* The renderer has associated tracks, but all are of unsupported types.
*/
public static final int RENDERER_SUPPORT_UNPLAYABLE_TRACKS = 1;
public static final int RENDERER_SUPPORT_UNSUPPORTED_TRACKS = 1;
/**
* The renderer has associated tracks, and can play at least one of them.
* The renderer has associated tracks and at least one is of a supported type, but all of the
* tracks whose types are supported exceed the renderer's capabilities.
*/
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 2;
public static final int RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS = 2;
/**
* The renderer has associated tracks and can play at least one of them.
*/
public static final int RENDERER_SUPPORT_PLAYABLE_TRACKS = 3;

/**
* The number of renderers to which tracks are mapped.
Expand Down Expand Up @@ -465,21 +469,49 @@ public TrackGroupArray getTrackGroups(int rendererIndex) {
*
* @param rendererIndex The renderer index.
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS},
* {@link #RENDERER_SUPPORT_UNPLAYABLE_TRACKS} and {@link #RENDERER_SUPPORT_NO_TRACKS}.
* {@link #RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS},
* {@link #RENDERER_SUPPORT_UNSUPPORTED_TRACKS} and {@link #RENDERER_SUPPORT_NO_TRACKS}.
*/
public int getRendererSupport(int rendererIndex) {
boolean hasTracks = false;
int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
int[][] rendererFormatSupport = formatSupport[rendererIndex];
for (int i = 0; i < rendererFormatSupport.length; i++) {
for (int j = 0; j < rendererFormatSupport[i].length; j++) {
hasTracks = true;
if ((rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK)
== RendererCapabilities.FORMAT_HANDLED) {
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
int trackRendererSupport;
switch (rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK) {
case RendererCapabilities.FORMAT_HANDLED:
return RENDERER_SUPPORT_PLAYABLE_TRACKS;
case RendererCapabilities.FORMAT_EXCEEDS_CAPABILITIES:
trackRendererSupport = RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS;
break;
default:
trackRendererSupport = RENDERER_SUPPORT_UNSUPPORTED_TRACKS;
break;
}
bestRendererSupport = Math.max(bestRendererSupport, trackRendererSupport);
}
}
return hasTracks ? RENDERER_SUPPORT_UNPLAYABLE_TRACKS : RENDERER_SUPPORT_NO_TRACKS;
return bestRendererSupport;
}

/**
* Returns the best level of support obtained from {@link #getRendererSupport(int)} for all
* renderers of the specified track type. If no renderers exist for the specified type then
* {@link #RENDERER_SUPPORT_NO_TRACKS} is returned.
*
* @param trackType The track type. One of the {@link C} {@code TRACK_TYPE_*} constants.
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS},
* {@link #RENDERER_SUPPORT_EXCEEDS_CAPABILITIES_TRACKS},
* {@link #RENDERER_SUPPORT_UNSUPPORTED_TRACKS} and {@link #RENDERER_SUPPORT_NO_TRACKS}.
*/
public int getTrackTypeRendererSupport(int trackType) {
int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
for (int i = 0; i < length; i++) {
if (rendererTrackTypes[i] == trackType) {
bestRendererSupport = Math.max(bestRendererSupport, getRendererSupport(i));
}
}
return bestRendererSupport;
}

/**
Expand Down Expand Up @@ -576,25 +608,6 @@ public TrackGroupArray getUnassociatedTrackGroups() {
return unassociatedTrackGroups;
}

/**
* Returns true if tracks of the specified type exist and have been associated with renderers,
* but are all unplayable. Returns false in all other cases.
*
* @param trackType The track type.
* @return True if tracks of the specified type exist, if at least one renderer exists that
* handles tracks of the specified type, and if all of the tracks if the specified type are
* unplayable. False in all other cases.
*/
public boolean hasOnlyUnplayableTracks(int trackType) {
int rendererSupport = RENDERER_SUPPORT_NO_TRACKS;
for (int i = 0; i < length; i++) {
if (rendererTrackTypes[i] == trackType) {
rendererSupport = Math.max(rendererSupport, getRendererSupport(i));
}
}
return rendererSupport == RENDERER_SUPPORT_UNPLAYABLE_TRACKS;
}

}

}

0 comments on commit 759cb32

Please sign in to comment.