Adds a minimal duration for RTP DTMF tones. This minimal duration can be configured by provisioning with the net.java.sip.communicator.service.protocol.minimalRtpDtmfToneDuration property, or by setting it in the account preferences.

cusax-fix
Vincent Lucas 13 years ago
parent 012f43d028
commit a1e648c6ef

@ -1104,6 +1104,9 @@ plugin.sipaccregwizz.KEEP_ALIVE=Keep alive
plugin.sipaccregwizz.KEEP_ALIVE_METHOD=Keep alive method
plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL=Keep alive interval
plugin.sipaccregwizz.KEEP_ALIVE_INTERVAL_INFO=Between 1 and 3600 seconds
plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION=Minimal RTP DTMF tone duration (ms)
plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION_INFO=Default RTP DTMF duration is 70 ms
plugin.sipaccregwizz.DTMF=DTMF
plugin.sipaccregwizz.DTMF_METHOD=DTMF method
plugin.sipaccregwizz.DTMF_AUTO=Auto: Choose automatically between RTP and Inband (no SIP INFO)
plugin.sipaccregwizz.DTMF_RTP=RTP ( RFC2833 / RFC 4733 )

@ -12,10 +12,12 @@
import net.java.sip.communicator.service.protocol.OperationFailedException;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.codec.*;
import org.jitsi.service.neomedia.format.*;
import org.jitsi.service.protocol.*;
import org.jitsi.util.StringUtils; // Disambiguation
/**
* Class responsible for sending a DTMF Tone using using rfc4733 or Inband.
@ -36,6 +38,11 @@ public class OperationSetDTMFJabberImpl
*/
private DTMFMethod dtmfMethod;
/**
* The minimal tone duration.
*/
private int minimalToneDuration;
/**
* Constructor.
*
@ -44,6 +51,7 @@ public class OperationSetDTMFJabberImpl
public OperationSetDTMFJabberImpl(ProtocolProviderServiceJabberImpl pps)
{
this.dtmfMethod = this.getDTMFMethod(pps);
this.minimalToneDuration = this.getMinimalToneDuration(pps);
}
/**
@ -99,7 +107,7 @@ public synchronized void startSendingDTMF(CallPeer callPeer, DTMFTone tone)
}
((AudioMediaStream)cp.getMediaHandler().getStream(MediaType.AUDIO))
.startSendingDTMF(tone, cpDTMFMethod);
.startSendingDTMF(tone, cpDTMFMethod, minimalToneDuration);
}
/**
@ -208,4 +216,39 @@ else if(dtmfString.equals("RTP_DTMF"))
return DTMFMethod.INBAND_DTMF;
}
}
/**
* Gets the minimal DTMF tone duration for this account.
*
* @param pps the Jabber Protocol provider service
*
* @return The minimal DTMF tone duration for this account.
*/
private int getMinimalToneDuration(ProtocolProviderServiceJabberImpl pps)
{
AccountID accountID = pps.getAccountID();
String minimalToneDurationString
= accountID.getAccountPropertyString("DTMF_MINIMAL_TONE_DURATION");
int minimalToneDuration
= OperationSetDTMF.DEFAULT_DTMF_MINIMAL_TONE_DURATION;
// Check if there is a specific value for this account.
if(!StringUtils.isNullOrEmpty(minimalToneDurationString))
{
minimalToneDuration = Integer.valueOf(minimalToneDurationString);
}
// Else look at the globl property.
else
{
ConfigurationService cfg
= JabberActivator.getConfigurationService();
// Check if there is a custom value for the minimal tone duration.
if(cfg != null)
{
minimalToneDuration = cfg.getInt(
OperationSetDTMF.PROP_MINIMAL_RTP_DTMF_TONE_DURATION,
minimalToneDuration);
}
}
return minimalToneDuration;
}
}

@ -13,10 +13,12 @@
import net.java.sip.communicator.service.protocol.OperationFailedException;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.codec.*;
import org.jitsi.service.neomedia.format.*;
import org.jitsi.service.protocol.*;
import org.jitsi.util.StringUtils; // Disambiguation
/**
* Class responsible for sending a DTMF Tone using SIP INFO or using rfc4733.
@ -43,6 +45,11 @@ public class OperationSetDTMFSipImpl
*/
private final DTMFInfo dtmfModeInfo;
/**
* The minimal tone duration.
*/
private int minimalToneDuration;
/**
* Constructor.
*
@ -51,6 +58,7 @@ public class OperationSetDTMFSipImpl
public OperationSetDTMFSipImpl(ProtocolProviderServiceSipImpl pps)
{
this.dtmfMethod = this.getDTMFMethod(pps);
this.minimalToneDuration = this.getMinimalToneDuration(pps);
dtmfModeInfo = new DTMFInfo(pps);
}
@ -116,7 +124,7 @@ public synchronized void startSendingDTMF(CallPeer callPeer, DTMFTone tone)
}
((AudioMediaStream)cp.getMediaHandler().getStream(MediaType.AUDIO))
.startSendingDTMF(tone, cpDTMFMethod);
.startSendingDTMF(tone, cpDTMFMethod, minimalToneDuration);
}
}
@ -250,4 +258,38 @@ else if(dtmfString.equals("SIP_INFO_DTMF"))
return DTMFMethod.INBAND_DTMF;
}
}
/**
* Gets the minimal DTMF tone duration for this account.
*
* @param pps the SIP Protocol provider service
*
* @return The minimal DTMF tone duration for this account.
*/
private int getMinimalToneDuration(ProtocolProviderServiceSipImpl pps)
{
AccountID accountID = pps.getAccountID();
String minimalToneDurationString
= accountID.getAccountPropertyString("DTMF_MINIMAL_TONE_DURATION");
int minimalToneDuration
= OperationSetDTMF.DEFAULT_DTMF_MINIMAL_TONE_DURATION;
// Check if there is a specific value for this account.
if(!StringUtils.isNullOrEmpty(minimalToneDurationString))
{
minimalToneDuration = Integer.valueOf(minimalToneDurationString);
}
// Else look at the globl property.
else
{
ConfigurationService cfg = SipActivator.getConfigurationService();
// Check if there is a custom value for the minimal tone duration.
if(cfg != null)
{
minimalToneDuration = cfg.getInt(
OperationSetDTMF.PROP_MINIMAL_RTP_DTMF_TONE_DURATION,
minimalToneDuration);
}
}
return minimalToneDuration;
}
}

@ -100,6 +100,11 @@ public class ConnectionPanel
"plugin.sipaccregwizz.DTMF_INBAND")
});
/**
* The text field used to change the DTMF minimal tone duration.
*/
private JTextField dtmfMinimalToneDurationValue = new JTextField();
private final JabberAccountRegistrationForm parentForm;
/**
@ -234,14 +239,64 @@ public void actionPerformed(ActionEvent e)
*/
private Component createDTMFPanel()
{
JPanel dtmfPanel = new TransparentPanel(new BorderLayout(10, 10));
JPanel emptyLabelPanel = new TransparentPanel();
// Labels.
JPanel dtmfLabels = new TransparentPanel(new GridLayout(0, 1, 5, 5));
JLabel dtmfMethodLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"));
dtmfPanel.add(dtmfMethodLabel, BorderLayout.WEST);
JLabel minimalDTMFToneDurationLabel = new JLabel(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"));
dtmfLabels.add(dtmfMethodLabel);
dtmfLabels.add(minimalDTMFToneDurationLabel);
dtmfLabels.add(emptyLabelPanel);
// Values
JPanel dtmfValues = new TransparentPanel(new GridLayout(0, 1, 5, 5));
dtmfMethodBox.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
boolean isEnabled = false;
String selectedItem
= (String) dtmfMethodBox.getSelectedItem();
if(selectedItem != null
&& (selectedItem.equals(Resources.getString(
"plugin.sipaccregwizz.DTMF_AUTO"))
|| selectedItem.equals(Resources.getString(
"plugin.sipaccregwizz.DTMF_RTP")))
)
{
isEnabled = true;
}
dtmfMinimalToneDurationValue.setEnabled(isEnabled);
}
});
dtmfMethodBox.setSelectedItem(
parentForm.getRegistration().getDefaultDTMFMethod());
dtmfPanel.add(dtmfMethodBox, BorderLayout.CENTER);
parentForm.getRegistration().getDefaultDTMFMethod());
dtmfMinimalToneDurationValue.setText(
JabberAccountRegistration.DEFAULT_MINIMAL_DTMF_TONE_DURATION);
JLabel dtmfMinimalToneDurationExampleLabel = new JLabel(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION_INFO"));
dtmfMinimalToneDurationExampleLabel.setForeground(Color.GRAY);
dtmfMinimalToneDurationExampleLabel.setFont(
dtmfMinimalToneDurationExampleLabel.getFont().deriveFont(8));
dtmfMinimalToneDurationExampleLabel.setMaximumSize(
new Dimension(40, 35));
dtmfMinimalToneDurationExampleLabel.setBorder(
BorderFactory.createEmptyBorder(0, 0, 8, 0));
dtmfValues.add(dtmfMethodBox);
dtmfValues.add(dtmfMinimalToneDurationValue);
dtmfValues.add(dtmfMinimalToneDurationExampleLabel);
// DTMF panel
JPanel dtmfPanel = new TransparentPanel(new BorderLayout(10, 10));
dtmfPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.sipaccregwizz.DTMF")));
dtmfPanel.add(dtmfLabels, BorderLayout.WEST);
dtmfPanel.add(dtmfValues, BorderLayout.CENTER);
return dtmfPanel;
}
@ -515,6 +570,26 @@ else if(dtmfMethod.equals("INBAND_DTMF"))
}
}
/**
* Returns the minimal DTMF tone duration.
*
* @return The minimal DTMF tone duration.
*/
String getDtmfMinimalToneDuration()
{
return dtmfMinimalToneDurationValue.getText();
}
/**
* Sets the minimal DTMF tone duration
*
* @param dtmfMinimalToneDuration
*/
void setDtmfMinimalToneDuration(String dtmfMinimalToneDuration)
{
dtmfMinimalToneDurationValue.setText(dtmfMinimalToneDuration);
}
/**
* Sets the <tt>serverOverridden</tt> property.
* @param isServerOverridden <tt>true</tt> to indicate that the server is

@ -47,8 +47,17 @@ public class JabberAccountRegistration
*/
public static final boolean DEFAULT_RESOURCE_AUTOGEN = true;
/**
* The default value for DTMF method.
*/
private String defaultDTMFMethod = "AUTO_DTMF";
/**
* The default value of minimale DTMF tone duration.
*/
public static String DEFAULT_MINIMAL_DTMF_TONE_DURATION = Integer.toString(
OperationSetDTMF.DEFAULT_DTMF_MINIMAL_TONE_DURATION);
/**
* The user identifier.
*/
@ -208,6 +217,11 @@ public class JabberAccountRegistration
*/
private String dtmfMethod = null;
/**
* The minimal DTMF tone duration set.
*/
private String dtmfMinimalToneDuration = DEFAULT_MINIMAL_DTMF_TONE_DURATION;
/**
* Initializes a new JabberAccountRegistration.
*/
@ -865,6 +879,26 @@ public void setDefaultDTMFMethod(String defaultDTMFMethod)
this.defaultDTMFMethod = defaultDTMFMethod;
}
/**
* Returns the minimal DTMF tone duration.
*
* @return The minimal DTMF tone duration.
*/
public String getDtmfMinimalToneDuration()
{
return dtmfMinimalToneDuration;
}
/**
* Sets the minimal DTMF tone duration.
*
* @param dtmfMinimalToneDuration The minimal DTMF tone duration to set.
*/
public void setDtmfMinimalToneDuration(String dtmfMinimalToneDuration)
{
this.dtmfMinimalToneDuration = dtmfMinimalToneDuration;
}
/**
* Sets the method used for RTP/SAVP indication.
*/

@ -16,6 +16,8 @@
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.protocol.*;
import org.jitsi.util.*;
/**
* The <tt>JabberAccountRegistrationForm</tt>.
*
@ -312,6 +314,8 @@ public boolean commitPage(JabberAccountRegistration registration)
registration.setPriority(Integer.parseInt(priority));
registration.setDTMFMethod(connectionPanel.getDTMFMethod());
registration.setDtmfMinimalToneDuration(
connectionPanel.getDtmfMinimalToneDuration());
securityPanel.commitPanel(registration);
@ -436,6 +440,10 @@ public void loadAccount(AccountID accountID)
connectionPanel.setDTMFMethod(
accountID.getAccountPropertyString("DTMF_METHOD"));
String dtmfMinimalToneDuration =
accountID.getAccountPropertyString("DTMF_MINIMAL_TONE_DURATION");
if(!StringUtils.isNullOrEmpty(dtmfMinimalToneDuration))
connectionPanel.setDtmfMinimalToneDuration(dtmfMinimalToneDuration);
securityPanel.loadAccount(accountID);

@ -196,6 +196,11 @@ public Iterator<Map.Entry<String,String>> getSummary()
Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"),
registration.getDTMFMethod());
summaryTable.put(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"),
registration.getDtmfMinimalToneDuration());
return summaryTable.entrySet().iterator();
}
@ -444,6 +449,10 @@ protected ProtocolProviderService installAccount(
accountProperties.put("DTMF_METHOD",
registration.getDefaultDTMFMethod());
accountProperties.put(
ProtocolProviderFactory.DTMF_MINIMAL_TONE_DURATION,
registration.getDtmfMinimalToneDuration());
accountProperties.put(ProtocolProviderFactory.DEFAULT_ENCRYPTION,
Boolean.toString(registration.isDefaultEncryption()));

@ -72,6 +72,11 @@ public class ConnectionPanel
"plugin.sipaccregwizz.DTMF_INBAND")
});
/**
* The text field used to change the DTMF minimal tone duration.
*/
private JTextField dtmfMinimalToneDurationValue = new JTextField();
private final JCheckBox mwiCheckBox;
private boolean isServerOverridden = false;
@ -376,14 +381,64 @@ private Component createKeepAlivePanel()
*/
private Component createDTMFPanel()
{
JPanel dtmfPanel = new TransparentPanel(new BorderLayout(10, 10));
JPanel emptyLabelPanel = new TransparentPanel();
// Labels.
JPanel dtmfLabels = new TransparentPanel(new GridLayout(0, 1, 5, 5));
JLabel dtmfMethodLabel = new JLabel(
Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"));
dtmfPanel.add(dtmfMethodLabel, BorderLayout.WEST);
JLabel minimalDTMFToneDurationLabel = new JLabel(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"));
dtmfLabels.add(dtmfMethodLabel);
dtmfLabels.add(minimalDTMFToneDurationLabel);
dtmfLabels.add(emptyLabelPanel);
// Values
JPanel dtmfValues = new TransparentPanel(new GridLayout(0, 1, 5, 5));
dtmfMethodBox.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
boolean isEnabled = false;
String selectedItem
= (String) dtmfMethodBox.getSelectedItem();
if(selectedItem != null
&& (selectedItem.equals(Resources.getString(
"plugin.sipaccregwizz.DTMF_AUTO"))
|| selectedItem.equals(Resources.getString(
"plugin.sipaccregwizz.DTMF_RTP")))
)
{
isEnabled = true;
}
dtmfMinimalToneDurationValue.setEnabled(isEnabled);
}
});
dtmfMethodBox.setSelectedItem(
regform.getRegistration().getDefaultDTMFMethod());
dtmfPanel.add(dtmfMethodBox, BorderLayout.CENTER);
dtmfMinimalToneDurationValue
.setText(SIPAccountRegistration.DEFAULT_MINIMAL_DTMF_TONE_DURATION);
JLabel dtmfMinimalToneDurationExampleLabel = new JLabel(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION_INFO"));
dtmfMinimalToneDurationExampleLabel.setForeground(Color.GRAY);
dtmfMinimalToneDurationExampleLabel.setFont(
dtmfMinimalToneDurationExampleLabel.getFont().deriveFont(8));
dtmfMinimalToneDurationExampleLabel.setMaximumSize(
new Dimension(40, 35));
dtmfMinimalToneDurationExampleLabel.setBorder(
BorderFactory.createEmptyBorder(0, 0, 8, 0));
dtmfValues.add(dtmfMethodBox);
dtmfValues.add(dtmfMinimalToneDurationValue);
dtmfValues.add(dtmfMinimalToneDurationExampleLabel);
// DTMF panel
JPanel dtmfPanel = new TransparentPanel(new BorderLayout(10, 10));
dtmfPanel.setBorder(BorderFactory.createTitledBorder(
Resources.getString("plugin.sipaccregwizz.DTMF")));
dtmfPanel.add(dtmfLabels, BorderLayout.WEST);
dtmfPanel.add(dtmfValues, BorderLayout.CENTER);
return dtmfPanel;
}
@ -647,6 +702,25 @@ else if(dtmfMethod.equals("INBAND_DTMF"))
}
}
/**
* Returns the minimal DTMF tone duration.
*
* @return The minimal DTMF tone duration.
*/
String getDtmfMinimalToneDuration()
{
return dtmfMinimalToneDurationValue.getText();
}
/**
* Sets the keep alive interval
* @param keepAliveInterval the keep alive interval
*/
void setKeepAliveInterval(String keepAliveInterval)
{
keepAliveIntervalValue.setText(keepAliveInterval);
}
/**
* Returns the voicemail URI.
* @return the voicemail URI.
@ -702,12 +776,13 @@ void setMessageWaitingIndications(boolean enabled)
}
/**
* Sets the keep alive interval
* @param keepAliveInterval the keep alive interval
* Sets the minimal DTMF tone duration
*
* @param dtmfMinimalToneDuration
*/
void setKeepAliveInterval(String keepAliveInterval)
void setDtmfMinimalToneDuration(String dtmfMinimalToneDuration)
{
keepAliveIntervalValue.setText(keepAliveInterval);
dtmfMinimalToneDurationValue.setText(dtmfMinimalToneDuration);
}
/**

@ -7,6 +7,7 @@
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.wizard.*;
/**
* The <tt>SIPAccountRegistration</tt> is used to store all user input data
@ -32,8 +33,17 @@ public class SIPAccountRegistration
public static String DEFAULT_KEEP_ALIVE_INTERVAL = "25";
/**
* The default value for DTMF method.
*/
private String defaultDTMFMethod = "AUTO_DTMF";
/**
* The default value of minimale DTMF tone duration.
*/
public static String DEFAULT_MINIMAL_DTMF_TONE_DURATION = Integer.toString(
OperationSetDTMF.DEFAULT_DTMF_MINIMAL_TONE_DURATION);
private String id;
private String password;
@ -84,8 +94,16 @@ public class SIPAccountRegistration
private String keepAliveInterval = DEFAULT_KEEP_ALIVE_INTERVAL;
/**
* DTMF method.
*/
private String dtmfMethod = null;
/**
* The minimal DTMF tone duration set.
*/
private String dtmfMinimalToneDuration = DEFAULT_MINIMAL_DTMF_TONE_DURATION;
private String defaultDomain = null;
private boolean xCapEnable = false;
@ -573,6 +591,26 @@ public void setDTMFMethod(String dtmfMethod)
this.dtmfMethod = dtmfMethod;
}
/**
* Returns the minimal DTMF tone duration.
*
* @return The minimal DTMF tone duration.
*/
public String getDtmfMinimalToneDuration()
{
return dtmfMinimalToneDuration;
}
/**
* Sets the minimal DTMF tone duration.
*
* @param dtmfMinimalToneDuration The minimal DTMF tone duration to set.
*/
public void setDtmfMinimalToneDuration(String dtmfMinimalToneDuration)
{
this.dtmfMinimalToneDuration = dtmfMinimalToneDuration;
}
/**
* Gets the method used for RTP/SAVP indication.
*

@ -301,6 +301,8 @@ public boolean commitPage(SIPAccountRegistration registration)
registration.setDTMFMethod(
connectionPanel.getDTMFMethod());
registration.setDtmfMinimalToneDuration(
connectionPanel.getDtmfMinimalToneDuration());
SIPAccRegWizzActivator.getUIService().getAccountRegWizardContainer()
.setBackButtonEnabled(true);
@ -393,6 +395,8 @@ public void loadAccount(AccountID accountID)
String dtmfMethod =
accountID.getAccountPropertyString("DTMF_METHOD");
String dtmfMinimalToneDuration =
accountID.getAccountPropertyString("DTMF_MINIMAL_TONE_DURATION");
String voicemailURI = accountID.getAccountPropertyString(
ProtocolProviderFactory.VOICEMAIL_URI);
@ -460,6 +464,8 @@ public void loadAccount(AccountID accountID)
connectionPanel.setKeepAliveInterval(keepAliveInterval);
connectionPanel.setDTMFMethod(dtmfMethod);
if(!StringUtils.isNullOrEmpty(dtmfMinimalToneDuration))
connectionPanel.setDtmfMinimalToneDuration(dtmfMinimalToneDuration);
boolean mwiEnabled = accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.VOICEMAIL_ENABLED, true);

@ -266,6 +266,10 @@ public Iterator<Map.Entry<String, String>> getSummary()
summaryTable.put(
Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"),
registration.getDTMFMethod());
summaryTable.put(
Resources.getString(
"plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"),
registration.getDtmfMinimalToneDuration());
if (registration.isXCapEnable() || registration.isXiVOEnable())
{
@ -509,6 +513,10 @@ else if(serverAddress == null &&
else
accountProperties.put("DTMF_METHOD",
registration.getDefaultDTMFMethod());
accountProperties.put(
ProtocolProviderFactory.DTMF_MINIMAL_TONE_DURATION,
registration.getDtmfMinimalToneDuration());
accountProperties.put(ProtocolProviderFactory.OVERRIDE_ENCODINGS,
Boolean.toString(registration.isOverrideEncodings()));

@ -17,6 +17,19 @@
public interface OperationSetDTMF
extends OperationSet
{
/**
* The minimal tone duration value for RFC4733 is 70 ms.
*/
public static final int DEFAULT_DTMF_MINIMAL_TONE_DURATION = 70;
/**
* The name of the <tt>ConfigurationService</tt> <tt>int</tt> property
* which indicates the minimal duration for a DTMF tone.
* The default value is 70 ms.
*/
public static final String PROP_MINIMAL_RTP_DTMF_TONE_DURATION =
"net.java.sip.communicator.service.protocol.minimalRtpDtmfToneDuration";
/**
* Sends the <tt>DTMFTone</tt> <tt>tone</tt> to <tt>callPeer</tt>.
*

@ -441,6 +441,12 @@ public abstract class ProtocolProviderFactory
*/
public static final String KEEP_ALIVE_INTERVAL = "KEEP_ALIVE_INTERVAL";
/**
* The minimal DTMF tone duration.
*/
public static final String DTMF_MINIMAL_TONE_DURATION
= "DTMF_MINIMAL_TONE_DURATION";
/**
* Paranoia mode when turned on requires all calls to be secure and
* indicated as such.

Loading…
Cancel
Save