[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rtp h263 test and fix #119

Merged
merged 6 commits into from
Aug 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Keep the input data constant in consume method
Earlier, the consume method of RtpH263Reader was changing the bytes of the
input bitstream during header parse. This commit copies the input into
local context and changes the local variable as per the specifications
thus keeping the input constant.
  • Loading branch information
ManishaJajoo committed Jul 18, 2022
commit 3bacb1646c9ecd01e403465c7643888e83a9e79d
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public void consume(
// | RR |P|V| PLEN |PEBIT|
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
int currentPosition = data.getPosition();
int header = data.readUnsignedShort();
ParsableByteArray bitstreamData = new ParsableByteArray(data.getData().clone());
int header = bitstreamData.readUnsignedShort();
boolean pBitIsSet = (header & 0x400) > 0;

// Check if optional V (Video Redundancy Coding), PLEN or PEBIT is present, RFC4629 Section 5.1.
Expand All @@ -123,16 +124,16 @@ public void consume(
}
gotFirstPacketOfH263Frame = true;

int payloadStartCode = data.peekUnsignedByte() & 0xFC;
int payloadStartCode = bitstreamData.peekUnsignedByte() & 0xFC;
// Packets that begin with a Picture Start Code(100000). Refer RFC4629 Section 6.1.
if (payloadStartCode < PICTURE_START_CODE) {
Log.w(TAG, "Picture start Code (PSC) missing, dropping packet.");
return;
}
// Setting first two bytes of the start code. Refer RFC4629 Section 6.1.1.
data.getData()[currentPosition] = 0;
data.getData()[currentPosition + 1] = 0;
data.setPosition(currentPosition);
bitstreamData.getData()[currentPosition] = 0;
bitstreamData.getData()[currentPosition + 1] = 0;
bitstreamData.setPosition(currentPosition);
} else if (gotFirstPacketOfH263Frame) {
// Check that this packet is in the sequence of the previous packet.
int expectedSequenceNumber = RtpPacket.getNextSequenceNumber(previousSequenceNumber);
Expand All @@ -154,7 +155,7 @@ public void consume(
}

if (fragmentedSampleSizeBytes == 0) {
parseVopHeader(data, isOutputFormatSet);
parseVopHeader(bitstreamData, isOutputFormatSet);
if (!isOutputFormatSet && isKeyFrame) {
if (width != payloadFormat.format.width || height != payloadFormat.format.height) {
trackOutput.format(
Expand All @@ -163,9 +164,9 @@ public void consume(
isOutputFormatSet = true;
}
}
int fragmentSize = data.bytesLeft();
int fragmentSize = bitstreamData.bytesLeft();
// Write the video sample.
trackOutput.sampleData(data, fragmentSize);
trackOutput.sampleData(bitstreamData, fragmentSize);
fragmentedSampleSizeBytes += fragmentSize;
sampleTimeUsOfFragmentedSample =
toSampleUs(startTimeOffsetUs, timestamp, firstReceivedTimestamp);
Expand Down