diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2012-11-27 22:17:19 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2012-11-27 22:17:19 +0000 |
commit | 3294ef4ba326ae74df152acfdd7a6dcddb87986e (patch) | |
tree | b7befa419fb49c658405276963895a9b79d2d085 /src/net/java/sip/communicator/service/protocol | |
parent | de67e1094fe85551c8395e6d7c471cdd122de855 (diff) | |
download | jitsi-3294ef4ba326ae74df152acfdd7a6dcddb87986e.zip jitsi-3294ef4ba326ae74df152acfdd7a6dcddb87986e.tar.gz jitsi-3294ef4ba326ae74df152acfdd7a6dcddb87986e.tar.bz2 |
Allows the telephony conferences utilizing the Jitsi VideoBridge server-side technology to associate an RTP stream with the participant who is contributing it. Fixes multiple NullPointerExceptions in MediaStreamStatsImpl and OneToOneCallPeerPanel. Fixes an ArrayIndexOutOfBoundsException in AccountID.
Diffstat (limited to 'src/net/java/sip/communicator/service/protocol')
10 files changed, 90 insertions, 104 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java index e490dd1..44f4a68 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java @@ -253,9 +253,8 @@ public abstract class AbstractCallPeer<T extends Call, protected ConferenceMember findConferenceMember(long ssrc) { List<ConferenceMember> members = getConferenceMembers(); - int memberCount = members.size(); - for (int i = 0; i < memberCount; i++) + for (int i = 0, memberCount = members.size(); i < memberCount; i++) { ConferenceMember member = members.get(i); diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java index ba1cf86..c373120 100644 --- a/src/net/java/sip/communicator/service/protocol/AccountID.java +++ b/src/net/java/sip/communicator/service/protocol/AccountID.java @@ -463,14 +463,15 @@ public abstract class AccountID public List<String> getSortedEnabledEncryptionProtocolList() { Map<String, Integer> encryptionProtocols - = this.getIntegerPropertiesByPrefix( + = getIntegerPropertiesByPrefix( ProtocolProviderFactory.ENCRYPTION_PROTOCOL, true); Map<String, Boolean> encryptionProtocolStatus - = this.getBooleanPropertiesByPrefix( + = getBooleanPropertiesByPrefix( ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS, true, false); + // If the account is not yet configured, then ZRTP is activated by // default. if(encryptionProtocols.size() == 0) @@ -484,49 +485,45 @@ public abstract class AccountID true); } - List<String> sortedEncryptionProtocolList + List<String> sortedEncryptionProtocols = new ArrayList<String>(encryptionProtocols.size()); - Iterator<String> names = encryptionProtocols.keySet().iterator(); - String name; - int index; + // First: add all protocol in the right order. - while(names.hasNext()) + for (Map.Entry<String, Integer> e : encryptionProtocols.entrySet()) { - name = names.next(); - index = encryptionProtocols.get(name); + int index = e.getValue(); // If the key is set. - if(index != -1) + if (index != -1) { - if(index > sortedEncryptionProtocolList.size()) - { - index = sortedEncryptionProtocolList.size(); - } - sortedEncryptionProtocolList.add(index, name); + if (index > sortedEncryptionProtocols.size()) + index = sortedEncryptionProtocols.size(); + + String name = e.getKey(); + + sortedEncryptionProtocols.add(index, name); } } // Second: remove all disabled protocol. - String encryptionProtocolPropertyName; - int prefixeLength + int namePrefixLength = ProtocolProviderFactory.ENCRYPTION_PROTOCOL.length() + 1; - names = encryptionProtocols.keySet().iterator(); - while(names.hasNext()) + + for (Iterator<String> i = sortedEncryptionProtocols.iterator(); + i.hasNext();) { - encryptionProtocolPropertyName = names.next(); - index = encryptionProtocols.get(encryptionProtocolPropertyName); - name = encryptionProtocolPropertyName.substring(prefixeLength); - // If the key is set. - if(index != -1 && !encryptionProtocolStatus.get( - ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + String name = i.next().substring(namePrefixLength); + + if (!encryptionProtocolStatus.get( + ProtocolProviderFactory.ENCRYPTION_PROTOCOL_STATUS + "." + name)) { - sortedEncryptionProtocolList.remove(index); + i.remove(); } } - return sortedEncryptionProtocolList; + return sortedEncryptionProtocols; } /** diff --git a/src/net/java/sip/communicator/service/protocol/ActiveCallsRepository.java b/src/net/java/sip/communicator/service/protocol/ActiveCallsRepository.java index e1ceeb4..ebe4008 100644 --- a/src/net/java/sip/communicator/service/protocol/ActiveCallsRepository.java +++ b/src/net/java/sip/communicator/service/protocol/ActiveCallsRepository.java @@ -100,7 +100,12 @@ public abstract class ActiveCallsRepository<T extends Call, { synchronized(activeCalls) { - return new LinkedList<T>(activeCalls.values()).iterator(); + /* + * Given that we know the elements that will go into the new List, + * it is more optimal in terms of memory and execution time to use + * ArrayList rather than LinkedList. + */ + return new ArrayList<T>(activeCalls.values()).iterator(); } } diff --git a/src/net/java/sip/communicator/service/protocol/event/RegistrationStateChangeListener.java b/src/net/java/sip/communicator/service/protocol/event/RegistrationStateChangeListener.java index aba6456..3b4d56d 100644 --- a/src/net/java/sip/communicator/service/protocol/event/RegistrationStateChangeListener.java +++ b/src/net/java/sip/communicator/service/protocol/event/RegistrationStateChangeListener.java @@ -10,8 +10,7 @@ import java.util.*; /** * An event listener that should be implemented by parties interested in changes - * that occur in the registration state of a - * <code>ProtocolProviderService</code>. + * that occur in the registration state of a <tt>ProtocolProviderService</tt>. * * @author Emil Ivov */ @@ -19,12 +18,11 @@ public interface RegistrationStateChangeListener extends EventListener { /** - * The method is called by a <code>ProtocolProviderService</code> - * implementation whenever a change in the registration state of the - * corresponding provider had occurred. + * The method is called by a <tt>ProtocolProviderService</tt> implementation + * whenever a change in its registration state has occurred. * - * @param evt - * the event describing the status change. + * @param evt a <tt>RegistrationStateChangeEvent</tt> which describes the + * registration state change. */ public void registrationStateChanged(RegistrationStateChangeEvent evt); } diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java index 3b31144..9d6812c 100644 --- a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java +++ b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java @@ -526,63 +526,38 @@ public abstract class AbstractOperationSetTelephonyConferencing< MediaAwareCallPeer<?,?,?> callPeer, MediaType mediaType) { - MediaStream stream = callPeer.getMediaHandler().getStream(mediaType); - long remoteSourceID; + long remoteSourceID + = callPeer.getMediaHandler().getRemoteSSRC(mediaType); - if (stream != null) + if (remoteSourceID != -1) { - remoteSourceID = stream.getRemoteSourceID(); - if (remoteSourceID != -1) - { - /* - * TODO Technically, we are detecting conflicts within a Call - * while we should be detecting them within the whole - * CallConference. - */ - MediaAwareCall<?,?,?> call = callPeer.getCall(); + /* + * TODO Technically, we are detecting conflicts within a Call + * while we should be detecting them within the whole + * CallConference. + */ + MediaAwareCall<?,?,?> call = callPeer.getCall(); - if (call != null) + if (call != null) + { + for (MediaAwareCallPeer<?,?,?> aCallPeer + : call.getCallPeerList()) { - for (MediaAwareCallPeer<?,?,?> aCallPeer - : call.getCallPeerList()) + if (aCallPeer != callPeer) { - if (aCallPeer != callPeer) + long aRemoteSourceID + = aCallPeer.getMediaHandler().getRemoteSSRC( + mediaType); + + if (aRemoteSourceID == remoteSourceID) { - MediaStream aStream - = aCallPeer.getMediaHandler().getStream( - mediaType); - - /* - * When the Jitsi VideoBridge server-side technology - * is utilized by the local peer/user to host a - * telephony conference, one and the same - * MediaStream instance will be shared by the - * CallPeers. This will definitely lead to a - * conflict. - */ - if (aStream == stream) - { - remoteSourceID = -1; - break; - } - else - { - long aRemoteSourceID - = stream.getRemoteSourceID(); - - if (aRemoteSourceID == remoteSourceID) - { - remoteSourceID = -1; - break; - } - } + remoteSourceID = -1; + break; } } } } } - else - remoteSourceID = -1; return remoteSourceID; } @@ -706,15 +681,15 @@ public abstract class AbstractOperationSetTelephonyConferencing< * Notifies this <tt>PropertyChangeListener</tt> that the value of a * specific property of the notifier it is registered with has changed. * - * @param event a <tt>PropertyChangeEvent</tt> which describes the source of + * @param ev a <tt>PropertyChangeEvent</tt> which describes the source of * the event, the name of the property which has changed its value and the * old and new values of the property * @see PropertyChangeListener#propertyChange(PropertyChangeEvent) */ @SuppressWarnings("unchecked") - public void propertyChange(PropertyChangeEvent event) + public void propertyChange(PropertyChangeEvent ev) { - String propertyName = event.getPropertyName(); + String propertyName = ev.getPropertyName(); if (CallPeerMediaHandler.AUDIO_LOCAL_SSRC.equals( propertyName) @@ -726,8 +701,7 @@ public abstract class AbstractOperationSetTelephonyConferencing< propertyName)) { Call call - = ((CallPeerMediaHandler<MediaAwareCallPeerT>) - event.getSource()) + = ((CallPeerMediaHandler<MediaAwareCallPeerT>) ev.getSource()) .getPeer() .getCall(); diff --git a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java index f5c4c98..7702c42 100644 --- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java @@ -606,15 +606,15 @@ public abstract class CallPeerMediaHandler } /** - * Gets the last-known remote SSRC of the audio <tt>MediaStream</tt> of this - * instance. + * Gets the last-known SSRC of an RTP stream with a specific + * <tt>MediaType</tt> received by a <tt>MediaStream</tt> of this instance. * - * @return the last-known remote SSRC of the audio <tt>MediaStream</tt> of - * this instance + * @return the last-known SSRC of an RTP stream with a specific + * <tt>MediaType</tt> received by a <tt>MediaStream</tt> of this instance */ - public long getAudioRemoteSSRC() + public long getRemoteSSRC(MediaType mediaType) { - return mediaHandler.getRemoteSSRC(this, MediaType.AUDIO); + return mediaHandler.getRemoteSSRC(this, mediaType); } /** @@ -1032,14 +1032,18 @@ public abstract class CallPeerMediaHandler synchronized (localAudioLevelListenerLock) { if (localAudioLevelListener != null) + { audioStream.setLocalUserAudioLevelListener( localAudioLevelListener); + } } synchronized (streamAudioLevelListenerLock) { if (streamAudioLevelListener != null) + { audioStream.setStreamAudioLevelListener( streamAudioLevelListener); + } } synchronized (csrcAudioLevelListenerLock) { diff --git a/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java b/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java index 9a9e654..5c03c0c 100644 --- a/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java +++ b/src/net/java/sip/communicator/service/protocol/media/DynamicRTPExtensionsRegistry.java @@ -192,7 +192,7 @@ public class DynamicRTPExtensionsRegistry { throw new IllegalStateException( "Impossible to map more than the 255 already mapped " - +" RTP extensions"); + +" RTP extensions"); } byte extID = nextExtensionMapping++; diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java index 92b2b25..55054ea 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java @@ -773,10 +773,10 @@ public abstract class MediaAwareCallPeer if (getConferenceMemberCount() > 2) { // this peer is now a conference focus with more than three - // participants. This means that the this peer is mixing and sending - // us audio for at least two separate participants. We therefore - // need to remove the stream level listeners and switch to CSRC - // level listening + // participants. This means that this peer is mixing and sending us + // audio for at least two separate participants. We therefore need + // to remove the stream level listeners and switch to CSRC level + // listening CallPeerMediaHandler<?> mediaHandler = getMediaHandler(); mediaHandler.setStreamAudioLevelListener(null); @@ -839,7 +839,8 @@ public abstract class MediaAwareCallPeer && ((conferenceMemberCount = getConferenceMemberCount()) > 0) && (conferenceMemberCount < 3)) { - long audioRemoteSSRC = getMediaHandler().getAudioRemoteSSRC(); + long audioRemoteSSRC + = getMediaHandler().getRemoteSSRC(MediaType.AUDIO); if (audioRemoteSSRC != CallPeerMediaHandler.SSRC_UNKNOWN) { @@ -873,9 +874,11 @@ public abstract class MediaAwareCallPeer = streamAudioLevelListeners.size(); for(int i = 0; i < streamAudioLevelListenerCount; i++) + { streamAudioLevelListeners.get(i).soundLevelChanged( this, newLevel); + } } } diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java index 5211d80..c5e2632 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaHandler.java @@ -149,26 +149,34 @@ public class MediaHandler Object source = evt.getSource(); if (source == audioStream) + { setLocalSSRC( MediaType.AUDIO, audioStream.getLocalSourceID()); + } else if (source == videoStream) + { setLocalSSRC( MediaType.VIDEO, videoStream.getLocalSourceID()); + } } else if (MediaStream.PNAME_REMOTE_SSRC.equals(propertyName)) { Object source = evt.getSource(); if (source == audioStream) + { setRemoteSSRC( MediaType.AUDIO, audioStream.getRemoteSourceID()); + } else if (source == videoStream) + { setRemoteSSRC( MediaType.VIDEO, videoStream.getRemoteSourceID()); + } } } }; @@ -817,8 +825,7 @@ public class MediaHandler { this.audioStream .removePropertyChangeListener( - streamPropertyChangeListener); - + streamPropertyChangeListener); this.audioStream.close(); } @@ -831,7 +838,7 @@ public class MediaHandler { this.audioStream .addPropertyChangeListener( - streamPropertyChangeListener); + streamPropertyChangeListener); audioLocalSSRC = this.audioStream.getLocalSourceID(); audioRemoteSSRC = this.audioStream.getRemoteSourceID(); } diff --git a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java index 6106360..ede1b3a 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -7,7 +7,6 @@ package net.java.sip.communicator.service.protocol.media; import java.net.*; -import java.util.*; import net.java.sip.communicator.service.netaddr.*; import net.java.sip.communicator.service.protocol.*; |