Fix review comments in RtpVP8Reader
Change-Id: Id47c746b199831d0bb51dc736c43fd20c2e79c08
This commit is contained in:
parent
f2e0953643
commit
8afa7a548a
@ -42,7 +42,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
private final RtpPayloadFormat payloadFormat;
|
private final RtpPayloadFormat payloadFormat;
|
||||||
|
|
||||||
private @MonotonicNonNull TrackOutput trackOutput;
|
private @MonotonicNonNull TrackOutput trackOutput;
|
||||||
@C.BufferFlags private int bufferFlags;
|
|
||||||
|
|
||||||
private long firstReceivedTimestamp;
|
private long firstReceivedTimestamp;
|
||||||
private int previousSequenceNumber;
|
private int previousSequenceNumber;
|
||||||
@ -78,7 +77,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
throws ParserException {
|
throws ParserException {
|
||||||
checkStateNotNull(trackOutput);
|
checkStateNotNull(trackOutput);
|
||||||
|
|
||||||
if (parseVP8Descriptor(data, sequenceNumber)) {
|
// Check if valid VP8 Payload Descriptor is present
|
||||||
|
boolean isValidVP8Descriptor = parseVP8Descriptor(data, sequenceNumber);
|
||||||
|
if (isValidVP8Descriptor) {
|
||||||
// VP8 Payload Header, RFC7741 Section 4.3
|
// VP8 Payload Header, RFC7741 Section 4.3
|
||||||
// 0 1 2 3 4 5 6 7
|
// 0 1 2 3 4 5 6 7
|
||||||
// +-+-+-+-+-+-+-+-+
|
// +-+-+-+-+-+-+-+-+
|
||||||
@ -89,7 +90,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
isKeyFrame = (data.peekUnsignedByte() & 0x01) == 0;
|
isKeyFrame = (data.peekUnsignedByte() & 0x01) == 0;
|
||||||
}
|
}
|
||||||
if (!isOutputFormatSet) {
|
if (!isOutputFormatSet) {
|
||||||
// Parsing frame data to get width and height, RFC6386 Section 9.1
|
// Parsing frame data to get width and height, RFC6386 Section 19.1
|
||||||
int currPosition = data.getPosition();
|
int currPosition = data.getPosition();
|
||||||
data.setPosition(currPosition + 6);
|
data.setPosition(currPosition + 6);
|
||||||
int width = data.readLittleEndianUnsignedShort() & 0x3fff;
|
int width = data.readLittleEndianUnsignedShort() & 0x3fff;
|
||||||
@ -97,10 +98,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
data.setPosition(currPosition);
|
data.setPosition(currPosition);
|
||||||
|
|
||||||
if (width != payloadFormat.format.width || height != payloadFormat.format.height) {
|
if (width != payloadFormat.format.width || height != payloadFormat.format.height) {
|
||||||
Format trackFormat = payloadFormat.format;
|
trackOutput.format(
|
||||||
Format.Builder formatBuilder = trackFormat.buildUpon();
|
payloadFormat.format.buildUpon().setWidth(width).setHeight(height).build());
|
||||||
formatBuilder.setWidth(width).setHeight(height);
|
|
||||||
trackOutput.format(formatBuilder.build());
|
|
||||||
}
|
}
|
||||||
isOutputFormatSet = true;
|
isOutputFormatSet = true;
|
||||||
}
|
}
|
||||||
@ -114,11 +113,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
if (firstReceivedTimestamp == C.TIME_UNSET) {
|
if (firstReceivedTimestamp == C.TIME_UNSET) {
|
||||||
firstReceivedTimestamp = timestamp;
|
firstReceivedTimestamp = timestamp;
|
||||||
}
|
}
|
||||||
bufferFlags = isKeyFrame ? C.BUFFER_FLAG_KEY_FRAME : 0;
|
|
||||||
long timeUs = toSampleUs(startTimeOffsetUs, timestamp, firstReceivedTimestamp);
|
long timeUs = toSampleUs(startTimeOffsetUs, timestamp, firstReceivedTimestamp);
|
||||||
trackOutput.sampleMetadata(
|
trackOutput.sampleMetadata(
|
||||||
timeUs,
|
timeUs,
|
||||||
bufferFlags,
|
isKeyFrame ? C.BUFFER_FLAG_KEY_FRAME : 0,
|
||||||
fragmentedSampleSizeBytes,
|
fragmentedSampleSizeBytes,
|
||||||
/* offset= */ 0,
|
/* offset= */ 0,
|
||||||
/* encryptionData= */ null);
|
/* encryptionData= */ null);
|
||||||
@ -156,11 +154,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
if (!gotFirstPacketOfVP8Frame) {
|
if (!gotFirstPacketOfVP8Frame) {
|
||||||
// For start of VP8 partition S=1 and PID=0 as per RFC7741 Section 4.2
|
// For start of VP8 partition S=1 and PID=0 as per RFC7741 Section 4.2
|
||||||
if ((header & 0x17) != 0x10) {
|
if ((header & 0x17) != 0x10) {
|
||||||
Log.w(
|
Log.w(TAG,"first payload octet of the RTP packet is not the beginning of a new VP8 "
|
||||||
TAG,
|
+ "partition, Dropping current packet");
|
||||||
Util.formatInvariant(
|
|
||||||
"first payload octet of the RTP packet is not the beginning of a new VP8 "
|
|
||||||
+ "partition, Dropping current packet"));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
gotFirstPacketOfVP8Frame = true;
|
gotFirstPacketOfVP8Frame = true;
|
||||||
@ -187,9 +182,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
int iHeader = payload.readUnsignedByte();
|
int iHeader = payload.readUnsignedByte();
|
||||||
if ((iHeader & 0x80) != 0) {
|
if ((iHeader & 0x80) != 0) {
|
||||||
payload.skipBytes(1);
|
payload.skipBytes(1);
|
||||||
Log.i(TAG, "15 bits PictureID");
|
|
||||||
} else {
|
|
||||||
Log.i(TAG, "7 bits PictureID");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user