mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Change RtpPacket class to parse header extension if exists
This commit is contained in:
parent
b5db8a6cbe
commit
7dd428534e
@ -143,6 +143,8 @@ public final class RtpPacket {
|
|||||||
public static final int MIN_SEQUENCE_NUMBER = 0;
|
public static final int MIN_SEQUENCE_NUMBER = 0;
|
||||||
public static final int MAX_SEQUENCE_NUMBER = 0xFFFF;
|
public static final int MAX_SEQUENCE_NUMBER = 0xFFFF;
|
||||||
public static final int CSRC_SIZE = 4;
|
public static final int CSRC_SIZE = 4;
|
||||||
|
public static final int EXTENSION_SIZE = 16;
|
||||||
|
|
||||||
|
|
||||||
/** Returns the next sequence number of the {@code sequenceNumber}. */
|
/** Returns the next sequence number of the {@code sequenceNumber}. */
|
||||||
public static int getNextSequenceNumber(int sequenceNumber) {
|
public static int getNextSequenceNumber(int sequenceNumber) {
|
||||||
@ -205,6 +207,8 @@ public final class RtpPacket {
|
|||||||
byte version = (byte) (firstByte >> 6);
|
byte version = (byte) (firstByte >> 6);
|
||||||
boolean padding = ((firstByte >> 5) & 0x1) == 1;
|
boolean padding = ((firstByte >> 5) & 0x1) == 1;
|
||||||
byte csrcCount = (byte) (firstByte & 0xF);
|
byte csrcCount = (byte) (firstByte & 0xF);
|
||||||
|
boolean hasExtension = ((firstByte & 0x10) >> 4) == 1;
|
||||||
|
|
||||||
|
|
||||||
if (version != RTP_VERSION) {
|
if (version != RTP_VERSION) {
|
||||||
return null;
|
return null;
|
||||||
@ -233,6 +237,12 @@ public final class RtpPacket {
|
|||||||
csrc = EMPTY;
|
csrc = EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Extension.
|
||||||
|
if (hasExtension){
|
||||||
|
byte[] extension = new byte[EXTENSION_SIZE];
|
||||||
|
packetBuffer.readBytes(extension, 0, EXTENSION_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
// Everything else will be RTP payload.
|
// Everything else will be RTP payload.
|
||||||
byte[] payloadData = new byte[packetBuffer.bytesLeft()];
|
byte[] payloadData = new byte[packetBuffer.bytesLeft()];
|
||||||
packetBuffer.readBytes(payloadData, 0, packetBuffer.bytesLeft());
|
packetBuffer.readBytes(payloadData, 0, packetBuffer.bytesLeft());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user