Java Code Examples for com.google.android.exoplayer2.RendererCapabilities#supportsFormat()

The following examples show how to use com.google.android.exoplayer2.RendererCapabilities#supportsFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be mapped.
 * <p>
 * A {@link TrackGroup} is mapped to the renderer that reports the highest of (listed in
 * decreasing order of support) {@link RendererCapabilities#FORMAT_HANDLED},
 * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}. In the case that two or more renderers
 * report the same level of support, the renderer with the lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that the group was
 * not mapped to any renderer.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The track group to map to a renderer.
 * @return The index of the renderer to which the track group was mapped, or
 *     {@code renderers.length} if it was not mapped to any renderer.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
Example 2
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be mapped.
 * <p>
 * A {@link TrackGroup} is mapped to the renderer that reports the highest of (listed in
 * decreasing order of support) {@link RendererCapabilities#FORMAT_HANDLED},
 * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}. In the case that two or more renderers
 * report the same level of support, the renderer with the lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that the group was
 * not mapped to any renderer.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The track group to map to a renderer.
 * @return The index of the renderer to which the track group was mapped, or
 *     {@code renderers.length} if it was not mapped to any renderer.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
Example 3
Source File: MappingTrackSelector.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be associated.
 * <p>
 * A {@link TrackGroup} is associated to a renderer that reports
 * {@link RendererCapabilities#FORMAT_HANDLED} support for one or more of the tracks in the group,
 * or {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES} if no such renderer exists, or
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE} if again no such renderer exists. In
 * the case that two or more renderers report the same level of support, the renderer with the
 * lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that no association
 * was made.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The {@link TrackGroup} whose associated renderer is to be found.
 * @return The index of the associated renderer, or {@code renderers.length} if no
 *     association was made.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
Example 4
Source File: MappingTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be mapped.
 * <p>
 * A {@link TrackGroup} is mapped to the renderer that reports the highest of (listed in
 * decreasing order of support) {@link RendererCapabilities#FORMAT_HANDLED},
 * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}. In the case that two or more renderers
 * report the same level of support, the renderer with the lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that the group was
 * not mapped to any renderer.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The track group to map to a renderer.
 * @return The index of the renderer to which the track group was mapped, or
 *     {@code renderers.length} if it was not mapped to any renderer.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
Example 5
Source File: MappingTrackSelector.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Finds the renderer to which the provided {@link TrackGroup} should be mapped.
 * <p>
 * A {@link TrackGroup} is mapped to the renderer that reports the highest of (listed in
 * decreasing order of support) {@link RendererCapabilities#FORMAT_HANDLED},
 * {@link RendererCapabilities#FORMAT_EXCEEDS_CAPABILITIES},
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_DRM} and
 * {@link RendererCapabilities#FORMAT_UNSUPPORTED_SUBTYPE}. In the case that two or more renderers
 * report the same level of support, the renderer with the lowest index is associated.
 * <p>
 * If all renderers report {@link RendererCapabilities#FORMAT_UNSUPPORTED_TYPE} for all of the
 * tracks in the group, then {@code renderers.length} is returned to indicate that the group was
 * not mapped to any renderer.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers.
 * @param group The track group to map to a renderer.
 * @return The index of the renderer to which the track group was mapped, or
 *     {@code renderers.length} if it was not mapped to any renderer.
 * @throws ExoPlaybackException If an error occurs finding a renderer.
 */
private static int findRenderer(RendererCapabilities[] rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int bestRendererIndex = rendererCapabilities.length;
  int bestFormatSupportLevel = RendererCapabilities.FORMAT_UNSUPPORTED_TYPE;
  for (int rendererIndex = 0; rendererIndex < rendererCapabilities.length; rendererIndex++) {
    RendererCapabilities rendererCapability = rendererCapabilities[rendererIndex];
    for (int trackIndex = 0; trackIndex < group.length; trackIndex++) {
      int formatSupportLevel = rendererCapability.supportsFormat(group.getFormat(trackIndex))
          & RendererCapabilities.FORMAT_SUPPORT_MASK;
      if (formatSupportLevel > bestFormatSupportLevel) {
        bestRendererIndex = rendererIndex;
        bestFormatSupportLevel = formatSupportLevel;
        if (bestFormatSupportLevel == RendererCapabilities.FORMAT_HANDLED) {
          // We can't do better.
          return bestRendererIndex;
        }
      }
    }
  }
  return bestRendererIndex;
}
 
Example 6
Source File: MappingTrackSelector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified {@link
 * TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The track group to evaluate.
 * @return An array containing {@link Capabilities} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
@Capabilities
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  @Capabilities int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}
 
Example 7
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified
 * {@link TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The track group to evaluate.
 * @return An array containing the result of calling
 *     {@link RendererCapabilities#supportsFormat} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}
 
Example 8
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified
 * {@link TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The track group to evaluate.
 * @return An array containing the result of calling
 *     {@link RendererCapabilities#supportsFormat} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}
 
Example 9
Source File: MappingTrackSelector.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified
 * {@link TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The {@link TrackGroup} to evaluate.
 * @return An array containing the result of calling
 *     {@link RendererCapabilities#supportsFormat} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}
 
Example 10
Source File: MappingTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified
 * {@link TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The track group to evaluate.
 * @return An array containing the result of calling
 *     {@link RendererCapabilities#supportsFormat} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}
 
Example 11
Source File: MappingTrackSelector.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Calls {@link RendererCapabilities#supportsFormat} for each track in the specified
 * {@link TrackGroup}, returning the results in an array.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderer.
 * @param group The track group to evaluate.
 * @return An array containing the result of calling
 *     {@link RendererCapabilities#supportsFormat} for each track in the group.
 * @throws ExoPlaybackException If an error occurs determining the format support.
 */
private static int[] getFormatSupport(RendererCapabilities rendererCapabilities, TrackGroup group)
    throws ExoPlaybackException {
  int[] formatSupport = new int[group.length];
  for (int i = 0; i < group.length; i++) {
    formatSupport[i] = rendererCapabilities.supportsFormat(group.getFormat(i));
  }
  return formatSupport;
}