org.checkerframework.checker.nullness.compatqual.NullableType Java Examples

The following examples show how to use org.checkerframework.checker.nullness.compatqual.NullableType. 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: SingleSampleMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public long selectTracks(
    @NullableType TrackSelection[] selections,
    boolean[] mayRetainStreamFlags,
    @NullableType SampleStream[] streams,
    boolean[] streamResetFlags,
    long positionUs) {
  for (int i = 0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      sampleStreams.remove(streams[i]);
      streams[i] = null;
    }
    if (streams[i] == null && selections[i] != null) {
      SampleStreamImpl stream = new SampleStreamImpl();
      sampleStreams.add(stream);
      streams[i] = stream;
      streamResetFlags[i] = true;
    }
  }
  return positionUs;
}
 
Example #2
Source File: AdPlaybackState.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a new instance with the specified ad set to the specified {@code state}. The ad
 * specified must currently either be in {@link #AD_STATE_UNAVAILABLE} or {@link
 * #AD_STATE_AVAILABLE}.
 *
 * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the
 * ad count specified later. Otherwise, {@code index} must be less than the current ad count.
 */
@CheckResult
public AdGroup withAdState(@AdState int state, int index) {
  Assertions.checkArgument(count == C.LENGTH_UNSET || index < count);
  @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1);
  Assertions.checkArgument(
      states[index] == AD_STATE_UNAVAILABLE
          || states[index] == AD_STATE_AVAILABLE
          || states[index] == state);
  long[] durationsUs =
      this.durationsUs.length == states.length
          ? this.durationsUs
          : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length);
  @NullableType
  Uri[] uris =
      this.uris.length == states.length ? this.uris : Arrays.copyOf(this.uris, states.length);
  states[index] = state;
  return new AdGroup(count, states, uris, durationsUs);
}
 
Example #3
Source File: TrackSelectionUtil.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates track selections for an array of track selection definitions, with at most one
 * multi-track adaptive selection.
 *
 * @param definitions The list of track selection {@link Definition definitions}. May include null
 *     values.
 * @param adaptiveTrackSelectionFactory A factory for the multi-track adaptive track selection.
 * @return The array of created track selection. For null entries in {@code definitions} returns
 *     null values.
 */
public static @NullableType TrackSelection[] createTrackSelectionsForDefinitions(
    @NullableType Definition[] definitions,
    AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory) {
  TrackSelection[] selections = new TrackSelection[definitions.length];
  boolean createdAdaptiveTrackSelection = false;
  for (int i = 0; i < definitions.length; i++) {
    Definition definition = definitions[i];
    if (definition == null) {
      continue;
    }
    if (definition.tracks.length > 1 && !createdAdaptiveTrackSelection) {
      createdAdaptiveTrackSelection = true;
      selections[i] = adaptiveTrackSelectionFactory.createAdaptiveTrackSelection(definition);
    } else {
      selections[i] =
          new FixedTrackSelection(
              definition.group, definition.tracks[0], definition.reason, definition.data);
    }
  }
  return selections;
}
 
Example #4
Source File: ClippingMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static boolean shouldKeepInitialDiscontinuity(
    long startUs, @NullableType TrackSelection[] selections) {
  // If the clipping start position is non-zero, the clipping sample streams will adjust
  // timestamps on buffers they read from the unclipped sample streams. These adjusted buffer
  // timestamps can be negative, because sample streams provide buffers starting at a key-frame,
  // which may be before the clipping start point. When the renderer reads a buffer with a
  // negative timestamp, its offset timestamp can jump backwards compared to the last timestamp
  // read in the previous period. Renderer implementations may not allow this, so we signal a
  // discontinuity which resets the renderers before they read the clipping sample stream.
  // However, for audio-only track selections we assume to have random access seek behaviour and
  // do not need an initial discontinuity to reset the renderer.
  if (startUs != 0) {
    for (TrackSelection trackSelection : selections) {
      if (trackSelection != null) {
        Format selectedFormat = trackSelection.getSelectedFormat();
        if (!MimeTypes.isAudio(selectedFormat.sampleMimeType)) {
          return true;
        }
      }
    }
  }
  return false;
}
 
Example #5
Source File: TrackSelectionUtil.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Creates track selections for an array of track selection definitions, with at most one
 * multi-track adaptive selection.
 *
 * @param definitions The list of track selection {@link Definition definitions}. May include null
 *     values.
 * @param adaptiveTrackSelectionFactory A factory for the multi-track adaptive track selection.
 * @return The array of created track selection. For null entries in {@code definitions} returns
 *     null values.
 */
