Skip to content

Commit

Permalink
Bumped version to 1.2.20; includes fixes for RTMP/E
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Apr 11, 2022
1 parent 316c45d commit 88cee98
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.red5</groupId>
<artifactId>red5-parent</artifactId>
<version>1.2.19</version>
<version>1.2.20</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/red5/client/Red5Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class Red5Client {
/**
* Current server version with revision
*/
public static final String VERSION = "Red5 Client 1.2.6";
public static final String VERSION = "Red5 Client 1.2.20";

/**
* Create a new Red5Client object using the connection local to the current thread A bit of magic that lets you access the red5 scope
Expand Down
48 changes: 27 additions & 21 deletions src/main/java/org/red5/client/net/rtmpe/RTMPEIoFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,38 @@ public void messageReceived(NextFilter nextFilter, IoSession session, Object obj
}
// complete the connection regardless of the S2 success or failure
completeConnection(session, conn, handshake);
} else {
// don't fall through to connected process if we didn't have enough for the handshake
break;
}
// allow fall-through
case RTMP.STATE_CONNECTED:
IoBuffer message = buffer.getBufferAsIoBuffer();
// assuming majority of connections will not be encrypted
if (!((RTMPConnection) conn).isEncrypted()) {
Cipher cipher = (Cipher) session.getAttribute(RTMPConnection.RTMPE_CIPHER_IN);
if (cipher != null) {
if (log.isDebugEnabled()) {
log.debug("Decrypting message: {}", message);
}
byte[] encrypted = new byte[message.remaining()];
message.get(encrypted);
message.free();
byte[] plain = cipher.update(encrypted);
IoBuffer messageDecrypted = IoBuffer.wrap(plain);
if (log.isDebugEnabled()) {
log.debug("Decrypted buffer: {}", messageDecrypted);
}
nextFilter.messageReceived(session, messageDecrypted);
// skip empty buffer
if (buffer.getBufferSize() > 0) {
IoBuffer message = buffer.getBufferAsIoBuffer();
// assuming majority of connections will not be encrypted
if (!((RTMPConnection) conn).isEncrypted()) {
log.trace("Receiving message: {}", message);
nextFilter.messageReceived(session, message);
} else {
log.warn("Decryption cipher is missing from the session");
Cipher cipher = (Cipher) session.getAttribute(RTMPConnection.RTMPE_CIPHER_IN);
if (cipher != null) {
if (log.isDebugEnabled()) {
log.debug("Decrypting message: {}", message);
}
byte[] encrypted = new byte[message.remaining()];
message.get(encrypted);
message.free();
byte[] plain = cipher.update(encrypted);
IoBuffer messageDecrypted = IoBuffer.wrap(plain);
if (log.isDebugEnabled()) {
log.debug("Decrypted buffer: {}", messageDecrypted);
}
nextFilter.messageReceived(session, messageDecrypted);
} else {
log.warn("Decryption cipher is missing from the session");
}
}
} else {
log.trace("Not decrypting message: {}", obj);
nextFilter.messageReceived(session, obj);
}
break;
case RTMP.STATE_ERROR:
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/org/red5/client/net/rtmp/RTMPClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ public class RTMPClientTest {
// task timer
private static Timer timer = new Timer();

// application name
private static String app = "oflaDemo"; //"vod";

// AMS sample
// private static String sourceStreamName = "mp4:sample1_1500kbps.f4v";

// sample video under oflaDemo example app
private static String sourceStreamName = "mp4:thx_deep_note_360p.mp4";

// local sample
private static String sourceStreamName = "flashContent";
//private static String sourceStreamName = "flashContent";

// https://github.com/Red5/red5-client/issues/26
@Test
Expand Down Expand Up @@ -76,7 +82,7 @@ public void resultReceived(IPendingServiceCall call) {
* client.invoke("loadPlaylist", params, new IPendingServiceCallback() {
* @Override public void resultReceived(IPendingServiceCall result) { System.out.println(result); } }); } } });
*/
client.connect("localhost", 1935, "vod", connectCallback);
client.connect("localhost", 1935, app, connectCallback);

do {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void testOutboundHandshake() {
// send in the combined server handshake, this creates C2
C2 = out.decodeServerResponse1(S0S1S2);
log.debug("C2 (third): {}", C2);

}

@Test
Expand Down

0 comments on commit 88cee98

Please sign in to comment.