use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.
the class MappingTrackSelector method buildTracksInfo.
@VisibleForTesting
static /* package */
TracksInfo buildTracksInfo(@NullableType TrackSelection[] selections, MappedTrackInfo mappedTrackInfo) {
ImmutableList.Builder<TracksInfo.TrackGroupInfo> builder = new ImmutableList.Builder<>();
for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) {
TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(rendererIndex);
@Nullable TrackSelection trackSelection = selections[rendererIndex];
for (int groupIndex = 0; groupIndex < trackGroupArray.length; groupIndex++) {
TrackGroup trackGroup = trackGroupArray.get(groupIndex);
@C.FormatSupport int[] trackSupport = new int[trackGroup.length];
boolean[] selected = new boolean[trackGroup.length];
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
trackSupport[trackIndex] = mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex);
boolean isTrackSelected = trackSelection != null && trackSelection.getTrackGroup().equals(trackGroup) && trackSelection.indexOf(trackIndex) != C.INDEX_UNSET;
selected[trackIndex] = isTrackSelected;
}
@C.TrackType int trackGroupType = mappedTrackInfo.getRendererType(rendererIndex);
builder.add(new TracksInfo.TrackGroupInfo(trackGroup, trackSupport, trackGroupType, selected));
}
}
TrackGroupArray unmappedTrackGroups = mappedTrackInfo.getUnmappedTrackGroups();
for (int groupIndex = 0; groupIndex < unmappedTrackGroups.length; groupIndex++) {
TrackGroup trackGroup = unmappedTrackGroups.get(groupIndex);
@C.FormatSupport int[] trackSupport = new int[trackGroup.length];
Arrays.fill(trackSupport, C.FORMAT_UNSUPPORTED_TYPE);
// A track group only contains tracks of the same type, thus only consider the first track.
@C.TrackType int trackGroupType = MimeTypes.getTrackType(trackGroup.getFormat(0).sampleMimeType);
// Initialized to false.
boolean[] selected = new boolean[trackGroup.length];
builder.add(new TracksInfo.TrackGroupInfo(trackGroup, trackSupport, trackGroupType, selected));
}
return new TracksInfo(builder.build());
}
use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.
the class RtspTrackTiming method resolveUri.
/**
* Resolves the input string to always be an absolute URL with RTP-Info headers
*
* <p>Handles some servers do not send absolute URL in RTP-Info headers. This method takes in
* RTP-Info header's url string, and returns the correctly formatted {@link Uri url} for this
* track. The input url string could be
*
* <ul>
* <li>A correctly formatted URL, like "{@code rtsp://foo.bar/video}".
* <li>A correct URI that is missing the scheme, like "{@code foo.bar/video}".
* <li>A path to the resource, like "{@code video}" or "{@code /video}".
* </ul>
*
* @param urlString The URL included in the RTP-Info header, without the {@code url=} identifier.
* @param sessionUri The session URI, must include an {@code rtsp} scheme, or {@link
* IllegalArgumentException} is thrown.
* @return The formatted URL.
*/
@VisibleForTesting
static /* package */
Uri resolveUri(String urlString, Uri sessionUri) {
checkArgument(checkNotNull(sessionUri.getScheme()).equals("rtsp"));
Uri uri = Uri.parse(urlString);
if (uri.isAbsolute()) {
return uri;
}
// The urlString is at least missing the scheme.
uri = Uri.parse("rtsp://" + urlString);
String sessionUriString = sessionUri.toString();
String host = checkNotNull(uri.getHost());
if (host.equals(sessionUri.getHost())) {
// Handles the case that the urlString is only missing the scheme.
return uri;
}
return sessionUriString.endsWith("/") ? UriUtil.resolveToUri(sessionUriString, urlString) : UriUtil.resolveToUri(sessionUriString + "/", urlString);
}
use of androidx.annotation.VisibleForTesting in project ExoPlayer by google.
the class CachedContentIndex method getNewId.
/**
* Returns an id which isn't used in the given array. If the maximum id in the array is smaller
* than {@link java.lang.Integer#MAX_VALUE} it just returns the next bigger integer. Otherwise it
* returns the smallest unused non-negative integer.
*/
@VisibleForTesting
static /* package */
int getNewId(SparseArray<@NullableType String> idToKey) {
int size = idToKey.size();
int id = size == 0 ? 0 : (idToKey.keyAt(size - 1) + 1);
if (id < 0) {
// TODO optimization: defragmentation or binary search?
for (id = 0; id < size; id++) {
if (id != idToKey.keyAt(id)) {
break;
}
}
}
return id;
}
use of androidx.annotation.VisibleForTesting in project android-priority-jobqueue by yigit.
the class FrameworkScheduler method toPersistentBundle.
@VisibleForTesting
static PersistableBundle toPersistentBundle(SchedulerConstraint constraint) {
PersistableBundle bundle = new PersistableBundle();
// put boolean is api 22
bundle.putString(KEY_UUID, constraint.getUuid());
bundle.putInt(KEY_NETWORK_STATUS, constraint.getNetworkStatus());
bundle.putLong(KEY_DELAY, constraint.getDelayInMs());
Long deadline = constraint.getOverrideDeadlineInMs();
if (deadline != null) {
bundle.putLong(KEY_DEADLINE, deadline);
}
return bundle;
}
use of androidx.annotation.VisibleForTesting in project Signal-Android by WhisperSystems.
the class AttachmentDatabase method getDataStream.
@SuppressWarnings("WeakerAccess")
@VisibleForTesting
@Nullable
protected InputStream getDataStream(AttachmentId attachmentId, String dataType, long offset) {
DataInfo dataInfo = getAttachmentDataFileInfo(attachmentId, dataType);
if (dataInfo == null) {
return null;
}
try {
if (dataInfo.random != null && dataInfo.random.length == 32) {
return ModernDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.random, dataInfo.file, offset);
} else {
InputStream stream = ClassicDecryptingPartInputStream.createFor(attachmentSecret, dataInfo.file);
long skipped = stream.skip(offset);
if (skipped != offset) {
Log.w(TAG, "Skip failed: " + skipped + " vs " + offset);
return null;
}
return stream;
}
} catch (IOException e) {
Log.w(TAG, e);
return null;
}
}
Aggregations