public static @NullableType TrackSelection[] createTrackSelectionsForDefinitions(
    @NullableType Definition[] definitions,
    AdaptiveTrackSelectionFactory adaptiveTrackSelectionFactory) {
  TrackSelection[] selections = new TrackSelection[definitions.length];
  boolean createdAdaptiveTrackSelection = false;
  for (int i = 0; i < definitions.length; i++) {
    Definition definition = definitions[i];
    if (definition == null) {
      continue;
    }
    if (definition.tracks.length > 1 && !createdAdaptiveTrackSelection) {
      createdAdaptiveTrackSelection = true;
      selections[i] = adaptiveTrackSelectionFactory.createAdaptiveTrackSelection(definition);
    } else {
      selections[i] =
          new FixedTrackSelection(
              definition.group, definition.tracks[0], definition.reason, definition.data);
    }
  }
  return selections;
}
 
Example #6
Source File: SilenceMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long selectTracks(
    @NullableType TrackSelection[] selections,
    boolean[] mayRetainStreamFlags,
    @NullableType SampleStream[] streams,
    boolean[] streamResetFlags,
    long positionUs) {
  positionUs = constrainSeekPosition(positionUs);
  for (int i = 0; i < selections.length; i++) {
    if (streams[i] != null && (selections[i] == null || !mayRetainStreamFlags[i])) {
      sampleStreams.remove(streams[i]);
      streams[i] = null;
    }
    if (streams[i] == null && selections[i] != null) {
      SilenceSampleStream stream = new SilenceSampleStream(durationUs);
      stream.seekTo(positionUs);
      sampleStreams.add(stream);
      streams[i] = stream;
      streamResetFlags[i] = true;
    }
  }
  return positionUs;
}
 
Example #7
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static boolean areSelectionOverridesEqual(
    Map<TrackGroupArray, @NullableType SelectionOverride> first,
    Map<TrackGroupArray, @NullableType SelectionOverride> second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  for (Map.Entry<TrackGroupArray, @NullableType SelectionOverride> firstEntry :
      first.entrySet()) {
    TrackGroupArray key = firstEntry.getKey();
    if (!second.containsKey(key) || !Util.areEqual(firstEntry.getValue(), second.get(key))) {
      return false;
    }
  }
  return true;
}
 
Example #8
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>>
    readSelectionOverrides(Parcel in) {
  int renderersWithOverridesCount = in.readInt();
  SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides =
      new SparseArray<>(renderersWithOverridesCount);
  for (int i = 0; i < renderersWithOverridesCount; i++) {
    int rendererIndex = in.readInt();
    int overrideCount = in.readInt();
    Map<TrackGroupArray, @NullableType SelectionOverride> overrides =
        new HashMap<>(overrideCount);
    for (int j = 0; j < overrideCount; j++) {
      TrackGroupArray trackGroups =
          Assertions.checkNotNull(in.readParcelable(TrackGroupArray.class.getClassLoader()));
      @Nullable
      SelectionOverride override = in.readParcelable(SelectionOverride.class.getClassLoader());
      overrides.put(trackGroups, override);
    }
    selectionOverrides.put(rendererIndex, overrides);
  }
  return selectionOverrides;
}
 
Example #9
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static void writeSelectionOverridesToParcel(
    Parcel dest,
    SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides) {
  int renderersWithOverridesCount = selectionOverrides.size();
  dest.writeInt(renderersWithOverridesCount);
  for (int i = 0; i < renderersWithOverridesCount; i++) {
    int rendererIndex = selectionOverrides.keyAt(i);
    Map<TrackGroupArray, @NullableType SelectionOverride> overrides =
        selectionOverrides.valueAt(i);
    int overrideCount = overrides.size();
    dest.writeInt(rendererIndex);
    dest.writeInt(overrideCount);
    for (Map.Entry<TrackGroupArray, @NullableType SelectionOverride> override :
        overrides.entrySet()) {
      dest.writeParcelable(override.getKey(), /* parcelableFlags= */ 0);
      dest.writeParcelable(override.getValue(), /* parcelableFlags= */ 0);
    }
  }
}
 
Example #10
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static boolean areSelectionOverridesEqual(
    SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> first,
    SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> second) {
  int firstSize = first.size();
  if (second.size() != firstSize) {
    return false;
  }
  for (int indexInFirst = 0; indexInFirst < firstSize; indexInFirst++) {
    int indexInSecond = second.indexOfKey(first.keyAt(indexInFirst));
    if (indexInSecond < 0
        || !areSelectionOverridesEqual(
            first.valueAt(indexInFirst), second.valueAt(indexInSecond))) {
      return false;
    }
  }
  return true;
}
 
