Skip to content

Commit 1b368bc

Browse files
committed
Possible fix for ObjectMap arrival at createStream instead of Number
1 parent f76bae1 commit 1b368bc

File tree

3 files changed

+44
-6
lines changed

3 files changed

+44
-6
lines changed

client/src/main/java/org/red5/client/net/rtmp/BaseRTMPClientHandler.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,26 @@ public CreateStreamCallBack(IPendingServiceCallback wrapped) {
10341034

10351035
@Override
10361036
public void resultReceived(IPendingServiceCall call) {
1037-
Number streamId = (Number) call.getResult();
1037+
// get the result as base object
1038+
Object callResult = call.getResult();
1039+
// we expect a number consisting of the stream id, but we'll check for an object map as well
1040+
Number streamId = null;
1041+
if (callResult instanceof Number) {
1042+
streamId = (Number) callResult;
1043+
} else if (callResult instanceof Map) {
1044+
Map<?, ?> map = (Map<?, ?>) callResult;
1045+
if (map.containsKey("streamId")) {
1046+
Object tmpStreamId = map.get("streamId");
1047+
if (tmpStreamId instanceof Number) {
1048+
streamId = (Number) tmpStreamId;
1049+
} else {
1050+
log.warn("CreateStreamCallBack resultReceived - stream id is not a number: {}", tmpStreamId);
1051+
}
1052+
}
1053+
} else if (callResult == null) {
1054+
log.warn("CreateStreamCallBack resultReceived - call result is null");
1055+
return;
1056+
}
10381057
log.debug("CreateStreamCallBack resultReceived - stream id: {} call: {} connection: {}", streamId, call, conn);
10391058
if (conn != null && streamId != null) {
10401059
log.debug("Setting new net stream");
@@ -1078,9 +1097,27 @@ public DeleteStreamCallBack(IPendingServiceCallback wrapped) {
10781097

10791098
@Override
10801099
public void resultReceived(IPendingServiceCall call) {
1081-
Number streamId = (Number) call.getResult();
1082-
log.debug("Stream id: {} connection: {}", streamId, conn);
1083-
log.debug("DeleteStreamCallBack resultReceived - stream id: {}", streamId);
1100+
// get the result as base object
1101+
Object callResult = call.getResult();
1102+
// we expect a number consisting of the stream id, but we'll check for an object map as well
1103+
Number streamId = null;
1104+
if (callResult instanceof Number) {
1105+
streamId = (Number) callResult;
1106+
} else if (callResult instanceof Map) {
1107+
Map<?, ?> map = (Map<?, ?>) callResult;
1108+
if (map.containsKey("streamId")) {
1109+
Object tmpStreamId = map.get("streamId");
1110+
if (tmpStreamId instanceof Number) {
1111+
streamId = (Number) tmpStreamId;
1112+
} else {
1113+
log.warn("DeleteStreamCallBack resultReceived - stream id is not a number: {}", tmpStreamId);
1114+
}
1115+
}
1116+
} else if (callResult == null) {
1117+
log.warn("DeleteStreamCallBack resultReceived - call result is null");
1118+
return;
1119+
}
1120+
log.debug("DeleteStreamCallBack resultReceived - stream id: {} call: {} connection: {}", streamId, call, conn);
10841121
if (conn != null && streamId != null) {
10851122
log.debug("Deleting net stream");
10861123
conn.removeClientStream(streamId);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<name>Red5</name>
2424
<description>The Red5 server</description>
2525
<groupId>org.red5</groupId>
26-
<version>1.3.12</version>
26+
<version>1.3.13</version>
2727
<url>https://github.com/Red5/red5-server</url>
2828
<inceptionYear>2005</inceptionYear>
2929
<organization>

red5-server.code-workspace

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
}
66
],
77
"settings": {
8-
"java.configuration.updateBuildConfiguration": "automatic"
8+
"java.configuration.updateBuildConfiguration": "automatic",
9+
"java.compile.nullAnalysis.mode": "automatic"
910
}
1011
}

0 commit comments

Comments
 (0)