Handle initial RTSP seek
PiperOrigin-RevId: 469143613 (cherry picked from commit c611435521a868d6675556f05bd2e325355b7e02)
This commit is contained in:
parent
5bdb165943
commit
218e97fadf
@ -187,6 +187,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
@Override
|
@Override
|
||||||
public void seek(long nextRtpTimestamp, long playbackStartTimeUs) {
|
public void seek(long nextRtpTimestamp, long playbackStartTimeUs) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
|
if (!isSeekPending) {
|
||||||
|
// Sets the isSeekPending flag, in the case preSeek() is not called, when seeking does not
|
||||||
|
// require RTSP message exchange. For example, playing back with non-zero start position.
|
||||||
|
isSeekPending = true;
|
||||||
|
}
|
||||||
this.nextRtpTimestamp = nextRtpTimestamp;
|
this.nextRtpTimestamp = nextRtpTimestamp;
|
||||||
this.playbackStartTimeUs = playbackStartTimeUs;
|
this.playbackStartTimeUs = playbackStartTimeUs;
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
trackSelected = true;
|
trackSelected = true;
|
||||||
|
if (positionUs != 0) {
|
||||||
|
// Track selection is performed only once in RTSP streams.
|
||||||
|
requestedSeekPositionUs = positionUs;
|
||||||
|
pendingSeekPositionUs = positionUs;
|
||||||
|
pendingSeekPositionUsForTcpRetry = positionUs;
|
||||||
|
}
|
||||||
maybeSetupTracks();
|
maybeSetupTracks();
|
||||||
return positionUs;
|
return positionUs;
|
||||||
}
|
}
|
||||||
@ -271,7 +277,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
// 2b.2. If RTSP PLAY (for the first seek) has not been sent, the new seek position will be
|
// 2b.2. If RTSP PLAY (for the first seek) has not been sent, the new seek position will be
|
||||||
// used in the following PLAY request.
|
// used in the following PLAY request.
|
||||||
|
|
||||||
// TODO(internal: b/198620566) Handle initial seek.
|
|
||||||
// TODO(internal: b/213153670) Handle dropped seek position.
|
// TODO(internal: b/213153670) Handle dropped seek position.
|
||||||
if (getBufferedPositionUs() == 0 && !isUsingRtpTcp) {
|
if (getBufferedPositionUs() == 0 && !isUsingRtpTcp) {
|
||||||
// Stores the seek position for later, if no RTP packet is received when using UDP.
|
// Stores the seek position for later, if no RTP packet is received when using UDP.
|
||||||
@ -569,7 +574,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRtspSetupCompleted() {
|
public void onRtspSetupCompleted() {
|
||||||
rtspClient.startPlayback(/* offsetMs= */ 0);
|
long offsetMs = 0;
|
||||||
|
if (pendingSeekPositionUs != C.TIME_UNSET) {
|
||||||
|
offsetMs = Util.usToMs(pendingSeekPositionUs);
|
||||||
|
} else if (pendingSeekPositionUsForTcpRetry != C.TIME_UNSET) {
|
||||||
|
offsetMs = Util.usToMs(pendingSeekPositionUsForTcpRetry);
|
||||||
|
}
|
||||||
|
rtspClient.startPlayback(offsetMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -608,6 +619,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
if (isSeekPending() && pendingSeekPositionUs == requestedSeekPositionUs) {
|
if (isSeekPending() && pendingSeekPositionUs == requestedSeekPositionUs) {
|
||||||
// Seek loadable only when all pending seeks are processed, or SampleQueues will report
|
// Seek loadable only when all pending seeks are processed, or SampleQueues will report
|
||||||
// inconsistent bufferedPosition.
|
// inconsistent bufferedPosition.
|
||||||
|
// Seeks to the start position when the initial seek position is set.
|
||||||
dataLoadable.seekToUs(startPositionUs, trackTiming.rtpTimestamp);
|
dataLoadable.seekToUs(startPositionUs, trackTiming.rtpTimestamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -622,7 +634,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
pendingSeekPositionUs = C.TIME_UNSET;
|
pendingSeekPositionUs = C.TIME_UNSET;
|
||||||
seekToUs(requestedSeekPositionUs);
|
seekToUs(requestedSeekPositionUs);
|
||||||
}
|
}
|
||||||
} else if (pendingSeekPositionUsForTcpRetry != C.TIME_UNSET) {
|
} else if (pendingSeekPositionUsForTcpRetry != C.TIME_UNSET && isUsingRtpTcp) {
|
||||||
seekToUs(pendingSeekPositionUsForTcpRetry);
|
seekToUs(pendingSeekPositionUsForTcpRetry);
|
||||||
pendingSeekPositionUsForTcpRetry = C.TIME_UNSET;
|
pendingSeekPositionUsForTcpRetry = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user