diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java index 97900c1e1d..f4b10981ca 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaTrack.java @@ -56,7 +56,7 @@ import com.google.common.collect.ImmutableMap; /** Prefix for the RFC6381 codecs string for AVC formats. */ private static final String H264_CODECS_PREFIX = "avc1."; /** Prefix for the RFC6416 codecs string for MPEG4V-ES formats. */ - private static final String MPEG4_CODECS_PREFIX = "mp4v"; + private static final String MPEG4_CODECS_PREFIX = "mp4v."; private static final String GENERIC_CONTROL_ATTR = "*"; @@ -181,12 +181,14 @@ import com.google.common.collect.ImmutableMap; Format.Builder formatBuilder, ImmutableMap fmtpAttributes) { @Nullable String configInput = fmtpAttributes.get(PARAMETER_MP4V_CONFIG); if (configInput != null) { - byte[] csd = Util.getBytesFromHexString(configInput); - formatBuilder.setInitializationData(ImmutableList.of(csd)); + byte[] configBuffer = Util.getBytesFromHexString(configInput); + formatBuilder.setInitializationData(ImmutableList.of(configBuffer)); Pair resolution = - CodecSpecificDataUtil.getVideoResolutionFromMpeg4VideoConfig(csd); - formatBuilder.setWidth(resolution.first); - formatBuilder.setHeight(resolution.second); + CodecSpecificDataUtil.getVideoResolutionFromMpeg4VideoConfig(configBuffer); + formatBuilder.setWidth(resolution.first).setHeight(resolution.second); + } else { + // set the default width and height + formatBuilder.setWidth(352).setHeight(288); } @Nullable String profileLevel = fmtpAttributes.get(PARAMETER_PROFILE_LEVEL_ID); formatBuilder.setCodecs(MPEG4_CODECS_PREFIX + (profileLevel == null ? "1" : profileLevel)); diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/RtpMPEG4Reader.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/RtpMPEG4Reader.java index 8154b9379b..82556057c6 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/RtpMPEG4Reader.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/reader/RtpMPEG4Reader.java @@ -88,7 +88,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; // Parse VOP Type and get the buffer flags int limit = data.bytesLeft(); trackOutput.sampleData(data, limit); - if (sampleLength == 0) bufferFlags = getBufferFlagsFromVop(data); + if (sampleLength == 0) { + bufferFlags = getBufferFlagsFromVop(data); + } sampleLength += limit; // Marker (M) bit: The marker bit is set to 1 to indicate the last RTP @@ -122,7 +124,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; */ @C.BufferFlags private static int getBufferFlagsFromVop(ParsableByteArray data) { - int flags = 0; // search for VOP_START_CODE (00 00 01 B6) byte[] inputData = data.getData(); byte[] startCode = new byte[] {0x0, 0x0, 0x1, (byte) 0xB6}; @@ -130,9 +131,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; if (vopStartCodePos != -1) { data.setPosition(vopStartCodePos + 4); int vopType = data.peekUnsignedByte() >> 6; - flags = vopType == I_VOP ? C.BUFFER_FLAG_KEY_FRAME : 0; + return (vopType == I_VOP ? C.BUFFER_FLAG_KEY_FRAME : 0); } - return flags; + return 0; } private static long toSampleUs(