Skip to content

Commit fbf327b

Browse files
committed
Work in progress: join bridge through network connections, avoiding the use of a mixer. Issue #1550.
1 parent 3ced59c commit fbf327b

11 files changed

Lines changed: 235 additions & 24 deletions

File tree

restcomm/restcomm.mscontrol.api/src/main/java/org/restcomm/connect/mscontrol/api/messages/JoinBridge.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
package org.restcomm.connect.mscontrol.api.messages;
2323

24+
import akka.actor.ActorRef;
2425
import jain.protocol.ip.mgcp.message.parms.ConnectionMode;
2526

2627
import org.restcomm.connect.commons.annotations.concurrency.Immutable;
@@ -34,10 +35,18 @@ public final class JoinBridge {
3435

3536
private final Object endpoint;
3637
private final ConnectionMode connectionMode;
38+
private final ActorRef call;
39+
private final boolean usingMixer; // true if call controller should join using mixer, false to join using network
3740

3841
public JoinBridge(final Object endpoint, final ConnectionMode connectionMode) {
42+
this(endpoint, connectionMode, null, true);
43+
}
44+
45+
public JoinBridge(final Object endpoint, final ConnectionMode connectionMode, final ActorRef call, final boolean usingMixer) {
3946
this.endpoint = endpoint;
4047
this.connectionMode = connectionMode;
48+
this.call = call;
49+
this.usingMixer = usingMixer;
4150
}
4251

4352
public Object getEndpoint() {
@@ -47,4 +56,8 @@ public Object getEndpoint() {
4756
public ConnectionMode getConnectionMode() {
4857
return connectionMode;
4958
}
59+
60+
public ActorRef getCall() { return call; }
61+
62+
public boolean isUsingMixer() { return usingMixer; }
5063
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.connect.mscontrol.api.messages;
23+
24+
import jain.protocol.ip.mgcp.message.parms.ConnectionMode;
25+
import org.restcomm.connect.commons.annotations.concurrency.Immutable;
26+
27+
/**
28+
* @author guilherme.jansen@telestax.com
29+
*/
30+
@Immutable
31+
public final class JoinBridgeNoMixer {
32+
33+
private final Object endpoint;
34+
private final ConnectionMode connectionMode;
35+
private final Object networkConnection;
36+
37+
public JoinBridgeNoMixer(final Object endpoint, final ConnectionMode connectionMode, final Object networkConnection) {
38+
this.endpoint = endpoint;
39+
this.connectionMode = connectionMode;
40+
this.networkConnection = networkConnection;
41+
}
42+
43+
public Object getEndpoint() {
44+
return endpoint;
45+
}
46+
47+
public ConnectionMode getConnectionMode() {
48+
return connectionMode;
49+
}
50+
51+
public Object getNetworkConnection() { return networkConnection; }
52+
}

restcomm/restcomm.mscontrol.api/src/main/java/org/restcomm/connect/mscontrol/api/messages/JoinCall.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import akka.actor.ActorRef;
2929
import org.restcomm.connect.commons.dao.Sid;
30+
import org.restcomm.connect.dao.entities.MediaAttributes;
3031

3132
/**
3233
* @author Henrique Rosa (henrique.rosa@telestax.com)
@@ -35,22 +36,34 @@
3536
@Immutable
3637
public final class JoinCall {
3738

38-
private final ActorRef call;
39+
private final ActorRef inboundCall;
40+
private final ActorRef outboundCall;
41+
private final MediaAttributes mediaAttributes;
3942
private final ConnectionMode connectionMode;
4043
private final Sid sid;
4144

4245
public JoinCall(final ActorRef call, final ConnectionMode connectionMode) {
43-
this(call, connectionMode, null);
46+
this(call, connectionMode, null, null, new MediaAttributes());
4447
}
4548

4649
public JoinCall(final ActorRef call, final ConnectionMode connectionMode, final Sid sid) {
47-
this.call = call;
50+
this(call, connectionMode, sid, null, new MediaAttributes());
51+
}
52+
53+
public JoinCall(final ActorRef call, final ConnectionMode connectionMode, final ActorRef outboundCall, final MediaAttributes mediaAttributes) {
54+
this(call, connectionMode, null, outboundCall, mediaAttributes);
55+
}
56+
57+
public JoinCall(final ActorRef call, final ConnectionMode connectionMode, final Sid sid, final ActorRef outboundCall, final MediaAttributes mediaAttributes) {
58+
this.inboundCall = call;
59+
this.outboundCall = outboundCall;
60+
this.mediaAttributes = mediaAttributes;
4861
this.connectionMode = connectionMode;
4962
this.sid = sid;
5063
}
5164

52-
public ActorRef getCall() {
53-
return call;
65+
public ActorRef getInboundCall() {
66+
return inboundCall;
5467
}
5568

5669
public ConnectionMode getConnectionMode() {
@@ -60,4 +73,8 @@ public ConnectionMode getConnectionMode() {
6073
public Sid getSid () {
6174
return sid;
6275
}
76+
77+
public ActorRef getOutboundCall() { return outboundCall; }
78+
79+
public MediaAttributes getMediaAttributes() { return mediaAttributes; }
6380
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* TeleStax, Open Source Cloud Communications
3+
* Copyright 2011-2017, Telestax Inc and individual contributors
4+
* by the @authors tag.
5+
*
6+
* This is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as
8+
* published by the Free Software Foundation; either version 2.1 of
9+
* the License, or (at your option) any later version.
10+
*
11+
* This software is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public
17+
* License along with this software; if not, write to the Free
18+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20+
*/
21+
22+
package org.restcomm.connect.mscontrol.api.messages;
23+
24+
import akka.actor.ActorRef;
25+
import jain.protocol.ip.mgcp.message.parms.ConnectionMode;
26+
import org.restcomm.connect.commons.annotations.concurrency.Immutable;
27+
28+
/**
29+
* @author guilherme.jansen@telestax.com
30+
*/
31+
@Immutable
32+
public final class ShareBridgeNetworkConnection {
33+
34+
private final Object endpoint;
35+
private final ConnectionMode connectionMode;
36+
private final ActorRef call;
37+
38+
public ShareBridgeNetworkConnection(final Object endpoint, final ConnectionMode connectionMode, final ActorRef call) {
39+
this.endpoint = endpoint;
40+
this.connectionMode = connectionMode;
41+
this.call = call;
42+
}
43+
44+
public Object getEndpoint() {
45+
return endpoint;
46+
}
47+
48+
public ConnectionMode getConnectionMode() {
49+
return connectionMode;
50+
}
51+
52+
public ActorRef getCall(){ return call; }
53+
}

restcomm/restcomm.mscontrol.jsr309/src/main/java/org/restcomm/connect/mscontrol/jsr309/Jsr309BridgeController.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,18 @@ private void onCreateMediaSession(CreateMediaSession message, ActorRef self, Act
379379
}
380380

381381
private void onJoinCall(JoinCall message, ActorRef self, ActorRef sender) {
382-
// Tell call to join bridge by passing reference to the media mixer
383-
final JoinBridge join = new JoinBridge(this.mediaMixer, message.getConnectionMode());
384-
message.getCall().tell(join, sender);
382+
MediaAttributes.MediaType mediaType = message.getMediaAttributes().getMediaType();
383+
if(!mediaType.equals(MediaAttributes.MediaType.AUDIO_ONLY)){
384+
// Tell outbound call to share the network connection of its call controller
385+
// with the call controller of the inbound call, so the call controller of the inbound call
386+
// can proceed joining calls without using a mixer
387+
final JoinBridge join = new JoinBridge(this.mediaMixer, message.getConnectionMode(), message.getInboundCall(), false);
388+
message.getOutboundCall().tell(join, sender);
389+
} else {
390+
// Tell inbound call to join bridge by passing reference to the media mixer
391+
final JoinBridge join = new JoinBridge(this.mediaMixer, message.getConnectionMode());
392+
message.getInboundCall().tell(join, sender);
393+
}
385394
}
386395

387396
private void onStop(Stop message, ActorRef self, ActorRef sender) throws Exception {
@@ -459,21 +468,22 @@ public void execute(Object message) throws Exception {
459468
if (MediaAttributes.MediaType.VIDEO_ONLY.equals(mediaAttributes.getMediaType())) {
460469
// video only
461470
configureVideoMediaSession(mediaAttributes);
462-
Parameters mixerParams = createMixerParams();
463-
mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO_VIDEO, mixerParams);
471+
//Parameters mixerParams = createMixerParams();
472+
//mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO_VIDEO, mixerParams);
464473
} else if (MediaAttributes.MediaType.AUDIO_VIDEO.equals(mediaAttributes.getMediaType())) {
465474
// audio and video
466475
configureVideoMediaSession(mediaAttributes);
467-
Parameters mixerParams = createMixerParams();
468-
mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO_VIDEO, mixerParams);
476+
//Parameters mixerParams = createMixerParams();
477+
//mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO_VIDEO, mixerParams);
469478
} else {
470479
// audio only
471-
Parameters mixerParams = createMixerParams();
472-
mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO, mixerParams);
480+
//Parameters mixerParams = createMixerParams();
481+
//mediaMixer = mediaSession.createMediaMixer(MediaMixer.AUDIO, mixerParams);
473482
}
474483

475-
mediaMixer.addListener(mixerAllocationListener);
476-
mediaMixer.confirm();
484+
//mediaMixer.addListener(mixerAllocationListener);
485+
//mediaMixer.confirm();
486+
fsm.transition(msg, active);
477487
// Wait for event confirmation before sending response to the conference
478488
} catch (MsControlException e) {
479489
// Move to a failed state, cleaning all resources and closing media session

restcomm/restcomm.mscontrol.jsr309/src/main/java/org/restcomm/connect/mscontrol/jsr309/Jsr309CallController.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.restcomm.connect.mscontrol.api.messages.Collect;
7575
import org.restcomm.connect.mscontrol.api.messages.CreateMediaSession;
7676
import org.restcomm.connect.mscontrol.api.messages.JoinBridge;
77+
import org.restcomm.connect.mscontrol.api.messages.JoinBridgeNoMixer;
7778
import org.restcomm.connect.mscontrol.api.messages.JoinComplete;
7879
import org.restcomm.connect.mscontrol.api.messages.JoinConference;
7980
import org.restcomm.connect.mscontrol.api.messages.Leave;
@@ -86,6 +87,7 @@
8687
import org.restcomm.connect.mscontrol.api.messages.Mute;
8788
import org.restcomm.connect.mscontrol.api.messages.Play;
8889
import org.restcomm.connect.mscontrol.api.messages.Record;
90+
import org.restcomm.connect.mscontrol.api.messages.ShareBridgeNetworkConnection;
8991
import org.restcomm.connect.mscontrol.api.messages.StartRecording;
9092
import org.restcomm.connect.mscontrol.api.messages.Stop;
9193
import org.restcomm.connect.mscontrol.api.messages.StopMediaGroup;
@@ -452,8 +454,12 @@ public void onReceive(Object message) throws Exception {
452454
onCollect((Collect) message, self, sender);
453455
} else if (Record.class.equals(klass)) {
454456
onRecord((Record) message, self, sender);
457+
} else if (ShareBridgeNetworkConnection.class.equals(klass)){
458+
onShareBridgeNetworkConnection((ShareBridgeNetworkConnection) message, self, sender);
455459
} else if (JoinBridge.class.equals(klass)) {
456460
onJoinBridge((JoinBridge) message, self, sender);
461+
} else if (JoinBridgeNoMixer.class.equals(klass)) {
462+
onJoinBridgeNoMixer((JoinBridgeNoMixer) message, self, sender);
457463
} else if (JoinConference.class.equals(klass)) {
458464
onJoinConference((JoinConference) message, self, sender);
459465
} else if (Stop.class.equals(klass)) {
@@ -721,18 +727,43 @@ private void onRecord(Record message, ActorRef self, ActorRef sender) {
721727
}
722728
}
723729

730+
private void onShareBridgeNetworkConnection(ShareBridgeNetworkConnection message, ActorRef self, ActorRef sender) throws Exception {
731+
final JoinBridgeNoMixer joinBridgeNoMixer = new JoinBridgeNoMixer(message.getEndpoint(), message.getConnectionMode(), networkConnection);
732+
message.getCall().tell(joinBridgeNoMixer, sender);
733+
}
734+
724735
private void onJoinBridge(JoinBridge message, ActorRef self, ActorRef sender) throws Exception {
725736
if (is(active)) {
726737
try {
727-
// join call leg to bridge
738+
// join call leg to bridge using mixer
728739
this.bridge = sender;
729740
this.mediaMixer = (MediaMixer) message.getEndpoint();
730741
this.networkConnection.join(Direction.DUPLEX, mediaMixer);
731742

732743
// alert call has joined successfully
733744
this.call.tell(new JoinComplete(), self);
734745
} catch (MsControlException e) {
735-
logger.error("Call bridging failed: " + e.getMessage());
746+
logger.error("Call bridging using mixer failed: " + e.getMessage());
747+
fsm.transition(e, failed);
748+
}
749+
}
750+
}
751+
752+
private void onJoinBridgeNoMixer(JoinBridgeNoMixer message, ActorRef self, ActorRef sender) throws Exception {
753+
if (is(active)) {
754+
try {
755+
// join call leg to bridge using network connection
756+
this.bridge = sender;
757+
final NetworkConnection bridgeNetworkConnection = (NetworkConnection) message.getNetworkConnection();
758+
this.networkConnection.join(Direction.DUPLEX, bridgeNetworkConnection);
759+
//this.networkConnection.getJoinableStream(JoinableStream.StreamType.audio).join(Direction.DUPLEX, bridgeNetworkConnection.getJoinableStream(JoinableStream.StreamType.audio));
760+
//this.networkConnection.getJoinableStream(JoinableStream.StreamType.video).join(Direction.DUPLEX, bridgeNetworkConnection.getJoinableStream(JoinableStream.StreamType.video));
761+
//this.networkConnection.joinInitiate(Direction.DUPLEX, bridgeNetworkConnection, null);
762+
763+
// alert call has joined successfully
764+
this.call.tell(new JoinComplete(), self);
765+
} catch (MsControlException e) {
766+
logger.error("Call bridging using network connection failed: " + e.getMessage());
736767
fsm.transition(e, failed);
737768
}
738769
}

restcomm/restcomm.mscontrol.jsr309/src/main/java/org/restcomm/connect/mscontrol/jsr309/Jsr309ConferenceController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private void onJoinCall(JoinCall message, ActorRef self, ActorRef sender) {
341341
if (is(active)) {
342342
// Tell call to join conference by passing reference of the media mixer
343343
final JoinConference join = new JoinConference(this.mediaMixer, message.getConnectionMode(), message.getSid());
344-
message.getCall().tell(join, sender);
344+
message.getInboundCall().tell(join, sender);
345345
}
346346
}
347347

restcomm/restcomm.mscontrol.mms/src/main/java/org/restcomm/connect/mscontrol/mms/MmsBridgeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ private void onCreateMediaSession(CreateMediaSession message, ActorRef self, Act
285285
private void onJoinCall(JoinCall message, ActorRef self, ActorRef sender) {
286286
// Tell call to join bridge by passing reference to the media mixer
287287
final JoinBridge join = new JoinBridge(this.endpoint, message.getConnectionMode());
288-
message.getCall().tell(join, sender);
288+
message.getInboundCall().tell(join, sender);
289289
}
290290

291291
private void onStop(Stop message, ActorRef self, ActorRef sender) throws Exception {

restcomm/restcomm.mscontrol.mms/src/main/java/org/restcomm/connect/mscontrol/mms/MmsConferenceController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ private void onJoinCall(JoinCall message, ActorRef self, ActorRef sender) {
382382
connectionMode = message.getConnectionMode();
383383
// Tell call to join conference by passing reference to the media mixer
384384
final JoinConference join = new JoinConference(this.cnfEndpoint, connectionMode, message.getSid());
385-
message.getCall().tell(join, sender);
385+
message.getInboundCall().tell(join, sender);
386386
}
387387

388388
/*private void onStopMediaGroup(StopMediaGroup message, ActorRef self, ActorRef sender) {

restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Bridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public Bridging(ActorRef source) {
307307
@Override
308308
public void execute(Object message) throws Exception {
309309
// Ask mscontroller to join inbound call
310-
final JoinCall join = new JoinCall(inboundCall, ConnectionMode.SendRecv);
310+
final JoinCall join = new JoinCall(inboundCall, ConnectionMode.SendRecv, outboundCall, mediaAttributes);
311311
mscontroller.tell(join, super.source);
312312
}
313313

0 commit comments

Comments
 (0)