mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Support colon (:) in RTSP timing.
Some RTSP servers use `npt`: notation rather than `npt=` PiperOrigin-RevId: 439333319
This commit is contained in:
parent
055c10d7b8
commit
4938028703
2 changed files with 9 additions and 1 deletions
|
|
@ -36,8 +36,9 @@ import java.util.regex.Pattern;
|
||||||
new RtspSessionTiming(/* startTimeMs= */ 0, /* stopTimeMs= */ C.TIME_UNSET);
|
new RtspSessionTiming(/* startTimeMs= */ 0, /* stopTimeMs= */ C.TIME_UNSET);
|
||||||
|
|
||||||
// We only support npt=xxx-[xxx], but not npt=-xxx. See RFC2326 Section 3.6.
|
// We only support npt=xxx-[xxx], but not npt=-xxx. See RFC2326 Section 3.6.
|
||||||
|
// Supports both npt= and npt: identifier.
|
||||||
private static final Pattern NPT_RANGE_PATTERN =
|
private static final Pattern NPT_RANGE_PATTERN =
|
||||||
Pattern.compile("npt=([.\\d]+|now)\\s?-\\s?([.\\d]+)?");
|
Pattern.compile("npt[:=]([.\\d]+|now)\\s?-\\s?([.\\d]+)?");
|
||||||
private static final String START_TIMING_NTP_FORMAT = "npt=%.3f-";
|
private static final String START_TIMING_NTP_FORMAT = "npt=%.3f-";
|
||||||
|
|
||||||
private static final long LIVE_START_TIME = 0;
|
private static final long LIVE_START_TIME = 0;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,13 @@ public class RtspSessionTimingTest {
|
||||||
assertThat(sessionTiming.isLive()).isFalse();
|
assertThat(sessionTiming.isLive()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parseTiming_withRangeTimingAndColonSeparator() throws Exception {
|
||||||
|
RtspSessionTiming sessionTiming = RtspSessionTiming.parseTiming("npt:0.000-32.054");
|
||||||
|
assertThat(sessionTiming.getDurationMs()).isEqualTo(32054);
|
||||||
|
assertThat(sessionTiming.isLive()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseTiming_withInvalidRangeTiming_throwsIllegalArgumentException() {
|
public void parseTiming_withInvalidRangeTiming_throwsIllegalArgumentException() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue