Commit 759cb323 by olly Committed by Oliver Woodman

Try exceeding renderer capabilities by default

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
parent 1055c520
...@@ -469,10 +469,12 @@ public class PlayerActivity extends Activity implements OnClickListener, ExoPlay ...@@ -469,10 +469,12 @@ public class PlayerActivity extends Activity implements OnClickListener, ExoPlay
updateButtonVisibilities(); updateButtonVisibilities();
MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo(); MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
if (mappedTrackInfo != null) { 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); 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); showToast(R.string.error_unsupported_audio);
} }
} }
......
...@@ -69,12 +69,12 @@ public class DefaultTrackSelector extends MappingTrackSelector { ...@@ -69,12 +69,12 @@ public class DefaultTrackSelector extends MappingTrackSelector {
* <li>Non seamless adaptation is allowed.</li> * <li>Non seamless adaptation is allowed.</li>
* <li>No max limit for video width/height.</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>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> * <li>No viewport width/height constraints are set.</li>
* </ul> * </ul>
*/ */
public Parameters() { 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); Integer.MAX_VALUE, Integer.MAX_VALUE, true);
} }
......
...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.trackselection; ...@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.trackselection;
import android.util.Pair; import android.util.Pair;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseBooleanArray; import android.util.SparseBooleanArray;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.RendererCapabilities; import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroup;
...@@ -138,8 +139,6 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -138,8 +139,6 @@ public abstract class MappingTrackSelector extends TrackSelector {
* @param groups The {@link TrackGroupArray} for which the override should be applied. * @param groups The {@link TrackGroupArray} for which the override should be applied.
* @param override The override. * @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, public final void setSelectionOverride(int rendererIndex, TrackGroupArray groups,
SelectionOverride override) { SelectionOverride override) {
Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.get(rendererIndex); Map<TrackGroupArray, SelectionOverride> overrides = selectionOverrides.get(rendererIndex);
...@@ -411,13 +410,18 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -411,13 +410,18 @@ public abstract class MappingTrackSelector extends TrackSelector {
*/ */
public static final int RENDERER_SUPPORT_NO_TRACKS = 0; 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. * The number of renderers to which tracks are mapped.
...@@ -465,21 +469,49 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -465,21 +469,49 @@ public abstract class MappingTrackSelector extends TrackSelector {
* *
* @param rendererIndex The renderer index. * @param rendererIndex The renderer index.
* @return One of {@link #RENDERER_SUPPORT_PLAYABLE_TRACKS}, * @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) { public int getRendererSupport(int rendererIndex) {
boolean hasTracks = false; int bestRendererSupport = RENDERER_SUPPORT_NO_TRACKS;
int[][] rendererFormatSupport = formatSupport[rendererIndex]; int[][] rendererFormatSupport = formatSupport[rendererIndex];
for (int i = 0; i < rendererFormatSupport.length; i++) { for (int i = 0; i < rendererFormatSupport.length; i++) {
for (int j = 0; j < rendererFormatSupport[i].length; j++) { for (int j = 0; j < rendererFormatSupport[i].length; j++) {
hasTracks = true; int trackRendererSupport;
if ((rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK) switch (rendererFormatSupport[i][j] & RendererCapabilities.FORMAT_SUPPORT_MASK) {
== RendererCapabilities.FORMAT_HANDLED) { case RendererCapabilities.FORMAT_HANDLED:
return RENDERER_SUPPORT_PLAYABLE_TRACKS; 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;
} }
/** /**
...@@ -576,25 +608,6 @@ public abstract class MappingTrackSelector extends TrackSelector { ...@@ -576,25 +608,6 @@ public abstract class MappingTrackSelector extends TrackSelector {
return unassociatedTrackGroups; 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;
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment