Skip to content

Commit

Permalink
Remove colibri1 (#898)
Browse files Browse the repository at this point in the history
* Remove colibri v1 classes.

* ref: Remove ColibriConfig.

* Remove injected SSRCs and leftovers.

* Remove GID.

* Remove rtpDescriptions from colibri API.

* Remove redundant API call.

* Clean up the colibri API a bit.

* ref: Remove the reInvite flag from colibri.
  • Loading branch information
bgrozev authored Apr 1, 2022
1 parent 2691ed9 commit a640057
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 3,573 deletions.
70 changes: 2 additions & 68 deletions src/main/java/org/jitsi/jicofo/FocusManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public class FocusManager
*/
private final static Logger logger = new LoggerImpl(FocusManager.class.getName());

/**
* The pseudo-random generator which is to be used when generating IDs.
*/
private static final Random RANDOM = new Random();

/**
* The thread that expires {@link JitsiMeetConference}s.
*/
Expand All @@ -75,13 +70,7 @@ public class FocusManager
private final List<JitsiMeetConference> conferencesCache = new CopyOnWriteArrayList<>();

/**
* The set of the IDs of conferences in {@link #conferences}.
*/
private final Set<Long> conferenceGids = new HashSet<>();

/**
* The object used to synchronize access to {@link #conferences} and
* {@link #conferenceGids}.
* The object used to synchronize access to {@link #conferences}.
*/
private final Object conferencesSyncRoot = new Object();

Expand All @@ -97,12 +86,6 @@ public class FocusManager
*/
private final Statistics statistics = new Statistics();

/**
* The ID of this Jicofo instance, used to generate conference GIDs. The special value 0 is valid in the Octo
* protocol, but only used when no value is explicitly configured.
*/
private int octoId;

/**
* Clock to use for pin timeouts.
*/
Expand Down Expand Up @@ -130,26 +113,6 @@ public FocusManager()
public void start()
{
expireThread.start();

int octoId = 0;
Integer configuredId = OctoConfig.config.getId();
if (configuredId != null)
{
octoId = configuredId;
}
if (octoId < 1 || octoId > 0xffff)
{
logger.warn(
"Jicofo ID is not set correctly set (value=" + octoId + "). Configure a valid value [1-65535] by "
+ "setting org.jitsi.jicofo.SHORT_ID in sip-communicator.properties or jicofo.octo.id in jicofo.conf. "
+ "Future versions will require this for Octo.");
this.octoId = 0;
}
else
{
logger.info("Initialized octoId=" + octoId);
this.octoId = octoId;
}
}

/**
Expand Down Expand Up @@ -286,17 +249,15 @@ private JitsiMeetConferenceImpl createConference(
JitsiMeetConferenceImpl conference;
synchronized (conferencesSyncRoot)
{
long id = generateConferenceId();
String jvbVersion = getBridgeVersionForConference(room);
conference
= new JitsiMeetConferenceImpl(
room,
this, config, logLevel,
id, jvbVersion, includeInStatistics);
jvbVersion, includeInStatistics);

conferences.put(room, conference);
conferencesCache.add(conference);
conferenceGids.add(id);
}

if (includeInStatistics)
Expand All @@ -307,27 +268,6 @@ private JitsiMeetConferenceImpl createConference(
return conference;
}

/**
* Generates a conference ID which is currently not used by an existing
* conference in a specific format (6 hexadecimal symbols).
* @return the generated ID.
*/
private long generateConferenceId()
{
long id;

synchronized (conferencesSyncRoot)
{
do
{
id = (octoId << 16) | RANDOM.nextInt(0x1_0000);
}
while (conferenceGids.contains(id));
}

return id;
}

/**
* Destroys the conference for given room name.
* @param roomName full MUC room name to destroy.
Expand Down Expand Up @@ -365,7 +305,6 @@ public void conferenceEnded(JitsiMeetConferenceImpl conference)
{
conferences.remove(roomName);
conferencesCache.remove(conference);
conferenceGids.remove(conference.getId());

// It is not clear whether the code below necessarily needs to
// hold the lock or not.
Expand Down Expand Up @@ -554,11 +493,6 @@ public JSONObject getStats()
return statistics;
}

public boolean isJicofoIdConfigured()
{
return octoId != 0;
}

@NotNull
OrderedJsonObject getDebugState(boolean full)
{
Expand Down
100 changes: 21 additions & 79 deletions src/main/java/org/jitsi/jicofo/conference/JitsiMeetConferenceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.jitsi.jicofo.auth.*;
import org.jitsi.jicofo.bridge.*;
import org.jitsi.jicofo.conference.colibri.*;
import org.jitsi.jicofo.conference.colibri.v1.*;
import org.jitsi.jicofo.conference.colibri.v2.*;
import org.jitsi.jicofo.conference.source.*;
import org.jitsi.jicofo.lipsynchack.*;
Expand Down Expand Up @@ -218,8 +217,6 @@ public class JitsiMeetConferenceImpl
*/
private boolean videoLimitReached = false;

private final long gid;

/**
* Requested bridge version from a pin. null if not pinned.
*/
Expand All @@ -245,7 +242,6 @@ public JitsiMeetConferenceImpl(
ConferenceListener listener,
@NotNull JitsiMeetConfig config,
Level logLevel,
long gid,
String jvbVersion,
boolean includeInStatistics)
{
Expand All @@ -260,21 +256,12 @@ public JitsiMeetConferenceImpl(
this.includeInStatistics = includeInStatistics;

this.jicofoServices = Objects.requireNonNull(JicofoServices.jicofoServicesSingleton);
this.gid = gid;
this.jvbVersion = jvbVersion;
if (ColibriConfig.config.getEnableColibri2())
{
colibriSessionManager = new ColibriV2SessionManager(
jicofoServices.getXmppServices().getServiceConnection().getXmppConnection(),
jicofoServices.getBridgeSelector(),
this,
logger);
}
else
{
colibriSessionManager
= new ColibriV1SessionManager(jicofoServices, gid, this, colibriRequestCallback, logger);
}
colibriSessionManager = new ColibriV2SessionManager(
jicofoServices.getXmppServices().getServiceConnection().getXmppConnection(),
jicofoServices.getBridgeSelector(),
this,
logger);
colibriSessionManager.addListener(colibriSessionManagerListener);

logger.info("Created new conference.");
Expand All @@ -285,10 +272,9 @@ public JitsiMeetConferenceImpl(
ConferenceListener listener,
@NotNull JitsiMeetConfig config,
Level logLevel,
long gid,
String jvbVersion)
{
this(roomName, listener, config, logLevel, gid, jvbVersion, false);
this(roomName, listener, config, logLevel, jvbVersion, false);
}

/**
Expand Down Expand Up @@ -1085,10 +1071,9 @@ public StanzaError onSessionTerminate(@NotNull JingleSession session, JingleIQ i
*/
private void propagateNewSources(Participant sourceOwner, ConferenceSourceMap sources)
{
final ConferenceSourceMap finalSources = sources
.copy()
.strip(ConferenceConfig.config.stripSimulcast(), true)
.unmodifiable();
final ConferenceSourceMap finalSources = (ConferenceConfig.config.stripSimulcast())
? sources.copy().stripSimulcast().unmodifiable()
: sources.copy().unmodifiable();
if (finalSources.isEmpty())
{
logger.debug("No new sources to propagate.");
Expand Down Expand Up @@ -1117,7 +1102,7 @@ public void onTransportInfo(@NotNull JingleSession session, List<ContentPacketEx
return;
}

colibriSessionManager.updateParticipant(participant, getTransport(contentList), null, null);
colibriSessionManager.updateParticipant(participant, getTransport(contentList), null);
}

/**
Expand Down Expand Up @@ -1220,7 +1205,7 @@ public StanzaError onAddSource(@NotNull JingleSession jingleSession, List<Conten
// Updates source groups on the bridge
// We may miss the notification, but the state will be synced up
// after conference has been relocated to the new bridge
colibriSessionManager.addSources(participant, sourcesAccepted);
colibriSessionManager.updateParticipant(participant, null, participant.getSources());

propagateNewSources(participant, sourcesAccepted);

Expand Down Expand Up @@ -1284,18 +1269,6 @@ private StanzaError onSessionAcceptInternal(
{
logger.debug("Received initial sources from " + participantId + ": " + sourcesAdvertised);
}
if (sourcesAdvertised.isEmpty() && ConferenceConfig.config.injectSsrcForRecvOnlyEndpoints()
&& !(ColibriConfig.config.getEnableColibri2()))
{
// We inject an SSRC in order to ensure that the participant has
// at least one SSRC advertised. Otherwise, non-local bridges in the
// conference will not be aware of the participant.
// This is not necessary (and might trigger unexpected behavior) with colibri2.
long ssrc = RANDOM.nextInt() & 0xffff_ffffL;
logger.info(participant + " did not advertise any SSRCs. Injecting " + ssrc);
sourcesAdvertised = new EndpointSourceSet(
new Source(ssrc, MediaType.AUDIO, participantId + "-injected0", null, true));
}
ConferenceSourceMap sourcesAccepted;
try
{
Expand All @@ -1315,8 +1288,7 @@ private StanzaError onSessionAcceptInternal(
colibriSessionManager.updateParticipant(
participant,
getTransport(contents),
sourcesAccepted,
getRtpDescriptions(contents));
sourcesAccepted);

// Propagate [participant]'s sources to the other participants.
propagateNewSources(participant, sourcesAccepted);
Expand All @@ -1326,26 +1298,6 @@ private StanzaError onSessionAcceptInternal(
return null;
}

/**
* Extract a map from content name to the first child of type {@link RtpDescriptionPacketExtension}.
*/
private Map<String, RtpDescriptionPacketExtension> getRtpDescriptions(
@NotNull List<ContentPacketExtension> contents)
{
Map<String, RtpDescriptionPacketExtension> rtpDescriptions = new HashMap<>();
for (ContentPacketExtension content : contents)
{
RtpDescriptionPacketExtension rtpDescription
= content.getFirstChildOfType(RtpDescriptionPacketExtension.class);
if (rtpDescription != null)
{
rtpDescriptions.put(content.getName(), rtpDescription);
}
}

return rtpDescriptions;
}

/**
* Find the first {@link IceUdpTransportPacketExtension} in a list of Jingle contents.
*/
Expand Down Expand Up @@ -1416,10 +1368,11 @@ private StanzaError removeSources(
return null;
}

colibriSessionManager.removeSources(
colibriSessionManager.updateParticipant(
participant,
sourcesAcceptedToBeRemoved,
removeColibriSourcesFromLocalBridge);
null,
participant.getSources(),
!removeColibriSourcesFromLocalBridge);

if (sendSourceRemove)
{
Expand All @@ -1436,10 +1389,9 @@ private StanzaError removeSources(
*/
private void sendSourceRemove(ConferenceSourceMap sources, Participant except)
{
final ConferenceSourceMap finalSources = sources
.copy()
.strip(ConferenceConfig.config.stripSimulcast(), true)
.unmodifiable();
final ConferenceSourceMap finalSources = ConferenceConfig.config.stripSimulcast()
? sources.copy().stripSimulcast().unmodifiable()
: sources.copy().unmodifiable();
if (finalSources.isEmpty())
{
logger.debug("No sources to remove.");
Expand Down Expand Up @@ -1616,8 +1568,6 @@ public OrderedJsonObject getDebugState()
o.put("conference_sources", conferenceSources.toJson());
o.put("audio_limit_reached", audioLimitReached);
o.put("video_limit_reached", videoLimitReached);
o.put("gid", gid);


return o;
}
Expand Down Expand Up @@ -1704,14 +1654,6 @@ public int getParticipantCount()
return participants.size();
}

/**
* Conference ID.
*/
public long getId()
{
return gid;
}

/**
* Get pinned bridge version. Returns null if not pinned.
*/
Expand Down Expand Up @@ -2104,9 +2046,9 @@ public void numVideoSendersChanged(int numVideoSenders)
}

/**
* Listener for events from {@link ColibriV1SessionManager}.
* Listener for events from {@link ColibriSessionManager}.
*/
private class ColibriSessionManagerListener implements ColibriV1SessionManager.Listener
private class ColibriSessionManagerListener implements ColibriSessionManager.Listener
{
@Override
public void bridgeCountChanged(int bridgeCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ private void doRun()
ColibriAllocation colibriAllocation;
try
{
colibriAllocation = colibriSessionManager.allocate(participant, offer.getContents(), reInvite);
colibriAllocation = colibriSessionManager.allocate(participant, offer.getContents());
}
catch (BridgeSelectionFailedException e)
{
Expand Down Expand Up @@ -357,10 +357,6 @@ else if (!canceled)
// not trigger a retry here.
meetConference.onInviteFailed(this);
}
else if (reInvite)
{
colibriSessionManager.updateParticipant(participant, null, null, null);
}

// TODO: include force-mute in the initial allocation, instead of sending 2 additional colibri messages.
if (chatRoom != null && !participant.hasModeratorRights())
Expand Down Expand Up @@ -456,7 +452,10 @@ private boolean doInviteOrReinvite(Jid address, Offer offer, ColibriAllocation c
ConferenceSourceMap conferenceSources = meetConference.getSources().copy();
// Add the bridge's feedback sources.
conferenceSources.add(colibriAllocation.getSources());
conferenceSources.strip(ConferenceConfig.config.stripSimulcast(), true);
if (ConferenceConfig.config.stripSimulcast())
{
conferenceSources.stripSimulcast();
}
conferenceSources.stripByMediaType(participant.getSupportedMediaTypes());
// Remove the participant's own sources (if they're present)
conferenceSources.remove(participant.getMucJid());
Expand Down
Loading

0 comments on commit a640057

Please sign in to comment.