Example #11
Source File: ClippingMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long selectTracks(
    @NullableType TrackSelection[] selections,
    boolean[] mayRetainStreamFlags,
    @NullableType SampleStream[] streams,
    boolean[] streamResetFlags,
    long positionUs) {
  sampleStreams = new ClippingSampleStream[streams.length];
  @NullableType SampleStream[] childStreams = new SampleStream[streams.length];
  for (int i = 0; i < streams.length; i++) {
    sampleStreams[i] = (ClippingSampleStream) streams[i];
    childStreams[i] = sampleStreams[i] != null ? sampleStreams[i].childStream : null;
  }
  long enablePositionUs =
      mediaPeriod.selectTracks(
          selections, mayRetainStreamFlags, childStreams, streamResetFlags, positionUs);
  pendingInitialDiscontinuityPositionUs =
      isPendingInitialDiscontinuity()
              && positionUs == startUs
              && shouldKeepInitialDiscontinuity(startUs, selections)
          ? enablePositionUs
          : C.TIME_UNSET;
  Assertions.checkState(
      enablePositionUs == positionUs
          || (enablePositionUs >= startUs
              && (endUs == C.TIME_END_OF_SOURCE || enablePositionUs <= endUs)));
  for (int i = 0; i < streams.length; i++) {
    if (childStreams[i] == null) {
      sampleStreams[i] = null;
    } else if (sampleStreams[i] == null || sampleStreams[i].childStream != childStreams[i]) {
      sampleStreams[i] = new ClippingSampleStream(childStreams[i]);
    }
    streams[i] = sampleStreams[i];
  }
  return enablePositionUs;
}
 
Example #12
Source File: AdPlaybackState.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a new instance with the specified {@code uri} set for the specified ad, and the ad
 * marked as {@link #AD_STATE_AVAILABLE}. The specified ad must currently be in {@link
 * #AD_STATE_UNAVAILABLE}, which is the default state.
 *
 * <p>This instance's ad count may be unknown, in which case {@code index} must be less than the
 * ad count specified later. Otherwise, {@code index} must be less than the current ad count.
 */
@CheckResult
public AdGroup withAdUri(Uri uri, int index) {
  Assertions.checkArgument(count == C.LENGTH_UNSET || index < count);
  @AdState int[] states = copyStatesWithSpaceForAdCount(this.states, index + 1);
  Assertions.checkArgument(states[index] == AD_STATE_UNAVAILABLE);
  long[] durationsUs =
      this.durationsUs.length == states.length
          ? this.durationsUs
          : copyDurationsUsWithSpaceForAdCount(this.durationsUs, states.length);
  @NullableType Uri[] uris = Arrays.copyOf(this.uris, states.length);
  uris[index] = uri;
  states[index] = AD_STATE_AVAILABLE;
  return new AdGroup(count, states, uris, durationsUs);
}
 
Example #13
Source File: AdPlaybackState.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private AdGroup(
    int count, @AdState int[] states, @NullableType Uri[] uris, long[] durationsUs) {
  Assertions.checkArgument(states.length == uris.length);
  this.count = count;
  this.states = states;
  this.uris = uris;
  this.durationsUs = durationsUs;
}
 
Example #14
Source File: CachedContentIndex.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void load(
    HashMap<String, CachedContent> content, SparseArray<@NullableType String> idToKey) {
  Assertions.checkState(!changed);
  if (!readFile(content, idToKey)) {
    content.clear();
    idToKey.clear();
    atomicFile.delete();
  }
}
 
Example #15
Source File: MaskingMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long selectTracks(
    @NullableType TrackSelection[] selections,
    boolean[] mayRetainStreamFlags,
    @NullableType SampleStream[] streams,
    boolean[] streamResetFlags,
    long positionUs) {
  if (preparePositionOverrideUs != C.TIME_UNSET && positionUs == preparePositionUs) {
    positionUs = preparePositionOverrideUs;
    preparePositionOverrideUs = C.TIME_UNSET;
  }
  return castNonNull(mediaPeriod)
      .selectTracks(selections, mayRetainStreamFlags, streams, streamResetFlags, positionUs);
}
 
Example #16
Source File: HlsSampleStreamWrapper.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void updateSampleStreams(@NullableType SampleStream[] streams) {
  hlsSampleStreams.clear();
  for (SampleStream stream : streams) {
    if (stream != null) {
      hlsSampleStreams.add((HlsSampleStream) stream);
    }
  }
}
 
Example #17
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Clears a track selection override for the specified renderer and {@link TrackGroupArray}.
 *
 * @param rendererIndex The renderer index.
 * @param groups The {@link TrackGroupArray} for which the override should be cleared.
 * @return This builder.
 */
public final ParametersBuilder clearSelectionOverride(
    int rendererIndex, TrackGroupArray groups) {
  Map<TrackGroupArray, @NullableType SelectionOverride> overrides =
      selectionOverrides.get(rendererIndex);
  if (overrides == null || !overrides.containsKey(groups)) {
    // Nothing to clear.
    return this;
  }
  overrides.remove(groups);
  if (overrides.isEmpty()) {
    selectionOverrides.remove(rendererIndex);
  }
  return this;
}
 
Example #18
Source File: RandomTrackSelection.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public @NullableType TrackSelection[] createTrackSelections(
    @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
  return TrackSelectionUtil.createTrackSelectionsForDefinitions(
      definitions,
      definition -> new RandomTrackSelection(definition.group, definition.tracks, random));
}
 
Example #19
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>>
    cloneSelectionOverrides(
        SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> selectionOverrides) {
  SparseArray<Map<TrackGroupArray, @NullableType SelectionOverride>> clone =
      new SparseArray<>();
  for (int i = 0; i < selectionOverrides.size(); i++) {
    clone.put(selectionOverrides.keyAt(i), new HashMap<>(selectionOverrides.valueAt(i)));
  }
  return clone;
}
 
Example #20
Source File: MediaPeriodHolder.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the dummy {@link
 * EmptySampleStream} that was associated with it.
 */
private void disassociateNoSampleRenderersWithEmptySampleStream(
    @NullableType SampleStream[] sampleStreams) {
  for (int i = 0; i < rendererCapabilities.length; i++) {
    if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE) {
      sampleStreams[i] = null;
    }
  }
}
 
Example #21
Source File: DownloadHelper.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public @NullableType TrackSelection[] createTrackSelections(
    @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
  @NullableType TrackSelection[] selections = new TrackSelection[definitions.length];
  for (int i = 0; i < definitions.length; i++) {
    selections[i] =
        definitions[i] == null
            ? null
            : new DownloadTrackSelection(definitions[i].group, definitions[i].tracks);
  }
  return selections;
}
 
Example #22
Source File: DownloadHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public @NullableType TrackSelection[] createTrackSelections(
    @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
  @NullableType TrackSelection[] selections = new TrackSelection[definitions.length];
  for (int i = 0; i < definitions.length; i++) {
    selections[i] =
        definitions[i] == null
            ? null
            : new DownloadTrackSelection(definitions[i].group, definitions[i].tracks);
  }
  return selections;
}
 
Example #23
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static int[] getAdaptiveVideoTracksForGroup(TrackGroup group, int[] formatSupport,
    boolean allowMixedMimeTypes, int requiredAdaptiveSupport, int maxVideoWidth,
    int maxVideoHeight, int maxVideoBitrate, int viewportWidth, int viewportHeight,
    boolean viewportOrientationMayChange) {
  if (group.length < 2) {
    return NO_TRACKS;
  }

  List<Integer> selectedTrackIndices = getViewportFilteredTrackIndices(group, viewportWidth,
      viewportHeight, viewportOrientationMayChange);
  if (selectedTrackIndices.size() < 2) {
    return NO_TRACKS;
  }

  String selectedMimeType = null;
  if (!allowMixedMimeTypes) {
    // Select the mime type for which we have the most adaptive tracks.
    HashSet<@NullableType String> seenMimeTypes = new HashSet<>();
    int selectedMimeTypeTrackCount = 0;
    for (int i = 0; i < selectedTrackIndices.size(); i++) {
      int trackIndex = selectedTrackIndices.get(i);
      String sampleMimeType = group.getFormat(trackIndex).sampleMimeType;
      if (seenMimeTypes.add(sampleMimeType)) {
        int countForMimeType = getAdaptiveVideoTrackCountForMimeType(group, formatSupport,
            requiredAdaptiveSupport, sampleMimeType, maxVideoWidth, maxVideoHeight,
            maxVideoBitrate, selectedTrackIndices);
        if (countForMimeType > selectedMimeTypeTrackCount) {
          selectedMimeType = sampleMimeType;
          selectedMimeTypeTrackCount = countForMimeType;
        }
      }
    }
  }

  // Filter by the selected mime type.
  filterAdaptiveVideoTrackCountForMimeType(group, formatSupport, requiredAdaptiveSupport,
      selectedMimeType, maxVideoWidth, maxVideoHeight, maxVideoBitrate, selectedTrackIndices);

  return selectedTrackIndices.size() < 2 ? NO_TRACKS : Util.toArray(selectedTrackIndices);
}
 
