1 /* 2 * Jicofo, the Jitsi Conference Focus. 3 * 4 * Copyright @ 2015 Atlassian Pty Ltd 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.jitsi.protocol.xmpp.colibri; 19 20 import org.jitsi.protocol.xmpp.colibri.exception.*; 21 import org.jitsi.xmpp.extensions.colibri.*; 22 import org.jitsi.xmpp.extensions.jingle.*; 23 import net.java.sip.communicator.service.protocol.*; 24 25 import org.jitsi.jicofo.*; 26 import org.jitsi.protocol.xmpp.util.*; 27 import org.jxmpp.jid.*; 28 import org.jxmpp.jid.parts.*; 29 30 import java.util.*; 31 32 /** 33 * This is Colibri conference allocated on the videobridge. It exposes 34 * operations like allocating/expiring channels, updating channel transport 35 * and so on. 36 * 37 * @author Pawel Domas 38 */ 39 public interface ColibriConference 40 { 41 /** 42 * Sets Jitsi videobridge XMPP address to be used to allocate 43 * the conferences. 44 * 45 * @param videobridgeJid the videobridge address to be set. 46 */ setJitsiVideobridge(Jid videobridgeJid)47 void setJitsiVideobridge(Jid videobridgeJid); 48 49 /** 50 * Returns XMPP address of currently used videobridge or <tt>null</tt> 51 * if the isn't any. 52 */ getJitsiVideobridge()53 Jid getJitsiVideobridge(); 54 55 /** 56 * Returns the identifier assigned for our conference by the videobridge. 57 * Will returns <tt>null</tt> if no conference has been allocated yet for 58 * this instance. 59 */ getConferenceId()60 String getConferenceId(); 61 62 /** 63 * Sets Jitsi Meet config that provides Colibri channels configurable 64 * properties. 65 * @param config <tt>JitsiMeetConfig</tt> to be used for allocating 66 * Colibri channels in this conference. 67 */ setConfig(JitsiMeetConfig config)68 void setConfig(JitsiMeetConfig config); 69 70 /** 71 * Sets world readable name that identifies the conference. 72 * @param name the new name. 73 */ setName(Localpart name)74 void setName(Localpart name); 75 76 /** 77 * Gets world readable name that identifies the conference. 78 * @return the name. 79 */ getName()80 Localpart getName(); 81 82 /** 83 * Returns <tt>true</tt> if conference has been allocated during last 84 * allocate channels request. Method is synchronized and will return 85 * <tt>true</tt> only for the first time is called, so that only one thread 86 * will get positive value. That is because there are multiple threads 87 * allocating channels on conference start and all of them will have 88 * conference ID == null before operation, so it can't be used to detect 89 * conference created event. 90 */ hasJustAllocated()91 boolean hasJustAllocated(); 92 93 /** 94 * Creates channels on the videobridge for given parameters. 95 * 96 * @param useBundle <tt>true</tt> if channel transport bundle should be used 97 * for this allocation. 98 * @param endpointId the ID of the Colibri endpoint. 99 * @param statsId the statistics Id to use if any. 100 * @param peerIsInitiator <tt>true</tt> if peer is ICE an initiator 101 * of ICE session. 102 * @param contents content list that describes peer media. 103 * @return <tt>ColibriConferenceIQ</tt> that describes allocated channels. 104 * 105 * @throws OperationFailedException if channel allocation fails. 106 */ createColibriChannels( boolean useBundle, String endpointId, String statsId, boolean peerIsInitiator, List<ContentPacketExtension> contents)107 default ColibriConferenceIQ createColibriChannels( 108 boolean useBundle, 109 String endpointId, 110 String statsId, 111 boolean peerIsInitiator, 112 List<ContentPacketExtension> contents) 113 throws ColibriException 114 { 115 return createColibriChannels( 116 useBundle, 117 endpointId, 118 statsId, 119 peerIsInitiator, 120 contents, 121 null /* sources */, 122 null /* source groups */, 123 null /* relays */); 124 } 125 126 /** 127 * Creates channels on the videobridge for given parameters. 128 * 129 * @param useBundle <tt>true</tt> if channel transport bundle should be used 130 * for this allocation. 131 * @param endpointId the ID of the Colibri endpoint. 132 * @param statsId the statistics Id to use if any. 133 * @param peerIsInitiator <tt>true</tt> if peer is ICE an initiator 134 * of ICE session. 135 * @param contents content list that describes peer media. 136 * @param sources the sources to include with the channel creation request, 137 * if any. 138 * @param sourceGroups the source groups to include with the channel 139 * creation request, if any. 140 * @param relays the Octo relay IDs to include in the channel creation 141 * request, if any. 142 * @return <tt>ColibriConferenceIQ</tt> that describes allocated channels. 143 * 144 * @throws ColibriException if channel allocation fails. 145 */ createColibriChannels( boolean useBundle, String endpointId, String statsId, boolean peerIsInitiator, List<ContentPacketExtension> contents, Map<String, List<SourcePacketExtension>> sources, Map<String, List<SourceGroupPacketExtension>> sourceGroups, List<String> relays)146 ColibriConferenceIQ createColibriChannels( 147 boolean useBundle, 148 String endpointId, 149 String statsId, 150 boolean peerIsInitiator, 151 List<ContentPacketExtension> contents, 152 Map<String, List<SourcePacketExtension>> sources, 153 Map<String, List<SourceGroupPacketExtension>> sourceGroups, 154 List<String> relays) 155 throws ColibriException; 156 157 /** 158 * Does Colibri channels update of RTP description, SSRC and transport 159 * information. This is a combined request and what it will contain depends 160 * which parameters are provided. Most of them is optional here. Request 161 * will be sent only if any data has been provided. Sends a colibri request, 162 * but does not wait for a response. 163 * 164 * @param localChannelsInfo (mandatory) <tt>ColibriConferenceIQ</tt> that 165 * contains the description of the channels for which update request will be 166 * sent to the bridge. 167 * @param rtpInfoMap (optional) the map of Colibri content name to 168 * <tt>RtpDescriptionPacketExtension</tt> which will be used to update 169 * the RTP description of the channel in corresponding content described by 170 * <tt>localChannelsInfo</tt>. 171 * @param sources (optional) the <tt>MediaSourceMap</tt> which maps Colibri 172 * content name to a list of <tt>SourcePacketExtension</tt> which will be 173 * used to update SSRCs of the channel in corresponding content described by 174 * <tt>localChannelsInfo</tt>. 175 * @param sourceGroups (optional) the <tt>MediaSourceGroupMap</tt> which maps 176 * Colibri content name to a list of <tt>SourceGroupPacketExtension</tt> 177 * which will be used to update SSRCs of the channel in corresponding 178 * content described by <tt>localChannelsInfo</tt>. 179 */ updateChannelsInfo( ColibriConferenceIQ localChannelsInfo, Map<String, RtpDescriptionPacketExtension> rtpInfoMap, MediaSourceMap sources, MediaSourceGroupMap sourceGroups)180 default void updateChannelsInfo( 181 ColibriConferenceIQ localChannelsInfo, 182 Map<String, RtpDescriptionPacketExtension> rtpInfoMap, 183 MediaSourceMap sources, 184 MediaSourceGroupMap sourceGroups) 185 { 186 updateChannelsInfo( 187 localChannelsInfo, 188 rtpInfoMap, 189 sources, 190 sourceGroups, 191 null, null, null, null); 192 } 193 194 /** 195 * Does Colibri channels update of RTP description, SSRC and transport 196 * information. This is a combined request and what it will contain depends 197 * which parameters are provided. Most of them is optional here. Request 198 * will be sent only if any data has been provided. Sends a colibri request, 199 * but does not wait for a response. 200 * 201 * @param localChannelsInfo (mandatory) <tt>ColibriConferenceIQ</tt> that 202 * contains the description of the channels for which update request will be 203 * sent to the bridge. 204 * @param rtpInfoMap (optional) the map of Colibri content name to 205 * <tt>RtpDescriptionPacketExtension</tt> which will be used to update 206 * the RTP description of the channel in corresponding content described by 207 * <tt>localChannelsInfo</tt>. 208 * @param sources (optional) the <tt>MediaSourceMap</tt> which maps Colibri 209 * content name to a list of <tt>SourcePacketExtension</tt> which will be 210 * used to update SSRCs of the channel in corresponding content described by 211 * <tt>localChannelsInfo</tt>. 212 * @param sourceGroups (optional) the <tt>MediaSourceGroupMap</tt> which maps 213 * Colibri content name to a list of <tt>SourceGroupPacketExtension</tt> 214 * which will be used to update SSRCs of the channel in corresponding 215 * content described by <tt>localChannelsInfo</tt>. 216 * @param bundleTransport (optional) the 217 * <tt>IceUdpTransportPacketExtension</tt> which will be used to set 218 * "bundle" transport of the first channel bundle from 219 * <tt>localChannelsInfo</tt>. 220 * @param transportMap (optional) the map of 221 * <tt>IceUdpTransportPacketExtension</tt> to Colibri content name 222 * which will be used to update transport of the channels in corresponding 223 * content described by <tt>localChannelsInfo</tt>. 224 * @param endpointId the ID of the endpoint for which the update applies 225 * (it is implicit that the update only works for channels of a single 226 * @param relays the Octo relay IDs to set. 227 * participant/endpoint). 228 */ updateChannelsInfo( ColibriConferenceIQ localChannelsInfo, Map<String, RtpDescriptionPacketExtension> rtpInfoMap, MediaSourceMap sources, MediaSourceGroupMap sourceGroups, IceUdpTransportPacketExtension bundleTransport, Map<String, IceUdpTransportPacketExtension> transportMap, String endpointId, List<String> relays)229 void updateChannelsInfo( 230 ColibriConferenceIQ localChannelsInfo, 231 Map<String, RtpDescriptionPacketExtension> rtpInfoMap, 232 MediaSourceMap sources, 233 MediaSourceGroupMap sourceGroups, 234 IceUdpTransportPacketExtension bundleTransport, 235 Map<String, IceUdpTransportPacketExtension> transportMap, 236 String endpointId, 237 List<String> relays); 238 239 /** 240 * Updates the RTP description for active channels (existing on the bridge). 241 * 242 * @param map the map of content name to RTP description packet extension. 243 * @param localChannelsInfo <tt>ColibriConferenceIQ</tt> that contains 244 * the description of the channel for which the RTP description will be 245 * updated on the bridge. 246 */ updateRtpDescription( Map<String, RtpDescriptionPacketExtension> map, ColibriConferenceIQ localChannelsInfo)247 void updateRtpDescription( 248 Map<String, RtpDescriptionPacketExtension> map, 249 ColibriConferenceIQ localChannelsInfo); 250 251 /** 252 * Updates transport information for active channels 253 * (existing on the bridge). 254 * 255 * @param map the map of content name to transport packet extension. 256 * @param localChannelsInfo <tt>ColibriConferenceIQ</tt> that contains 257 * the description of the channel for which transport information will be 258 * updated on the bridge. 259 */ updateTransportInfo( Map<String, IceUdpTransportPacketExtension> map, ColibriConferenceIQ localChannelsInfo)260 void updateTransportInfo( 261 Map<String, IceUdpTransportPacketExtension> map, 262 ColibriConferenceIQ localChannelsInfo); 263 264 /** 265 * Updates simulcast layers on the bridge. 266 * @param ssrcGroups the map of media SSRC groups that will be updated on 267 * the bridge. 268 * @param localChannelsInfo <tt>ColibriConferenceIQ</tt> that contains 269 * the description of the channel for which SSRC groups information will be 270 * updated on the bridge. 271 */ updateSourcesInfo( MediaSourceMap ssrcs, MediaSourceGroupMap ssrcGroups, ColibriConferenceIQ localChannelsInfo)272 void updateSourcesInfo( 273 MediaSourceMap ssrcs, 274 MediaSourceGroupMap ssrcGroups, 275 ColibriConferenceIQ localChannelsInfo); 276 277 /** 278 * Updates the transport of a specific channel bundle. 279 * 280 * @param transport the transport packet extension that contains channel 281 * bundle transport candidates. 282 * @param channelBundleId the ID of the channel bundle for which to update 283 * the transport. 284 */ updateBundleTransportInfo( IceUdpTransportPacketExtension transport, String channelBundleId)285 void updateBundleTransportInfo( 286 IceUdpTransportPacketExtension transport, 287 String channelBundleId); 288 289 /** 290 * Expires the channels described by given <tt>ColibriConferenceIQ</tt>. 291 * 292 * @param channelInfo the <tt>ColibriConferenceIQ</tt> that contains 293 * information about the channel to be expired. 294 */ expireChannels(ColibriConferenceIQ channelInfo)295 void expireChannels(ColibriConferenceIQ channelInfo); 296 297 /** 298 * Expires the channels described by given <tt>ColibriConferenceIQ</tt>. 299 * Optionally will wait for the response if <tt>synchronous</tt> is set to 300 * <tt>true</tt>. 301 * 302 * The method is deprecated to discourage it's usage. It's been added to 303 * mitigate temporarily JVB's out of order processing issue where it can 304 * happen that two packets regarding one conference will be processed not in 305 * the order in which they were received. The issues is to be fixed on 306 * the JVB side. 307 * 308 * @param channelInfo the <tt>ColibriConferenceIQ</tt> that contains 309 * information about the channel to be expired. 310 * @param synchronous if <tt>true</tt> the current thread must be blocked 311 * until the response packet is received. 312 */ 313 @Deprecated expireChannels(ColibriConferenceIQ channelInfo, boolean synchronous)314 void expireChannels(ColibriConferenceIQ channelInfo, boolean synchronous); 315 316 /** 317 * Expires all channels in current conference and this instance goes into 318 * disposed state(like calling {@link #dispose()} method). It must not be 319 * used anymore. 320 */ expireConference()321 void expireConference(); 322 323 /** 324 * Mutes audio channels described in given IQ by changing their media 325 * direction to {@link org.jitsi.service.neomedia.MediaDirection#SENDONLY}. 326 * @param channelsInfo the IQ that describes the channels to be muted. 327 * @param mute <tt>true</tt> to mute or <tt>false</tt> to unmute audio 328 * channels described in <tt>channelsInfo</tt>. 329 * @return <tt>true</tt> if the operation has succeeded or <tt>false</tt> 330 * otherwise. 331 */ muteParticipant(ColibriConferenceIQ channelsInfo, boolean mute)332 boolean muteParticipant(ColibriConferenceIQ channelsInfo, boolean mute); 333 334 /** 335 * Disposes of any resources allocated by this instance. Once disposed this 336 * instance must not be used anymore. 337 */ dispose()338 void dispose(); 339 340 /** 341 * Checks whether or not this instance has been disposed. The instance must 342 * not be used for any Colibri operations once disposed. 343 * 344 * @return <tt>true</tt> if this instance is in "disposed" state or 345 * <tt>false</tt> otherwise. 346 */ isDisposed()347 boolean isDisposed(); 348 349 /** 350 * Sets the "global" id of the conference. 351 */ setGID(String gid)352 void setGID(String gid) ; 353 } 354