Local user sound level indicator listeners and implementation in the UI + some fixes in the call conference ui

cusax-fix
Yana Stamcheva 17 years ago
parent b9aaf11106
commit 8a0d4781ec

@ -70,6 +70,9 @@ public CallDialog(Call call)
{
this.call = call;
this.callDurationTimer = new Timer(1000, new CallTimerListener());
this.callDurationTimer.setRepeats(true);
// The call duration parameter is not known yet.
this.setCallTitle(null);
@ -151,9 +154,6 @@ public CallDialog(Call call)
buttonsPanel.setBorder(
new ExtendedEtchedBorder(EtchedBorder.LOWERED, 1, 0, 0, 0));
this.callDurationTimer = new Timer(1000, new CallTimerListener());
this.callDurationTimer.setRepeats(true);
}
/**

@ -393,7 +393,8 @@ public CreateConferenceCallThread(
public void run()
{
OperationSetTelephonyConferencing confOpSet
= protocolProvider.getOperationSet(OperationSetTelephonyConferencing.class);
= protocolProvider.getOperationSet(
OperationSetTelephonyConferencing.class);
/*
* XXX If we are here and we just discover that

@ -134,7 +134,7 @@ public void setParticipantName(String participantName)
*/
public void setParticipantState(String participantState)
{
callStatusLabel.setText(participantState);
callStatusLabel.setText(participantState.toLowerCase());
}
/**

@ -107,6 +107,12 @@ private void addLocalCallPeer()
constraints.insets = new Insets(0, 0, 10, 10);
mainPanel.add(localPeerPanel, constraints);
OperationSetBasicTelephony telephonyOpSet = call.getProtocolProvider()
.getOperationSet(OperationSetBasicTelephony.class);
if (telephonyOpSet != null)
telephonyOpSet.addLocalUserSoundLevelListener(localPeerPanel);
}
/**

@ -171,8 +171,6 @@ private void initTitleBar()
*/
private Component createStatusBar()
{
callStatusLabel.setText(callPeer.getState().getStateString());
TransparentPanel statusBar
= new TransparentPanel(
new FlowLayout(FlowLayout.RIGHT, 0, 0));
@ -407,7 +405,7 @@ public void setPeerName(String name)
*/
public void setPeerState(String state)
{
callStatusLabel.setText(state);
callStatusLabel.setText(state.toLowerCase());
}
/**

@ -26,7 +26,8 @@
public class ConferencePeerPanel
extends BasicConferenceParticipantPanel
implements CallPeerRenderer,
StreamSoundLevelListener
StreamSoundLevelListener,
LocalUserSoundLevelListener
{
/**
* The parent dialog containing this panel.
@ -327,4 +328,15 @@ public void streamSoundLevelChanged(StreamSoundLevelEvent event)
{
this.updateSoundBar(event.getLevel());
}
/**
* Updates the sound bar level of the local user participating in the
* conference.
* @param event the <tt>LocalUserSoundLevelEvent</tt> that notifies us of
* the sound level change
*/
public void localUserSoundLevelChanged(LocalUserSoundLevelEvent event)
{
this.updateSoundBar(event.getLevel());
}
}

@ -123,7 +123,7 @@ public void updateSoundLevel(int soundLevel)
Component c = getComponent(i);
if (c instanceof JLabel)
{
if (i <= activeBarNumber)
if (i < activeBarNumber)
((JLabel) c).setIcon(soundLevelActiveImage);
else
((JLabel) c).setIcon(soundLevelInactiveImage);

@ -69,7 +69,7 @@ public int getCallPeerCount()
*
* @param callPeer the new <tt>CallPeer</tt>
*/
public void addCallPeer(CallPeerGibberishImpl callPeer)
public void addCallPeer(final CallPeerGibberishImpl callPeer)
{
if(callPeers.contains(callPeer))
return;
@ -84,7 +84,28 @@ public void addCallPeer(CallPeerGibberishImpl callPeer)
callPeer, CallPeerEvent.CALL_PEER_ADDED);
callPeer.setState(CallPeerState.ALERTING_REMOTE_SIDE, "no reason");
callPeer.setState(CallPeerState.CONNECTED, "no reason");
Timer timer1 = new Timer(false);
timer1.schedule(new TimerTask()
{
@Override
public void run()
{
callPeer.setState(CallPeerState.CONNECTED, "no reason");
}
}, 1500);
final Random random = new Random();
Timer timer = new Timer(false);
timer.scheduleAtFixedRate(new TimerTask()
{
@Override
public void run()
{
callPeer.fireStreamSoundLevelEvent(random.nextInt(255));
}
}, 1800, 100);
}
/**

@ -49,16 +49,6 @@ public CallPeerGibberishImpl(String address, CallGibberishImpl owningCall)
final Random random = new Random();
Timer timer = new Timer(false);
timer.scheduleAtFixedRate(new TimerTask()
{
@Override
public void run()
{
fireStreamSoundLevelEvent(random.nextInt(255));
}
}, 500, 100);
// Make this peer a conference focus.
if (owningCall.getCallPeerCount() > 1)
{
@ -66,11 +56,13 @@ public void run()
final ConferenceMemberGibberishImpl member1
= new ConferenceMemberGibberishImpl(this);
member1.setDisplayName("Dragancho");
member1.setState(ConferenceMemberState.CONNECTED);
this.addConferenceMember(member1);
final ConferenceMemberGibberishImpl member2
= new ConferenceMemberGibberishImpl(this);
member2.setDisplayName("Ivancho");
member2.setState(ConferenceMemberState.CONNECTED);
this.addConferenceMember(member2);
Timer timer1 = new Timer(false);

@ -82,6 +82,19 @@ public Call createConfCall(String[] callees)
telephonyOpSet.fireCallEvent(CallEvent.CALL_INITIATED, newCall);
final Random random = new Random();
Timer timer1 = new Timer(false);
timer1.scheduleAtFixedRate(new TimerTask()
{
@Override
public void run()
{
telephonyOpSet.fireLocalUserSoundLevelEvent(
protocolProvider,
random.nextInt(255));
}
}, 500, 100);
return newCall;
}

@ -32,6 +32,12 @@ public abstract class AbstractOperationSetBasicTelephony
*/
private final List<CallListener> callListeners = new Vector<CallListener>();
/**
* A list of listeners registered for local user sound level events.
*/
private final List<LocalUserSoundLevelListener> soundLevelListeners
= new Vector<LocalUserSoundLevelListener>();
/**
* Registers <tt>listener</tt> with this provider so that it
* could be notified when incoming calls are received.
@ -121,4 +127,63 @@ public void setMute(CallPeer peer, boolean mute)
* this implementation takes inspiration from them.
*/
}
/**
* Adds the given <tt>LocalUserSoundLevelListener</tt> to this operation set.
* @param l the <tt>LocalUserSoundLevelListener</tt> to add
*/
public void addLocalUserSoundLevelListener(LocalUserSoundLevelListener l)
{
synchronized(soundLevelListeners)
{
if (!soundLevelListeners.contains(l))
soundLevelListeners.add(l);
}
}
/**
* Removes the given <tt>LocalUserSoundLevelListener</tt> from this
* operation set.
* @param l the <tt>LocalUserSoundLevelListener</tt> to remove
*/
public void removeLocalUserSoundLevelListener(LocalUserSoundLevelListener l)
{
synchronized(soundLevelListeners)
{
soundLevelListeners.remove(l);
}
}
/**
* Creates and dispatches a <tt>LocalUserSoundLevelEvent</tt> notifying
* registered listeners that the local user sound level has changed.
*
* @param protocolProvider the protocol provider for which the level is
* @param level the new level
*/
public void fireLocalUserSoundLevelEvent(
ProtocolProviderService protocolProvider, int level)
{
LocalUserSoundLevelEvent soundLevelEvent
= new LocalUserSoundLevelEvent(protocolProvider, level);
List<LocalUserSoundLevelListener> listeners;
synchronized (soundLevelListeners)
{
listeners = new ArrayList<LocalUserSoundLevelListener>(
soundLevelListeners);
}
logger.debug("Dispatching a LocalUserSoundLevelEvent to "
+ listeners.size()
+ " listeners. event is: " + soundLevelEvent);
for (Iterator<LocalUserSoundLevelListener> listenerIter
= listeners.iterator(); listenerIter.hasNext();)
{
LocalUserSoundLevelListener listener = listenerIter.next();
listener.localUserSoundLevelChanged(soundLevelEvent);
}
}
}

