com.google.android.exoplayer2.RendererConfiguration Java Examples

The following examples show how to use com.google.android.exoplayer2.RendererConfiguration. 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: TrackSelectorResult.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer. A null entry
 *     indicates the corresponding renderer should be disabled.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to {@link
 *     TrackSelector#onSelectionActivated(Object)} should the selection be activated.
 */
public TrackSelectorResult(
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] selections,
    Object info) {
  this.rendererConfigurations = rendererConfigurations;
  this.selections = new TrackSelectionArray(selections);
  this.info = info;
  length = rendererConfigurations.length;
}
 
Example #2
Source File: TrackSelectorResult.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer. A null entry
 *     indicates the corresponding renderer should be disabled.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to {@link
 *     TrackSelector#onSelectionActivated(Object)} should the selection be activated.
 */
public TrackSelectorResult(
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] selections,
    Object info) {
  this.rendererConfigurations = rendererConfigurations;
  this.selections = new TrackSelectionArray(selections);
  this.info = info;
  length = rendererConfigurations.length;
}
 
Example #3
Source File: TrackSelectorResult.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer. A null entry
 *     indicates the corresponding renderer should be disabled.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to {@link
 *     TrackSelector#onSelectionActivated(Object)} should the selection be activated.
 */
public TrackSelectorResult(
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] selections,
    Object info) {
  this.rendererConfigurations = rendererConfigurations;
  this.selections = new TrackSelectionArray(selections);
  this.info = info;
  length = rendererConfigurations.length;
}
 
Example #4
Source File: TrackSelectorResult.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer. A null entry
 *     indicates the corresponding renderer should be disabled.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to {@link
 *     TrackSelector#onSelectionActivated(Object)} should the selection be activated.
 */
public TrackSelectorResult(
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] selections,
    Object info) {
  this.rendererConfigurations = rendererConfigurations;
  this.selections = new TrackSelectionArray(selections);
  this.info = info;
  length = rendererConfigurations.length;
}
 
Example #5
Source File: TrackSelectorResult.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer. A null entry
 *     indicates the corresponding renderer should be disabled.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to {@link
 *     TrackSelector#onSelectionActivated(Object)} should the selection be activated.
 */
public TrackSelectorResult(
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] selections,
    Object info) {
  this.rendererConfigurations = rendererConfigurations;
  this.selections = new TrackSelectionArray(selections);
  this.info = info;
  length = rendererConfigurations.length;
}
 
Example #6
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or {@link
 *     C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    MappedTrackInfo mappedTrackInfo,
    int[][][] renderererFormatSupports,
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] trackSelections,
    int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
    int rendererType = mappedTrackInfo.getRendererType(i);
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(
          renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #7
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param renderererFormatSupports The {@link Capabilities} for each mapped track, indexed by
 *     renderer, track group and track (in that order).
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or {@link
 *     C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    MappedTrackInfo mappedTrackInfo,
    @Capabilities int[][][] renderererFormatSupports,
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] trackSelections,
    int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
    int rendererType = mappedTrackInfo.getRendererType(i);
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(
          renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #8
Source File: DefaultTrackSelector.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or {@link
 *     C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    MappedTrackInfo mappedTrackInfo,
    int[][][] renderererFormatSupports,
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] trackSelections,
    int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
    int rendererType = mappedTrackInfo.getRendererType(i);
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(
          renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #9
Source File: DefaultTrackSelector.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupports)
        throws ExoPlaybackException {
  Parameters params = parametersReference.get();
  int rendererCount = mappedTrackInfo.getRendererCount();
  TrackSelection.@NullableType Definition[] definitions =
      selectAllTracks(
          mappedTrackInfo,
          rendererFormatSupports,
          rendererMixedMimeTypeAdaptationSupports,
          params);

  // Apply track disabling and overriding.
  for (int i = 0; i < rendererCount; i++) {
    if (params.getRendererDisabled(i)) {
      definitions[i] = null;
      continue;
    }
    TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
    if (params.hasSelectionOverride(i, rendererTrackGroups)) {
      SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
      definitions[i] =
          override == null
              ? null
              : new TrackSelection.Definition(
                  rendererTrackGroups.get(override.groupIndex),
                  override.tracks,
                  override.reason,
                  override.data);
    }
  }

  @NullableType
  TrackSelection[] rendererTrackSelections =
      trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter());

  // Initialize the renderer configurations to the default configuration for all renderers with
  // selections, and null otherwise.
  @NullableType RendererConfiguration[] rendererConfigurations =
      new RendererConfiguration[rendererCount];
  for (int i = 0; i < rendererCount; i++) {
    boolean forceRendererDisabled = params.getRendererDisabled(i);
    boolean rendererEnabled =
        !forceRendererDisabled
            && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
                || rendererTrackSelections[i] != null);
    rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
  }

  // Configure audio and video renderers to use tunneling if appropriate.
  maybeConfigureRenderersForTunneling(
      mappedTrackInfo,
      rendererFormatSupports,
      rendererConfigurations,
      rendererTrackSelections,
      params.tunnelingAudioSessionId);

  return Pair.create(rendererConfigurations, rendererTrackSelections);
}
 
