Skip to content

Commit

Permalink
Merge pull request #97 from chubais/fix/skip-rtp-extension
Browse files Browse the repository at this point in the history
Skip rtp extension
  • Loading branch information
alexeyvasilyev authored Dec 16, 2024
2 parents c8c73d9 + 3688525 commit 04f6407
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -667,7 +668,17 @@ private static void readRtpData(
if (videoSeqNum > header.sequenceNumber)
Log.w(TAG, "Invalid video seq num " + videoSeqNum + "/" + header.sequenceNumber);
videoSeqNum = header.sequenceNumber;
byte[] nalUnit = videoParser.processRtpPacketAndGetNalUnit(data, header.payloadSize, header.marker == 1);

byte[] nalUnit;
// If extendion bit set in header, skip extension data
if (header.extension == 1) {
int skipBytes = ((data[2] & 0xFF) << 8 | (data[3] & 0xFF)) * 4 + 4;
nalUnit = videoParser.processRtpPacketAndGetNalUnit(Arrays.copyOfRange(data, skipBytes, data.length),
header.payloadSize - skipBytes, header.marker == 1);
} else {
nalUnit = videoParser.processRtpPacketAndGetNalUnit(data, header.payloadSize, header.marker == 1);
}

if (nalUnit != null) {
boolean isH265 = sdpInfo.videoTrack.videoCodec == VIDEO_CODEC_H265;
byte type = VideoCodecUtils.INSTANCE.getNalUnitType(nalUnit, 0, nalUnit.length, isH265);
Expand Down

0 comments on commit 04f6407

Please sign in to comment.