Fix review comments on RtpMPEG4Reader
This commit is contained in:
parent
706d5ac252
commit
ef9393a337
@ -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<String, String> 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<Integer, Integer> 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));
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user