Skip to content

Commit b591501

Browse files
committed
Addressed timestamp rollover/range issue
1 parent c568879 commit b591501

File tree

16 files changed

+64
-44
lines changed

16 files changed

+64
-44
lines changed

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.red5</groupId>
55
<artifactId>red5-parent</artifactId>
6-
<version>1.3.5</version>
6+
<version>1.3.6</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>red5-client</artifactId>

client/src/main/java/org/red5/client/Red5Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public final class Red5Client {
1818
/**
1919
* Current server version with revision
2020
*/
21-
public static final String VERSION = "Red5 Client 1.3.5";
21+
public static final String VERSION = "Red5 Client 1.3.6";
2222

2323
/**
2424
* Create a new Red5Client object using the connection local to the current thread A bit of magic that lets you access the red5 scope

common/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.red5</groupId>
55
<artifactId>red5-parent</artifactId>
6-
<version>1.3.5</version>
6+
<version>1.3.6</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>red5-server-common</artifactId>
@@ -124,7 +124,7 @@
124124
<dependency>
125125
<groupId>net.engio</groupId>
126126
<artifactId>mbassador</artifactId>
127-
<version>1.3.5</version>
127+
<version>1.3.6</version>
128128
</dependency> -->
129129
<dependency>
130130
<groupId>junit</groupId>

common/src/main/java/org/red5/server/api/Red5.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public final class Red5 {
5555
/**
5656
* Server version with revision
5757
*/
58-
public static final String VERSION = "Red5 Server 1.3.5";
58+
public static final String VERSION = "Red5 Server 1.3.6";
5959

6060
/**
6161
* Server version for fmsVer requests
6262
*/
63-
public static final String FMS_VERSION = "RED5/1,3,5,0";
63+
public static final String FMS_VERSION = "RED5/1,3,6,0";
6464

6565
/**
6666
* Server capabilities

common/src/main/java/org/red5/server/stream/AbstractClientStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public void setConnection(IStreamCapableConnection conn) {
7272
* @return Stream capable connection object
7373
*/
7474
public IStreamCapableConnection getConnection() {
75-
return conn.get();
75+
// prevent NPE on first call
76+
return conn != null ? conn.get() : null;
7677
}
7778

7879
/** {@inheritDoc} */

common/src/main/java/org/red5/server/stream/PlayEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public void execute(ISchedulingService service) {
483483
sendStreamNotFoundStatus(item);
484484
throw new StreamNotFoundException(itemName);
485485
}
486-
//continue with common play processes (live and vod)
486+
// continue with common play processes (live and vod)
487487
if (sendNotifications) {
488488
if (withReset) {
489489
sendReset();

common/src/main/java/org/red5/server/stream/PlaylistSubscriberStream.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,17 @@ public long getCreationTime() {
790790
/** {@inheritDoc} */
791791
public int getCurrentTimestamp() {
792792
int lastMessageTs = engine.getLastMessageTimestamp();
793+
/* XXX(paul) I think this is incorrect
793794
if (lastMessageTs >= 0) {
794795
return 0;
795796
}
796797
return lastMessageTs;
798+
*/
799+
// XXX(paul) this seems to be what the correct logic would be
800+
if (lastMessageTs >= 0) {
801+
return lastMessageTs;
802+
}
803+
return 0;
797804
}
798805

799806
/** {@inheritDoc} */

common/src/main/java/org/red5/server/stream/consumer/ConnectionConsumer.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,9 @@ public void pushMessage(IPipe pipe, IMessage message) {
142142
int eventTime = msg.getTimestamp();
143143
log.debug("Message timestamp: {}", eventTime);
144144
if (eventTime < 0) {
145-
//eventTime += Integer.MIN_VALUE;
146-
//log.debug("Message has negative timestamp, applying {} offset: {}", Integer.MIN_VALUE, eventTime);
147-
// everyone seems to prefer positive timestamps
148-
eventTime += (eventTime * -1);
149-
log.debug("Message has negative timestamp, flipping it to positive: {}", Integer.MIN_VALUE, eventTime);
145+
// handle roll-over -1 is top of the range when keeping things positive
146+
eventTime ^= Integer.MIN_VALUE;
147+
log.debug("Message has negative timestamp, applying {} ts: {}", Integer.MIN_VALUE, eventTime);
150148
msg.setTimestamp(eventTime);
151149
}
152150
// get the data type (AMF)

common/src/test/java/org/red5/server/stream/consumer/TestConnectionConsumer.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,27 @@ public class TestConnectionConsumer {
2323

2424
@Before
2525
public void setUp() {
26-
connection = new RTMPMinaConnection();
27-
channel = new Channel(connection, 1);
26+
connection = new RTMPMinaConnection() {
27+
28+
@Override
29+
public Channel getChannel(int channelId) {
30+
Channel channel = new Channel(this, channelId);
31+
return channel;
32+
}
33+
34+
};
35+
channel = connection.getChannel(1);
2836
underTest = new ConnectionConsumer(connection, channel, channel, channel);
2937
}
3038

3139
@Test
3240
public void testNegativeTimestampsAreRolledOver() {
3341
log.debug("\n testNegativeTimestampsAreRolledOver");
42+
// https://www.rfc-editor.org/rfc/rfc1982
43+
log.debug("\n max: {} min: {} 0:{} -1:{}", Integer.toHexString(Integer.MAX_VALUE), Integer.toHexString(Integer.MIN_VALUE), Integer.toHexString(0), Integer.toHexString(-1));
44+
3445
VideoData videoData1 = new VideoData();
35-
videoData1.setTimestamp(-1);
46+
videoData1.setTimestamp(-1); // maximum timestamp value 0xffffffff expect 2147483647
3647
underTest.pushMessage(null, RTMPMessage.build(videoData1));
3748

3849
assertEquals(Integer.MAX_VALUE, videoData1.getTimestamp());

io/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>org.red5</groupId>
55
<artifactId>red5-parent</artifactId>
6-
<version>1.3.5</version>
6+
<version>1.3.6</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>red5-io</artifactId>

0 commit comments

Comments
 (0)