Adds a warning dialog when trying to make an audio call with no audio device or no codecs enabled.

cusax-fix
Damian Minkov 13 years ago
parent e30fd21a9a
commit fd097c2eb2

@ -88,6 +88,9 @@ service.gui.CALL_VIA=Call via:
service.gui.CALL_NAME_OR_NUMBER=Call name or number
service.gui.CALL_NOT_SUPPORTING_PARTICIPANT=This call only supports participants from the {0} network and your {1} account. {2} does not contain any address for this network or account.
service.gui.CALL_WITH=Call with
service.gui.CALL_NO_AUDIO_DEVICE=You have no audio device configured.
service.gui.CALL_NO_AUDIO_CODEC=You have no audio codecs enabled.
service.gui.CALL_NO_DEVICE_CODECS_Q=Would you like to continue the call?
service.gui.CANCEL=&Cancel
service.gui.CHAT=Chat
service.gui.CHANGE_FONT=Change font

@ -29,7 +29,9 @@
import net.java.sip.communicator.util.account.*;
import org.jitsi.service.neomedia.*;
import org.jitsi.service.neomedia.codec.*;
import org.jitsi.service.neomedia.device.*;
import org.jitsi.service.neomedia.format.*;
import org.jitsi.service.resources.*;
/**
@ -1709,6 +1711,56 @@ private static void addMissedCallNotification(String peerName, long callTime)
new UINotification(peerName, callTime, missedCallGroup));
}
/**
* Returns of supported/enabled list of audio formats for a provider.
* @param protocolProvider the provider to check.
* @return list of supported/enabled auido formats or empty list
* otherwise.
*/
private static List<MediaFormat> getAudioFormats(
MediaDevice device,
ProtocolProviderService protocolProvider)
{
List<MediaFormat> res = new ArrayList<MediaFormat>();
Map<String, String> accountProperties
= protocolProvider.getAccountID().getAccountProperties();
String overrideEncodings
= accountProperties.get(ProtocolProviderFactory.OVERRIDE_ENCODINGS);
List<MediaFormat> formats;
if(Boolean.parseBoolean(overrideEncodings))
{
/*
* The account properties associated with account
* override the global EncodingConfiguration.
*/
EncodingConfiguration encodingConfiguration
= ProtocolMediaActivator.getMediaService()
.createEmptyEncodingConfiguration();
encodingConfiguration.loadProperties(
accountProperties,
ProtocolProviderFactory.ENCODING_PROP_PREFIX);
formats = device.getSupportedFormats(
null, null, encodingConfiguration);
}
else /* The global EncodingConfiguration is in effect. */
{
formats = device.getSupportedFormats();
}
// skip the special telephony event
for(MediaFormat format : formats)
{
if(!format.getEncoding().equals(Constants.TELEPHONE_EVENT))
res.add(format);
}
return res;
}
/**
* Creates a new (audio-only or video) <tt>Call</tt> to a contact specified
* as a <tt>Contact</tt> instance or a <tt>String</tt> contact
@ -1777,6 +1829,45 @@ private CreateCallThread(
@Override
public void run()
{
if(!video)
{
// if it is not video let's check for available audio codecs
// and available audio devices
MediaService mediaService = GuiActivator.getMediaService();
MediaDevice dev = mediaService.getDefaultDevice(
MediaType.AUDIO, MediaUseCase.CALL);
List<MediaFormat> formats = getAudioFormats(dev, protocolProvider);
String errorMsg = null;
if(!dev.getDirection().allowsSending())
errorMsg = GuiActivator.getResources().getI18NString(
"service.gui.CALL_NO_AUDIO_DEVICE");
else if(formats.isEmpty())
{
errorMsg = GuiActivator.getResources().getI18NString(
"service.gui.CALL_NO_AUDIO_CODEC");
}
if(errorMsg != null)
{
if(GuiActivator.getUIService()
.getPopupDialog().showConfirmPopupDialog(
errorMsg + " " +
GuiActivator.getResources().getI18NString(
"service.gui.CALL_NO_DEVICE_CODECS_Q"),
GuiActivator.getResources().getI18NString(
"service.gui.CALL"),
PopupDialog.YES_NO_OPTION,
PopupDialog.QUESTION_MESSAGE)
== PopupDialog.NO_OPTION)
{
return;
}
}
}
Contact contact = this.contact;
String stringContact = this.stringContact;

@ -828,7 +828,8 @@ public void processInviteOK(ClientTransaction clientTransaction,
//we are connected from a SIP point of view (cause we sent our
//ACK) so make sure we set the state accordingly or the hangup
//method won't know how to end the call.
setState(CallPeerState.CONNECTED);
setState(CallPeerState.CONNECTED,
"Error:" + exc.getLocalizedMessage());
hangup();
}
catch (Exception e)

Loading…
Cancel
Save