@ -11,53 +11,53 @@
* <code>ConferenceMember</code> in the conference it is participating in.
*
* @author Lubomir Marinov
* @author Yana Stamcheva
*/
public enum ConferenceMemberState
{
/**
* A Public Switched Telephone Network (PSTN) ALERTING or SIP 180 Ringing
* was returned for the outbound call; endpoint is being alerted.
*/
ALTERTING,
ALERTING("Alerting"),
/**
* The endpoint is a participant in the conference. Depending on the media
* policies, he/she can send and receive media to and from other
* participants.
*/
CONNECTED,
CONNECTED("Connected"),
/**
* Endpoint is dialing into the conference, not yet in the roster (probably
* being authenticated).
*/
DIALING_IN,
DIALING_IN("Dialing in"),
/**
* Focus has dialed out to connect the endpoint to the conference, but the
* endpoint is not yet in the roster (probably being authenticated).
*/
DIALING_OUT,
DIALING_OUT("Dialing out"),
/**
* The endpoint is not a participant in the conference, and no active dialog
* exists between the endpoint and the focus.
*/
DISCONNECTED,
DISCONNECTED("Disconnected"),
/**
* Focus is in the process of disconnecting the endpoint (e.g., in SIP a
* DISCONNECT or BYE was sent to the endpoint).
*/
DISCONNECTING,
DISCONNECTING("Disconnecting"),
/**
* Active signaling dialog exists between an endpoint and a focus and the
* endpoint can "listen" to the conference, but the endpoint's media is not
* being mixed into the conference.
*/
MUTED_VIA_FOCUS,
MUTED_VIA_FOCUS("Muted via focus"),
/**
* Active signaling dialog exists between an endpoint and a focus, but
@ -65,17 +65,47 @@ public enum ConferenceMemberState
* "hearing" the conference mix nor is his/her media being mixed in the
* conference.
*/
ON_HOLD,
ON_HOLD("On hold"),
/**
* Endpoint is not yet in the session, but it is anticipated that he/she
* will join in the near future.
*/
PENDING,
PENDING("Pending"),
/**
* The state of the device and signaling session of the associated
* <code>ConferenceMember</code> in the conference is unknown.
*/
UNKNOWN
UNKNOWN("Unknown");
/**
* The name of this state.
*/
private final String stateName;
/**
* Creates an instance of <tt>ConferenceMemberState</tt> by specifying the
* name of the state.
* @param name the name of the state
*/
private ConferenceMemberState(String name)
{
this.stateName = name;
}
/**
* Returns the name of this <tt>ConferenceMemberState</tt> (e.g. "connected"
* or "dialing out"). The name returned by this method is meant to be used
* by user interface implementations in order to provide more readable
* state string.
*
* @return the name of this <tt>ConferenceMemberState</tt> (e.g. "connected"
* or "dialing out")
*/
@Override
public String toString()
{
return stateName;
}
}

@ -135,4 +135,17 @@ public void hangupCallPeer(CallPeer peer)
* <tt>peer</tt>; otherwise, <tt>false</tt>
*/
public void setMute(CallPeer peer, boolean mute);
/**
* Adds the given <tt>LocalUserSoundLevelListener</tt> to this operation set.
* @param l the <tt>LocalUserSoundLevelListener</tt> to add
*/
public void addLocalUserSoundLevelListener(LocalUserSoundLevelListener l);
/**
* Removes the given <tt>LocalUserSoundLevelListener</tt> from this
* operation set.
* @param l the <tt>LocalUserSoundLevelListener</tt> to remove
*/
public void removeLocalUserSoundLevelListener(LocalUserSoundLevelListener l);
}

@ -0,0 +1,70 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.protocol.event;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
/**
* @author Yana Stamcheva
*/
public class LocalUserSoundLevelEvent
extends EventObject
{
/**
* The maximum level that can be reported for a participant in a conference.
* Level values should be distributed among MAX_LEVEL and MIN_LEVEL in a
* way that would appear uniform to users.
*/
public static final int MAX_LEVEL = 255;
/**
* The maximum (zero) level that can be reported for a participant in a
* conference. Level values should be distributed among MAX_LEVEL and
* MIN_LEVEL in a way that would appear uniform to users.
*/
public static final int MIN_LEVEL = 0;
/**
* The audio stream level, for the change of which this event is about.
*/
private final int level;
/**
* Creates an <tt>StreamSoundLevelEvent</tt> for the given <tt>callPeer</tt>
* by indicating the current sound level of the audio stream.
*
* @param protocolProvider the <tt>ProtocolProviderService</tt>
* @param level the current sound level of the audio stream
*/
public LocalUserSoundLevelEvent(
ProtocolProviderService protocolProvider, int level)
{
super(protocolProvider);
this.level = level;
}
/**
* Returns the <tt>ProtocolProviderService</tt>.
* @return the <tt>ProtocolProviderService</tt>
*/
public ProtocolProviderService getSourceProvider()
{
return (ProtocolProviderService) getSource();
}
/**
* Returns the current sound level of the audio stream.
* @return the current sound level of the audio stream
*/
public int getLevel()
{
return level;
}
}

@ -0,0 +1,23 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.protocol.event;
/**
* Notifies interested parties in sound level changes of the local user audio
* stream.
* @author Yana Stamcheva
*/
public interface LocalUserSoundLevelListener
{
/**
* Indicates that a change has occurred in the sound level of the local
* user.
* @param event the <tt>LocalUserSoundLevelEvent</tt> containing the new
* level
*/
public void localUserSoundLevelChanged(LocalUserSoundLevelEvent event);
}
Loading…
Cancel
Save