Handle when additional spaces are in SDP's RTPMAP atrribute
Issue: #9379 PiperOrigin-RevId: 395226701
This commit is contained in:
parent
730cdbb9e6
commit
093d117127
@ -63,8 +63,11 @@
|
|||||||
`Player.EVENT_STATIC_METADATA_CHANGED`. Use `Player.getMediaMetadata`,
|
`Player.EVENT_STATIC_METADATA_CHANGED`. Use `Player.getMediaMetadata`,
|
||||||
`Player.Listener.onMediaMetadataChanged` and
|
`Player.Listener.onMediaMetadataChanged` and
|
||||||
`Player.EVENT_MEDIA_METADATA_CHANGED` for convenient access to
|
`Player.EVENT_MEDIA_METADATA_CHANGED` for convenient access to
|
||||||
structured metadata, or access the raw static metadata directly from
|
structured metadata, or access the raw static metadata directly from the
|
||||||
the `TrackSelection#getFormat()`.
|
`TrackSelection#getFormat()`.
|
||||||
|
* RTSP:
|
||||||
|
* Handle when additional spaces are in SDP's RTPMAP atrribute
|
||||||
|
([#9379](https://github.com/google/ExoPlayer/issues/9379)).
|
||||||
|
|
||||||
### 2.15.0 (2021-08-10)
|
### 2.15.0 (2021-08-10)
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
/** Parses the RTPMAP attribute value (with the part "a=rtpmap:" removed). */
|
/** Parses the RTPMAP attribute value (with the part "a=rtpmap:" removed). */
|
||||||
public static RtpMapAttribute parse(String rtpmapString) throws ParserException {
|
public static RtpMapAttribute parse(String rtpmapString) throws ParserException {
|
||||||
String[] rtpmapInfo = Util.split(rtpmapString, " ");
|
String[] rtpmapInfo = Util.splitAtFirst(rtpmapString, " ");
|
||||||
checkArgument(rtpmapInfo.length == 2);
|
checkArgument(rtpmapInfo.length == 2);
|
||||||
int payloadType = parseInt(rtpmapInfo[0]);
|
int payloadType = parseInt(rtpmapInfo[0]);
|
||||||
|
|
||||||
String[] mediaInfo = Util.split(rtpmapInfo[1], "/");
|
String[] mediaInfo = Util.split(rtpmapInfo[1].trim(), "/");
|
||||||
checkArgument(mediaInfo.length >= 2);
|
checkArgument(mediaInfo.length >= 2);
|
||||||
int clockRate = parseInt(mediaInfo[1]);
|
int clockRate = parseInt(mediaInfo[1]);
|
||||||
int encodingParameters = C.INDEX_UNSET;
|
int encodingParameters = C.INDEX_UNSET;
|
||||||
|
@ -18,7 +18,6 @@ package com.google.android.exoplayer2.source.rtsp;
|
|||||||
import static com.google.android.exoplayer2.source.rtsp.MediaDescription.MEDIA_TYPE_AUDIO;
|
import static com.google.android.exoplayer2.source.rtsp.MediaDescription.MEDIA_TYPE_AUDIO;
|
||||||
import static com.google.android.exoplayer2.source.rtsp.RtpPayloadFormat.getMimeTypeFromRtpMediaType;
|
import static com.google.android.exoplayer2.source.rtsp.RtpPayloadFormat.getMimeTypeFromRtpMediaType;
|
||||||
import static com.google.android.exoplayer2.source.rtsp.SessionDescription.ATTR_CONTROL;
|
import static com.google.android.exoplayer2.source.rtsp.SessionDescription.ATTR_CONTROL;
|
||||||
import static com.google.android.exoplayer2.source.rtsp.SessionDescription.ATTR_RTPMAP;
|
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
|
import static com.google.android.exoplayer2.util.Assertions.checkArgument;
|
||||||
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
import static com.google.android.exoplayer2.util.NalUnitUtil.NAL_START_CODE;
|
import static com.google.android.exoplayer2.util.NalUnitUtil.NAL_START_CODE;
|
||||||
@ -95,13 +94,6 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
formatBuilder.setAverageBitrate(mediaDescription.bitrate);
|
formatBuilder.setAverageBitrate(mediaDescription.bitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rtpmap is mandatory in an RTSP session with dynamic payload types (RFC2326 Section C.1.3).
|
|
||||||
checkArgument(mediaDescription.attributes.containsKey(ATTR_RTPMAP));
|
|
||||||
String rtpmapAttribute = castNonNull(mediaDescription.attributes.get(ATTR_RTPMAP));
|
|
||||||
|
|
||||||
// rtpmap string format: RFC2327 Page 22.
|
|
||||||
String[] rtpmap = Util.split(rtpmapAttribute, " ");
|
|
||||||
checkArgument(rtpmap.length == 2);
|
|
||||||
int rtpPayloadType = mediaDescription.rtpMapAttribute.payloadType;
|
int rtpPayloadType = mediaDescription.rtpMapAttribute.payloadType;
|
||||||
|
|
||||||
String mimeType = getMimeTypeFromRtpMediaType(mediaDescription.rtpMapAttribute.mediaEncoding);
|
String mimeType = getMimeTypeFromRtpMediaType(mediaDescription.rtpMapAttribute.mediaEncoding);
|
||||||
|
@ -191,6 +191,25 @@ public class SessionDescriptionTest {
|
|||||||
assertThat(sessionDescription.attributes).containsEntry(ATTR_CONTROL, "session1");
|
assertThat(sessionDescription.attributes).containsEntry(ATTR_CONTROL, "session1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parse_sdpStringWithExtraSpaceInRtpMapAttribute_succeeds() throws Exception {
|
||||||
|
String testMediaSdpInfo =
|
||||||
|
"v=0\r\n"
|
||||||
|
+ "o=MNobody 2890844526 2890842807 IN IP4 192.0.2.46\r\n"
|
||||||
|
+ "s=SDP Seminar\r\n"
|
||||||
|
+ "t=0 0\r\n"
|
||||||
|
+ "a=control:*\r\n"
|
||||||
|
+ "m=audio 3456 RTP/AVP 0\r\n"
|
||||||
|
+ "a=rtpmap:97 AC3/44100 \r\n";
|
||||||
|
|
||||||
|
SessionDescription sessionDescription = SessionDescriptionParser.parse(testMediaSdpInfo);
|
||||||
|
MediaDescription.RtpMapAttribute rtpMapAttribute =
|
||||||
|
sessionDescription.mediaDescriptionList.get(0).rtpMapAttribute;
|
||||||
|
assertThat(rtpMapAttribute.payloadType).isEqualTo(97);
|
||||||
|
assertThat(rtpMapAttribute.mediaEncoding).isEqualTo("AC3");
|
||||||
|
assertThat(rtpMapAttribute.clockRate).isEqualTo(44100);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildMediaDescription_withInvalidRtpmapAttribute_throwsIllegalStateException() {
|
public void buildMediaDescription_withInvalidRtpmapAttribute_throwsIllegalStateException() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user