Example #24
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 #25
Source File: DefaultTrackSelector.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static int[] getAdaptiveVideoTracksForGroup(TrackGroup group, int[] formatSupport,
    boolean allowMixedMimeTypes, int requiredAdaptiveSupport, int maxVideoWidth,
    int maxVideoHeight, int maxVideoBitrate, int viewportWidth, int viewportHeight,
    boolean viewportOrientationMayChange) {
  if (group.length < 2) {
    return NO_TRACKS;
  }

  List<Integer> selectedTrackIndices = getViewportFilteredTrackIndices(group, viewportWidth,
      viewportHeight, viewportOrientationMayChange);
  if (selectedTrackIndices.size() < 2) {
    return NO_TRACKS;
  }

  String selectedMimeType = null;
  if (!allowMixedMimeTypes) {
    // Select the mime type for which we have the most adaptive tracks.
    HashSet<@NullableType String> seenMimeTypes = new HashSet<>();
    int selectedMimeTypeTrackCount = 0;
    for (int i = 0; i < selectedTrackIndices.size(); i++) {
      int trackIndex = selectedTrackIndices.get(i);
      String sampleMimeType = group.getFormat(trackIndex).sampleMimeType;
      if (seenMimeTypes.add(sampleMimeType)) {
        int countForMimeType = getAdaptiveVideoTrackCountForMimeType(group, formatSupport,
            requiredAdaptiveSupport, sampleMimeType, maxVideoWidth, maxVideoHeight,
            maxVideoBitrate, selectedTrackIndices);
        if (countForMimeType > selectedMimeTypeTrackCount) {
          selectedMimeType = sampleMimeType;
          selectedMimeTypeTrackCount = countForMimeType;
        }
      }
    }
  }

  // Filter by the selected mime type.
  filterAdaptiveVideoTrackCountForMimeType(group, formatSupport, requiredAdaptiveSupport,
      selectedMimeType, maxVideoWidth, maxVideoHeight, maxVideoBitrate, selectedTrackIndices);

  return selectedTrackIndices.size() < 2 ? NO_TRACKS : Util.toArray(selectedTrackIndices);
}
 
Example #26
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 #27
Source File: ApkUtils.java    From android-arscblamer with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a file whose name matches {@code filename}, or null if no file was found.
 *
 * @param apkFile The file containing the apk zip archive.
 * @param filename The full filename (e.g. res/raw/foo.bar).
 * @return A byte array containing the contents of the matching file, or null if not found.
 * @throws IOException Thrown if there's a matching file, but it cannot be read from the apk.
 */
public static byte @NullableType [] getFile(File apkFile, String filename) throws IOException {
  try (ZipFile apkZip = new ZipFile(apkFile)) {
    ZipEntry zipEntry = apkZip.getEntry(filename);
    if (zipEntry == null) {
      return null;
    }
    try (InputStream in = apkZip.getInputStream(zipEntry)) {
      return ByteStreams.toByteArray(in);
    }
  }
}
 
Example #28
Source File: MediaPeriodHolder.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For each renderer of type {@link C#TRACK_TYPE_NONE}, we will remove the dummy {@link
 * EmptySampleStream} that was associated with it.
 */
private void disassociateNoSampleRenderersWithEmptySampleStream(
    @NullableType SampleStream[] sampleStreams) {
  for (int i = 0; i < rendererCapabilities.length; i++) {
    if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE) {
      sampleStreams[i] = null;
    }
  }
}
 
Example #29
Source File: FixedTrackSelection.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public @NullableType TrackSelection[] createTrackSelections(
    @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
  return TrackSelectionUtil.createTrackSelectionsForDefinitions(
      definitions,
      definition ->
          new FixedTrackSelection(definition.group, definition.tracks[0], reason, data));
}
 
Example #30
Source File: RandomTrackSelection.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public @NullableType TrackSelection[] createTrackSelections(
    @NullableType Definition[] definitions, BandwidthMeter bandwidthMeter) {
  return TrackSelectionUtil.createTrackSelectionsForDefinitions(
      definitions,
      definition -> new RandomTrackSelection(definition.group, definition.tracks, random));
}