Skip to content

Commit

Permalink
Replace Number with int for PrivateNetstreamData in client. Update to…
Browse files Browse the repository at this point in the history
… 1.3.26
  • Loading branch information
mondain committed Nov 29, 2023
1 parent 2d0baec commit 8701d73
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 27 deletions.
2 changes: 1 addition & 1 deletion client/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.3.25</version>
<version>1.3.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/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.3.25";
public static final String VERSION = "Red5 Client 1.3.26";

/**
* 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

Expand Down Expand Up @@ -98,7 +98,7 @@ public abstract class BaseRTMPClientHandler extends BaseRTMPHandler implements I
/**
* Net stream handling
*/
private volatile CopyOnWriteArrayList<NetStreamPrivateData> streamDataList = new CopyOnWriteArrayList<>();
private volatile CopyOnWriteArraySet<NetStreamPrivateData> streamDataList = new CopyOnWriteArraySet<>();

/**
* Task to start on connection close
Expand Down Expand Up @@ -577,7 +577,8 @@ public void publish(Number streamId, String name, String mode, INetStreamEventHa
log.debug("publish - stream id: {}, name: {}, mode: {}", streamId, name, mode);
// setup the netstream handler
if (handler != null) {
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId().equals(streamId.doubleValue())).findFirst().orElse(null);
final int sid = streamId.intValue();
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId() == sid).findFirst().orElse(null);
if (streamData != null) {
log.debug("Setting handler on stream data - handler: {}", handler);
streamData.handler = handler;
Expand Down Expand Up @@ -608,7 +609,8 @@ public void unpublish(Number streamId) {
@Override
public void publishStreamData(Number streamId, IMessage message) {
// get the stream data by index of the list
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId().equals(streamId.doubleValue())).findFirst().orElse(null);
final int sid = streamId.intValue();
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId() == sid).findFirst().orElse(null);
if (streamData != null) {
if (streamData.connConsumer != null) {
streamData.connConsumer.pushMessage(null, message);
Expand Down Expand Up @@ -808,9 +810,10 @@ protected void onCommand(RTMPConnection conn, Channel channel, Header source, IC
}
if (streamId != null) {
// try lookup by stream id, if null return the first one
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId().equals(streamId)).findFirst().orElse(streamDataList.get(0));
final int sid = streamId.intValue();
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId() == sid).findFirst().orElse(null);
if (streamData == null) {
log.warn("Stream data was null for id: {}", streamId);
log.warn("Stream data was null for id: {} entry count: {}", streamId, streamDataList.size());
} else if (streamData.handler != null) {
log.debug("Got stream data and handler");
streamData.handler.onStreamEvent((Notify) command);
Expand Down Expand Up @@ -1028,24 +1031,24 @@ public void resultReceived(IPendingServiceCall call) {
Object callResult = call.getResult();
if (callResult != null) {
// we expect a number consisting of the stream id, but we'll check for an object map as well
Number streamId = null;
int streamId = -1;
if (callResult instanceof Number) {
streamId = (Number) callResult;
streamId = ((Number) callResult).intValue();
} else if (callResult instanceof Map) {
Map<?, ?> map = (Map<?, ?>) callResult;
// XXX(paul) log out the map contents
log.warn("CreateStreamCallBack resultReceived - map: {}", map);
if (map.containsKey("streamId")) {
Object tmpStreamId = map.get("streamId");
if (tmpStreamId instanceof Number) {
streamId = (Number) tmpStreamId;
streamId = ((Number) tmpStreamId).intValue();
} else {
log.warn("CreateStreamCallBack resultReceived - stream id is not a number: {}", tmpStreamId);
}
}
}
log.debug("CreateStreamCallBack resultReceived - stream id: {} call: {} connection: {}", streamId, call, conn);
if (conn != null && streamId != null) {
if (conn != null && streamId != -1) {
log.debug("Setting new net stream");
NetStream stream = new NetStream(streamEventDispatcher);
stream.setConnection(conn);
Expand Down Expand Up @@ -1100,7 +1103,8 @@ public void resultReceived(IPendingServiceCall call) {
log.debug("Deleting net stream");
conn.removeClientStream(streamId);
// send a delete notify?
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId().equals(streamId)).findFirst().orElse(null);
final int sid = streamId.intValue();
NetStreamPrivateData streamData = streamDataList.stream().filter(s -> s.getStreamId() == sid).findFirst().orElse(null);
if (streamData != null) {
streamDataList.remove(streamData);
} else {
Expand Down Expand Up @@ -1148,22 +1152,22 @@ private final class NetStreamPrivateData {

public volatile ConnectionConsumer connConsumer;

final Number streamId;
private final int streamId;

NetStreamPrivateData(Number streamId) {
NetStreamPrivateData(int streamId) {
this.streamId = streamId;
if (streamEventHandler != null) {
handler = streamEventHandler;
}
}

public Number getStreamId() {
public int getStreamId() {
return streamId;
}

@Override
public int hashCode() {
return streamId.hashCode();
return streamId;
}

}
Expand Down
23 changes: 23 additions & 0 deletions client/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<configuration>

<jmxConfigurator />

<appender class="ch.qos.logback.core.ConsoleAppender" name="CONSOLE">
<encoder>
<pattern>[%p] [%thread] %logger - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>

<logger name="org.red5.server.service.ReflectionUtils" level="TRACE" />
<logger name="org.red5.server.service.ServiceInvoker" level="TRACE" />
<logger name="org.red5.server.net.rtmp.RTMPHandler" level="TRACE" />

<logger name="org.red5.client.net.rtmp.BaseRTMPClientHandler" level="TRACE" />
<logger name="org.red5.client.test" level="DEBUG" />

</configuration>
4 changes: 2 additions & 2 deletions common/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.3.25</version>
<version>1.3.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server-common</artifactId>
Expand Down Expand Up @@ -124,7 +124,7 @@
<dependency>
<groupId>net.engio</groupId>
<artifactId>mbassador</artifactId>
<version>1.3.25</version>
<version>1.3.26</version>
</dependency> -->
<dependency>
<groupId>junit</groupId>
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/org/red5/server/api/Red5.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public final class Red5 {
/**
* Server version with revision
*/
public static final String VERSION = "Red5 Server 1.3.25";
public static final String VERSION = "Red5 Server 1.3.26";