Example #10
Source File: DefaultTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or {@link
 *     C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    MappedTrackInfo mappedTrackInfo,
    int[][][] renderererFormatSupports,
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] trackSelections,
    int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
    int rendererType = mappedTrackInfo.getRendererType(i);
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(
          renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #11
Source File: DefaultTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupports)
        throws ExoPlaybackException {
  Parameters params = parametersReference.get();
  int rendererCount = mappedTrackInfo.getRendererCount();
  TrackSelection.@NullableType Definition[] definitions =
      selectAllTracks(
          mappedTrackInfo,
          rendererFormatSupports,
          rendererMixedMimeTypeAdaptationSupports,
          params);

  // Apply track disabling and overriding.
  for (int i = 0; i < rendererCount; i++) {
    if (params.getRendererDisabled(i)) {
      definitions[i] = null;
      continue;
    }
    TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
    if (params.hasSelectionOverride(i, rendererTrackGroups)) {
      SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
      definitions[i] =
          override == null
              ? null
              : new TrackSelection.Definition(
                  rendererTrackGroups.get(override.groupIndex),
                  override.tracks,
                  override.reason,
                  override.data);
    }
  }

  @NullableType
  TrackSelection[] rendererTrackSelections =
      trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter());

  // Initialize the renderer configurations to the default configuration for all renderers with
  // selections, and null otherwise.
  @NullableType RendererConfiguration[] rendererConfigurations =
      new RendererConfiguration[rendererCount];
  for (int i = 0; i < rendererCount; i++) {
    boolean forceRendererDisabled = params.getRendererDisabled(i);
    boolean rendererEnabled =
        !forceRendererDisabled
            && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
                || rendererTrackSelections[i] != null);
    rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
  }

  // Configure audio and video renderers to use tunneling if appropriate.
  maybeConfigureRenderersForTunneling(
      mappedTrackInfo,
      rendererFormatSupports,
      rendererConfigurations,
      rendererTrackSelections,
      params.tunnelingAudioSessionId);

  return Pair.create(rendererConfigurations, rendererTrackSelections);
}
 
