2020import org .jitsi .nlj .format .*;
2121import org .jitsi .nlj .rtp .*;
2222import org .jitsi .nlj .util .*;
23- import org .jitsi .utils .*;
2423import org .jitsi .utils .event .*;
2524import org .jitsi .utils .logging2 .*;
2625import org .jitsi .videobridge .cc .allocation .*;
2726import org .jitsi .xmpp .extensions .colibri .*;
2827import org .json .simple .*;
2928
30- import java .io .*;
3129import java .time .*;
3230import 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 }
0 commit comments