Skip to content

Commit

Permalink
Formatting...
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Apr 18, 2023
1 parent 5c5b782 commit daaff41
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,17 @@ public void testDecodeBufferExTS() {
assertNotNull(packet);
assertTrue(packet.getMessage() instanceof AudioData);
}

@Test
public void testExtendedTImestampPartialPacket() {
//Buffer contains 2 complete objects and 1 incomplete object.
//Buffer contains 2 complete objects and 1 incomplete object.
byte[] buf = IOUtils.hexStringToByteArray("03ffffff00004b090100000005584fce270100002800000042419e1e45152c236f0000030000030000030000030000030000030000030000030000030000030000030000030000030000030000030000030000030000030000049c03ffffff000008080100000005584fd1af01211004608c1c03ffffff000049090100000005");
RTMPConnection conn = RTMPConnManager.getInstance().createConnection(RTMPMinaConnection.class);
conn.setStateCode(RTMP.STATE_CONNECTED);
RTMPClientProtocolDecoder decoder = new RTMPClientProtocolDecoder();
List<Object> objects = decoder.decodeBuffer(conn, IoBuffer.wrap(buf));
//RTMPDecodeState state = conn.getDecoderState();
//RTMPDecodeState state = conn.getDecoderState();
assertTrue(objects.size() == 2);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, IoBuffer in,
int headerLength = RTMPUtils.getHeaderLength(headerSize);
headerLength += chh.getSize() - 1;
//If remaining bytes is less than known headerLength return null and set decoder state.
//This length does not include 4-byte extended timestamp field if present.
if (in.remaining() < headerLength ) {
//This length does not include 4-byte extended timestamp field if present.
if (in.remaining() < headerLength) {
state.bufferDecoding(headerLength - in.remaining());
in.position(startPostion);
return null;
}
}

Header lastHeader = rtmp.getLastReadHeader(channelId);
if (log.isTraceEnabled()) {
log.trace("{} lastHeader: {}", Header.HeaderType.values()[headerSize], lastHeader);
Expand Down Expand Up @@ -406,12 +406,12 @@ public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, IoBuffer in,
header.setStreamId(RTMPUtils.readReverseInt(in));
// read the extended timestamp if we have the indication that it exists
if (timeBase >= MEDIUM_INT_MAX) {
headerLength+=4;
if (in.remaining() < 4 ) {
headerLength += 4;
if (in.remaining() < 4) {
state.bufferDecoding(headerLength - in.remaining());
in.position(startPostion);
return null;
}
}
long ext = in.getUnsignedInt();
timeBase = (int) (ext ^ (ext >>> 32));
if (log.isTraceEnabled()) {
Expand All @@ -432,12 +432,12 @@ public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, IoBuffer in,
header.setStreamId(lastHeader.getStreamId());
// read the extended timestamp if we have the indication that it exists
if (timeDelta >= MEDIUM_INT_MAX) {
headerLength+=4;
if (in.remaining() < 4 ) {
headerLength += 4;
if (in.remaining() < 4) {
state.bufferDecoding(headerLength - in.remaining());
in.position(startPostion);
return null;
}
}
long ext = in.getUnsignedInt();
timeDelta = (int) (ext ^ (ext >>> 32));
header.setExtended(true);
Expand All @@ -455,12 +455,12 @@ public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, IoBuffer in,
header.setStreamId(lastHeader.getStreamId());
// read the extended timestamp if we have the indication that it exists
if (timeDelta >= MEDIUM_INT_MAX) {
headerLength+=4;
if (in.remaining() < 4 ) {
headerLength += 4;
if (in.remaining() < 4) {
state.bufferDecoding(headerLength - in.remaining());
in.position(startPostion);
return null;
}
}
long ext = in.getUnsignedInt();
timeDelta = (int) (ext ^ (ext >>> 32));
header.setExtended(true);
Expand All @@ -479,8 +479,8 @@ public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, IoBuffer in,
// This field is present in Type 3 chunks when the most recent Type 0, 1, or 2 chunk for the same chunk stream ID
// indicated the presence of an extended timestamp field
if (lastHeader.isExtended()) {
headerLength+=4;
if (in.remaining() < 4 ) {
headerLength += 4;
if (in.remaining() < 4) {
state.bufferDecoding(headerLength - in.remaining());
in.position(startPostion);
return null;
Expand Down

0 comments on commit daaff41

Please sign in to comment.