Skip to content

Commit ce94dbb

Browse files
authored
Remove MultiStreamConfig, always enable multi-stream mode. (#1948)
* Remove MultiStreamConfig, always enable multi-stream mode. * ref: Remove "2" from class and function names. * squash: Remove "new" from class names.
1 parent 739c394 commit ce94dbb

26 files changed

+569
-3360
lines changed

jvb/src/main/java/org/jitsi/videobridge/AbstractEndpoint.java

Lines changed: 24 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020
import org.jitsi.nlj.format.*;
2121
import org.jitsi.nlj.rtp.*;
2222
import org.jitsi.nlj.util.*;
23-
import org.jitsi.utils.*;
2423
import org.jitsi.utils.event.*;
2524
import org.jitsi.utils.logging2.*;
2625
import org.jitsi.videobridge.cc.allocation.*;
2726
import org.jitsi.xmpp.extensions.colibri.*;
2827
import org.json.simple.*;
2928

30-
import java.io.*;
3129
import java.time.*;
3230
import java.util.*;
3331

@@ -61,15 +59,10 @@ public abstract class AbstractEndpoint
6159
*/
6260
private final Conference conference;
6361

64-
/**
65-
* The map of receiver endpoint id -> video constraints.
66-
*/
67-
private final ReceiverConstraintsMap receiverVideoConstraintsMap = new ReceiverConstraintsMap();
68-
6962
/**
7063
* The map of source name -> ReceiverConstraintsMap.
7164
*/
72-
private final Map<String, ReceiverConstraintsMap> receiverVideoConstraintsMapV2 = new HashMap<>();
65+
private final Map<String, ReceiverConstraintsMap> receiverVideoConstraints = new HashMap<>();
7366

7467
/**
7568
* The statistic Id of this <tt>Endpoint</tt>.
@@ -248,6 +241,8 @@ public String getStatsId()
248241
*
249242
* @return the (unique) identifier/ID of this instance
250243
*/
244+
@NotNull
245+
@Override
251246
public final String getId()
252247
{
253248
return id;
@@ -380,49 +375,20 @@ public JSONObject getDebugState()
380375
{
381376
JSONObject debugState = new JSONObject();
382377

383-
if (MultiStreamConfig.config.getEnabled())
384-
{
385-
JSONObject receiverVideoConstraints = new JSONObject();
378+
JSONObject receiverVideoConstraints = new JSONObject();
386379

387-
receiverVideoConstraintsMapV2.forEach(
388-
(sourceName, receiverConstraints) ->
389-
receiverVideoConstraints.put(sourceName, receiverConstraints.getDebugState()));
380+
this.receiverVideoConstraints.forEach(
381+
(sourceName, receiverConstraints) ->
382+
receiverVideoConstraints.put(sourceName, receiverConstraints.getDebugState()));
390383

391-
debugState.put("receiverVideoConstraints", receiverVideoConstraints);
392-
debugState.put("maxReceiverVideoConstraintsMap", new HashMap<>(maxReceiverVideoConstraintsMap));
393-
}
394-
else
395-
{
396-
debugState.put("maxReceiverVideoConstraints", maxReceiverVideoConstraints);
397-
debugState.put("receiverVideoConstraints", receiverVideoConstraintsMap.getDebugState());
398-
}
384+
debugState.put("receiverVideoConstraints", receiverVideoConstraints);
385+
debugState.put("maxReceiverVideoConstraintsMap", new HashMap<>(maxReceiverVideoConstraintsMap));
399386
debugState.put("expired", expired);
400387
debugState.put("statsId", statsId);
401388

402389
return debugState;
403390
}
404391

405-
/**
406-
* Computes and sets the {@link #maxReceiverVideoConstraints} from the
407-
* specified video constraints.
408-
*
409-
* @param newMaxHeight the maximum height resulting from the current set of constraints.
410-
* (Currently we only support constraining the height, and not frame rate.)
411-
*/
412-
private void receiverVideoConstraintsChanged(int newMaxHeight)
413-
{
414-
VideoConstraints oldReceiverMaxVideoConstraints = this.maxReceiverVideoConstraints;
415-
416-
417-
VideoConstraints newReceiverMaxVideoConstraints = new VideoConstraints(newMaxHeight, -1.0);
418-
419-
if (!newReceiverMaxVideoConstraints.equals(oldReceiverMaxVideoConstraints))
420-
{
421-
maxReceiverVideoConstraints = newReceiverMaxVideoConstraints;
422-
sendVideoConstraints(newReceiverMaxVideoConstraints);
423-
}
424-
}
425-
426392
/**
427393
* Computes and sets the {@link #maxReceiverVideoConstraints} from the specified video constraints of the media
428394
* source identified by the given source name.
@@ -431,7 +397,7 @@ private void receiverVideoConstraintsChanged(int newMaxHeight)
431397
* @param newMaxHeight the maximum height resulting from the current set of constraints.
432398
* (Currently we only support constraining the height, and not frame rate.)
433399
*/
434-
private void receiverVideoConstraintsChangedV2(String sourceName, int newMaxHeight)
400+
private void receiverVideoConstraintsChanged(String sourceName, int newMaxHeight)
435401
{
436402
VideoConstraints oldReceiverMaxVideoConstraints = this.maxReceiverVideoConstraintsMap.get(sourceName);
437403

@@ -487,28 +453,6 @@ private void receiverVideoConstraintsChangedV2(String sourceName, int newMaxHeig
487453
protected abstract void
488454
sendVideoConstraintsV2(@NotNull String sourceName, @NotNull VideoConstraints maxVideoConstraints);
489455

490-
/**
491-
* Notifies this instance that a specified received wants to receive
492-
* the specified video constraints from the endpoint attached to this
493-
* instance (the sender).
494-
*
495-
* The receiver can be either another endpoint, or a remote bridge.
496-
*
497-
* @param receiverId the id that specifies the receiver endpoint
498-
* @param newVideoConstraints the video constraints that the receiver
499-
* wishes to receive.
500-
*/
501-
public void addReceiver(String receiverId, VideoConstraints newVideoConstraints)
502-
{
503-
VideoConstraints oldVideoConstraints = receiverVideoConstraintsMap.put(receiverId, newVideoConstraints);
504-
if (oldVideoConstraints == null || !oldVideoConstraints.equals(newVideoConstraints))
505-
{
506-
logger.debug(
507-
() -> "Changed receiver constraints: " + receiverId + ": " + newVideoConstraints.getMaxHeight());
508-
receiverVideoConstraintsChanged(receiverVideoConstraintsMap.getMaxHeight());
509-
}
510-
}
511-
512456
/**
513457
* Notifies this instance that a specified received wants to receive the specified video constraints from the media
514458
* source with the given source name.
@@ -519,18 +463,18 @@ public void addReceiver(String receiverId, VideoConstraints newVideoConstraints)
519463
* @param sourceName the name of the media source for which the constraints are to be applied.
520464
* @param newVideoConstraints the video constraints that the receiver wishes to receive.
521465
*/
522-
public void addReceiverV2(
466+
public void addReceiver(
523467
@NotNull String receiverId,
524468
@NotNull String sourceName,
525469
@NotNull VideoConstraints newVideoConstraints
526470
)
527471
{
528-
ReceiverConstraintsMap sourceConstraints = receiverVideoConstraintsMapV2.get(sourceName);
472+
ReceiverConstraintsMap sourceConstraints = receiverVideoConstraints.get(sourceName);
529473

530474
if (sourceConstraints == null)
531475
{
532476
sourceConstraints = new ReceiverConstraintsMap();
533-
receiverVideoConstraintsMapV2.put(sourceName, sourceConstraints);
477+
receiverVideoConstraints.put(sourceName, sourceConstraints);
534478
}
535479

536480
VideoConstraints oldVideoConstraints = sourceConstraints.put(receiverId, newVideoConstraints);
@@ -540,7 +484,7 @@ public void addReceiverV2(
540484
logger.debug(
541485
() -> "Changed receiver constraints: " + receiverId + "->" + sourceName + ": " +
542486
newVideoConstraints.getMaxHeight());
543-
receiverVideoConstraintsChangedV2(sourceName, sourceConstraints.getMaxHeight());
487+
receiverVideoConstraintsChanged(sourceName, sourceConstraints.getMaxHeight());
544488
}
545489
}
546490

@@ -553,27 +497,16 @@ public void addReceiverV2(
553497
*/
554498
public void removeReceiver(String receiverId)
555499
{
556-
if (MultiStreamConfig.config.getEnabled())
500+
for (Map.Entry<String, ReceiverConstraintsMap> sourceConstraintsEntry
501+
: receiverVideoConstraints.entrySet())
557502
{
558-
for (Map.Entry<String, ReceiverConstraintsMap> sourceConstraintsEntry
559-
: receiverVideoConstraintsMapV2.entrySet())
560-
{
561-
String sourceName = sourceConstraintsEntry.getKey();
562-
ReceiverConstraintsMap sourceConstraints = sourceConstraintsEntry.getValue();
563-
564-
if (sourceConstraints.remove(receiverId) != null)
565-
{
566-
logger.debug(() -> "Removed receiver " + receiverId + " for " + sourceName);
567-
receiverVideoConstraintsChangedV2(sourceName, sourceConstraints.getMaxHeight());
568-
}
569-
}
570-
}
571-
else
572-
{
573-
if (receiverVideoConstraintsMap.remove(receiverId) != null)
503+
String sourceName = sourceConstraintsEntry.getKey();
504+
ReceiverConstraintsMap sourceConstraints = sourceConstraintsEntry.getValue();
505+
506+
if (sourceConstraints.remove(receiverId) != null)
574507
{
575-
logger.debug(() -> "Removed receiver " + receiverId);
576-
receiverVideoConstraintsChanged(receiverVideoConstraintsMap.getMaxHeight());
508+
logger.debug(() -> "Removed receiver " + receiverId + " for " + sourceName);
509+
receiverVideoConstraintsChanged(sourceName, sourceConstraints.getMaxHeight());
577510
}
578511
}
579512
}
@@ -587,14 +520,14 @@ public void removeReceiver(String receiverId)
587520
*/
588521
public void removeSourceReceiver(String receiverId, String sourceName)
589522
{
590-
ReceiverConstraintsMap sourceConstraints = receiverVideoConstraintsMapV2.get(sourceName);
523+
ReceiverConstraintsMap sourceConstraints = receiverVideoConstraints.get(sourceName);
591524

592525
if (sourceConstraints != null)
593526
{
594527
if (sourceConstraints.remove(receiverId) != null)
595528
{
596529
logger.debug(() -> "Removed receiver " + receiverId + " for " + sourceName);
597-
receiverVideoConstraintsChangedV2(sourceName, sourceConstraints.getMaxHeight());
530+
receiverVideoConstraintsChanged(sourceName, sourceConstraints.getMaxHeight());
598531
}
599532
}
600533
}

jvb/src/main/java/org/jitsi/videobridge/EndpointMessageTransport.java

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -129,44 +129,17 @@ public BridgeChannelMessage clientHello(ClientHelloMessage message)
129129
@Override
130130
public BridgeChannelMessage videoType(VideoTypeMessage videoTypeMessage)
131131
{
132-
if (MultiStreamConfig.config.getEnabled())
133-
{
134-
sourceVideoType(
132+
return sourceVideoType(
135133
new SourceVideoTypeMessage(
136-
videoTypeMessage.getVideoType(),
137-
endpointIdToSourceName(endpoint.getId()),
138-
videoTypeMessage.getEndpointId())
139-
);
140-
141-
return null;
142-
}
143-
144-
endpoint.setVideoType(videoTypeMessage.getVideoType());
145-
146-
Conference conference = endpoint.getConference();
147-
148-
if (conference == null || conference.isExpired())
149-
{
150-
getLogger().warn("Unable to forward VideoTypeMessage, conference is null or expired");
151-
return null;
152-
}
153-
154-
videoTypeMessage.setEndpointId(endpoint.getId());
155-
156-
/* Forward videoType messages to Relays. */
157-
conference.sendMessage(videoTypeMessage, Collections.emptyList(), true);
158-
159-
return null;
134+
videoTypeMessage.getVideoType(),
135+
endpointIdToSourceName(endpoint.getId()),
136+
videoTypeMessage.getEndpointId())
137+
);
160138
}
161139

162140
@Override
163141
public BridgeChannelMessage sourceVideoType(SourceVideoTypeMessage sourceVideoTypeMessage)
164142
{
165-
if (!MultiStreamConfig.config.getEnabled())
166-
{
167-
return null;
168-
}
169-
170143
String sourceName = sourceVideoTypeMessage.getSourceName();
171144

172145
if (getLogger().isDebugEnabled())

0 commit comments

Comments
 (0)