/**
* Server version for fmsVer requests
*/
public static final String FMS_VERSION = "RED5/1,3,25,0";
public static final String FMS_VERSION = "RED5/1,3,26,0";

/**
* Server capabilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public abstract class AbstractClientStream extends AbstractStream implements ICl
/**
* Stream identifier. Unique across server.
*/
private Number streamId = 0.0d;
private int streamId;

/**
* Stream name of the broadcasting stream.
Expand All @@ -43,10 +43,20 @@ public abstract class AbstractClientStream extends AbstractStream implements ICl
* @param streamId
* Stream id
*/
public void setStreamId(Number streamId) {
public void setStreamId(int streamId) {
this.streamId = streamId;
}

/**
* Setter for stream id
*
* @param streamId
* Stream id
*/
public void setStreamId(Number streamId) {
this.streamId = streamId.intValue();
}

/**
* Return stream id
*
Expand Down
2 changes: 1 addition & 1 deletion io/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.3.25</version>
<version>1.3.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-io</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<name>Red5</name>
<description>The Red5 server</description>
<groupId>org.red5</groupId>
<version>1.3.25</version>
<version>1.3.26</version>
<url>https://github.com/Red5/red5-server</url>
<inceptionYear>2005</inceptionYear>
<organization>
Expand Down
2 changes: 1 addition & 1 deletion server/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.3.25</version>
<version>1.3.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion service/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.3.25</version>
<version>1.3.26</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-service</artifactId>
Expand Down

0 comments on commit 8701d73

Please sign in to comment.