|
|
@@ -71,24 +71,6 @@ class VideoStopReceiptRestartTest {
|
|
|
assertTrue(world.open.contains("other_legacy_stream"));
|
|
|
}
|
|
|
|
|
|
- @Test void negotiatedSsrcKeepsTheOriginalPoolNumberForCloseAndReturn() throws Exception {
|
|
|
- External world = new External();
|
|
|
- Instance instance = new Instance(world);
|
|
|
- String pool = "CITY_VIDEO_VMP_SSRC_INFO_restart-test_node-a";
|
|
|
- world.ssrcRedis.strings().delete(pool);
|
|
|
- world.ssrcRedis.strings().opsForSet().add(pool, "200000001");
|
|
|
- SSRCInfo original = instance.open(STREAM);
|
|
|
- // The device renegotiates a different SSRC while the original pool number stays owned.
|
|
|
- String negotiated = "0999999999";
|
|
|
- assertTrue(instance.receipts.recordNegotiatedSsrc(world.node.getId(), STREAM, original, negotiated, false));
|
|
|
- SSRCInfo current = new SSRCInfo(original.getPort(), negotiated, "rtp", STREAM, original.getTimeOutTaskKey());
|
|
|
- assertTrue(new Instance(world).rtp.closeManagedRTPServer(world.node, current));
|
|
|
- assertEquals(1L, world.ssrcRedis.strings().opsForSet().size(pool), "the original pool number is returned once");
|
|
|
- // The next allocation proves which number came back: the original, never the negotiated one.
|
|
|
- assertEquals(original.getSsrc(), new Instance(world).open("next_stream").getSsrc());
|
|
|
- assertEquals(0L, world.ssrcRedis.strings().opsForSet().size(pool));
|
|
|
- }
|
|
|
-
|
|
|
@Test void delayedLegacyCloseReturnsSsrcWhenTheCallerNeverRetries() throws Exception {
|
|
|
External world = new External(); world.delayClose = true;
|
|
|
Instance instance = new Instance(world);
|
|
|
@@ -102,21 +84,36 @@ class VideoStopReceiptRestartTest {
|
|
|
assertEquals(1, world.closeRequests.size());
|
|
|
}
|
|
|
|
|
|
- @Test void ssrcRenegotiationKeepsTheOriginalPoolIdentityForCleanup() throws Exception {
|
|
|
+ @Test void negotiatedSsrcReturnsTheOriginalPoolNumberExactlyOnce() throws Exception {
|
|
|
External world = new External();
|
|
|
Instance instance = new Instance(world);
|
|
|
String pool = "CITY_VIDEO_VMP_SSRC_INFO_restart-test_node-a";
|
|
|
SSRCInfo original = instance.open(LEGACY);
|
|
|
assertNotNull(original);
|
|
|
- String negotiated = "9777777777";
|
|
|
- // Device-selected SSRC: the receipt keeps the pool number but accepts the real current SSRC.
|
|
|
- assertTrue(instance.receipts.recordNegotiatedSsrc(world.node.getId(), LEGACY, original, negotiated, false));
|
|
|
- SSRCInfo current = new SSRCInfo(original.getPort(), negotiated, "rtp", LEGACY, original.getTimeOutTaskKey());
|
|
|
- new Instance(world).rtp.closeRTPServer(world.node, current);
|
|
|
- assertEquals(1, world.closeRequests.size());
|
|
|
- // The returned number is the original pool value; a device-negotiated SSRC is never returned.
|
|
|
+ assertEquals(99L, world.ssrcRedis.strings().opsForSet().size(pool), "the pool number is acquired, not available");
|
|
|
+ // A token-owned SN cannot be returned by the unowned legacy release path.
|
|
|
+ instance.ssrcFactory.releaseSsrc(world.node.getId(), original.getSsrc());
|
|
|
+ assertFalse(instance.ssrcFactory.wasReleased(world.node.getId(), original.getSsrc(), original.getTimeOutTaskKey()));
|
|
|
+ assertTrue(instance.receipts.recordNegotiatedSsrc(world.node.getId(), LEGACY, original, "9777777777",
|
|
|
+ () -> instance.ssrcFactory.releaseSsrc(world.node.getId(), original.getSsrc(), original.getTimeOutTaskKey())));
|
|
|
+ assertTrue(instance.ssrcFactory.wasReleased(world.node.getId(), original.getSsrc(), original.getTimeOutTaskKey()));
|
|
|
+ assertEquals(100L, world.ssrcRedis.strings().opsForSet().size(pool), "returned once");
|
|
|
assertTrue(world.ssrcRedis.strings().opsForSet().isMember(pool, original.getSsrc().substring(1)));
|
|
|
- assertFalse(world.ssrcRedis.strings().opsForSet().isMember(pool, negotiated.substring(1)));
|
|
|
+ // The negotiated value was never a pool number.
|
|
|
+ assertFalse(world.ssrcRedis.strings().opsForSet().isMember(pool, "9777777777".substring(1)));
|
|
|
+ // Closing afterwards must not return it a second time.
|
|
|
+ new Instance(world).rtp.closeRTPServer(world.node, new SSRCInfo(original.getPort(), "9777777777", "rtp", LEGACY, original.getTimeOutTaskKey()));
|
|
|
+ assertEquals(100L, world.ssrcRedis.strings().opsForSet().size(pool), "a duplicate close never returns it twice");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test void failedPoolReturnIsNeverRecordedAsReturned() throws Exception {
|
|
|
+ External world = new External();
|
|
|
+ Instance instance = new Instance(world);
|
|
|
+ SSRCInfo original = instance.open(LEGACY);
|
|
|
+ assertFalse(instance.receipts.recordNegotiatedSsrc(world.node.getId(), LEGACY, original, "9666666666", () -> false));
|
|
|
+ VideoStopReceipts.Allocation allocation = instance.receipts.read(world.node.getId(), LEGACY).allocation;
|
|
|
+ assertFalse(allocation.poolReturned, "a refused return must not be claimed as done");
|
|
|
+ assertEquals("9666666666", allocation.negotiatedSsrc);
|
|
|
}
|
|
|
|
|
|
@Test void staleAllocationTokenCannotAnnotateANewerSameNameAllocation() throws Exception {
|
|
|
@@ -126,7 +123,8 @@ class VideoStopReceiptRestartTest {
|
|
|
instance.rtp.closeRTPServer(world.node, original);
|
|
|
SSRCInfo replacement = instance.open(LEGACY);
|
|
|
assertNotEquals(original.getTimeOutTaskKey(), replacement.getTimeOutTaskKey());
|
|
|
- assertFalse(instance.receipts.recordNegotiatedSsrc(world.node.getId(), LEGACY, original, "9666666666", false));
|
|
|
+ assertFalse(instance.receipts.recordNegotiatedSsrc(world.node.getId(), LEGACY, original, "9666666666",
|
|
|
+ () -> instance.ssrcFactory.releaseSsrc(world.node.getId(), original.getSsrc(), original.getTimeOutTaskKey())));
|
|
|
new Instance(world).rtp.closeRTPServer(world.node, replacement);
|
|
|
assertEquals(2, world.closeRequests.size());
|
|
|
}
|
|
|
@@ -263,6 +261,7 @@ class VideoStopReceiptRestartTest {
|
|
|
final SIPProcessorObserver observer = new SIPProcessorObserver();
|
|
|
final SIPCommander commander = new SIPCommander();
|
|
|
final External world;
|
|
|
+ final SSRCFactory ssrcFactory;
|
|
|
final VideoStopReceipts receipts;
|
|
|
Instance(External world) throws Exception {
|
|
|
this.world = world;
|
|
|
@@ -271,7 +270,7 @@ class VideoStopReceiptRestartTest {
|
|
|
StringRedisTemplate strings = world.redis.strings();
|
|
|
receipts = new VideoStopReceipts(redis);
|
|
|
RedisVideoLifecycleStore lifecycle = new RedisVideoLifecycleStore(strings);
|
|
|
- SSRCFactory ssrc = new SSRCFactory(); wire(ssrc, "redisTemplate", world.ssrcRedis.strings()); wire(ssrc, "userSetting", settings);
|
|
|
+ SSRCFactory ssrc = new SSRCFactory(); ssrcFactory = ssrc; wire(ssrcFactory, "redisTemplate", world.ssrcRedis.strings()); wire(ssrcFactory, "userSetting", settings);
|
|
|
wire(invites, "redisTemplate", redis); wire(invites, "userSetting", settings);
|
|
|
wire(sessions, "redisTemplate", redis); wire(sessions, "userSetting", settings);
|
|
|
RedisCatchStorageImpl cache = new RedisCatchStorageImpl();
|