com.google.android.exoplayer2.source.SampleStream Java Examples
The following examples show how to use
com.google.android.exoplayer2.source.SampleStream.
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: DashMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void releaseDisabledStreams( TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams) { for (int i = 0; i < selections.length; i++) { if (selections[i] == null || !mayRetainStreamFlags[i]) { if (streams[i] instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) streams[i]; stream.release(this); } else if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } }
Example #2
Source File: DashMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void releaseDisabledStreams( TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams) { for (int i = 0; i < selections.length; i++) { if (selections[i] == null || !mayRetainStreamFlags[i]) { if (streams[i] instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) streams[i]; stream.release(this); } else if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } }
Example #3
Source File: DashMediaPeriod.java From MediaSDK with Apache License 2.0 | 6 votes |
private void releaseDisabledStreams( TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams) { for (int i = 0; i < selections.length; i++) { if (selections[i] == null || !mayRetainStreamFlags[i]) { if (streams[i] instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) streams[i]; stream.release(this); } else if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } }
Example #4
Source File: DashMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void releaseDisabledStreams( TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams) { for (int i = 0; i < selections.length; i++) { if (selections[i] == null || !mayRetainStreamFlags[i]) { if (streams[i] instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) streams[i]; stream.release(this); } else if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } }
Example #5
Source File: ExoPlayerImplInternal.java From K-Sonic with MIT License | 6 votes |
public MediaPeriodHolder(Renderer[] renderers, RendererCapabilities[] rendererCapabilities, long rendererPositionOffsetUs, TrackSelector trackSelector, LoadControl loadControl, MediaSource mediaSource, Object periodUid, int periodIndex, boolean isLastPeriod, long startPositionUs) { this.renderers = renderers; this.rendererCapabilities = rendererCapabilities; this.rendererPositionOffsetUs = rendererPositionOffsetUs; this.trackSelector = trackSelector; this.loadControl = loadControl; this.mediaSource = mediaSource; this.uid = Assertions.checkNotNull(periodUid); this.index = periodIndex; this.isLast = isLastPeriod; this.startPositionUs = startPositionUs; sampleStreams = new SampleStream[renderers.length]; mayRetainStreamFlags = new boolean[renderers.length]; mediaPeriod = mediaSource.createPeriod(periodIndex, loadControl.getAllocator(), startPositionUs); }
Example #6
Source File: ExoPlayerImplInternal.java From MediaSDK with Apache License 2.0 | 6 votes |
private boolean hasReadingPeriodFinishedReading() { MediaPeriodHolder readingPeriodHolder = queue.getReadingPeriod(); if (!readingPeriodHolder.prepared) { return false; } for (int i = 0; i < renderers.length; i++) { Renderer renderer = renderers[i]; SampleStream sampleStream = readingPeriodHolder.sampleStreams[i]; if (renderer.getStream() != sampleStream || (sampleStream != null && !renderer.hasReadStreamToEnd())) { // The current reading period is still being read by at least one renderer. return false; } } return true; }
Example #7
Source File: MediaPeriodHolder.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Creates a new holder with information required to play it as part of a timeline. * * @param rendererCapabilities The renderer capabilities. * @param rendererPositionOffsetUs The renderer time of the start of the period, in microseconds. * @param trackSelector The track selector. * @param allocator The allocator. * @param mediaSource The media source that produced the media period. * @param info Information used to identify this media period in its timeline period. */ public MediaPeriodHolder( RendererCapabilities[] rendererCapabilities, long rendererPositionOffsetUs, TrackSelector trackSelector, Allocator allocator, MediaSource mediaSource, MediaPeriodInfo info) { this.rendererCapabilities = rendererCapabilities; this.rendererPositionOffsetUs = rendererPositionOffsetUs; this.trackSelector = trackSelector; this.mediaSource = mediaSource; this.uid = info.id.periodUid; this.info = info; sampleStreams = new SampleStream[rendererCapabilities.length]; mayRetainStreamFlags = new boolean[rendererCapabilities.length]; mediaPeriod = createMediaPeriod( info.id, mediaSource, allocator, info.startPositionUs, info.endPositionUs); }
Example #8
Source File: MediaPeriodHolder.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Creates a new holder with information required to play it as part of a timeline. * * @param rendererCapabilities The renderer capabilities. * @param rendererPositionOffsetUs The renderer time of the start of the period, in microseconds. * @param trackSelector The track selector. * @param allocator The allocator. * @param mediaSource The media source that produced the media period. * @param info Information used to identify this media period in its timeline period. * @param emptyTrackSelectorResult A {@link TrackSelectorResult} with empty selections for each * renderer. */ public MediaPeriodHolder( RendererCapabilities[] rendererCapabilities, long rendererPositionOffsetUs, TrackSelector trackSelector, Allocator allocator, MediaSource mediaSource, MediaPeriodInfo info, TrackSelectorResult emptyTrackSelectorResult) { this.rendererCapabilities = rendererCapabilities; this.rendererPositionOffsetUs = rendererPositionOffsetUs; this.trackSelector = trackSelector; this.mediaSource = mediaSource; this.uid = info.id.periodUid; this.info = info; this.trackGroups = TrackGroupArray.EMPTY; this.trackSelectorResult = emptyTrackSelectorResult; sampleStreams = new SampleStream[rendererCapabilities.length]; mayRetainStreamFlags = new boolean[rendererCapabilities.length]; mediaPeriod = createMediaPeriod( info.id, mediaSource, allocator, info.startPositionUs, info.endPositionUs); }
Example #9
Source File: HlsSampleStreamWrapper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void updateSampleStreams(SampleStream[] streams) { hlsSampleStreams.clear(); for (SampleStream stream : streams) { if (stream != null) { hlsSampleStreams.add((HlsSampleStream) stream); } } }
Example #10
Source File: BaseRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void enable(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, long offsetUs) throws ExoPlaybackException { Assertions.checkState(state == STATE_DISABLED); this.configuration = configuration; state = STATE_ENABLED; onEnabled(joining); replaceStream(formats, stream, offsetUs); onPositionReset(positionUs, joining); }
Example #11
Source File: MediaPeriodHolder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with * a dummy {@link EmptySampleStream}. */ private void associateNoSampleRenderersWithEmptySampleStream(SampleStream[] sampleStreams) { for (int i = 0; i < rendererCapabilities.length; i++) { if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE && trackSelectorResult.isRendererEnabled(i)) { sampleStreams[i] = new EmptySampleStream(); } } }
Example #12
Source File: BaseRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void replaceStream(Format[] formats, SampleStream stream, long offsetUs) throws ExoPlaybackException { Assertions.checkState(!streamIsFinal); this.stream = stream; readEndOfStream = false; streamFormats = formats; streamOffsetUs = offsetUs; onStreamChanged(formats, offsetUs); }
Example #13
Source File: MediaPeriodHolder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * 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(SampleStream[] sampleStreams) { for (int i = 0; i < rendererCapabilities.length; i++) { if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE) { sampleStreams[i] = null; } } }
Example #14
Source File: HlsSampleStreamWrapper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void updateSampleStreams(SampleStream[] streams) { hlsSampleStreams.clear(); for (SampleStream stream : streams) { if (stream != null) { hlsSampleStreams.add((HlsSampleStream) stream); } } }
Example #15
Source File: DashMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void releaseOrphanEmbeddedStreams( TrackSelection[] selections, SampleStream[] streams, int[] streamIndexToTrackGroupIndex) { for (int i = 0; i < selections.length; i++) { if (streams[i] instanceof EmptySampleStream || streams[i] instanceof EmbeddedSampleStream) { // We need to release an embedded stream if the corresponding primary stream is released. int primaryStreamIndex = getPrimaryStreamIndex(i, streamIndexToTrackGroupIndex); boolean mayRetainStream; if (primaryStreamIndex == C.INDEX_UNSET) { // If the corresponding primary stream is not selected, we may retain an existing // EmptySampleStream. mayRetainStream = streams[i] instanceof EmptySampleStream; } else { // If the corresponding primary stream is selected, we may retain the embedded stream if // the stream's parent still matches. mayRetainStream = (streams[i] instanceof EmbeddedSampleStream) && ((EmbeddedSampleStream) streams[i]).parent == streams[primaryStreamIndex]; } if (!mayRetainStream) { if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } } }
Example #16
Source File: MediaPeriodHolder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with * a dummy {@link EmptySampleStream}. */ private void associateNoSampleRenderersWithEmptySampleStream(SampleStream[] sampleStreams) { for (int i = 0; i < rendererCapabilities.length; i++) { if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE && trackSelectorResult.isRendererEnabled(i)) { sampleStreams[i] = new EmptySampleStream(); } } }
Example #17
Source File: DashMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void releaseOrphanEmbeddedStreams( TrackSelection[] selections, SampleStream[] streams, int[] streamIndexToTrackGroupIndex) { for (int i = 0; i < selections.length; i++) { if (streams[i] instanceof EmptySampleStream || streams[i] instanceof EmbeddedSampleStream) { // We need to release an embedded stream if the corresponding primary stream is released. int primaryStreamIndex = getPrimaryStreamIndex(i, streamIndexToTrackGroupIndex); boolean mayRetainStream; if (primaryStreamIndex == C.INDEX_UNSET) { // If the corresponding primary stream is not selected, we may retain an existing // EmptySampleStream. mayRetainStream = streams[i] instanceof EmptySampleStream; } else { // If the corresponding primary stream is selected, we may retain the embedded stream if // the stream's parent still matches. mayRetainStream = (streams[i] instanceof EmbeddedSampleStream) && ((EmbeddedSampleStream) streams[i]).parent == streams[primaryStreamIndex]; } if (!mayRetainStream) { if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } } }
Example #18
Source File: MediaPeriodHolder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * 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(SampleStream[] sampleStreams) { for (int i = 0; i < rendererCapabilities.length; i++) { if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE) { sampleStreams[i] = null; } } }
Example #19
Source File: BaseRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void enable(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, long offsetUs) throws ExoPlaybackException { Assertions.checkState(state == STATE_DISABLED); this.configuration = configuration; state = STATE_ENABLED; onEnabled(joining); replaceStream(formats, stream, offsetUs); onPositionReset(positionUs, joining); }
Example #20
Source File: BaseRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void replaceStream(Format[] formats, SampleStream stream, long offsetUs) throws ExoPlaybackException { Assertions.checkState(!streamIsFinal); this.stream = stream; readEndOfStream = false; streamFormats = formats; streamOffsetUs = offsetUs; onStreamChanged(formats, offsetUs); }
Example #21
Source File: MediaPeriodHolder.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * For each renderer of type {@link C#TRACK_TYPE_NONE} that was enabled, we will associate it with * a dummy {@link EmptySampleStream}. */ private void associateNoSampleRenderersWithEmptySampleStream( @NullableType SampleStream[] sampleStreams) { TrackSelectorResult trackSelectorResult = Assertions.checkNotNull(this.trackSelectorResult); for (int i = 0; i < rendererCapabilities.length; i++) { if (rendererCapabilities[i].getTrackType() == C.TRACK_TYPE_NONE && trackSelectorResult.isRendererEnabled(i)) { sampleStreams[i] = new EmptySampleStream(); } } }
Example #22
Source File: DashMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams, boolean[] streamResetFlags, long positionUs) { int[] streamIndexToTrackGroupIndex = getStreamIndexToTrackGroupIndex(selections); releaseDisabledStreams(selections, mayRetainStreamFlags, streams); releaseOrphanEmbeddedStreams(selections, streams, streamIndexToTrackGroupIndex); selectNewStreams( selections, streams, streamResetFlags, positionUs, streamIndexToTrackGroupIndex); ArrayList<ChunkSampleStream<DashChunkSource>> sampleStreamList = new ArrayList<>(); ArrayList<EventSampleStream> eventSampleStreamList = new ArrayList<>(); for (SampleStream sampleStream : streams) { if (sampleStream instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) sampleStream; sampleStreamList.add(stream); } else if (sampleStream instanceof EventSampleStream) { eventSampleStreamList.add((EventSampleStream) sampleStream); } } sampleStreams = newSampleStreamArray(sampleStreamList.size()); sampleStreamList.toArray(sampleStreams); eventSampleStreams = new EventSampleStream[eventSampleStreamList.size()]; eventSampleStreamList.toArray(eventSampleStreams); compositeSequenceableLoader = compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams); return positionUs; }
Example #23
Source File: DashMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public long selectTracks(TrackSelection[] selections, boolean[] mayRetainStreamFlags, SampleStream[] streams, boolean[] streamResetFlags, long positionUs) { int[] streamIndexToTrackGroupIndex = getStreamIndexToTrackGroupIndex(selections); releaseDisabledStreams(selections, mayRetainStreamFlags, streams); releaseOrphanEmbeddedStreams(selections, streams, streamIndexToTrackGroupIndex); selectNewStreams( selections, streams, streamResetFlags, positionUs, streamIndexToTrackGroupIndex); ArrayList<ChunkSampleStream<DashChunkSource>> sampleStreamList = new ArrayList<>(); ArrayList<EventSampleStream> eventSampleStreamList = new ArrayList<>(); for (SampleStream sampleStream : streams) { if (sampleStream instanceof ChunkSampleStream) { @SuppressWarnings("unchecked") ChunkSampleStream<DashChunkSource> stream = (ChunkSampleStream<DashChunkSource>) sampleStream; sampleStreamList.add(stream); } else if (sampleStream instanceof EventSampleStream) { eventSampleStreamList.add((EventSampleStream) sampleStream); } } sampleStreams = newSampleStreamArray(sampleStreamList.size()); sampleStreamList.toArray(sampleStreams); eventSampleStreams = new EventSampleStream[eventSampleStreamList.size()]; eventSampleStreamList.toArray(eventSampleStreams); compositeSequenceableLoader = compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(sampleStreams); return positionUs; }
Example #24
Source File: DashMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void releaseOrphanEmbeddedStreams( TrackSelection[] selections, SampleStream[] streams, int[] streamIndexToTrackGroupIndex) { for (int i = 0; i < selections.length; i++) { if (streams[i] instanceof EmptySampleStream || streams[i] instanceof EmbeddedSampleStream) { // We need to release an embedded stream if the corresponding primary stream is released. int primaryStreamIndex = getPrimaryStreamIndex(i, streamIndexToTrackGroupIndex); boolean mayRetainStream; if (primaryStreamIndex == C.INDEX_UNSET) { // If the corresponding primary stream is not selected, we may retain an existing // EmptySampleStream. mayRetainStream = streams[i] instanceof EmptySampleStream; } else { // If the corresponding primary stream is selected, we may retain the embedded stream if // the stream's parent still matches. mayRetainStream = (streams[i] instanceof EmbeddedSampleStream) && ((EmbeddedSampleStream) streams[i]).parent == streams[primaryStreamIndex]; } if (!mayRetainStream) { if (streams[i] instanceof EmbeddedSampleStream) { ((EmbeddedSampleStream) streams[i]).release(); } streams[i] = null; } } } }
Example #25
Source File: BaseRenderer.java From K-Sonic with MIT License | 5 votes |
@Override public final void enable(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, long offsetUs) throws ExoPlaybackException { Assertions.checkState(state == STATE_DISABLED); this.configuration = configuration; state = STATE_ENABLED; onEnabled(joining); replaceStream(formats, stream, offsetUs); onPositionReset(positionUs, joining); }
Example #26
Source File: BaseRenderer.java From K-Sonic with MIT License | 5 votes |
@Override public final void replaceStream(Format[] formats, SampleStream stream, long offsetUs) throws ExoPlaybackException { Assertions.checkState(!streamIsFinal); this.stream = stream; readEndOfStream = false; streamOffsetUs = offsetUs; onStreamChanged(formats); }
Example #27
Source File: HlsSampleStreamWrapper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void updateSampleStreams(SampleStream[] streams) { hlsSampleStreams.clear(); for (SampleStream stream : streams) { if (stream != null) { hlsSampleStreams.add((HlsSampleStream) stream); } } }
Example #28
Source File: BaseRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public final void replaceStream(Format[] formats, SampleStream stream, long offsetUs) throws ExoPlaybackException { Assertions.checkState(!streamIsFinal); this.stream = stream; readingPositionUs = offsetUs; streamFormats = formats; streamOffsetUs = offsetUs; onStreamChanged(formats, offsetUs); }
Example #29
Source File: BaseRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public final void enable(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, long offsetUs) throws ExoPlaybackException { Assertions.checkState(state == STATE_DISABLED); this.configuration = configuration; state = STATE_ENABLED; onEnabled(joining); replaceStream(formats, stream, offsetUs); onPositionReset(positionUs, joining); }
Example #30
Source File: MediaPeriodHolder.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * 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; } } }