use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.
the class SsMediaPeriodTest method getSteamKeys_isCompatibleWithSsManifestFilter.
@Test
public void getSteamKeys_isCompatibleWithSsManifestFilter() {
SsManifest testManifest = createSsManifest(createStreamElement(/* name= */
"video", C.TRACK_TYPE_VIDEO, createVideoFormat(/* bitrate= */
200000), createVideoFormat(/* bitrate= */
400000), createVideoFormat(/* bitrate= */
800000)), createStreamElement(/* name= */
"audio", C.TRACK_TYPE_AUDIO, createAudioFormat(/* bitrate= */
48000), createAudioFormat(/* bitrate= */
96000)), createStreamElement(/* name= */
"text", C.TRACK_TYPE_TEXT, createTextFormat(/* language= */
"eng")));
FilterableManifestMediaPeriodFactory<SsManifest> mediaPeriodFactory = (manifest, periodIndex) -> {
MediaPeriodId mediaPeriodId = new MediaPeriodId(/* periodUid= */
new Object());
return new SsMediaPeriod(manifest, mock(SsChunkSource.Factory.class), mock(TransferListener.class), mock(CompositeSequenceableLoaderFactory.class), mock(DrmSessionManager.class), new DrmSessionEventListener.EventDispatcher().withParameters(/* windowIndex= */
0, mediaPeriodId), mock(LoadErrorHandlingPolicy.class), new MediaSourceEventListener.EventDispatcher().withParameters(/* windowIndex= */
0, mediaPeriodId, /* mediaTimeOffsetMs= */
0), mock(LoaderErrorThrower.class), mock(Allocator.class));
};
MediaPeriodAsserts.assertGetStreamKeysAndManifestFilterIntegration(mediaPeriodFactory, testManifest);
}
use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.
the class SsManifest method copy.
@Override
public final SsManifest copy(List<StreamKey> streamKeys) {
ArrayList<StreamKey> sortedKeys = new ArrayList<>(streamKeys);
Collections.sort(sortedKeys);
StreamElement currentStreamElement = null;
List<StreamElement> copiedStreamElements = new ArrayList<>();
List<Format> copiedFormats = new ArrayList<>();
for (int i = 0; i < sortedKeys.size(); i++) {
StreamKey key = sortedKeys.get(i);
StreamElement streamElement = streamElements[key.groupIndex];
if (streamElement != currentStreamElement && currentStreamElement != null) {
// We're advancing to a new stream element. Add the current one.
copiedStreamElements.add(currentStreamElement.copy(copiedFormats.toArray(new Format[0])));
copiedFormats.clear();
}
currentStreamElement = streamElement;
copiedFormats.add(streamElement.formats[key.streamIndex]);
}
if (currentStreamElement != null) {
// Add the last stream element.
copiedStreamElements.add(currentStreamElement.copy(copiedFormats.toArray(new Format[0])));
}
StreamElement[] copiedStreamElementsArray = copiedStreamElements.toArray(new StreamElement[0]);
return new SsManifest(majorVersion, minorVersion, durationUs, dvrWindowLengthUs, lookAheadCount, isLive, protectionElement, copiedStreamElementsArray);
}
use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.
the class SsManifestTest method assertManifestEquals.
private static void assertManifestEquals(SsManifest expected, SsManifest actual) {
assertThat(actual.durationUs).isEqualTo(expected.durationUs);
assertThat(actual.dvrWindowLengthUs).isEqualTo(expected.dvrWindowLengthUs);
assertThat(actual.isLive).isEqualTo(expected.isLive);
assertThat(actual.lookAheadCount).isEqualTo(expected.lookAheadCount);
assertThat(actual.majorVersion).isEqualTo(expected.majorVersion);
assertThat(actual.minorVersion).isEqualTo(expected.minorVersion);
assertThat(actual.protectionElement.uuid).isEqualTo(expected.protectionElement.uuid);
assertThat(actual.protectionElement).isEqualTo(expected.protectionElement);
for (int i = 0; i < expected.streamElements.length; i++) {
StreamElement expectedStreamElement = expected.streamElements[i];
StreamElement actualStreamElement = actual.streamElements[i];
assertThat(actualStreamElement.chunkCount).isEqualTo(expectedStreamElement.chunkCount);
assertThat(actualStreamElement.displayHeight).isEqualTo(expectedStreamElement.displayHeight);
assertThat(actualStreamElement.displayWidth).isEqualTo(expectedStreamElement.displayWidth);
assertThat(actualStreamElement.language).isEqualTo(expectedStreamElement.language);
assertThat(actualStreamElement.maxHeight).isEqualTo(expectedStreamElement.maxHeight);
assertThat(actualStreamElement.maxWidth).isEqualTo(expectedStreamElement.maxWidth);
assertThat(actualStreamElement.name).isEqualTo(expectedStreamElement.name);
assertThat(actualStreamElement.subType).isEqualTo(expectedStreamElement.subType);
assertThat(actualStreamElement.timescale).isEqualTo(expectedStreamElement.timescale);
assertThat(actualStreamElement.type).isEqualTo(expectedStreamElement.type);
assertThat(actualStreamElement.formats).isEqualTo(expectedStreamElement.formats);
}
}
use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.
the class SsManifestTest method copyRemoveStreamElement.
@Test
public void copyRemoveStreamElement() throws Exception {
Format[][] formats = newFormats(2, 3);
SsManifest sourceManifest = createSsManifest(createStreamElement("1", formats[0]), createStreamElement("2", formats[1]));
List<StreamKey> keys = Collections.singletonList(new StreamKey(1, 0));
SsManifest copyManifest = sourceManifest.copy(keys);
SsManifest expectedManifest = createSsManifest(createStreamElement("2", formats[1][0]));
assertManifestEquals(expectedManifest, copyManifest);
}
use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.
the class SsMediaSource method onLoadError.
@Override
public LoadErrorAction onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
MediaLoadData mediaLoadData = new MediaLoadData(loadable.type);
long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
false, retryDelayMs);
boolean wasCanceled = !loadErrorAction.isRetry();
manifestEventDispatcher.loadError(loadEventInfo, loadable.type, error, wasCanceled);
if (wasCanceled) {
loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
}
return loadErrorAction;
}
Aggregations