mirror of
https://github.com/samsonjs/media.git
synced 2026-04-09 11:55:46 +00:00
Always re-send format if sample buffer is null
Also clear the playingPeriodHolder in the case the renderers are being disabled. This is required to ensure that setPlayingPeriodHolder isn't turned into a no-op, which will break the seek. Issue: #2330 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144635220
This commit is contained in:
parent
60a3eda1e0
commit
79a0899124
8 changed files with 29 additions and 16 deletions
|
|
@ -514,13 +514,14 @@ public final class ExoPlayerTest extends TestCase {
|
|||
|
||||
@Override
|
||||
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer) {
|
||||
if (readFormat) {
|
||||
if (buffer == null || !readFormat) {
|
||||
formatHolder.format = format;
|
||||
readFormat = true;
|
||||
return C.RESULT_FORMAT_READ;
|
||||
} else {
|
||||
buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
|
||||
return C.RESULT_BUFFER_READ;
|
||||
}
|
||||
formatHolder.format = format;
|
||||
readFormat = true;
|
||||
return C.RESULT_FORMAT_READ;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -251,11 +251,11 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
|
|||
* {@link C#RESULT_BUFFER_READ} is only returned if {@link #setCurrentStreamFinal()} has been
|
||||
* called. {@link C#RESULT_NOTHING_READ} is returned otherwise.
|
||||
*
|
||||
* @see SampleStream#readData(FormatHolder, DecoderInputBuffer)
|
||||
* @param formatHolder A {@link FormatHolder} to populate in the case of reading a format.
|
||||
* @param buffer A {@link DecoderInputBuffer} to populate in the case of reading a sample or the
|
||||
* end of the stream. If the end of the stream has been reached, the
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer.
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer. May be null if the
|
||||
* caller requires that the format of the stream be read even if it's not changing.
|
||||
* @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ} or
|
||||
* {@link C#RESULT_BUFFER_READ}.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -610,6 +610,7 @@ import java.io.IOException;
|
|||
enabledRenderers = new Renderer[0];
|
||||
rendererMediaClock = null;
|
||||
rendererMediaClockSource = null;
|
||||
playingPeriodHolder = null;
|
||||
}
|
||||
|
||||
// Update the holders.
|
||||
|
|
|
|||
|
|
@ -265,7 +265,8 @@ public final class DefaultTrackOutput implements TrackOutput {
|
|||
* @param formatHolder A {@link FormatHolder} to populate in the case of reading a format.
|
||||
* @param buffer A {@link DecoderInputBuffer} to populate in the case of reading a sample or the
|
||||
* end of the stream. If the end of the stream has been reached, the
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer.
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer. May be null if the
|
||||
* caller requires that the format of the stream be read even if it's not changing.
|
||||
* @param loadingFinished True if an empty queue should be considered the end of the stream.
|
||||
* @param decodeOnlyUntilUs If a buffer is read, the {@link C#BUFFER_FLAG_DECODE_ONLY} flag will
|
||||
* be set if the buffer's timestamp is less than this value.
|
||||
|
|
@ -751,7 +752,8 @@ public final class DefaultTrackOutput implements TrackOutput {
|
|||
* about the sample, but not its data. The size and absolute position of the data in the
|
||||
* rolling buffer is stored in {@code extrasHolder}, along with an encryption id if present
|
||||
* and the absolute position of the first byte that may still be required after the current
|
||||
* sample has been read.
|
||||
* sample has been read. May be null if the caller requires that the format of the stream be
|
||||
* read even if it's not changing.
|
||||
* @param downstreamFormat The current downstream {@link Format}. If the format of the next
|
||||
* sample is different to the current downstream format then a format will be read.
|
||||
* @param extrasHolder The holder into which extra sample information should be written.
|
||||
|
|
@ -761,14 +763,14 @@ public final class DefaultTrackOutput implements TrackOutput {
|
|||
public synchronized int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
|
||||
Format downstreamFormat, BufferExtrasHolder extrasHolder) {
|
||||
if (queueSize == 0) {
|
||||
if (upstreamFormat != null && upstreamFormat != downstreamFormat) {
|
||||
if (upstreamFormat != null && (buffer == null || upstreamFormat != downstreamFormat)) {
|
||||
formatHolder.format = upstreamFormat;
|
||||
return C.RESULT_FORMAT_READ;
|
||||
}
|
||||
return C.RESULT_NOTHING_READ;
|
||||
}
|
||||
|
||||
if (formats[relativeReadIndex] != downstreamFormat) {
|
||||
if (buffer == null || formats[relativeReadIndex] != downstreamFormat) {
|
||||
formatHolder.format = formats[relativeReadIndex];
|
||||
return C.RESULT_FORMAT_READ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,6 +235,9 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb
|
|||
if (pendingDiscontinuity) {
|
||||
return C.RESULT_NOTHING_READ;
|
||||
}
|
||||
if (buffer == null) {
|
||||
return stream.readData(formatHolder, null);
|
||||
}
|
||||
if (sentEos) {
|
||||
buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
|
||||
return C.RESULT_BUFFER_READ;
|
||||
|
|
|
|||
|
|
@ -44,11 +44,17 @@ public interface SampleStream {
|
|||
|
||||
/**
|
||||
* Attempts to read from the stream.
|
||||
* <p>
|
||||
* If no data is available then {@link C#RESULT_NOTHING_READ} is returned. If the format of the
|
||||
* media is changing or if {@code buffer == null} then {@code formatHolder} is populated and
|
||||
* {@link C#RESULT_FORMAT_READ} is returned. Else {@code buffer} is populated and
|
||||
* {@link C#RESULT_BUFFER_READ} is returned.
|
||||
*
|
||||
* @param formatHolder A {@link FormatHolder} to populate in the case of reading a format.
|
||||
* @param buffer A {@link DecoderInputBuffer} to populate in the case of reading a sample or the
|
||||
* end of the stream. If the end of the stream has been reached, the
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer.
|
||||
* {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer. May be null if the
|
||||
* caller requires that the format of the stream be read even if it's not changing.
|
||||
* @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ} or
|
||||
* {@link C#RESULT_BUFFER_READ}.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -206,13 +206,13 @@ import java.util.Arrays;
|
|||
|
||||
@Override
|
||||
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer) {
|
||||
if (streamState == STREAM_STATE_END_OF_STREAM) {
|
||||
buffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
|
||||
return C.RESULT_BUFFER_READ;
|
||||
} else if (streamState == STREAM_STATE_SEND_FORMAT) {
|
||||
if (buffer == null || streamState == STREAM_STATE_SEND_FORMAT) {
|
||||
formatHolder.format = format;
|
||||
streamState = STREAM_STATE_SEND_SAMPLE;
|
||||
return C.RESULT_FORMAT_READ;
|
||||
} else if (streamState == STREAM_STATE_END_OF_STREAM) {
|
||||
buffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
|
||||
return C.RESULT_BUFFER_READ;
|
||||
}
|
||||
|
||||
Assertions.checkState(streamState == STREAM_STATE_SEND_SAMPLE);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import java.io.IOException;
|
|||
/* package */ final class HlsSampleStream implements SampleStream {
|
||||
|
||||
public final int group;
|
||||
|
||||
|
||||
private final HlsSampleStreamWrapper sampleStreamWrapper;
|
||||
|
||||
public HlsSampleStream(HlsSampleStreamWrapper sampleStreamWrapper, int group) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue