Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ classes
media-server-docs/sources-mobicents/src
media-server-docs/sources-telscale/src
client/jsr-309/tck/tck-run

/**/*.iml
.idea
7 changes: 6 additions & 1 deletion bootstrap/src/main/config/mediaserver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@
<resources>
<localConnection poolSize="100" />
<remoteConnection poolSize="50" />
<player poolSize="50" />
<player poolSize="50">
<cache>
<cacheSize>100</cacheSize>
<cacheEnabled>false</cacheEnabled>
</cache>
</player>
<recorder poolSize="50" />
<dtmfDetector poolSize="50" dbi="-35" />
<dtmfGenerator poolSize="50" toneVolume="-20" toneDuration="80" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.commons.configuration2.XMLConfiguration;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.ex.ConfigurationException;
import org.apache.commons.configuration2.ex.ConfigurationRuntimeException;
import org.apache.commons.configuration2.tree.ImmutableNode;
import org.apache.log4j.Logger;
import org.mobicents.media.core.configuration.DtlsConfiguration;
Expand Down Expand Up @@ -136,6 +137,7 @@ private static void configureResource(HierarchicalConfiguration<ImmutableNode> s
dst.setDtmfGeneratorToneDuration(src.getInt("dtmfGenerator[@toneDuration]", ResourcesConfiguration.DTMF_GENERATOR_TONE_DURATION));
dst.setSignalDetectorCount(src.getInt("signalDetector[@poolSize]", ResourcesConfiguration.SIGNAL_DETECTOR_COUNT));
dst.setSignalGeneratorCount(src.getInt("signalGenerator[@poolSize]", ResourcesConfiguration.SIGNAL_GENERATOR_COUNT));
configurePlayer(src, dst);
}