Example #12
Source File: MappingTrackSelector.java    From K-Sonic with MIT License 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param rendererCapabilities The {@link RendererCapabilities} of the renderers for which
 *     {@link TrackSelection}s are to be generated.
 * @param rendererTrackGroupArrays An array of {@link TrackGroupArray}s where each entry
 *     corresponds to the renderer of equal index in {@code renderers}.
 * @param rendererFormatSupports Maps every available track to a specific level of support as
 *     defined by the renderer {@code FORMAT_*} constants.
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or
 *     {@link C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    RendererCapabilities[] rendererCapabilities, TrackGroupArray[] rendererTrackGroupArrays,
    int[][][] rendererFormatSupports, RendererConfiguration[] rendererConfigurations,
    TrackSelection[] trackSelections, int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < rendererCapabilities.length; i++) {
    int rendererType = rendererCapabilities[i].getTrackType();
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(rendererFormatSupports[i], rendererTrackGroupArrays[i],
          trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #13
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        @Capabilities int[][][] rendererFormatSupports,
        @AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports)
        throws ExoPlaybackException {
  Parameters params = parametersReference.get();
  int rendererCount = mappedTrackInfo.getRendererCount();
  TrackSelection.@NullableType Definition[] definitions =
      selectAllTracks(
          mappedTrackInfo,
          rendererFormatSupports,
          rendererMixedMimeTypeAdaptationSupports,
          params);

  // Apply track disabling and overriding.
  for (int i = 0; i < rendererCount; i++) {
    if (params.getRendererDisabled(i)) {
      definitions[i] = null;
      continue;
    }
    TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
    if (params.hasSelectionOverride(i, rendererTrackGroups)) {
      SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
      definitions[i] =
          override == null
              ? null
              : new TrackSelection.Definition(
                  rendererTrackGroups.get(override.groupIndex),
                  override.tracks,
                  override.reason,
                  override.data);
    }
  }

  @NullableType
  TrackSelection[] rendererTrackSelections =
      trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter());

  // Initialize the renderer configurations to the default configuration for all renderers with
  // selections, and null otherwise.
  @NullableType RendererConfiguration[] rendererConfigurations =
      new RendererConfiguration[rendererCount];
  for (int i = 0; i < rendererCount; i++) {
    boolean forceRendererDisabled = params.getRendererDisabled(i);
    boolean rendererEnabled =
        !forceRendererDisabled
            && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
                || rendererTrackSelections[i] != null);
    rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
  }

  // Configure audio and video renderers to use tunneling if appropriate.
  maybeConfigureRenderersForTunneling(
      mappedTrackInfo,
      rendererFormatSupports,
      rendererConfigurations,
      rendererTrackSelections,
      params.tunnelingAudioSessionId);

  return Pair.create(rendererConfigurations, rendererTrackSelections);
}
 
Example #14
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determines whether tunneling should be enabled, replacing {@link RendererConfiguration}s in
 * {@code rendererConfigurations} with configurations that enable tunneling on the appropriate
 * renderers if so.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererConfigurations The renderer configurations. Configurations may be replaced with
 *     ones that enable tunneling as a result of this call.
 * @param trackSelections The renderer track selections.
 * @param tunnelingAudioSessionId The audio session id to use when tunneling, or {@link
 *     C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
 */
private static void maybeConfigureRenderersForTunneling(
    MappedTrackInfo mappedTrackInfo,
    int[][][] renderererFormatSupports,
    @NullableType RendererConfiguration[] rendererConfigurations,
    @NullableType TrackSelection[] trackSelections,
    int tunnelingAudioSessionId) {
  if (tunnelingAudioSessionId == C.AUDIO_SESSION_ID_UNSET) {
    return;
  }
  // Check whether we can enable tunneling. To enable tunneling we require exactly one audio and
  // one video renderer to support tunneling and have a selection.
  int tunnelingAudioRendererIndex = -1;
  int tunnelingVideoRendererIndex = -1;
  boolean enableTunneling = true;
  for (int i = 0; i < mappedTrackInfo.getRendererCount(); i++) {
    int rendererType = mappedTrackInfo.getRendererType(i);
    TrackSelection trackSelection = trackSelections[i];
    if ((rendererType == C.TRACK_TYPE_AUDIO || rendererType == C.TRACK_TYPE_VIDEO)
        && trackSelection != null) {
      if (rendererSupportsTunneling(
          renderererFormatSupports[i], mappedTrackInfo.getTrackGroups(i), trackSelection)) {
        if (rendererType == C.TRACK_TYPE_AUDIO) {
          if (tunnelingAudioRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingAudioRendererIndex = i;
          }
        } else {
          if (tunnelingVideoRendererIndex != -1) {
            enableTunneling = false;
            break;
          } else {
            tunnelingVideoRendererIndex = i;
          }
        }
      }
    }
  }
  enableTunneling &= tunnelingAudioRendererIndex != -1 && tunnelingVideoRendererIndex != -1;
  if (enableTunneling) {
    RendererConfiguration tunnelingRendererConfiguration =
        new RendererConfiguration(tunnelingAudioSessionId);
    rendererConfigurations[tunnelingAudioRendererIndex] = tunnelingRendererConfiguration;
    rendererConfigurations[tunnelingVideoRendererIndex] = tunnelingRendererConfiguration;
  }
}
 
Example #15
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupports)
        throws ExoPlaybackException {
  Parameters params = parametersReference.get();
  int rendererCount = mappedTrackInfo.getRendererCount();
  @NullableType TrackSelection[] rendererTrackSelections =
      selectAllTracks(
          mappedTrackInfo,
          rendererFormatSupports,
          rendererMixedMimeTypeAdaptationSupports,
          params);

  // Apply track disabling and overriding.
  for (int i = 0; i < rendererCount; i++) {
    if (params.getRendererDisabled(i)) {
      rendererTrackSelections[i] = null;
    } else {
      TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
      if (params.hasSelectionOverride(i, rendererTrackGroups)) {
        SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
        if (override == null) {
          rendererTrackSelections[i] = null;
        } else if (override.length == 1) {
          rendererTrackSelections[i] =
              new FixedTrackSelection(
                  rendererTrackGroups.get(override.groupIndex), override.tracks[0]);
        } else {
          rendererTrackSelections[i] =
              Assertions.checkNotNull(adaptiveTrackSelectionFactory)
                  .createTrackSelection(
                      rendererTrackGroups.get(override.groupIndex),
                      getBandwidthMeter(),
                      override.tracks);
        }
      }
    }
  }

  // Initialize the renderer configurations to the default configuration for all renderers with
  // selections, and null otherwise.
  @NullableType RendererConfiguration[] rendererConfigurations =
      new RendererConfiguration[rendererCount];
  for (int i = 0; i < rendererCount; i++) {
    boolean forceRendererDisabled = params.getRendererDisabled(i);
    boolean rendererEnabled =
        !forceRendererDisabled
            && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
                || rendererTrackSelections[i] != null);
    rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
  }

  // Configure audio and video renderers to use tunneling if appropriate.
  maybeConfigureRenderersForTunneling(
      mappedTrackInfo,
      rendererFormatSupports,
      rendererConfigurations,
      rendererTrackSelections,
      params.tunnelingAudioSessionId);

  return Pair.create(rendererConfigurations, rendererTrackSelections);
}
 
