Commit 49380287 by claincly Committed by Ian Baker

Support colon (:) in RTSP timing.

Some RTSP servers use `npt`: notation rather than `npt=`

PiperOrigin-RevId: 439333319
parent 055c10d7
......@@ -36,8 +36,9 @@ import java.util.regex.Pattern;
new RtspSessionTiming(/* startTimeMs= */ 0, /* stopTimeMs= */ C.TIME_UNSET);
// 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 =
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 long LIVE_START_TIME = 0;
......
......@@ -55,6 +55,13 @@ public class RtspSessionTimingTest {
}
@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
public void parseTiming_withInvalidRangeTiming_throwsIllegalArgumentException() {
assertThrows(
IllegalArgumentException.class, () -> RtspSessionTiming.parseTiming("npt=10.000-2.054"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment