📄 sipprovider.java
字号:
enum = sipPhoneVector.elements();
int i=0;
while (enum.hasMoreElements())
{
SipPhone sp = (SipPhone)enum.nextElement();
SipManager sm = sp.getSipManager();
if (sm.getAddress().equals(address));
ret[i] = new TermData(sp.getAddress(), true);
i++;
}
return ret;
}
/** This allows for any context-specific parameters to be set.
* The map may include such pairs as "name"="xxx" or "password"="yyy".
* The provider is not active until this has
* been called. The property map may be null.
*
* Creation date: (2000-02-11 12:13:36)
* @author: Richard Deadman
* @param props The name value properties map
*
*/
public void initialize(java.util.Map props) throws ProviderUnavailableException
{
console.logEntry();
loadProperties();
}
/** Release a connection to a call (Connection).
* This should block until the connection is released. The service provider does
* not have to send a disconnect message for this connection, since it is generated by the framework.
*
* @param address The address that we want to release
* @param call The call to disconnect from
*
* @exception RawException Some low-level state exception occured.
*
*/
public void release(String address, CallId call) throws PrivilegeViolationException, ResourceUnavailableException, MethodNotSupportedException, RawStateException
{
console.logEntry();
SipPhone mySP = getSipPhoneByAddress(address);
mySP.SipHangup(call);
}
/** Tell the provider that it may release a call id for future use. This is necessary to ensure that
* TelephonyProvider call ids are not reused until the Generic JTAPI Framework layer is notified of
* the death of the call.
* Creation date: (2000-02-17 22:25:48)
* @author: Richard Deadman
* @param id The CallId that may be freed.
*
*/
public void releaseCallId(CallId id)
{
console.logEntry();
}
/** Remove a listener for RawEvents
*
* @param ro Listener to remove
* @return void
*
*/
public void removeListener(TelephonyListener ro)
{
if (ro == listener)
{
listener = null;
}else
{
System.err.println("Request to remove a TelephonyListener from "
+ this.getClass().getName() + ", but it wasn't registered");
}
}
/** Perform any cleanup after my holder has finished with me.
* Creation date: (2000-02-11 13:07:46)
* @author: Richard Deadman
*
*/
public void shutdown()
{
console.logEntry();
}
//initialisation du provider-----------------------------------------------------------
//lecture des propriet?s et creation des adresees et des terminaux
public void loadProperties()
{
try
{
File pFile = new File("sip-provider.properties");
FileInputStream pIS = new FileInputStream(pFile);
System.out.println(pIS.toString());
properties.load(pIS);
pIS.close();
String strPhone = properties.getProperty("gjtapi.sip.sip_phone");
StringTokenizer st = new StringTokenizer(strPhone,",");
while (st.hasMoreTokens())
{
pFile = new File(st.nextToken());
pIS = new FileInputStream(pFile);
properties.load(pIS);
SipPhone sipPhone = new SipPhone(properties,this);
sipPhoneVector.add(sipPhone);
console.debug("------------------------"+sipPhone.getAddress());
pIS.close();
}
System.getProperties().putAll(properties);
}
//Catch IO & FileNotFound & NullPointer exceptions
catch (Throwable exc)
{
console.warn(
"Warning:Failed to load properties!"
+ "\nThis is only a warning.SipCommunicator will use defaults.",
exc);
}
}
//methode utilitaires--------------------------------------
private SipPhone getSipPhoneByAddress(String address)
{
SipPhone ret = null;
Enumeration enum = sipPhoneVector.elements();
while (enum.hasMoreElements())
{
SipPhone sp = (SipPhone)enum.nextElement();
if ( sp.getAddress().equals(address))
{
ret = sp;
}
}
return ret;
}
//fin methodes utilitaires
// methode de l'interphace SipPhoneListener
public void sipCallActive(CallId id, int cause)
{
console.logEntry();
listener.callActive(id, cause);
}
public void sipConnectionInProgress(CallId id, String address, int cause)
{
console.logEntry();
listener.connectionInProgress(id, address, cause);
}
void sipConnectionAlerting(CallId id, String address, int cause)
{
console.logEntry();
listener.connectionAlerting(id, address, cause);
}
public void sipConnectionAuthorizeCallAttempt(CallId id, String address, int cause)
{
console.logEntry();
}
public void sipConnectionCallDelivery(CallId id, String address, int cause)
{console.logEntry();
}
public void sipConnectionConnected(CallId id, String address, int cause)
{
console.logEntry();
// listener.callActive(id, cause);
listener.connectionConnected(id, address, cause);
//listener.connectionDisconnected(id, address, cause);
}
public void sipConnectionDisconnected(CallId id, String address, int cause)
{
this.releaseCallId(id);
console.logEntry();
}
public void sipConnectionFailed(CallId id, String address, int cause)
{
console.logEntry();
}
public void sipTerminalConnectionCreated(CallId id, String address, String terminal, int cause)
{
console.logEntry();
listener.terminalConnectionCreated(id, address, terminal, cause);
}
//media methods---------------------------------------------------------------------
//----------------------------------------------------------------------------------
public boolean allocateMedia(String terminal, int type, Dictionary resourceArgs)
{
return true;
}
public boolean freeMedia(String terminal, int type)
{
return true;
}
public boolean isMediaTerminal(String terminal)
{
return true;
}
public void play(String terminal, String[] streamIds, int offset, javax.telephony.media.RTC[] rtcs, Dictionary optArgs) throws javax.telephony.media.MediaResourceException
{
console.logEntry();
try
{
String[] add = this.getAddresses(terminal);
for(int i=0; i < add.length; i++)
{
SipPhone sipPhone = this.getSipPhoneByAddress(add[i]);
sipPhone.play(streamIds[0]);
}
}
catch (javax.telephony.InvalidArgumentException ex)
{
console.debug(ex.toString());
}
}
public void record(String terminal, String streamId, javax.telephony.media.RTC[] rtcs, Dictionary optArgs) throws javax.telephony.media.MediaResourceException
{
console.logEntry();
try
{
String[] add = this.getAddresses(terminal);
for(int i=0; i < add.length; i++)
{
SipPhone sipPhone = this.getSipPhoneByAddress(add[i]);
sipPhone.record(streamId);
}
}
catch (javax.telephony.InvalidArgumentException ex)
{
console.debug(ex.toString());
}
}
public RawSigDetectEvent retrieveSignals(String terminal, int num, javax.telephony.media.Symbol[] patterns, javax.telephony.media.RTC[] rtcs, Dictionary optArgs) throws javax.telephony.media.MediaResourceException
{
return null;
}
public void sendSignals(String terminal, javax.telephony.media.Symbol[] syms, javax.telephony.media.RTC[] rtcs, Dictionary optArgs) throws javax.telephony.media.MediaResourceException
{
}
public void stop(String terminal)
{
console.logEntry();
try
{
String[] add = this.getAddresses(terminal);
for(int i=0; i < add.length; i++)
{
SipPhone sipPhone = this.getSipPhoneByAddress(add[i]);
sipPhone.stop();
}
}
catch (javax.telephony.InvalidArgumentException ex)
{
console.debug(ex.toString());
}
}
public void triggerRTC(String terminal, javax.telephony.media.Symbol action)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -