com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder Java Examples
The following examples show how to use
com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder.
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: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ConcatenatedTimeline( Collection<MediaSourceHolder> mediaSourceHolders, int windowCount, int periodCount, ShuffleOrder shuffleOrder, boolean isAtomic) { super(isAtomic, shuffleOrder); this.windowCount = windowCount; this.periodCount = periodCount; int childCount = mediaSourceHolders.size(); firstPeriodInChildIndices = new int[childCount]; firstWindowInChildIndices = new int[childCount]; timelines = new Timeline[childCount]; uids = new Object[childCount]; childIndexByUid = new HashMap<>(); int index = 0; for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { timelines[index] = mediaSourceHolder.timeline; firstPeriodInChildIndices[index] = mediaSourceHolder.firstPeriodIndexInChild; firstWindowInChildIndices[index] = mediaSourceHolder.firstWindowIndexInChild; uids[index] = mediaSourceHolder.uid; childIndexByUid.put(uids[index], index++); } }
Example #2
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public final MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) { int mediaSourceHolderIndex = findMediaSourceHolderByPeriodIndex(id.periodIndex); MediaSourceHolder holder = mediaSourceHolders.get(mediaSourceHolderIndex); DeferredMediaPeriod mediaPeriod = new DeferredMediaPeriod(holder.mediaSource, id, allocator); mediaSourceByMediaPeriod.put(mediaPeriod, holder); holder.activeMediaPeriods.add(mediaPeriod); if (!holder.hasStartedPreparing) { holder.hasStartedPreparing = true; prepareChildSource(holder, holder.mediaSource); } else if (holder.isPrepared) { MediaPeriodId idInSource = id.copyWithPeriodIndex(id.periodIndex - holder.firstPeriodIndexInChild); mediaPeriod.createPeriod(idInSource); } return mediaPeriod; }
Example #3
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Adds a {@link MediaSource} to the playlist and executes a custom action on completion. * * @param index The index at which the new {@link MediaSource} will be inserted. This index must * be in the range of 0 <= index <= {@link #getSize()}. * @param mediaSource The {@link MediaSource} to be added to the list. * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media * source has been added to the playlist. */ public final synchronized void addMediaSource( int index, MediaSource mediaSource, @Nullable Runnable actionOnCompletion) { Assertions.checkNotNull(mediaSource); MediaSourceHolder mediaSourceHolder = new MediaSourceHolder(mediaSource); mediaSourcesPublic.add(index, mediaSourceHolder); if (player != null) { player .createMessage(this) .setType(MSG_ADD) .setPayload(new MessageData<>(index, mediaSourceHolder, actionOnCompletion)) .send(); } else if (actionOnCompletion != null) { actionOnCompletion.run(); } }
Example #4
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * @param isAtomic Whether the concatenating media source will be treated as atomic, i.e., treated * as a single item for repeating and shuffling. * @param useLazyPreparation Whether playlist items are prepared lazily. If false, all manifest * loads and other initial preparation steps happen immediately. If true, these initial * preparations are triggered only when the player starts buffering the media. * @param shuffleOrder The {@link ShuffleOrder} to use when shuffling the child media sources. * @param mediaSources The {@link MediaSource}s to concatenate. It is valid for the same {@link * MediaSource} instance to be present more than once in the array. */ @SuppressWarnings("initialization") public ConcatenatingMediaSource( boolean isAtomic, boolean useLazyPreparation, ShuffleOrder shuffleOrder, MediaSource... mediaSources) { for (MediaSource mediaSource : mediaSources) { Assertions.checkNotNull(mediaSource); } this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder; this.mediaSourceByMediaPeriod = new IdentityHashMap<>(); this.mediaSourcesPublic = new ArrayList<>(); this.mediaSourceHolders = new ArrayList<>(); this.pendingOnCompletionActions = new ArrayList<>(); this.query = new MediaSourceHolder(/* mediaSource= */ null); this.isAtomic = isAtomic; this.useLazyPreparation = useLazyPreparation; window = new Timeline.Window(); addMediaSources(Arrays.asList(mediaSources)); }
Example #5
Source File: ConcatenatingMediaSource.java From MediaSDK with Apache License 2.0 | 6 votes |
public ConcatenatedTimeline( Collection<MediaSourceHolder> mediaSourceHolders, ShuffleOrder shuffleOrder, boolean isAtomic) { super(isAtomic, shuffleOrder); int childCount = mediaSourceHolders.size(); firstPeriodInChildIndices = new int[childCount]; firstWindowInChildIndices = new int[childCount]; timelines = new Timeline[childCount]; uids = new Object[childCount]; childIndexByUid = new HashMap<>(); int index = 0; int windowCount = 0; int periodCount = 0; for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { timelines[index] = mediaSourceHolder.mediaSource.getTimeline(); firstWindowInChildIndices[index] = windowCount; firstPeriodInChildIndices[index] = periodCount; windowCount += timelines[index].getWindowCount(); periodCount += timelines[index].getPeriodCount(); uids[index] = mediaSourceHolder.uid; childIndexByUid.put(uids[index], index++); } this.windowCount = windowCount; this.periodCount = periodCount; }
Example #6
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSourceHolder) { if (newIndex > 0) { MediaSourceHolder previousHolder = mediaSourceHolders.get(newIndex - 1); newMediaSourceHolder.reset( newIndex, previousHolder.firstWindowIndexInChild + previousHolder.timeline.getWindowCount(), previousHolder.firstPeriodIndexInChild + previousHolder.timeline.getPeriodCount()); } else { newMediaSourceHolder.reset( newIndex, /* firstWindowIndexInChild= */ 0, /* firstPeriodIndexInChild= */ 0); } correctOffsets( newIndex, /* childIndexUpdate= */ 1, newMediaSourceHolder.timeline.getWindowCount(), newMediaSourceHolder.timeline.getPeriodCount()); mediaSourceHolders.add(newIndex, newMediaSourceHolder); if (!useLazyPreparation) { newMediaSourceHolder.hasStartedPreparing = true; prepareChildSource(newMediaSourceHolder, newMediaSourceHolder.mediaSource); } }
Example #7
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public final MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator) { int mediaSourceHolderIndex = findMediaSourceHolderByPeriodIndex(id.periodIndex); MediaSourceHolder holder = mediaSourceHolders.get(mediaSourceHolderIndex); DeferredMediaPeriod mediaPeriod = new DeferredMediaPeriod(holder.mediaSource, id, allocator); mediaSourceByMediaPeriod.put(mediaPeriod, holder); holder.activeMediaPeriods.add(mediaPeriod); if (!holder.hasStartedPreparing) { holder.hasStartedPreparing = true; prepareChildSource(holder, holder.mediaSource); } else if (holder.isPrepared) { MediaPeriodId idInSource = id.copyWithPeriodIndex(id.periodIndex - holder.firstPeriodIndexInChild); mediaPeriod.createPeriod(idInSource); } return mediaPeriod; }
Example #8
Source File: ConcatenatingMediaSource.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSourceHolder) { if (newIndex > 0) { MediaSourceHolder previousHolder = mediaSourceHolders.get(newIndex - 1); newMediaSourceHolder.reset( newIndex, previousHolder.firstWindowIndexInChild + previousHolder.timeline.getWindowCount(), previousHolder.firstPeriodIndexInChild + previousHolder.timeline.getPeriodCount()); } else { newMediaSourceHolder.reset( newIndex, /* firstWindowIndexInChild= */ 0, /* firstPeriodIndexInChild= */ 0); } correctOffsets( newIndex, /* childIndexUpdate= */ 1, newMediaSourceHolder.timeline.getWindowCount(), newMediaSourceHolder.timeline.getPeriodCount()); mediaSourceHolders.add(newIndex, newMediaSourceHolder); mediaSourceByUid.put(newMediaSourceHolder.uid, newMediaSourceHolder); if (!useLazyPreparation) { newMediaSourceHolder.hasStartedPreparing = true; prepareChildSource(newMediaSourceHolder, newMediaSourceHolder.mediaSource); } }
Example #9
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSourceHolder) { if (newIndex > 0) { MediaSourceHolder previousHolder = mediaSourceHolders.get(newIndex - 1); newMediaSourceHolder.reset( newIndex, previousHolder.firstWindowIndexInChild + previousHolder.timeline.getWindowCount(), previousHolder.firstPeriodIndexInChild + previousHolder.timeline.getPeriodCount()); } else { newMediaSourceHolder.reset( newIndex, /* firstWindowIndexInChild= */ 0, /* firstPeriodIndexInChild= */ 0); } correctOffsets( newIndex, /* childIndexUpdate= */ 1, newMediaSourceHolder.timeline.getWindowCount(), newMediaSourceHolder.timeline.getPeriodCount()); mediaSourceHolders.add(newIndex, newMediaSourceHolder); if (!useLazyPreparation) { newMediaSourceHolder.hasStartedPreparing = true; prepareChildSource(newMediaSourceHolder, newMediaSourceHolder.mediaSource); } }
Example #10
Source File: ConcatenatingMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSourceHolder) { if (newIndex > 0) { MediaSourceHolder previousHolder = mediaSourceHolders.get(newIndex - 1); newMediaSourceHolder.reset( newIndex, previousHolder.firstWindowIndexInChild + previousHolder.timeline.getWindowCount(), previousHolder.firstPeriodIndexInChild + previousHolder.timeline.getPeriodCount()); } else { newMediaSourceHolder.reset( newIndex, /* firstWindowIndexInChild= */ 0, /* firstPeriodIndexInChild= */ 0); } correctOffsets( newIndex, /* childIndexUpdate= */ 1, newMediaSourceHolder.timeline.getWindowCount(), newMediaSourceHolder.timeline.getPeriodCount()); mediaSourceHolders.add(newIndex, newMediaSourceHolder); mediaSourceByUid.put(newMediaSourceHolder.uid, newMediaSourceHolder); if (!useLazyPreparation) { newMediaSourceHolder.hasStartedPreparing = true; prepareChildSource(newMediaSourceHolder, newMediaSourceHolder.mediaSource); } }
Example #11
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Adds a {@link MediaSource} to the playlist and executes a custom action on completion. * * @param index The index at which the new {@link MediaSource} will be inserted. This index must * be in the range of 0 <= index <= {@link #getSize()}. * @param mediaSource The {@link MediaSource} to be added to the list. * @param actionOnCompletion A {@link Runnable} which is executed immediately after the media * source has been added to the playlist. */ public final synchronized void addMediaSource( int index, MediaSource mediaSource, @Nullable Runnable actionOnCompletion) { Assertions.checkNotNull(mediaSource); MediaSourceHolder mediaSourceHolder = new MediaSourceHolder(mediaSource); mediaSourcesPublic.add(index, mediaSourceHolder); if (player != null) { player .createMessage(this) .setType(MSG_ADD) .setPayload(new MessageData<>(index, mediaSourceHolder, actionOnCompletion)) .send(); } else if (actionOnCompletion != null) { actionOnCompletion.run(); } }
Example #12
Source File: ConcatenatingMediaSource.java From MediaSDK with Apache License 2.0 | 6 votes |
private void updateMediaSourceInternal(MediaSourceHolder mediaSourceHolder, Timeline timeline) { if (mediaSourceHolder == null) { throw new IllegalArgumentException(); } if (mediaSourceHolder.childIndex + 1 < mediaSourceHolders.size()) { MediaSourceHolder nextHolder = mediaSourceHolders.get(mediaSourceHolder.childIndex + 1); int windowOffsetUpdate = timeline.getWindowCount() - (nextHolder.firstWindowIndexInChild - mediaSourceHolder.firstWindowIndexInChild); if (windowOffsetUpdate != 0) { correctOffsets( mediaSourceHolder.childIndex + 1, /* childIndexUpdate= */ 0, windowOffsetUpdate); } } scheduleTimelineUpdate(); }
Example #13
Source File: ConcatenatingMediaSource.java From MediaSDK with Apache License 2.0 | 6 votes |
private void addMediaSourceInternal(int newIndex, MediaSourceHolder newMediaSourceHolder) { if (newIndex > 0) { MediaSourceHolder previousHolder = mediaSourceHolders.get(newIndex - 1); Timeline previousTimeline = previousHolder.mediaSource.getTimeline(); newMediaSourceHolder.reset( newIndex, previousHolder.firstWindowIndexInChild + previousTimeline.getWindowCount()); } else { newMediaSourceHolder.reset(newIndex, /* firstWindowIndexInChild= */ 0); } Timeline newTimeline = newMediaSourceHolder.mediaSource.getTimeline(); correctOffsets(newIndex, /* childIndexUpdate= */ 1, newTimeline.getWindowCount()); mediaSourceHolders.add(newIndex, newMediaSourceHolder); mediaSourceByUid.put(newMediaSourceHolder.uid, newMediaSourceHolder); prepareChildSource(newMediaSourceHolder, newMediaSourceHolder.mediaSource); if (isEnabled() && mediaSourceByMediaPeriod.isEmpty()) { enabledMediaSourceHolders.add(newMediaSourceHolder); } else { disableChildSource(newMediaSourceHolder); } }
Example #14
Source File: ConcatenatingMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public ConcatenatedTimeline( Collection<MediaSourceHolder> mediaSourceHolders, int windowCount, int periodCount, ShuffleOrder shuffleOrder, boolean isAtomic) { super(isAtomic, shuffleOrder); this.windowCount = windowCount; this.periodCount = periodCount; int childCount = mediaSourceHolders.size(); firstPeriodInChildIndices = new int[childCount]; firstWindowInChildIndices = new int[childCount]; timelines = new Timeline[childCount]; uids = new Object[childCount]; childIndexByUid = new HashMap<>(); int index = 0; for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { timelines[index] = mediaSourceHolder.timeline; firstPeriodInChildIndices[index] = mediaSourceHolder.firstPeriodIndexInChild; firstWindowInChildIndices[index] = mediaSourceHolder.firstWindowIndexInChild; uids[index] = mediaSourceHolder.uid; childIndexByUid.put(uids[index], index++); } }
Example #15
Source File: ConcatenatingMediaSource.java From Telegram with GNU General Public License v2.0 | 6 votes |
public ConcatenatedTimeline( Collection<MediaSourceHolder> mediaSourceHolders, int windowCount, int periodCount, ShuffleOrder shuffleOrder, boolean isAtomic) { super(isAtomic, shuffleOrder); this.windowCount = windowCount; this.periodCount = periodCount; int childCount = mediaSourceHolders.size(); firstPeriodInChildIndices = new int[childCount]; firstWindowInChildIndices = new int[childCount]; timelines = new Timeline[childCount]; uids = new Object[childCount]; childIndexByUid = new HashMap<>(); int index = 0; for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { timelines[index] = mediaSourceHolder.timeline; firstPeriodInChildIndices[index] = mediaSourceHolder.firstPeriodIndexInChild; firstWindowInChildIndices[index] = mediaSourceHolder.firstWindowIndexInChild; uids[index] = mediaSourceHolder.uid; childIndexByUid.put(uids[index], index++); } }
Example #16
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public ConcatenatedTimeline( Collection<MediaSourceHolder> mediaSourceHolders, int windowCount, int periodCount, ShuffleOrder shuffleOrder, boolean isAtomic) { super(isAtomic, shuffleOrder); this.windowCount = windowCount; this.periodCount = periodCount; int childCount = mediaSourceHolders.size(); firstPeriodInChildIndices = new int[childCount]; firstWindowInChildIndices = new int[childCount]; timelines = new Timeline[childCount]; uids = new Object[childCount]; childIndexByUid = new HashMap<>(); int index = 0; for (MediaSourceHolder mediaSourceHolder : mediaSourceHolders) { timelines[index] = mediaSourceHolder.timeline; firstPeriodInChildIndices[index] = mediaSourceHolder.firstPeriodIndexInChild; firstWindowInChildIndices[index] = mediaSourceHolder.firstWindowIndexInChild; uids[index] = mediaSourceHolder.uid; childIndexByUid.put(uids[index], index++); } }
Example #17
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * @param isAtomic Whether the concatenating media source will be treated as atomic, i.e., treated * as a single item for repeating and shuffling. * @param useLazyPreparation Whether playlist items are prepared lazily. If false, all manifest * loads and other initial preparation steps happen immediately. If true, these initial * preparations are triggered only when the player starts buffering the media. * @param shuffleOrder The {@link ShuffleOrder} to use when shuffling the child media sources. * @param mediaSources The {@link MediaSource}s to concatenate. It is valid for the same {@link * MediaSource} instance to be present more than once in the array. */ @SuppressWarnings("initialization") public ConcatenatingMediaSource( boolean isAtomic, boolean useLazyPreparation, ShuffleOrder shuffleOrder, MediaSource... mediaSources) { for (MediaSource mediaSource : mediaSources) { Assertions.checkNotNull(mediaSource); } this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder; this.mediaSourceByMediaPeriod = new IdentityHashMap<>(); this.mediaSourcesPublic = new ArrayList<>(); this.mediaSourceHolders = new ArrayList<>(); this.pendingOnCompletionActions = new ArrayList<>(); this.query = new MediaSourceHolder(/* mediaSource= */ null); this.isAtomic = isAtomic; this.useLazyPreparation = useLazyPreparation; window = new Timeline.Window(); addMediaSources(Arrays.asList(mediaSources)); }
Example #18
Source File: ConcatenatingMediaSource.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override protected @Nullable MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( MediaSourceHolder mediaSourceHolder, MediaPeriodId mediaPeriodId) { for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) { // Ensure the reported media period id has the same window sequence number as the one created // by this media source. Otherwise it does not belong to this child source. if (mediaSourceHolder.activeMediaPeriods.get(i).id.windowSequenceNumber == mediaPeriodId.windowSequenceNumber) { Object periodUid = getPeriodUid(mediaSourceHolder, mediaPeriodId.periodUid); return mediaPeriodId.copyWithPeriodUid(periodUid); } } return null; }
Example #19
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected @Nullable MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( MediaSourceHolder mediaSourceHolder, MediaPeriodId mediaPeriodId) { for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) { // Ensure the reported media period id has the same window sequence number as the one created // by this media source. Otherwise it does not belong to this child source. if (mediaSourceHolder.activeMediaPeriods.get(i).id.windowSequenceNumber == mediaPeriodId.windowSequenceNumber) { return mediaPeriodId.copyWithPeriodIndex( mediaPeriodId.periodIndex + mediaSourceHolder.firstPeriodIndexInChild); } } return null; }
Example #20
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void updateMediaSourceInternal(MediaSourceHolder mediaSourceHolder, Timeline timeline) { if (mediaSourceHolder == null) { throw new IllegalArgumentException(); } DeferredTimeline deferredTimeline = mediaSourceHolder.timeline; if (deferredTimeline.getTimeline() == timeline) { return; } int windowOffsetUpdate = timeline.getWindowCount() - deferredTimeline.getWindowCount(); int periodOffsetUpdate = timeline.getPeriodCount() - deferredTimeline.getPeriodCount(); if (windowOffsetUpdate != 0 || periodOffsetUpdate != 0) { correctOffsets( mediaSourceHolder.childIndex + 1, /* childIndexUpdate= */ 0, windowOffsetUpdate, periodOffsetUpdate); } mediaSourceHolder.timeline = deferredTimeline.cloneWithNewTimeline(timeline); if (!mediaSourceHolder.isPrepared && !timeline.isEmpty()) { timeline.getWindow(/* windowIndex= */ 0, window); long defaultPeriodPositionUs = window.getPositionInFirstPeriodUs() + window.getDefaultPositionUs(); for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) { DeferredMediaPeriod deferredMediaPeriod = mediaSourceHolder.activeMediaPeriods.get(i); deferredMediaPeriod.setDefaultPreparePositionUs(defaultPeriodPositionUs); MediaPeriodId idInSource = deferredMediaPeriod.id.copyWithPeriodIndex( deferredMediaPeriod.id.periodIndex - mediaSourceHolder.firstPeriodIndexInChild); deferredMediaPeriod.createPeriod(idInSource); } mediaSourceHolder.isPrepared = true; } scheduleListenerNotification(/* actionOnCompletion= */ null); }
Example #21
Source File: ConcatenatingMediaSource.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void releasePeriod(MediaPeriod mediaPeriod) { MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByMediaPeriod.remove(mediaPeriod)); holder.mediaSource.releasePeriod(mediaPeriod); holder.activeMediaPeriodIds.remove(((MaskingMediaPeriod) mediaPeriod).id); if (!mediaSourceByMediaPeriod.isEmpty()) { disableUnusedMediaSources(); } maybeReleaseChildSource(holder); }
Example #22
Source File: ConcatenatingMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected @Nullable MediaPeriodId getMediaPeriodIdForChildMediaPeriodId( MediaSourceHolder mediaSourceHolder, MediaPeriodId mediaPeriodId) { for (int i = 0; i < mediaSourceHolder.activeMediaPeriods.size(); i++) { // Ensure the reported media period id has the same window sequence number as the one created // by this media source. Otherwise it does not belong to this child source. if (mediaSourceHolder.activeMediaPeriods.get(i).id.windowSequenceNumber == mediaPeriodId.windowSequenceNumber) { Object periodUid = getPeriodUid(mediaSourceHolder, mediaPeriodId.periodUid); return mediaPeriodId.copyWithPeriodUid(periodUid); } } return null; }
Example #23
Source File: ConcatenatingMediaSource.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override protected final void onChildSourceInfoRefreshed( MediaSourceHolder mediaSourceHolder, MediaSource mediaSource, Timeline timeline, @Nullable Object manifest) { updateMediaSourceInternal(mediaSourceHolder, timeline); }
Example #24
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void moveMediaSourceInternal(int currentIndex, int newIndex) { int startIndex = Math.min(currentIndex, newIndex); int endIndex = Math.max(currentIndex, newIndex); int windowOffset = mediaSourceHolders.get(startIndex).firstWindowIndexInChild; int periodOffset = mediaSourceHolders.get(startIndex).firstPeriodIndexInChild; mediaSourceHolders.add(newIndex, mediaSourceHolders.remove(currentIndex)); for (int i = startIndex; i <= endIndex; i++) { MediaSourceHolder holder = mediaSourceHolders.get(i); holder.firstWindowIndexInChild = windowOffset; holder.firstPeriodIndexInChild = periodOffset; windowOffset += holder.timeline.getWindowCount(); periodOffset += holder.timeline.getPeriodCount(); } }
Example #25
Source File: ConcatenatingMediaSource.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public final void releasePeriod(MediaPeriod mediaPeriod) { MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByMediaPeriod.remove(mediaPeriod)); ((DeferredMediaPeriod) mediaPeriod).releasePeriod(); holder.activeMediaPeriods.remove(mediaPeriod); maybeReleaseChildSource(holder); }
Example #26
Source File: ConcatenatingMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public final void releasePeriod(MediaPeriod mediaPeriod) { MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByMediaPeriod.remove(mediaPeriod)); ((DeferredMediaPeriod) mediaPeriod).releasePeriod(); holder.activeMediaPeriods.remove(mediaPeriod); maybeReleaseChildSource(holder); }
Example #27
Source File: ConcatenatingMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected final void onChildSourceInfoRefreshed( MediaSourceHolder mediaSourceHolder, MediaSource mediaSource, Timeline timeline, @Nullable Object manifest) { updateMediaSourceInternal(mediaSourceHolder, timeline); }
Example #28
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void removeMediaSourceInternal(int index) { MediaSourceHolder holder = mediaSourceHolders.remove(index); Timeline oldTimeline = holder.timeline; correctOffsets( index, /* childIndexUpdate= */ -1, -oldTimeline.getWindowCount(), -oldTimeline.getPeriodCount()); holder.isRemoved = true; if (holder.activeMediaPeriods.isEmpty()) { releaseChildSource(holder); } }
Example #29
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override protected final void onChildSourceInfoRefreshed( MediaSourceHolder mediaSourceHolder, MediaSource mediaSource, Timeline timeline, @Nullable Object manifest) { updateMediaSourceInternal(mediaSourceHolder, timeline); }
Example #30
Source File: ConcatenatingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void releasePeriod(MediaPeriod mediaPeriod) { MediaSourceHolder holder = Assertions.checkNotNull(mediaSourceByMediaPeriod.remove(mediaPeriod)); ((DeferredMediaPeriod) mediaPeriod).releasePeriod(); holder.activeMediaPeriods.remove(mediaPeriod); if (holder.activeMediaPeriods.isEmpty() && holder.isRemoved) { releaseChildSource(holder); } }