Fix some minor review comments in RtpH265Reader
This commit is contained in:
parent
aa6874655d
commit
ca1c1c26d5
@ -44,10 +44,10 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
// Format specific parameter names.
|
// Format specific parameter names.
|
||||||
private static final String PARAMETER_PROFILE_LEVEL_ID = "profile-level-id";
|
private static final String PARAMETER_PROFILE_LEVEL_ID = "profile-level-id";
|
||||||
private static final String PARAMETER_SPROP_PARAMS = "sprop-parameter-sets";
|
private static final String PARAMETER_SPROP_PARAMS = "sprop-parameter-sets";
|
||||||
private static final String PARAMETER_SPROP_H265_SPS = "sprop-sps";
|
private static final String PARAMETER_H265_SPROP_SPS = "sprop-sps";
|
||||||
private static final String PARAMETER_SPROP_H265_PPS = "sprop-pps";
|
private static final String PARAMETER_H265_SPROP_PPS = "sprop-pps";
|
||||||
private static final String PARAMETER_SPROP_H265_VPS = "sprop-vps";
|
private static final String PARAMETER_H265_SPROP_VPS = "sprop-vps";
|
||||||
private static final String PARAMETER_SPROP_H265_MAX_DON_DIFF = "sprop-max-don-diff";
|
private static final String PARAMETER_H265_SPROP_MAX_DON_DIFF = "sprop-max-don-diff";
|
||||||
|
|
||||||
/** Prefix for the RFC6381 codecs string for AAC formats. */
|
/** Prefix for the RFC6381 codecs string for AAC formats. */
|
||||||
private static final String AAC_CODECS_PREFIX = "mp4a.40.";
|
private static final String AAC_CODECS_PREFIX = "mp4a.40.";
|
||||||
@ -222,19 +222,19 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
|
|
||||||
private static void processH265FmtpAttribute(
|
private static void processH265FmtpAttribute(
|
||||||
Format.Builder formatBuilder, ImmutableMap<String, String> fmtpAttributes) {
|
Format.Builder formatBuilder, ImmutableMap<String, String> fmtpAttributes) {
|
||||||
if (fmtpAttributes.containsKey(PARAMETER_SPROP_H265_MAX_DON_DIFF)) {
|
if (fmtpAttributes.containsKey(PARAMETER_H265_SPROP_MAX_DON_DIFF)) {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
Integer.parseInt(checkNotNull(fmtpAttributes.get(PARAMETER_SPROP_H265_MAX_DON_DIFF)))
|
Integer.parseInt(checkNotNull(fmtpAttributes.get(PARAMETER_H265_SPROP_MAX_DON_DIFF)))
|
||||||
== 0,
|
== 0,
|
||||||
"non-zero sprop-max-don-diff is not supported");
|
"non-zero sprop-max-don-diff is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
checkArgument(fmtpAttributes.containsKey(PARAMETER_SPROP_H265_VPS));
|
checkArgument(fmtpAttributes.containsKey(PARAMETER_H265_SPROP_VPS));
|
||||||
String spropVPS = checkNotNull(fmtpAttributes.get(PARAMETER_SPROP_H265_VPS));
|
String spropVPS = checkNotNull(fmtpAttributes.get(PARAMETER_H265_SPROP_VPS));
|
||||||
checkArgument(fmtpAttributes.containsKey(PARAMETER_SPROP_H265_SPS));
|
checkArgument(fmtpAttributes.containsKey(PARAMETER_H265_SPROP_SPS));
|
||||||
String spropSPS = checkNotNull(fmtpAttributes.get(PARAMETER_SPROP_H265_SPS));
|
String spropSPS = checkNotNull(fmtpAttributes.get(PARAMETER_H265_SPROP_SPS));
|
||||||
checkArgument(fmtpAttributes.containsKey(PARAMETER_SPROP_H265_PPS));
|
checkArgument(fmtpAttributes.containsKey(PARAMETER_H265_SPROP_PPS));
|
||||||
String spropPPS = checkNotNull(fmtpAttributes.get(PARAMETER_SPROP_H265_PPS));
|
String spropPPS = checkNotNull(fmtpAttributes.get(PARAMETER_H265_SPROP_PPS));
|
||||||
ImmutableList<byte[]> initializationData =
|
ImmutableList<byte[]> initializationData =
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
getInitializationDataFromParameterSet(spropVPS),
|
getInitializationDataFromParameterSet(spropVPS),
|
||||||
@ -248,8 +248,7 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
NalUnitUtil.parseH265SpsNalUnit(
|
NalUnitUtil.parseH265SpsNalUnit(
|
||||||
spsNalDataWithStartCode, NAL_START_CODE.length, spsNalDataWithStartCode.length);
|
spsNalDataWithStartCode, NAL_START_CODE.length, spsNalDataWithStartCode.length);
|
||||||
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
formatBuilder.setPixelWidthHeightRatio(spsData.pixelWidthHeightRatio);
|
||||||
formatBuilder.setHeight(spsData.height);
|
formatBuilder.setHeight(spsData.height).setWidth(spsData.width);
|
||||||
formatBuilder.setWidth(spsData.width);
|
|
||||||
|
|
||||||
formatBuilder.setCodecs(
|
formatBuilder.setCodecs(
|
||||||
CodecSpecificDataUtil.buildHevcCodecString(
|
CodecSpecificDataUtil.buildHevcCodecString(
|
||||||
|
@ -68,10 +68,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
/** Scratch for Fragmentation Unit RTP packets. */
|
/** Scratch for Fragmentation Unit RTP packets. */
|
||||||
private final ParsableByteArray fuScratchBuffer;
|
private final ParsableByteArray fuScratchBuffer;
|
||||||
|
private final ParsableByteArray nalStartCodeArray;
|
||||||
private final ParsableByteArray nalStartCodeArray =
|
|
||||||
new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
|
|
||||||
|
|
||||||
private final RtpPayloadFormat payloadFormat;
|
private final RtpPayloadFormat payloadFormat;
|
||||||
|
|
||||||
private @MonotonicNonNull TrackOutput trackOutput;
|
private @MonotonicNonNull TrackOutput trackOutput;
|
||||||
@ -84,8 +81,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
/** Creates an instance. */
|
/** Creates an instance. */
|
||||||
public RtpH265Reader(RtpPayloadFormat payloadFormat) {
|
public RtpH265Reader(RtpPayloadFormat payloadFormat) {
|
||||||
this.payloadFormat = payloadFormat;
|
|
||||||
fuScratchBuffer = new ParsableByteArray();
|
fuScratchBuffer = new ParsableByteArray();
|
||||||
|
nalStartCodeArray = new ParsableByteArray(NalUnitUtil.NAL_START_CODE);
|
||||||
|
this.payloadFormat = payloadFormat;
|
||||||
firstReceivedTimestamp = C.TIME_UNSET;
|
firstReceivedTimestamp = C.TIME_UNSET;
|
||||||
previousSequenceNumber = C.INDEX_UNSET;
|
previousSequenceNumber = C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
@ -235,11 +233,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
(data.getData()[1] & 0x7); // last 3 bits in byte 1 of payload header, RFC7798 Section 1.1.4
|
(data.getData()[1] & 0x7); // last 3 bits in byte 1 of payload header, RFC7798 Section 1.1.4
|
||||||
int fuHeader = data.getData()[2];
|
int fuHeader = data.getData()[2];
|
||||||
int nalUnitType = fuHeader & 0x3F;
|
int nalUnitType = fuHeader & 0x3F;
|
||||||
byte nalHeader[] = new byte[2];
|
|
||||||
|
|
||||||
nalHeader[0] = (byte) (nalUnitType << 1); // RFC7798 Section 1.1.4
|
|
||||||
// layerId must be zero according to RFC7798 Section 1.1.4, so copying the tid only
|
|
||||||
nalHeader[1] = (byte) tid;
|
|
||||||
boolean isFirstFuPacket = (fuHeader & 0x80) > 0;
|
boolean isFirstFuPacket = (fuHeader & 0x80) > 0;
|
||||||
boolean isLastFuPacket = (fuHeader & 0x40) > 0;
|
boolean isLastFuPacket = (fuHeader & 0x40) > 0;
|
||||||
|
|
||||||
@ -249,12 +243,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
|
|
||||||
// Overwrite a few bytes in Rtp buffer to get HEVC NAL Unit
|
// Overwrite a few bytes in Rtp buffer to get HEVC NAL Unit
|
||||||
// Rtp Byte 0 -> Ignore
|
// Rtp Byte 0 -> Ignore
|
||||||
// Rtp Byte 1 -> Byte 0 of HEVC NAL Header
|
// Rtp Byte 1 -> nal_unit_type, RFC7798 Section 1.1.4
|
||||||
// Rtp Byte 2 -> Byte 1 of HEVC NAL Header
|
// Rtp Byte 2 -> layerId required to be zero so copying only tid, RFC7798 Section 1.1.4
|
||||||
// Rtp Payload -> HEVC NAL bytes, so leave them unchanged
|
// Rtp Payload -> HEVC NAL bytes, so leave them unchanged
|
||||||
// Set data position from byte 1 as byte 0 was ignored
|
// Set data position from byte 1 as byte 0 was ignored
|
||||||
data.getData()[1] = (byte) nalHeader[0];
|
data.getData()[1] = (byte) (nalUnitType << 1);
|
||||||
data.getData()[2] = (byte) nalHeader[1];
|
data.getData()[2] = (byte) tid;
|
||||||
fuScratchBuffer.reset(data.getData());
|
fuScratchBuffer.reset(data.getData());
|
||||||
fuScratchBuffer.setPosition(1);
|
fuScratchBuffer.setPosition(1);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user