aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-08-28 22:36:45 +0300
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-08-28 22:36:45 +0300
commit3b8328475a234700f97f70d3156310e657fb6ece (patch)
treec84799f2d446e49e1441b507d492126ba34f2515 /src/net
parentef5607f85e2054676f5ee5bd8c3a538b1748369e (diff)
downloadjitsi-3b8328475a234700f97f70d3156310e657fb6ece.zip
jitsi-3b8328475a234700f97f70d3156310e657fb6ece.tar.gz
jitsi-3b8328475a234700f97f70d3156310e657fb6ece.tar.bz2
Cleans up code, fixes javadocs, applies tiny optimizations.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java39
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerMediaHandlerJabberGTalkImpl.java174
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java263
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java6
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java52
-rw-r--r--src/net/java/sip/communicator/service/protocol/AccountID.java14
6 files changed, 315 insertions, 233 deletions
diff --git a/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java b/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java
index 0658890..5638352 100644
--- a/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java
+++ b/src/net/java/sip/communicator/impl/neomedia/SecurityConfigForm.java
@@ -41,37 +41,40 @@ public class SecurityConfigForm
final ResourceManagementService resources
= NeomediaActivator.getResources();
-
JPanel mainPanel = new TransparentPanel(new BorderLayout(0, 10));
+
add(mainPanel, BorderLayout.NORTH);
JTextPane pane = new JTextPane();
+
pane.setEditable(false);
pane.setOpaque(false);
- pane.setText(resources.getI18NString(
- "impl.media.security.zrtp.DESCRIPTION",
- new String[]{resources.getSettingsString(
- "service.gui.APPLICATION_NAME")}));
-
+ pane.setText(
+ resources.getI18NString(
+ "impl.media.security.zrtp.DESCRIPTION",
+ new String[]
+ {
+ resources.getSettingsString(
+ "service.gui.APPLICATION_NAME")
+ }));
mainPanel.add(pane);
- JButton zrtpButton = new JButton(
- resources.getI18NString("impl.media.security.zrtp.ZRTP_NINJA"));
+ JButton zrtpButton
+ = new JButton(
+ resources.getI18NString(
+ "impl.media.security.zrtp.ZRTP_NINJA"));
zrtpButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
- SIPCommDialog zrtpDialog = new SIPCommDialog()
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- @Override
- protected void close(boolean escaped) {}
- };
+ @SuppressWarnings("serial")
+ SIPCommDialog zrtpDialog
+ = new SIPCommDialog()
+ {
+ @Override
+ protected void close(boolean escaped) {}
+ };
zrtpDialog.setTitle(
resources.getI18NString("impl.media.security.zrtp.CONFIG"));
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerMediaHandlerJabberGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerMediaHandlerJabberGTalkImpl.java
index 6d62eff..6d2d242 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerMediaHandlerJabberGTalkImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerMediaHandlerJabberGTalkImpl.java
@@ -94,26 +94,29 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
// a given DESCRIPTION.
EncryptionPacketExtension encryptionPacketExtension
= description.getFirstChildOfType(
- EncryptionPacketExtension.class);
+ EncryptionPacketExtension.class);
+
if(encryptionPacketExtension != null)
{
AccountID accountID
= getPeer().getProtocolProvider().getAccountID();
- // ZRTP
- ZrtpHashPacketExtension zrtpHashPacketExtension =
- encryptionPacketExtension.getFirstChildOfType(
- ZrtpHashPacketExtension.class);
-
- if(zrtpHashPacketExtension != null
- && zrtpHashPacketExtension.getValue() != null
- && accountID.getAccountPropertyBoolean(
+ if (accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
true)
- && accountID.isEncryptionProtocolEnabled("ZRTP")
- && getPeer().getCall().isSipZrtpAttribute())
+ && accountID.isEncryptionProtocolEnabled("ZRTP")
+ && getPeer().getCall().isSipZrtpAttribute())
{
- addAdvertisedEncryptionMethod(SrtpControlType.ZRTP);
+ // ZRTP
+ ZrtpHashPacketExtension zrtpHashPacketExtension
+ = encryptionPacketExtension.getFirstChildOfType(
+ ZrtpHashPacketExtension.class);
+
+ if ((zrtpHashPacketExtension != null)
+ && (zrtpHashPacketExtension.getValue() != null))
+ {
+ addAdvertisedEncryptionMethod(SrtpControlType.ZRTP);
+ }
}
}
}
@@ -137,23 +140,25 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
// a given DESCRIPTION.
EncryptionPacketExtension encryptionPacketExtension
= description.getFirstChildOfType(
- EncryptionPacketExtension.class);
+ EncryptionPacketExtension.class);
+
if(encryptionPacketExtension != null)
{
AccountID accountID
= getPeer().getProtocolProvider().getAccountID();
// SDES
- if(accountID.isEncryptionProtocolEnabled("SDES")
- && accountID.getAccountPropertyBoolean(
+ if(accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true))
+ true)
+ && accountID.isEncryptionProtocolEnabled("SDES"))
{
Map<MediaTypeSrtpControl, SrtpControl> srtpControls
= getSrtpControls();
MediaTypeSrtpControl key
= new MediaTypeSrtpControl(mediaType, SrtpControlType.SDES);
SrtpControl control = srtpControls.get(key);
+
if(control == null)
{
control
@@ -162,10 +167,11 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
}
SDesControl tmpSDesControl = (SDesControl) control;
- SrtpCryptoAttribute selectedSdes = selectSdesCryptoSuite(
- isInitiator,
- tmpSDesControl,
- encryptionPacketExtension);
+ SrtpCryptoAttribute selectedSdes
+ = selectSdesCryptoSuite(
+ isInitiator,
+ tmpSDesControl,
+ encryptionPacketExtension);
if(selectedSdes != null)
{
@@ -180,7 +186,8 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
MediaTypeSrtpControl mtsc = entry.getKey();
if ((mtsc.mediaType == mediaType)
- && (mtsc.srtpControlType != SrtpControlType.SDES))
+ && (mtsc.srtpControlType
+ != SrtpControlType.SDES))
{
entry.getValue().cleanup();
iter.remove();
@@ -204,16 +211,17 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
= getPeer().getProtocolProvider().getAccountID();
// SDES
- if(accountID.isEncryptionProtocolEnabled("SDES")
- && accountID.getAccountPropertyBoolean(
+ if(accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true))
+ true)
+ && accountID.isEncryptionProtocolEnabled("SDES"))
{
Map<MediaTypeSrtpControl, SrtpControl> srtpControls
= getSrtpControls();
MediaTypeSrtpControl key
= new MediaTypeSrtpControl(mediaType, SrtpControlType.SDES);
SrtpControl control = srtpControls.get(key);
+
if(control != null)
{
control.cleanup();
@@ -303,72 +311,82 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
RtpDescriptionPacketExtension description,
RtpDescriptionPacketExtension remoteDescription)
{
- boolean isRemoteZrtpCapable = (remoteDescription == null);
- if(remoteDescription != null)
+ boolean isRemoteZrtpCapable;
+
+ if (remoteDescription == null)
+ isRemoteZrtpCapable = true;
+ else
{
- // Conforming to XEP-0167 schema there is 0 or 1 ENCRYPTION
- // element for a given DESCRIPTION.
+ // Conforming to XEP-0167 schema there is 0 or 1 ENCRYPTION element
+ // for a given DESCRIPTION.
EncryptionPacketExtension remoteEncryption
= remoteDescription.getFirstChildOfType(
EncryptionPacketExtension.class);
- if(remoteEncryption != null
- && isRemoteZrtpCapable(remoteEncryption))
- {
- isRemoteZrtpCapable = true;
- }
+
+ isRemoteZrtpCapable
+ = (remoteEncryption != null)
+ && isRemoteZrtpCapable(remoteEncryption);
}
- if(getPeer().getProtocolProvider().getAccountID()
- .getAccountPropertyBoolean(
- ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true)
- && getPeer().getProtocolProvider().getAccountID()
- .isEncryptionProtocolEnabled("ZRTP")
- && getPeer().getCall().isSipZrtpAttribute()
- && isRemoteZrtpCapable)
+ boolean zrtpHashSet = false; // Will become true if at least one is set.
+
+ if (isRemoteZrtpCapable)
{
- Map<MediaTypeSrtpControl, SrtpControl> srtpControls
- = getSrtpControls();
- MediaTypeSrtpControl key
- = new MediaTypeSrtpControl(mediaType, SrtpControlType.ZRTP);
- SrtpControl control = srtpControls.get(key);
+ CallPeer peer = getPeer();
+ AccountID accountID = peer.getProtocolProvider().getAccountID();
- if(control == null)
+ if(accountID.getAccountPropertyBoolean(
+ ProtocolProviderFactory.DEFAULT_ENCRYPTION,
+ true)
+ && accountID.isEncryptionProtocolEnabled("ZRTP")
+ && peer.getCall().isSipZrtpAttribute())
{
- control = JabberActivator.getMediaService().createZrtpControl();
- srtpControls.put(key, control);
- }
+ Map<MediaTypeSrtpControl, SrtpControl> srtpControls
+ = getSrtpControls();
+ MediaTypeSrtpControl key
+ = new MediaTypeSrtpControl(mediaType, SrtpControlType.ZRTP);
+ SrtpControl control = srtpControls.get(key);
- ZrtpControl zcontrol = (ZrtpControl) control;
- int versionIndex = zcontrol.getNumberSupportedVersions();
- boolean zrtpHashSet = false; // will become true if at least one is set
+ if(control == null)
+ {
+ control
+ = JabberActivator.getMediaService().createZrtpControl();
+ srtpControls.put(key, control);
+ }
- for (int i = 0; i < versionIndex; i++)
- {
- String helloHash[] = ((ZrtpControl) control).getHelloHashSep(i);
- if (helloHash != null && helloHash[1].length() > 0)
+ ZrtpControl zcontrol = (ZrtpControl) control;
+ int versionIndex = zcontrol.getNumberSupportedVersions();
+
+ for (int i = 0; i < versionIndex; i++)
{
- ZrtpHashPacketExtension hash =
- new ZrtpHashPacketExtension();
- hash.setVersion(helloHash[0]);
- hash.setValue(helloHash[1]);
-
- EncryptionPacketExtension encryption =
- description
- .getFirstChildOfType(EncryptionPacketExtension.class);
- if (encryption == null)
+ String helloHash[]
+ = ((ZrtpControl) control).getHelloHashSep(i);
+
+ if ((helloHash != null) && (helloHash[1].length() > 0))
{
- encryption = new EncryptionPacketExtension();
- description.addChildExtension(encryption);
+ ZrtpHashPacketExtension hash
+ = new ZrtpHashPacketExtension();
+
+ hash.setVersion(helloHash[0]);
+ hash.setValue(helloHash[1]);
+
+ EncryptionPacketExtension encryption
+ = description.getFirstChildOfType(
+ EncryptionPacketExtension.class);
+
+ if (encryption == null)
+ {
+ encryption = new EncryptionPacketExtension();
+ description.addChildExtension(encryption);
+ }
+ encryption.addChildExtension(hash);
+ zrtpHashSet = true;
}
- encryption.addChildExtension(hash);
- zrtpHashSet = true;
}
}
- return zrtpHashSet;
}
- return false;
+ return zrtpHashSet;
}
/**
@@ -394,10 +412,10 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
AccountID accountID = getPeer().getProtocolProvider().getAccountID();
// check if SDES and encryption is enabled at all
- if(accountID.isEncryptionProtocolEnabled("SDES")
- && accountID.getAccountPropertyBoolean(
+ if (accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true))
+ true)
+ && accountID.isEncryptionProtocolEnabled("SDES"))
{
// get or create the control
Map<MediaTypeSrtpControl, SrtpControl> srtpControls
@@ -432,12 +450,12 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
EncryptionPacketExtension localEncryption
= localDescription.getFirstChildOfType(
EncryptionPacketExtension.class);
+
if(localEncryption == null)
{
localEncryption = new EncryptionPacketExtension();
localDescription.addChildExtension(localEncryption);
}
-
for(SrtpCryptoAttribute ca:
sdcontrol.getInitiatorCryptoAttributes())
{
@@ -456,6 +474,7 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
EncryptionPacketExtension remoteEncryption
= remoteDescription.getFirstChildOfType(
EncryptionPacketExtension.class);
+
if(remoteEncryption != null)
{
SrtpCryptoAttribute selectedSdes = selectSdesCryptoSuite(
@@ -468,13 +487,16 @@ public abstract class AbstractCallPeerMediaHandlerJabberGTalkImpl
EncryptionPacketExtension localEncryption
= localDescription.getFirstChildOfType(
EncryptionPacketExtension.class);
+
if(localEncryption == null)
{
localEncryption = new EncryptionPacketExtension();
localDescription.addChildExtension(localEncryption);
}
+
CryptoPacketExtension crypto
= new CryptoPacketExtension(selectedSdes);
+
localEncryption.addChildExtension(crypto);
return true;
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java
index 140914a..7cbd5f7 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java
@@ -113,10 +113,12 @@ public class CallPeerMediaHandlerSipImpl
public String createOffer()
throws OperationFailedException
{
- if (localSess == null)
- return createFirstOffer().toString();
- else
- return createUpdateOffer(localSess).toString();
+ SessionDescription offer
+ = (localSess == null)
+ ? createFirstOffer()
+ : createUpdateOffer(localSess);
+
+ return offer.toString();
}
/**
@@ -139,8 +141,11 @@ public class CallPeerMediaHandlerSipImpl
String userName
= getPeer().getProtocolProvider().getAccountID().getUserID();
- SessionDescription sDes = SdpUtils.createSessionDescription(
- getTransportManager().getLastUsedLocalHost(), userName, mediaDescs);
+ SessionDescription sDes
+ = SdpUtils.createSessionDescription(
+ getTransportManager().getLastUsedLocalHost(),
+ userName,
+ mediaDescs);
this.localSess = sDes;
return localSess;
@@ -193,6 +198,7 @@ public class CallPeerMediaHandlerSipImpl
if(direction != MediaDirection.INACTIVE)
{
boolean hadSavp = false;
+
for (String profileName : getRtpTransports())
{
/*
@@ -357,11 +363,12 @@ public class CallPeerMediaHandlerSipImpl
{
Vector<MediaDescription> answerDescriptions
= createMediaDescriptionsForAnswer(offer);
-
//wrap everything up in a session description
- SessionDescription answer = SdpUtils.createSessionDescription(
- getTransportManager().getLastUsedLocalHost(), getUserName(),
- answerDescriptions);
+ SessionDescription answer
+ = SdpUtils.createSessionDescription(
+ getTransportManager().getLastUsedLocalHost(),
+ getUserName(),
+ answerDescriptions);
this.localSess = answer;
return localSess;
@@ -392,11 +399,12 @@ public class CallPeerMediaHandlerSipImpl
{
Vector<MediaDescription> answerDescriptions
= createMediaDescriptionsForAnswer(newOffer);
-
// wrap everything up in a session description
- SessionDescription newAnswer = SdpUtils.createSessionUpdateDescription(
- previousAnswer, getTransportManager().getLastUsedLocalHost(),
- answerDescriptions);
+ SessionDescription newAnswer
+ = SdpUtils.createSessionUpdateDescription(
+ previousAnswer,
+ getTransportManager().getLastUsedLocalHost(),
+ answerDescriptions);
this.localSess = newAnswer;
return localSess;
@@ -432,20 +440,21 @@ public class CallPeerMediaHandlerSipImpl
this.setCallInfoURL(SdpUtils.getCallInfoURL(offer));
boolean atLeastOneValidDescription = false;
- boolean rejectedAvpOfferDueToSavpRequired = false;
+ boolean rejectedAvpOfferDueToSavpMandatory = false;
AccountID accountID = getPeer().getProtocolProvider().getAccountID();
- boolean encryptionEnabled
+ int savpOption
= accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true);
- int savpOption
- = accountID.getAccountPropertyInt(
- ProtocolProviderFactory.SAVP_OPTION,
- ProtocolProviderFactory.SAVP_OFF);
+ true)
+ ? accountID.getAccountPropertyInt(
+ ProtocolProviderFactory.SAVP_OPTION,
+ ProtocolProviderFactory.SAVP_OFF)
+ : ProtocolProviderFactory.SAVP_OFF;
boolean masterStreamSet = false;
List<MediaType> seenMediaTypes = new ArrayList<MediaType>();
+
for (MediaDescription mediaDescription : remoteDescriptions)
{
String transportProtocol;
@@ -463,10 +472,9 @@ public class CallPeerMediaHandlerSipImpl
//ignore RTP/AVP(F) stream when RTP/SAVP(F) is mandatory
if ((savpOption == ProtocolProviderFactory.SAVP_MANDATORY)
&& !(transportProtocol.equals("RTP/SAVP")
- || transportProtocol.equals("RTP/SAVPF"))
- && encryptionEnabled)
+ || transportProtocol.equals("RTP/SAVPF")))
{
- rejectedAvpOfferDueToSavpRequired = true;
+ rejectedAvpOfferDueToSavpMandatory = true;
continue;
}
@@ -488,8 +496,10 @@ public class CallPeerMediaHandlerSipImpl
continue;
}
- List<MediaFormat> remoteFormats = SdpUtils.extractFormats(
- mediaDescription, getDynamicPayloadTypes());
+ List<MediaFormat> remoteFormats
+ = SdpUtils.extractFormats(
+ mediaDescription,
+ getDynamicPayloadTypes());
MediaDevice dev = getDefaultDevice(mediaType);
MediaDirection devDirection
@@ -618,19 +628,25 @@ public class CallPeerMediaHandlerSipImpl
qualityControls.setMaxFrameRate(frameRate);
}
- MediaDescription md = createMediaDescription(transportProtocol,
- mutuallySupportedFormats, connector,
- direction, rtpExtensions);
+ MediaDescription md
+ = createMediaDescription(
+ transportProtocol,
+ mutuallySupportedFormats,
+ connector,
+ direction,
+ rtpExtensions);
// Sets ZRTP or SDES, depending on the preferences for this account.
- this.setAndAddPreferredEncryptionProtocol(
+ setAndAddPreferredEncryptionProtocol(
mediaType,
md,
mediaDescription);
// create the corresponding stream...
- MediaFormat fmt = findMediaFormat(remoteFormats,
- mutuallySupportedFormats.get(0));
+ MediaFormat fmt
+ = findMediaFormat(
+ remoteFormats,
+ mutuallySupportedFormats.get(0));
boolean masterStream = false;
// if we have more than one stream, lets the audio be the master
@@ -660,16 +676,24 @@ public class CallPeerMediaHandlerSipImpl
atLeastOneValidDescription = true;
}
- if (rejectedAvpOfferDueToSavpRequired && !atLeastOneValidDescription)
- throw new OperationFailedException("Offer contained no valid "
- + "media descriptions. Insecure media was rejected (only "
- + "RTP/AVP instead of RTP/SAVP).",
- OperationFailedException.ILLEGAL_ARGUMENT);
if (!atLeastOneValidDescription)
- throw new OperationFailedException("Offer contained no valid "
- + "media descriptions.",
- OperationFailedException.ILLEGAL_ARGUMENT);
+ {
+ if (rejectedAvpOfferDueToSavpMandatory)
+ {
+ throw new OperationFailedException(
+ "Offer contained no valid media descriptions. Insecure"
+ + " media was rejected (only RTP/AVP instead of"
+ + " RTP/SAVP).",
+ OperationFailedException.ILLEGAL_ARGUMENT);
+ }
+ else
+ {
+ throw new OperationFailedException(
+ "Offer contained no valid media descriptions.",
+ OperationFailedException.ILLEGAL_ARGUMENT);
+ }
+ }
return answerDescriptions;
}
@@ -686,12 +710,12 @@ public class CallPeerMediaHandlerSipImpl
MediaType mediaType, MediaDescription md)
{
MediaAwareCallPeer<?, ?, ?> peer = getPeer();
+ AccountID accountID = peer.getProtocolProvider().getAccountID();
- if(peer.getProtocolProvider().getAccountID().getAccountPropertyBoolean(
+ if(accountID.getAccountPropertyBoolean(
ProtocolProviderFactory.DEFAULT_ENCRYPTION,
true)
- && peer.getProtocolProvider().getAccountID()
- .isEncryptionProtocolEnabled("ZRTP")
+ && accountID.isEncryptionProtocolEnabled("ZRTP")
&& peer.getCall().isSipZrtpAttribute())
{
try
@@ -711,12 +735,13 @@ public class CallPeerMediaHandlerSipImpl
ZrtpControl zcontrol = (ZrtpControl) scontrol;
int versionIndex = zcontrol.getNumberSupportedVersions();
- boolean zrtpHashSet = false; // will become true if at least one is set
+ boolean zrtpHashSet = false; // will become true if at least one is set
- for (int i = 0; i < versionIndex; i++) {
+ for (int i = 0; i < versionIndex; i++)
+ {
String helloHash = zcontrol.getHelloHash(i);
- if (helloHash != null && helloHash.length() > 0)
+ if ((helloHash != null) && helloHash.length() > 0)
{
md.setAttribute(SdpUtils.ZRTP_HASH_ATTR, helloHash);
zrtpHashSet = true;
@@ -739,7 +764,8 @@ public class CallPeerMediaHandlerSipImpl
* @param localMd the description of the local peer.
* @param remoteMd the description of the remote peer.
*
- * @return True if SDES is added tp the media description. False, otherwise.
+ * @return <tt>true</tt> if SDES is added to the media description;
+ * <tt>false</tt>, otherwise.
*/
private boolean updateMediaDescriptionForSDes(
MediaType mediaType,
@@ -749,10 +775,10 @@ public class CallPeerMediaHandlerSipImpl
AccountID accountID = getPeer().getProtocolProvider().getAccountID();
// check if SDES and encryption is enabled at all
- if(!accountID.isEncryptionProtocolEnabled("SDES")
- || !accountID.getAccountPropertyBoolean(
- ProtocolProviderFactory.DEFAULT_ENCRYPTION,
- true))
+ if(!accountID.getAccountPropertyBoolean(
+ ProtocolProviderFactory.DEFAULT_ENCRYPTION,
+ true)
+ || !accountID.isEncryptionProtocolEnabled("SDES"))
{
return false;
}
@@ -777,9 +803,9 @@ public class CallPeerMediaHandlerSipImpl
if (ciphers == null)
{
- ciphers =
- SipActivator.getResources().getSettingsString(
- SDesControl.SDES_CIPHER_SUITES);
+ ciphers
+ = SipActivator.getResources().getSettingsString(
+ SDesControl.SDES_CIPHER_SUITES);
}
sdcontrol.setEnabledCiphers(Arrays.asList(ciphers.split(",")));
@@ -789,10 +815,11 @@ public class CallPeerMediaHandlerSipImpl
@SuppressWarnings("unchecked")
Vector<Attribute> atts = localMd.getAttributes(true);
- for(SrtpCryptoAttribute ca:
- sdcontrol.getInitiatorCryptoAttributes())
+ for (SrtpCryptoAttribute ca
+ : sdcontrol.getInitiatorCryptoAttributes())
+ {
atts.add(SdpUtils.createAttribute("crypto", ca.encode()));
-
+ }
return true;
}
// act as responder
@@ -815,8 +842,7 @@ public class CallPeerMediaHandlerSipImpl
}
else
{
- // none of the offered suites match, destroy the sdes
- // control
+ // none of the offered suites match, destroy the sdes control
sdcontrol.cleanup();
srtpControls.remove(key);
logger.warn("Received unsupported sdes crypto attribute.");
@@ -827,33 +853,34 @@ public class CallPeerMediaHandlerSipImpl
private List<String> getRtpTransports() throws OperationFailedException
{
+ AccountID accountID = getPeer().getProtocolProvider().getAccountID();
+ int savpOption
+ = accountID.getAccountPropertyBoolean(
+ ProtocolProviderFactory.DEFAULT_ENCRYPTION,
+ true)
+ ? accountID.getAccountPropertyInt(
+ ProtocolProviderFactory.SAVP_OPTION,
+ ProtocolProviderFactory.SAVP_OFF)
+ : ProtocolProviderFactory.SAVP_OFF;
List<String> result = new ArrayList<String>(2);
- int savpOption = ProtocolProviderFactory.SAVP_OFF;
- if(getPeer()
- .getProtocolProvider()
- .getAccountID()
- .getAccountPropertyBoolean(
- ProtocolProviderFactory.DEFAULT_ENCRYPTION, true))
+
+ switch (savpOption)
{
- savpOption = getPeer()
- .getProtocolProvider()
- .getAccountID()
- .getAccountPropertyInt(
- ProtocolProviderFactory.SAVP_OPTION,
- ProtocolProviderFactory.SAVP_OFF);
- }
- if(savpOption == ProtocolProviderFactory.SAVP_MANDATORY)
+ case ProtocolProviderFactory.SAVP_MANDATORY:
result.add("RTP/SAVP");
- else if(savpOption == ProtocolProviderFactory.SAVP_OFF)
+ break;
+ case ProtocolProviderFactory.SAVP_OFF:
result.add(SdpConstants.RTP_AVP);
- else if(savpOption == ProtocolProviderFactory.SAVP_OPTIONAL)
- {
+ break;
+ case ProtocolProviderFactory.SAVP_OPTIONAL:
result.add("RTP/SAVP");
result.add(SdpConstants.RTP_AVP);
+ break;
+ default:
+ throw new OperationFailedException(
+ "invalid value for SAVP_OPTION",
+ OperationFailedException.GENERAL_ERROR);
}
- else
- throw new OperationFailedException("invalid value for SAVP_OPTION",
- OperationFailedException.GENERAL_ERROR);
return result;
}
@@ -878,7 +905,7 @@ public class CallPeerMediaHandlerSipImpl
/**
* Handles the specified <tt>answer</tt> by creating and initializing the
* corresponding <tt>MediaStream</tt>s. This method basically just adds
- * synchronisation on top of {@link #doNonSynchronisedProcessAnswer(
+ * synchronization on top of {@link #doNonSynchronisedProcessAnswer(
* SessionDescription)}
*
* @param answer the SDP <tt>SessionDescription</tt>.
@@ -928,9 +955,11 @@ public class CallPeerMediaHandlerSipImpl
boolean masterStreamSet = false;
List<MediaType> seenMediaTypes = new ArrayList<MediaType>();
+
for (MediaDescription mediaDescription : remoteDescriptions)
{
MediaType mediaType;
+
try
{
mediaType = SdpUtils.getMediaType(mediaDescription);
@@ -957,9 +986,10 @@ public class CallPeerMediaHandlerSipImpl
continue;
}
- List<MediaFormat> supportedFormats = SdpUtils.extractFormats(
- mediaDescription, getDynamicPayloadTypes());
-
+ List<MediaFormat> supportedFormats
+ = SdpUtils.extractFormats(
+ mediaDescription,
+ getDynamicPayloadTypes());
MediaDevice dev = getDefaultDevice(mediaType);
if(!isDeviceActive(dev))
@@ -988,11 +1018,9 @@ public class CallPeerMediaHandlerSipImpl
StreamConnector connector
= getTransportManager().getStreamConnector(mediaType);
-
//determine the direction that we need to announce.
MediaDirection remoteDirection
= SdpUtils.getDirection(mediaDescription);
-
MediaDirection direction
= devDirection.getDirectionForAnswer(remoteDirection);
@@ -1005,36 +1033,37 @@ public class CallPeerMediaHandlerSipImpl
// update the RTP extensions that we will be exchanging.
List<RTPExtension> remoteRTPExtensions
- = SdpUtils.extractRTPExtensions(
- mediaDescription, getRtpExtensionsRegistry());
-
+ = SdpUtils.extractRTPExtensions(
+ mediaDescription,
+ getRtpExtensionsRegistry());
List<RTPExtension> supportedExtensions
- = getExtensionsForType(mediaType);
-
- List<RTPExtension> rtpExtensions = intersectRTPExtensions(
- remoteRTPExtensions, supportedExtensions);
+ = getExtensionsForType(mediaType);
+ List<RTPExtension> rtpExtensions
+ = intersectRTPExtensions(
+ remoteRTPExtensions,
+ supportedExtensions);
// check for options from remote party and set
// is quality controls supported
if(mediaType.equals(MediaType.VIDEO))
{
- supportQualityControls =
- SdpUtils.containsAttribute(mediaDescription, "imageattr");
+ supportQualityControls
+ = SdpUtils.containsAttribute(mediaDescription, "imageattr");
}
// select the crypto key the peer has chosen from our proposal
Map<MediaTypeSrtpControl, SrtpControl> srtpControls
= getSrtpControls();
- MediaTypeSrtpControl key =
- new MediaTypeSrtpControl(mediaType, SrtpControlType.SDES);
+ MediaTypeSrtpControl key
+ = new MediaTypeSrtpControl(mediaType, SrtpControlType.SDES);
SrtpControl scontrol = srtpControls.get(key);
if(scontrol != null)
{
if(selectSdesCryptoSuite(
- true,
- (SDesControl) scontrol,
- mediaDescription) == null)
+ true,
+ (SDesControl) scontrol,
+ mediaDescription) == null)
{
scontrol.cleanup();
srtpControls.remove(key);
@@ -1066,6 +1095,7 @@ public class CallPeerMediaHandlerSipImpl
}
boolean masterStream = false;
+
// if we have more than one stream, lets the audio be the master
if(!masterStreamSet)
{
@@ -1098,8 +1128,14 @@ public class CallPeerMediaHandlerSipImpl
}
// create the corresponding stream...
- initStream(connector, dev, supportedFormats.get(0), target,
- direction, rtpExtensions, masterStream);
+ initStream(
+ connector,
+ dev,
+ supportedFormats.get(0),
+ target,
+ direction,
+ rtpExtensions,
+ masterStream);
}
}
@@ -1144,9 +1180,15 @@ public class CallPeerMediaHandlerSipImpl
List<RTPExtension> extensions )
throws OperationFailedException
{
- return SdpUtils.createMediaDescription(transport, formats, connector,
- direction, extensions,
- getDynamicPayloadTypes(), getRtpExtensionsRegistry());
+ return
+ SdpUtils.createMediaDescription(
+ transport,
+ formats,
+ connector,
+ direction,
+ extensions,
+ getDynamicPayloadTypes(),
+ getRtpExtensionsRegistry());
}
/**
@@ -1338,10 +1380,11 @@ public class CallPeerMediaHandlerSipImpl
MediaDescription remoteMd)
{
// Sets ZRTP or SDES, depending on the preferences for this account.
- List<String> preferredEncryptionProtocols = getPeer()
- .getProtocolProvider()
- .getAccountID()
- .getSortedEnabledEncryptionProtocolList();
+ List<String> preferredEncryptionProtocols
+ = getPeer()
+ .getProtocolProvider()
+ .getAccountID()
+ .getSortedEnabledEncryptionProtocolList();
for(int i = 0; i < preferredEncryptionProtocols.size(); ++i)
{
@@ -1351,7 +1394,7 @@ public class CallPeerMediaHandlerSipImpl
{
if(updateMediaDescriptionForZrtp(mediaType, localMd))
{
- // Stops once an encryption advertisement has been choosen.
+ // Stops once an encryption advertisement has been chosen.
return;
}
}
@@ -1364,7 +1407,7 @@ public class CallPeerMediaHandlerSipImpl
localMd,
remoteMd))
{
- // Stops once an encryption advertisement has been choosen.
+ // Stops once an encryption advertisement has been chosen.
return;
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
index f2b49df..37b4eb2 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
@@ -347,13 +347,14 @@ public class CallSipImpl
throws OperationFailedException
{
// create the invite request
- Request invite = messageFactory
- .createInviteRequest(calleeAddress, cause);
+ Request invite
+ = messageFactory.createInviteRequest(calleeAddress, cause);
// Transaction
ClientTransaction inviteTransaction = null;
SipProvider jainSipProvider
= getProtocolProvider().getDefaultJainSipProvider();
+
try
{
inviteTransaction = jainSipProvider.getNewClientTransaction(invite);
@@ -365,6 +366,7 @@ public class CallSipImpl
+ "This is most probably a network connection error.",
OperationFailedException.INTERNAL_ERROR, ex, logger);
}
+
// create the call peer
CallPeerSipImpl callPeer
= createCallPeerFor(inviteTransaction, jainSipProvider);
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
index 9f9c4c0..029c5ce 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/sdp/SdpUtils.java
@@ -1381,16 +1381,20 @@ public class SdpUtils
numChannelsStr = "/" + channels;
}
- Attribute rtpmap = sdpFactory.createAttribute(SdpConstants.RTPMAP,
- payloadType + " " + format.getEncoding() + "/"
- + format.getClockRateString() + numChannelsStr);
+ Attribute rtpmap
+ = sdpFactory.createAttribute(
+ SdpConstants.RTPMAP,
+ payloadType + " " + format.getEncoding() + "/"
+ + format.getClockRateString() + numChannelsStr);
mediaAttributes.add(rtpmap);
// a=fmtp:
if( format.getFormatParameters().size() > 0)
{
- Attribute fmtp = sdpFactory.createAttribute("fmtp",
+ Attribute fmtp
+ = sdpFactory.createAttribute(
+ "fmtp",
payloadType + " " + encodeFmtp(format));
mediaAttributes.add(fmtp);
@@ -1417,8 +1421,11 @@ public class SdpUtils
if ((rtpPort + 1) != rtcpPort)
{
- Attribute rtcpAttr = sdpFactory.createAttribute(RTCP_ATTR, Integer
- .toString(rtcpPort));
+ Attribute rtcpAttr
+ = sdpFactory.createAttribute(
+ RTCP_ATTR,
+ Integer.toString(rtcpPort));
+
mediaAttributes.add(rtcpAttr);
}
@@ -1429,34 +1436,38 @@ public class SdpUtils
{
byte extID
= rtpExtensionsRegistry.obtainExtensionMapping(extension);
-
String uri = extension.getURI().toString();
MediaDirection extDirection = extension.getDirection();
String attributes = extension.getExtensionAttributes();
-
//this is what our extmap value should look like:
//extmap:<value>["/"<direction>] <URI> <extensionattributes>
String attrValue
= Byte.toString(extID)
- + ((extDirection == MediaDirection.SENDRECV)
- ? ""
- : ("/" + extDirection.toString()))
- + " " + uri
- + (attributes == null? "" : (" " + attributes));
-
- Attribute extMapAttr = sdpFactory.createAttribute(
- EXTMAP_ATTR, attrValue);
+ + ((extDirection == MediaDirection.SENDRECV)
+ ? ""
+ : ("/" + extDirection.toString()))
+ + " "
+ + uri
+ + (attributes == null? "" : (" " + attributes));
+
+ Attribute extMapAttr
+ = sdpFactory.createAttribute(EXTMAP_ATTR, attrValue);
+
mediaAttributes.add(extMapAttr);
}
}
MediaDescription mediaDesc = null;
+
try
{
- mediaDesc = sdpFactory.createMediaDescription(mediaType.toString(),
- connector.getDataSocket().getLocalPort(), 1,
- transport, payloadTypesArray);
-
+ mediaDesc
+ = sdpFactory.createMediaDescription(
+ mediaType.toString(),
+ connector.getDataSocket().getLocalPort(),
+ 1,
+ transport,
+ payloadTypesArray);
// add all the attributes we have created above
mediaDesc.setAttributes(mediaAttributes);
}
@@ -1468,7 +1479,6 @@ public class SdpUtils
OperationFailedException.INTERNAL_ERROR, cause,
logger);
}
-
return mediaDesc;
}
diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java
index 287c040..96a0141 100644
--- a/src/net/java/sip/communicator/service/protocol/AccountID.java
+++ b/src/net/java/sip/communicator/service/protocol/AccountID.java
@@ -750,12 +750,14 @@ public abstract class AccountID
public boolean isEncryptionProtocolEnabled(String encryptionProtocolName)
{
// The default value is false, except for ZRTP.
- boolean defaultValue = (encryptionProtocolName.equals("ZRTP"));
- return getAccountPropertyBoolean(
- ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS
- + "."
- + encryptionProtocolName,
- defaultValue);
+ boolean defaultValue = "ZRTP".equals(encryptionProtocolName);
+
+ return
+ getAccountPropertyBoolean(
+ ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS
+ + "."
+ + encryptionProtocolName,
+ defaultValue);
}
/**