use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.
the class SsMediaPeriod method buildTrackGroups.
private static TrackGroupArray buildTrackGroups(SsManifest manifest, DrmSessionManager drmSessionManager) {
TrackGroup[] trackGroups = new TrackGroup[manifest.streamElements.length];
for (int i = 0; i < manifest.streamElements.length; i++) {
Format[] manifestFormats = manifest.streamElements[i].formats;
Format[] exposedFormats = new Format[manifestFormats.length];
for (int j = 0; j < manifestFormats.length; j++) {
Format manifestFormat = manifestFormats[j];
exposedFormats[j] = manifestFormat.copyWithCryptoType(drmSessionManager.getCryptoType(manifestFormat));
}
trackGroups[i] = new TrackGroup(/* id= */
Integer.toString(i), exposedFormats);
}
return new TrackGroupArray(trackGroups);
}
use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.
the class SsMediaSource method startLoadingManifest.
private void startLoadingManifest() {
if (manifestLoader.hasFatalError()) {
return;
}
ParsingLoadable<SsManifest> loadable = new ParsingLoadable<>(manifestDataSource, manifestUri, C.DATA_TYPE_MANIFEST, manifestParser);
long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type));
manifestEventDispatcher.loadStarted(new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs), loadable.type);
}
use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.
the class SsMediaSource method onLoadCanceled.
@Override
public void onLoadCanceled(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) {
LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
manifestEventDispatcher.loadCanceled(loadEventInfo, loadable.type);
}
use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.
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 androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.
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);
}
Aggregations