private static void configureDtls(HierarchicalConfiguration<ImmutableNode> src, DtlsConfiguration dst){
Expand All @@ -147,4 +149,21 @@ private static void configureDtls(HierarchicalConfiguration<ImmutableNode> src,
dst.setAlgorithmCertificate(src.getString("certificate[@algorithm]", DtlsConfiguration.ALGORITHM_CERTIFICATE));
}

private static void configurePlayer(HierarchicalConfiguration<ImmutableNode> src, ResourcesConfiguration dst) {
HierarchicalConfiguration<ImmutableNode> player = src.configurationAt("player");
dst.setPlayerCount(player.getInt("[@poolSize]", ResourcesConfiguration.PLAYER_COUNT));

HierarchicalConfiguration<ImmutableNode> cache;
try {
cache = player.configurationAt("cache");
} catch (ConfigurationRuntimeException exception) {
log.info("No cache was specified for player");
return;
}
dst.setPlayerCache(
cache.getBoolean("cacheEnabled", ResourcesConfiguration.PLAYER_CACHE_ENABLED),
cache.getInt("cacheSize", ResourcesConfiguration.PLAYER_CACHE_SIZE)
);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
package org.mobicents.media.server.bootstrap.ioc;

import org.mobicents.media.core.configuration.MediaServerConfiguration;
import org.mobicents.media.server.bootstrap.ioc.provider.DirectRemoteStreamProvider;
import org.mobicents.media.server.bootstrap.ioc.provider.AudioPlayerFactoryProvider;
import org.mobicents.media.server.bootstrap.ioc.provider.AudioPlayerPoolProvider;
import org.mobicents.media.server.bootstrap.ioc.provider.AudioRecorderFactoryProvider;
Expand Down Expand Up @@ -75,6 +76,8 @@
import org.mobicents.media.server.scheduler.Scheduler;
import org.mobicents.media.server.spi.ServerManager;
import org.mobicents.media.server.spi.dsp.DspFactory;
import org.mobicents.media.server.bootstrap.ioc.provider.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.RemoteStreamProvider;

import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
Expand Down Expand Up @@ -120,6 +123,12 @@ protected void configure() {
bind(EndpointInstallerListType.INSTANCE).toProvider(EndpointInstallerListProvider.class).in(Singleton.class);
bind(ServerManager.class).toProvider(MgcpControllerProvider.class).in(Singleton.class);
bind(DtlsSrtpServerProvider.class).toProvider(DtlsSrtpServerProviderProvider.class).in(Singleton.class);
Class remoteStreamProvider;
if (this.config.getResourcesConfiguration().getPlayerCacheEnabled()) {
remoteStreamProvider = CachedRemoteStreamProvider.class;
} else {
remoteStreamProvider = DirectRemoteStreamProvider.class;
}
bind(RemoteStreamProvider.class).toProvider(remoteStreamProvider).in(Singleton.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package org.mobicents.media.server.bootstrap.ioc.provider;

import org.mobicents.media.server.impl.resource.mediaplayer.audio.RemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerImpl;
import org.mobicents.media.server.scheduler.PriorityQueueScheduler;
Expand All @@ -39,16 +40,18 @@ public class AudioPlayerFactoryProvider implements Provider<AudioPlayerFactory>

private final PriorityQueueScheduler mediaScheduler;
private final DspFactory dspFactory;
private final RemoteStreamProvider remoteStreamProvider;

@Inject
public AudioPlayerFactoryProvider(PriorityQueueScheduler mediaScheduler, DspFactory dspFactory) {
public AudioPlayerFactoryProvider(PriorityQueueScheduler mediaScheduler, DspFactory dspFactory, RemoteStreamProvider remoteStreamProvider) {
this.mediaScheduler = mediaScheduler;
this.dspFactory = dspFactory;
this.remoteStreamProvider = remoteStreamProvider;
}

@Override
public AudioPlayerFactory get() {
return new AudioPlayerFactory(mediaScheduler, dspFactory);
return new AudioPlayerFactory(mediaScheduler, dspFactory, remoteStreamProvider);
}

public static final class AudioPlayerFactoryType extends TypeLiteral<PooledObjectFactory<AudioPlayerImpl>> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.mobicents.media.server.bootstrap.ioc.provider;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.mobicents.media.core.configuration.MediaServerConfiguration;

/**
* Created by achikin on 6/3/16.
*/
public class CachedRemoteStreamProvider implements Provider<org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider> {

private static org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider instance;

@Inject
public CachedRemoteStreamProvider(MediaServerConfiguration config) {
instance = new org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider(config.getResourcesConfiguration().getPlayerCacheSize());
}

@Override
public org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider get() {
return instance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.mobicents.media.server.bootstrap.ioc.provider;

import com.google.inject.Provider;

/**
* Created by achikin on 6/7/16.
*/
public class DirectRemoteStreamProvider implements Provider<org.mobicents.media.server.impl.resource.mediaplayer.audio.DirectRemoteStreamProvider> {

private org.mobicents.media.server.impl.resource.mediaplayer.audio.DirectRemoteStreamProvider instance;

public DirectRemoteStreamProvider() {
instance = new org.mobicents.media.server.impl.resource.mediaplayer.audio.DirectRemoteStreamProvider();
}

@Override
public org.mobicents.media.server.impl.resource.mediaplayer.audio.DirectRemoteStreamProvider get() {
return instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void testLoadConfiguration() throws Exception {
ResourcesConfiguration resources = config.getResourcesConfiguration();
Assert.assertEquals(200, resources.getLocalConnectionCount());
Assert.assertEquals(100, resources.getRemoteConnectionCount());
Assert.assertEquals(100, resources.getPlayerCount());
Assert.assertEquals(100, resources.getRecorderCount());
Assert.assertEquals(100, resources.getDtmfDetectorCount());
Assert.assertEquals(-25, resources.getDtmfDetectorDbi());
Expand All @@ -115,6 +114,10 @@ public void testLoadConfiguration() throws Exception {
Assert.assertEquals(DtlsConfiguration.KEY_PATH, dtls.getKeyPath());
Assert.assertEquals(SignatureAlgorithm.ecdsa, dtls.getAlgorithmCertificate().getSignatureAlgorithm());
Assert.assertEquals(ClientCertificateType.ecdsa_sign, dtls.getAlgorithmCertificate().getClientCertificate());

Assert.assertEquals(100, resources.getPlayerCount());
Assert.assertEquals(100, resources.getPlayerCacheSize());
Assert.assertEquals(true, resources.getPlayerCacheEnabled());
}

/**
Expand Down
7 changes: 6 additions & 1 deletion bootstrap/src/test/resources/mediaserver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
<resources>
<localConnection poolSize="200" />
<remoteConnection poolSize="100" />
<player poolSize="100" />
<player poolSize="100">
<cache>
<cacheSize>100</cacheSize>
<cacheEnabled>true</cacheEnabled>
</cache>
</player>
<recorder poolSize="100" />
<dtmfDetector poolSize="100" dbi="-25" />
<dtmfGenerator poolSize="100" toneVolume="-25" toneDuration="100" />
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<name>Client</name>

<modules>
<module>jsr-309</module>
<!--<module>jsr-309</module>-->
<module>mgcp</module>
</modules>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfDetectorPool;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand All @@ -49,7 +50,6 @@
import org.mobicents.media.server.mgcp.connection.LocalConnectionPool;
import org.mobicents.media.server.mgcp.connection.RtpConnectionFactory;
import org.mobicents.media.server.mgcp.connection.RtpConnectionPool;
import org.mobicents.media.server.mgcp.endpoint.BridgeEndpoint;
import org.mobicents.media.server.mgcp.endpoint.connection.RTPEnvironment;
import org.mobicents.media.server.mgcp.resources.ResourcesPool;
import org.mobicents.media.server.spi.Connection;
Expand Down Expand Up @@ -141,7 +141,7 @@ public void setUp() throws ResourceUnavailableException, TooManyConnectionsExcep
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.dtmf.GeneratorImpl;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand All @@ -61,9 +62,6 @@
import org.mobicents.media.server.mgcp.connection.LocalConnectionPool;
import org.mobicents.media.server.mgcp.connection.RtpConnectionFactory;
import org.mobicents.media.server.mgcp.connection.RtpConnectionPool;
import org.mobicents.media.server.mgcp.endpoint.BaseMixerEndpointImpl;
import org.mobicents.media.server.mgcp.endpoint.BridgeEndpoint;
import org.mobicents.media.server.mgcp.endpoint.IvrEndpoint;
import org.mobicents.media.server.mgcp.resources.ResourcesPool;
import org.mobicents.media.server.scheduler.Clock;
import org.mobicents.media.server.scheduler.PriorityQueueScheduler;
Expand Down Expand Up @@ -156,7 +154,7 @@ public void setUp() throws ResourceUnavailableException, IOException {
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.dtmf.GeneratorImpl;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand All @@ -61,8 +62,6 @@
import org.mobicents.media.server.mgcp.connection.LocalConnectionPool;
import org.mobicents.media.server.mgcp.connection.RtpConnectionFactory;
import org.mobicents.media.server.mgcp.connection.RtpConnectionPool;
import org.mobicents.media.server.mgcp.endpoint.BaseMixerEndpointImpl;
import org.mobicents.media.server.mgcp.endpoint.IvrEndpoint;
import org.mobicents.media.server.mgcp.resources.ResourcesPool;
import org.mobicents.media.server.scheduler.Clock;
import org.mobicents.media.server.scheduler.Scheduler;
Expand Down Expand Up @@ -155,7 +154,7 @@ public void setUp() throws ResourceUnavailableException, IOException, Interrupte
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfDetectorPool;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand Down Expand Up @@ -139,7 +140,7 @@ public void setUp() throws ResourceUnavailableException, IOException, TooManyCon
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfDetectorPool;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand Down Expand Up @@ -142,7 +143,7 @@ public void setUp() throws ResourceUnavailableException, IOException {
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.mobicents.media.server.impl.resource.dtmf.DtmfDetectorPool;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorFactory;
import org.mobicents.media.server.impl.resource.dtmf.DtmfGeneratorPool;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.CachedRemoteStreamProvider;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerFactory;
import org.mobicents.media.server.impl.resource.mediaplayer.audio.AudioPlayerPool;
import org.mobicents.media.server.impl.resource.phone.PhoneSignalDetectorFactory;
Expand Down Expand Up @@ -109,7 +110,7 @@ public class BaseConnectionTest implements ConnectionListener {
private PhoneSignalDetectorPool signalDetectorPool;
private PhoneSignalGeneratorFactory signalGeneratorFactory;
private PhoneSignalGeneratorPool signalGeneratorPool;

//Dtls Server Provider
protected ProtocolVersion minVersion = ProtocolVersion.DTLSv10;
protected ProtocolVersion maxVersion = ProtocolVersion.DTLSv12;
Expand All @@ -126,6 +127,7 @@ public class BaseConnectionTest implements ConnectionListener {
@Before
public void setUp() throws ResourceUnavailableException, IOException, TooManyConnectionsException {
//use default clock

clock = new WallClock();

//create single thread scheduler
Expand All @@ -141,7 +143,7 @@ public void setUp() throws ResourceUnavailableException, IOException, TooManyCon
this.rtpConnectionPool = new RtpConnectionPool(0, rtpConnectionFactory);
this.localConnectionFactory = new LocalConnectionFactory(channelsManager);
this.localConnectionPool = new LocalConnectionPool(0, localConnectionFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory);
this.playerFactory = new AudioPlayerFactory(mediaScheduler, dspFactory, new CachedRemoteStreamProvider(100));
this.playerPool = new AudioPlayerPool(0, playerFactory);
this.recorderFactory = new AudioRecorderFactory(mediaScheduler);
this.recorderPool = new AudioRecorderPool(0, recorderFactory);
Expand Down
Loading