mirror of https://github.com/sipwise/jitsi.git
parent
936b4790ec
commit
db293d098b
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Jitsi, 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;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.event.*;
|
||||
|
||||
/**
|
||||
* This class represents group of several calls. It is used to make
|
||||
* cross-protocol conference calls.
|
||||
*
|
||||
* @author Sebastien Vincent
|
||||
*/
|
||||
public class CallGroup
|
||||
implements CallChangeListener
|
||||
{
|
||||
/**
|
||||
* List of <tt>Call</tt>s.
|
||||
*/
|
||||
private List<Call> calls = new ArrayList<Call>();
|
||||
|
||||
/**
|
||||
* Synchronization object.
|
||||
*/
|
||||
private final Object syncRoot = new Object();
|
||||
|
||||
/**
|
||||
* Returns list of existing <tt>Call</tt>s in this <tt>CallGroup</tt>.
|
||||
*
|
||||
* @return list of existing <tt>Call</tt>s in this <tt>CallGroup</tt>.
|
||||
*/
|
||||
public List<Call> getCalls()
|
||||
{
|
||||
return calls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires <tt>CallGroupEvent</tt>.
|
||||
*
|
||||
* @param call source <tt>Call</tt>
|
||||
* @param eventID event ID
|
||||
*/
|
||||
public void fireCallGroupEvent(Call call, int eventID)
|
||||
{
|
||||
CallGroupEvent evt = new CallGroupEvent(call, eventID);
|
||||
|
||||
for(Call c : calls)
|
||||
{
|
||||
if(c == call)
|
||||
continue;
|
||||
|
||||
switch(eventID)
|
||||
{
|
||||
case CallGroupEvent.CALLGROUP_CALL_ADDED:
|
||||
c.callAdded(evt);
|
||||
call.callAdded(new CallGroupEvent(c, eventID));
|
||||
break;
|
||||
case CallGroupEvent.CALLGROUP_CALL_REMOVED:
|
||||
c.callRemoved(evt);
|
||||
call.callRemoved(new CallGroupEvent(c, eventID));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a call.
|
||||
*
|
||||
* @param call call to add
|
||||
*/
|
||||
public void addCall(Call call)
|
||||
{
|
||||
synchronized(syncRoot)
|
||||
{
|
||||
if(!calls.contains(call))
|
||||
{
|
||||
call.addCallChangeListener(this);
|
||||
call.setCallGroup(this);
|
||||
calls.add(call);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a call.
|
||||
*
|
||||
* @param call call to remove
|
||||
*/
|
||||
public void removeCall(Call call)
|
||||
{
|
||||
synchronized(syncRoot)
|
||||
{
|
||||
if(calls.contains(call))
|
||||
{
|
||||
call.removeCallChangeListener(this);
|
||||
calls.remove(call);
|
||||
call.setCallGroup(null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a new call peer has joined the source call.
|
||||
*
|
||||
* @param evt the <tt>CallPeerEvent</tt> containing the source call
|
||||
* and call peer.
|
||||
*/
|
||||
public void callPeerAdded(CallPeerEvent evt)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a call peer has left the source call.
|
||||
*
|
||||
* @param evt the <tt>CallPeerEvent</tt> containing the source call
|
||||
* and call peer.
|
||||
*/
|
||||
public void callPeerRemoved(CallPeerEvent evt)
|
||||
{
|
||||
/* not used */
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates that a change has occurred in the state of the source call.
|
||||
*
|
||||
* @param evt the <tt>CallChangeEvent</tt> instance containing the source
|
||||
* calls and its old and new state.
|
||||
*/
|
||||
public void callStateChanged(CallChangeEvent evt)
|
||||
{
|
||||
Call call = evt.getSourceCall();
|
||||
if(evt.getEventType() == CallChangeEvent.CALL_STATE_CHANGE)
|
||||
{
|
||||
CallState state = (CallState)evt.getNewValue();
|
||||
|
||||
if(evt.getNewValue() == evt.getOldValue())
|
||||
return;
|
||||
|
||||
if(state == CallState.CALL_ENDED)
|
||||
{
|
||||
fireCallGroupEvent(call, CallGroupEvent.CALLGROUP_CALL_REMOVED);
|
||||
}
|
||||
else if(state == CallState.CALL_IN_PROGRESS)
|
||||
{
|
||||
fireCallGroupEvent(call, CallGroupEvent.CALLGROUP_CALL_ADDED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Jitsi, 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.*;
|
||||
|
||||
/**
|
||||
* An event class representing that an <tt>Call</tt> or <tt>CallPeer</tt> is
|
||||
* added/removed to/from a <tt>CallGroup</tt>.
|
||||
*
|
||||
* @author Sebastien Vincent
|
||||
*/
|
||||
public class CallGroupEvent
|
||||
extends EventObject
|
||||
{
|
||||
/**
|
||||
* Serial version UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* CALLGROUP_CALL_ADDED event name.
|
||||
*/
|
||||
public static final int CALLGROUP_CALL_ADDED = 0;
|
||||
|
||||
/**
|
||||
* CALLGROUP_CALL_REMOVED event name.
|
||||
*/
|
||||
public static final int CALLGROUP_CALL_REMOVED = 1;
|
||||
|
||||
/**
|
||||
* The id indicating the type of this event.
|
||||
*/
|
||||
private final int eventID;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param call call source
|
||||
* @param eventID event ID
|
||||
*/
|
||||
public CallGroupEvent(Call call, int eventID)
|
||||
{
|
||||
super(call);
|
||||
this.eventID = eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns one of the CALLGROUP_XXX member ints indicating
|
||||
* the type of this event.
|
||||
* @return one of the CALLGROUP_XXX member ints indicating
|
||||
* the type of this event.
|
||||
*/
|
||||
public int getEventID()
|
||||
{
|
||||
return this.eventID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the source call.
|
||||
*
|
||||
* @return The source call
|
||||
*/
|
||||
public Call getSourceCall()
|
||||
{
|
||||
return (Call)getSource();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Jitsi, 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.*;
|
||||
|
||||
/**
|
||||
* Instances of this class are used for listening for notifications coming out
|
||||
* of a <tt>CallGroup</tt>.
|
||||
*
|
||||
* @author Sebastien Vincent
|
||||
*/
|
||||
public interface CallGroupListener
|
||||
extends EventListener
|
||||
{
|
||||
/**
|
||||
* Notified when a call are added to a <tt>CallGroup</tt>.
|
||||
*
|
||||
* @param evt event
|
||||
*/
|
||||
public void callAdded(CallGroupEvent evt);
|
||||
|
||||
/**
|
||||
* Notified when a call are removed from a <tt>CallGroup</tt>.
|
||||
*
|
||||
* @param evt event
|
||||
*/
|
||||
public void callRemoved(CallGroupEvent evt);
|
||||
}
|
||||
Loading…
Reference in new issue