Java 类com.google.android.exoplayer2.RendererConfiguration 实例源码

项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that a null override can be cleared when there is no-sample renderer.
 */
@Test
public void testSelectTracksWithNoSampleRendererWithClearedNullOverride()
    throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  trackSelector.clearSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP));
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isEqualTo(expectedTrackSelection[0]);
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {true, true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that an override is not applied for a different set of available track groups
 * when there is no-sample renderer.
 */
@Test
public void testSelectTracksWithNoSampleRendererWithNullOverrideForDifferentTracks()
    throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER,
      new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP, VIDEO_TRACK_GROUP));
  assertThat(result.selections.get(0)).isEqualTo(expectedTrackSelection[0]);
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {true, true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that disabling another renderer works when there is no-sample renderer.
 */
@Test
public void testSelectTracksDisablingNormalRendererWithNoSampleRenderer()
    throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  trackSelector.setRendererDisabled(0, true);
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isNull();
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {false, true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {null, DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that disabling no-sample renderer work.
 */
@Test
public void testSelectTracksDisablingNoSampleRenderer()
    throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  trackSelector.setRendererDisabled(2, true);
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isEqualTo(expectedTrackSelection[0]);
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {true, true, false}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT, null})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests the result of {@link MappingTrackSelector#selectTracks(RendererCapabilities[],
 * TrackGroupArray[], int[][][])} is propagated correctly to the result of
 * {@link MappingTrackSelector#selectTracks(RendererCapabilities[], TrackGroupArray)}.
 */
@Test
public void testSelectTracks() throws ExoPlaybackException {
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(
      TRACK_SELECTIONS);
  TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isEqualTo(TRACK_SELECTIONS[0]);
  assertThat(result.selections.get(1)).isEqualTo(TRACK_SELECTIONS[1]);
  assertThat(new boolean[] {true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that a null override clears a track selection.
 */
@Test
public void testSelectTracksWithNullOverride() throws ExoPlaybackException {
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(
      TRACK_SELECTIONS);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isNull();
  assertThat(result.selections.get(1)).isEqualTo(TRACK_SELECTIONS[1]);
  assertThat(new boolean[] {false, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {null, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that a null override can be cleared.
 */
@Test
public void testSelectTracksWithClearedNullOverride() throws ExoPlaybackException {
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(
      TRACK_SELECTIONS);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  trackSelector.clearSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP));
  TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isEqualTo(TRACK_SELECTIONS[0]);
  assertThat(result.selections.get(1)).isEqualTo(TRACK_SELECTIONS[1]);
  assertThat(new boolean[] {true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that an override is not applied for a different set of available track groups.
 */
@Test
public void testSelectTracksWithNullOverrideForDifferentTracks() throws ExoPlaybackException {
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(
      TRACK_SELECTIONS);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES,
      new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP, VIDEO_TRACK_GROUP));
  assertThat(result.selections.get(0)).isEqualTo(TRACK_SELECTIONS[0]);
  assertThat(result.selections.get(1)).isEqualTo(TRACK_SELECTIONS[1]);
  assertThat(new boolean[] {true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests the result of {@link MappingTrackSelector#selectTracks(RendererCapabilities[],
 * TrackGroupArray[], int[][][])} is propagated correctly to the result of
 * {@link MappingTrackSelector#selectTracks(RendererCapabilities[], TrackGroupArray)}
 * when there is no-sample renderer.
 */
@Test
public void testSelectTracksWithNoSampleRenderer() throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isEqualTo(expectedTrackSelection[0]);
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {true, true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {DEFAULT, DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:MappingTrackSelectorTest.java   
/**
 * Tests that a null override clears a track selection when there is no-sample renderer.
 */
@Test
public void testSelectTracksWithNoSampleRendererWithNullOverride() throws ExoPlaybackException {
  TrackSelection[] expectedTrackSelection = TRACK_SELECTIONS_WITH_NO_SAMPLE_RENDERER;
  FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector(expectedTrackSelection);
  trackSelector.setSelectionOverride(0, new TrackGroupArray(VIDEO_TRACK_GROUP), null);
  TrackSelectorResult result = trackSelector.selectTracks(
      RENDERER_CAPABILITIES_WITH_NO_SAMPLE_RENDERER, TRACK_GROUPS);
  assertThat(result.selections.get(0)).isNull();
  assertThat(result.selections.get(1)).isEqualTo(expectedTrackSelection[1]);
  assertThat(result.selections.get(2)).isNull();
  assertThat(new boolean[] {false, true, true}).isEqualTo(result.renderersEnabled);
  assertThat(new RendererConfiguration[] {null, DEFAULT, DEFAULT})
      .isEqualTo(result.rendererConfigurations);
}
项目:transistor    文件:SimpleDecoderAudioRendererTest.java   
@Test
public void testImmediatelyReadEndOfStreamPlaysAudioSinkToEndOfStream() throws Exception {
  audioRenderer.enable(RendererConfiguration.DEFAULT, new Format[] {FORMAT},
      new FakeSampleStream(FORMAT), 0, false, 0);
  audioRenderer.setCurrentStreamFinal();
  when(mockAudioSink.isEnded()).thenReturn(true);
  while (!audioRenderer.isEnded()) {
    audioRenderer.render(0, 0);
  }
  verify(mockAudioSink, times(1)).playToEndOfStream();
  audioRenderer.disable();
  verify(mockAudioSink, times(1)).release();
}
项目:Exoplayer2Radio    文件:MappingTrackSelector.java   
/**
 * 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;
  }
}
项目:K-Sonic    文件:MappingTrackSelector.java   
/**
 * 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;
  }
}
项目:transistor    文件:MappingTrackSelector.java   
/**
 * 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;
  }
}
项目:Exoplayer2Radio    文件:TrackSelectorResult.java   
/**
 * @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;
}
项目:K-Sonic    文件:TrackSelectorResult.java   
/**
 * @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;
}
项目:transistor    文件:TrackSelectorResult.java   
/**
 * @param groups The track groups provided to the {@link TrackSelector}.
 * @param renderersEnabled An array containing whether each renderer is enabled after the track
 *     selection operation.
 * @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.
 * @param rendererConfigurations A {@link RendererConfiguration} for each enabled renderer,
 *     to be used with the selections.
 */
public TrackSelectorResult(TrackGroupArray groups, boolean[] renderersEnabled,
    TrackSelectionArray selections, Object info,
    RendererConfiguration[] rendererConfigurations) {
  this.groups = groups;
  this.renderersEnabled = renderersEnabled;
  this.selections = selections;
  this.info = info;
  this.rendererConfigurations = rendererConfigurations;
}