Skip to content

Commit

Permalink
Make TIMEOUT_ON_FRAME_COUNT configurable through sip-communicator.pro…
Browse files Browse the repository at this point in the history
…perties
  • Loading branch information
csaba.varro authored and bgrozev committed Apr 12, 2016
1 parent 6bf326c commit 989b7f2
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
Expand Up @@ -15,12 +15,14 @@
*/ */
package org.jitsi.videobridge.simulcast; package org.jitsi.videobridge.simulcast;


import net.java.sip.communicator.util.ServiceUtils;
import net.sf.fmj.media.rtp.*; import net.sf.fmj.media.rtp.*;
import net.sf.fmj.media.rtp.util.*; import net.sf.fmj.media.rtp.util.*;
import org.jitsi.impl.neomedia.*; import org.jitsi.impl.neomedia.*;
import org.jitsi.impl.neomedia.rtcp.*; import org.jitsi.impl.neomedia.rtcp.*;
import org.jitsi.impl.neomedia.rtcp.termination.strategies.*; import org.jitsi.impl.neomedia.rtcp.termination.strategies.*;
import org.jitsi.impl.neomedia.transform.*; import org.jitsi.impl.neomedia.transform.*;
import org.jitsi.service.configuration.*;
import org.jitsi.util.*; import org.jitsi.util.*;
import org.jitsi.util.function.*; import org.jitsi.util.function.*;
import org.jitsi.videobridge.*; import org.jitsi.videobridge.*;
Expand Down Expand Up @@ -56,8 +58,7 @@ public class SimulcastEngine
* If the owning endpoint (viewed as a sender) has signaled simulcast, this * If the owning endpoint (viewed as a sender) has signaled simulcast, this
* object receives it. * object receives it.
*/ */
private final SimulcastReceiver simulcastReceiver private final SimulcastReceiver simulcastReceiver;
= new SimulcastReceiver(this);


/** /**
* For each <tt>SimulcastReceiver</tt> we have a <tt>SimulcastSender</tt>. * For each <tt>SimulcastReceiver</tt> we have a <tt>SimulcastSender</tt>.
Expand Down Expand Up @@ -111,6 +112,11 @@ public class SimulcastEngine
public SimulcastEngine(VideoChannel videoChannel) public SimulcastEngine(VideoChannel videoChannel)
{ {
this.videoChannel = videoChannel; this.videoChannel = videoChannel;
simulcastReceiver = new SimulcastReceiver(this,
ServiceUtils.getService(
videoChannel.getBundleContext(),
ConfigurationService.class)
);
} }


/** /**
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/ */
package org.jitsi.videobridge.simulcast; package org.jitsi.videobridge.simulcast;


import org.jitsi.service.configuration.*;
import org.jitsi.impl.neomedia.*; import org.jitsi.impl.neomedia.*;
import org.jitsi.util.*; import org.jitsi.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
Expand Down Expand Up @@ -48,7 +49,19 @@ public class SimulcastReceiver
* from its remote peer or it will be declared paused/stopped/not streaming * from its remote peer or it will be declared paused/stopped/not streaming
* by its {@code SimulcastReceiver}. * 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 * The list of listeners to be notified by this receiver when a change in
Expand Down Expand Up @@ -95,9 +108,16 @@ public class SimulcastReceiver
* *
* @param simulcastEngine the <tt>SimulcastEngine</tt> that owns this * @param simulcastEngine the <tt>SimulcastEngine</tt> that owns this
* receiver. * 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; this.simulcastEngine = simulcastEngine;
} }


Expand All @@ -111,6 +131,29 @@ public SimulcastEngine getSimulcastEngine()
return this.simulcastEngine; 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. * Returns true if the endpoint has signaled one or more simulcast streams.
* *
Expand Down

0 comments on commit 989b7f2

Please sign in to comment.