Example #16
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupports)
        throws ExoPlaybackException {
  Parameters params = parametersReference.get();
  int rendererCount = mappedTrackInfo.getRendererCount();
  @NullableType TrackSelection[] rendererTrackSelections =
      selectAllTracks(
          mappedTrackInfo,
          rendererFormatSupports,
          rendererMixedMimeTypeAdaptationSupports,
          params);

  // Apply track disabling and overriding.
  for (int i = 0; i < rendererCount; i++) {
    if (params.getRendererDisabled(i)) {
      rendererTrackSelections[i] = null;
    } else {
      TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
      if (params.hasSelectionOverride(i, rendererTrackGroups)) {
        SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
        if (override == null) {
          rendererTrackSelections[i] = null;
        } else if (override.length == 1) {
          rendererTrackSelections[i] =
              new FixedTrackSelection(
                  rendererTrackGroups.get(override.groupIndex), override.tracks[0]);
        } else {
          rendererTrackSelections[i] =
              Assertions.checkNotNull(adaptiveTrackSelectionFactory)
                  .createTrackSelection(
                      rendererTrackGroups.get(override.groupIndex),
                      getBandwidthMeter(),
                      override.tracks);
        }
      }
    }
  }

  // Initialize the renderer configurations to the default configuration for all renderers with
  // selections, and null otherwise.
  @NullableType RendererConfiguration[] rendererConfigurations =
      new RendererConfiguration[rendererCount];
  for (int i = 0; i < rendererCount; i++) {
    boolean forceRendererDisabled = params.getRendererDisabled(i);
    boolean rendererEnabled =
        !forceRendererDisabled
            && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE
                || rendererTrackSelections[i] != null);
    rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
  }

  // Configure audio and video renderers to use tunneling if appropriate.
  maybeConfigureRenderersForTunneling(
      mappedTrackInfo,
      rendererFormatSupports,
      rendererConfigurations,
      rendererTrackSelections,
      params.tunnelingAudioSessionId);

  return Pair.create(rendererConfigurations, rendererTrackSelections);
}
 
Example #17
Source File: TrackSelectorResult.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * @param groups The groups provided to the {@link TrackSelector}.
 * @param selections A {@link TrackSelectionArray} containing the selection for each renderer.
 * @param info An opaque object that will be returned to
 *     {@link TrackSelector#onSelectionActivated(Object)} should the selections be activated.
 * @param rendererConfigurations A {@link RendererConfiguration} for each renderer, to be used
 *     with the selections.
 */
public TrackSelectorResult(TrackGroupArray groups, TrackSelectionArray selections, Object info,
    RendererConfiguration[] rendererConfigurations) {
  this.groups = groups;
  this.selections = selections;
  this.info = info;
  this.rendererConfigurations = rendererConfigurations;
}
 
Example #18
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Given mapped track information, returns a track selection and configuration for each renderer.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
 *     each mapped track, indexed by renderer, track group and track (in that order).
 * @param rendererMixedMimeTypeAdaptationSupport The result of {@link
 *     RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
 * @return A pair consisting of the track selections and configurations for each renderer. A null
 *     configuration indicates the renderer should be disabled, in which case the track selection
 *     will also be null. A track selection may also be null for a non-disabled renderer if {@link
 *     RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
 * @throws ExoPlaybackException If an error occurs while selecting the tracks.
 */
protected abstract Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupport)
        throws ExoPlaybackException;
 
Example #19
Source File: MappingTrackSelector.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Given mapped track information, returns a track selection and configuration for each renderer.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
 *     each mapped track, indexed by renderer, track group and track (in that order).
 * @param rendererMixedMimeTypeAdaptationSupport The result of {@link
 *     RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
 * @return A pair consisting of the track selections and configurations for each renderer. A null
 *     configuration indicates the renderer should be disabled, in which case the track selection
 *     will also be null. A track selection may also be null for a non-disabled renderer if {@link
 *     RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
 * @throws ExoPlaybackException If an error occurs while selecting the tracks.
 */
protected abstract Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupport)
        throws ExoPlaybackException;
 
Example #20
Source File: MappingTrackSelector.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Given mapped track information, returns a track selection and configuration for each renderer.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererFormatSupports The {@link Capabilities} for ach mapped track, indexed by
 *     renderer, track group and track (in that order).
 * @param rendererMixedMimeTypeAdaptationSupport The {@link AdaptiveSupport} for mixed MIME type
 *     adaptation for the renderer.
 * @return A pair consisting of the track selections and configurations for each renderer. A null
 *     configuration indicates the renderer should be disabled, in which case the track selection
 *     will also be null. A track selection may also be null for a non-disabled renderer if {@link
 *     RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
 * @throws ExoPlaybackException If an error occurs while selecting the tracks.
 */
protected abstract Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        @Capabilities int[][][] rendererFormatSupports,
        @AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport)
        throws ExoPlaybackException;
 
Example #21
Source File: MappingTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Given mapped track information, returns a track selection and configuration for each renderer.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
 *     each mapped track, indexed by renderer, track group and track (in that order).
 * @param rendererMixedMimeTypeAdaptationSupport The result of {@link
 *     RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
 * @return A pair consisting of the track selections and configurations for each renderer. A null
 *     configuration indicates the renderer should be disabled, in which case the track selection
 *     will also be null. A track selection may also be null for a non-disabled renderer if {@link
 *     RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
 * @throws ExoPlaybackException If an error occurs while selecting the tracks.
 */
protected abstract Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupport)
        throws ExoPlaybackException;
 
Example #22
Source File: MappingTrackSelector.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Given mapped track information, returns a track selection and configuration for each renderer.
 *
 * @param mappedTrackInfo Mapped track information.
 * @param rendererFormatSupports The result of {@link RendererCapabilities#supportsFormat} for
 *     each mapped track, indexed by renderer, track group and track (in that order).
 * @param rendererMixedMimeTypeAdaptationSupport The result of {@link
 *     RendererCapabilities#supportsMixedMimeTypeAdaptation()} for each renderer.
 * @return A pair consisting of the track selections and configurations for each renderer. A null
 *     configuration indicates the renderer should be disabled, in which case the track selection
 *     will also be null. A track selection may also be null for a non-disabled renderer if {@link
 *     RendererCapabilities#getTrackType()} is {@link C#TRACK_TYPE_NONE}.
 * @throws ExoPlaybackException If an error occurs while selecting the tracks.
 */
protected abstract Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]>
    selectTracks(
        MappedTrackInfo mappedTrackInfo,
        int[][][] rendererFormatSupports,
        int[] rendererMixedMimeTypeAdaptationSupport)
        throws ExoPlaybackException;