当前位置:操作系统 > 安卓/Android >>

Android2.3 Sip简单分析

sip在sdk中有三个目录:server、net、telephony;
以下是针对net目录下Sip的分析:
net目录包含九个目标文件(SimpleSessionDescription、SipAudioCall、SipErrorCode、SipException、SipManager、SipProfile、SipRegistrationListener、SipSession、SipSessionAdapter)。
[cpp]  
public class SipErrorCode 该类定义了Sip错误代码,定义如下:  
    /** Not an error. 未定义错误 */  
    public static final int NO_ERROR = 0;  
  
    /** When some socket error occurs. 当一些发生套接字错误。 */  
    public static final int SOCKET_ERROR = -1;  
  
    /** When server responds with an error. 当服务器响应一个错误。*/  
    public static final int SERVER_ERROR = -2;  
  
    /** When transaction is terminated unexpectedly. 当交易被意外终止。*/  
    public static final int TRANSACTION_TERMINTED = -3;  
  
    /** When some error occurs on the device, possibly due to a bug. 当一些错误发生在设备上,这可能是由于一个错误。*/  
    public static final int CLIENT_ERROR = -4;  
  
    /** When the transaction gets timed out. 当事务被超时。*/  
    public static final int TIME_OUT = -5;  
  
    /** When the remote URI is not valid. 当远程URI是无效的。*/  
    public static final int INVALID_REMOTE_URI = -6;  
  
    /** When the peer is not reachable. 当对端不可达。*/  
    public static final int PEER_NOT_REACHABLE = -7;  
  
    /** When invalid credentials are provided. 当无效的凭证。*/  
    public static final int INVALID_CREDENTIALS = -8;  
  
    /** The client is in a transaction and cannot initiate a new one. 客户在交易中不能启动一个新的。*/  
    public static final int IN_PROGRESS = -9;  
  
    /** When data connection is lost. 当数据连接丢失。*/  
    public static final int DATA_CONNECTION_LOST = -10;  
  
    /** Cross-domain authentication required. 跨域认证。*/  
    public static final int CROSS_DOMAIN_AUTHENTICATION = -11;  
  
    /** When the server is not reachable. 当服务器不可达。*/  
    public static final int SERVER_UNREACHABLE = -12;  
  
  
public interface SipRegistrationListener SIP注册事件监听器  
该类包含了三个回调函数:  
void onRegistering(String localProfileUri)  发送的注册请求时调用  
void onRegistrationDone(String localProfileUri, long expiryTime)  注册成功时调用  
onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) 注册失败时调用  
  
  
public class SipException extends Exception  表示一般的SIP相关的异常。  
  
public class SipSessionAdapter extends ISipSessionListener.Stub   会话适配器类 会话监听  
该类定义了一些通话事件,如下:  
    public void onCalling(ISipSession session) { // 正通话中  
    }  
  
    public void onRinging(ISipSession session, SipProfile caller, String sessionDescription) { // 响铃  
    }  
  
    public void onRingingBack(ISipSession session) {  
    }  
  
    public void onCallEstablished(ISipSession session, String sessionDescription) { //建立通话  
    }  
  
    public void onCallEnded(ISipSession session) {  //通话结束  
    }  
  
    public void onCallBusy(ISipSession session) {   //通话忙  
    }  
  
    public void onCallTransferring(ISipSession session, String sessionDescription) {    //呼叫转移  
    }  
  
    public void onCallChangeFailed(ISipSession session, int errorCode, String message) { //打电话失败  
    }  
  
    public void onError(ISipSession session, int errorCode, String message) {  //错误  
    }  
  
    public void onRegistering(ISipSession session) {    //正在注册  
    }  
  
    public void onRegistrationDone(ISipSession session, int duration) { //注册完成  
    }  
  
    public void onRegistrationFailed(ISipSession session, int errorCode, String message) { //注册失败  
    }  
  
    public void onRegistrationTimeout(ISipSession session) { //注册超时  
    }  
  
  
public class SipProfile implements Parcelable, Serializable, Cloneable  定义一个SIP配置文件  
包括一个SIP帐户、传输协议、端口、密码、文件、id、域和服务器等的信息!  
  
public static class Builder  辅助类,辅助构造一个SIP配置文件  
  
public final class SipSession  Sip会话信息  
该类中定义了一个状态类State(,如“注册”,“呼出”,和“呼叫) 定义如下:  
 /** When session is ready to initiate a call or transaction. 当会话已准备好发起呼叫或交易。*/  
        public static final int READY_TO_CALL = 0;  
  
        /** When the registration request is sent out. 当注册请求被发送出去。*/  
        public static final int REGISTERING = 1;  
  
        /** When the unregistration request is sent out. 当注销请求发送出去。*/  
        public static final int DEREGISTERING = 2;  
  
        /** When an INVITE request is received. 当INVITE请求被接受。*/  
        public static final int INCOMING_CALL = 3;  
  
        /** When an OK response is sent for the INVITE request received.  
         * 当一个OK响应发送的INVITE请求。*/  
        public static final int INCOMING_CALL_ANSWERING = 4;  
  
        /** When an INVITE request is sent. 
         * 当INVITE请求被发送。 */  
        public static final int OUTGOING_CALL = 5;  
  
&n
补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,