Permalink
Browse files

Make TIMEOUT_ON_FRAME_COUNT configurable through sip-communicator.pro…

…perties
  • Loading branch information...
csaba.varro authored and bgrozev committed Apr 8, 2016
1 parent 6bf326c commit 989b7f2671ac9e40c84ab31d57a5e74b5130284b
@@ -15,12 +15,14 @@
*/
package org.jitsi.videobridge.simulcast;
import net.java.sip.communicator.util.ServiceUtils;
import net.sf.fmj.media.rtp.*;
import net.sf.fmj.media.rtp.util.*;
import org.jitsi.impl.neomedia.*;
import org.jitsi.impl.neomedia.rtcp.*;
import org.jitsi.impl.neomedia.rtcp.termination.strategies.*;
import org.jitsi.impl.neomedia.transform.*;
import org.jitsi.service.configuration.*;
import org.jitsi.util.*;
import org.jitsi.util.function.*;
import org.jitsi.videobridge.*;
@@ -56,8 +58,7 @@
* If the owning endpoint (viewed as a sender) has signaled simulcast, this
* object receives it.
*/
private final SimulcastReceiver simulcastReceiver
= new SimulcastReceiver(this);
private final SimulcastReceiver simulcastReceiver;
/**
* For each <tt>SimulcastReceiver</tt> we have a <tt>SimulcastSender</tt>.
@@ -111,6 +112,11 @@
public SimulcastEngine(VideoChannel videoChannel)
{
this.videoChannel = videoChannel;
simulcastReceiver = new SimulcastReceiver(this,
ServiceUtils.getService(
videoChannel.getBundleContext(),
ConfigurationService.class)
);
}
/**
@@ -15,6 +15,7 @@
*/
package org.jitsi.videobridge.simulcast;
import org.jitsi.service.configuration.*;
import org.jitsi.impl.neomedia.*;
import org.jitsi.util.*;
import java.util.concurrent.*;
@@ -48,7 +49,19 @@
* from its remote peer or it will be declared paused/stopped/not streaming
* by its {@code SimulcastReceiver}.
*/
private static final int TIMEOUT_ON_FRAME_COUNT = 5;
private static int TIMEOUT_ON_FRAME_COUNT = -1; // -1 means uninitialized
/**
* The default value for TIMEOUT_ON_FRAME_COUNT if the config not specifies
* it
*/
private static final int DEFAULT_TIMEOUT_ON_FRAME_COUNT = 5;
/**
* Configuration key for TIMEOUT_ON_FRAME_COUNT
*/
private static final String TIMEOUT_ON_FRAME_COUNT_CONFIG_KEY
= "org.jitsi.videobridge.TIMEOUT_ON_FRAME_COUNT";
/**
* The list of listeners to be notified by this receiver when a change in
@@ -95,9 +108,16 @@
*
* @param simulcastEngine the <tt>SimulcastEngine</tt> that owns this
* receiver.
* @param cfg Needed to read TIMEOUT_ON_FRAME_COUNT
*/
public SimulcastReceiver(SimulcastEngine simulcastEngine)
public SimulcastReceiver(SimulcastEngine simulcastEngine,
ConfigurationService cfg)
{
if (TIMEOUT_ON_FRAME_COUNT < 0) // Initialize config only once
{
initializeConfiguration(cfg);
}
this.simulcastEngine = simulcastEngine;
}
@@ -111,6 +131,29 @@ public SimulcastEngine getSimulcastEngine()
return this.simulcastEngine;
}
/**
* Reads TIMEOUT_ON_FRAME_COUNT from the <tt>ConfigurationService</tt>
*
* @param cfg The global <tt>ConfigurationService</tt> object
*/
private static void initializeConfiguration(ConfigurationService cfg) {
if (cfg == null)
{
logger.warn("Can't set TIMEOUT_ON_FRAME_COUNT because "
+ "the configuration service was not found. "
+ "Using " + DEFAULT_TIMEOUT_ON_FRAME_COUNT
+ " as default");
TIMEOUT_ON_FRAME_COUNT = DEFAULT_TIMEOUT_ON_FRAME_COUNT;
}
else
{
TIMEOUT_ON_FRAME_COUNT = cfg.getInt(
TIMEOUT_ON_FRAME_COUNT_CONFIG_KEY,
DEFAULT_TIMEOUT_ON_FRAME_COUNT);
}
}
/**
* Returns true if the endpoint has signaled one or more simulcast streams.
*

0 comments on commit 989b7f2

Please sign in to comment.