2017-03-09 13 views
0

私は現在VoIP/SIP通話を行うためのアプリケーションを開発中です なぜ私は私のRegistrationListenerを登録できませんか分かりません 私はasteriskをSIPプロバイダとして使用しています。私のプログラム()を使用してVoIP通話をしたい

これは私のコード

主な活動

public class MainActivity extends AppCompatActivity { 

private static final int CALL_ADDRESS = 1; 
Button Connect_Button; 
public SipManager manager = null; 
public SipProfile MyProfile = null; 
public String sipAddress = null; 

public CommsController cc; 

public Context ctx = this; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Connect_Button = (Button) findViewById(R.id.ConnectB); 




      cc = new CommsController(); 
      cc.createManager(this); 

      cc.createProfile("example","192.168.1.29","54321"); 

      cc.openProfile(ctx); 

      try { 
       System.out.println("+++ IS API SUPPORTED: " + cc.getManager().isApiSupported(this)); 
       System.out.println("+++ IS VOIP SUPORTED: " + cc.getManager().isVoipSupported(this)); 
       System.out.println("+++ MANAGER INSTANCE: " + cc.getManager().toString()); 
       boolean isOpened = cc.getManager().isOpened(cc.getMe().getUriString()); 
       System.out.println("+++ IS OPENED: "+isOpened); 

       if(isOpened){ 

        cc.createRegistrationListener(); 
        cc.getManager().register(cc.getMe(), 30000, cc.getSrl()); 





       } 

      }catch(SipException sipex){ 
       System.out.println(sipex.getCause()+", "+ sipex.getMessage()); 

      } 
} 



public Context getContext(){return ctx;} 

public CommsController getCc() { 
    return cc; 
} 

}

コントローラ

public class CommsController { 

public String sipAddress = null; 
public SipManager manager = null; 
public SipProfile me = null; 
public SipAudioCall call = null; 
public Context ctx; 
private PendingIntent pendingIntent; 
public SipRegistrationListener srl; 



private static final int CALL_ADDRESS = 1; 
private static final int SET_AUTH_INFO = 2; 
private static final int UPDATE_SETTINGS_DIALOG = 3; 
private static final int HANG_UP = 4; 

SipAudioCall.Listener listener = new SipAudioCall.Listener(){ 
    @Override 
    public void onCallEstablished(SipAudioCall call) { 
     call.startAudio(); 
     call.setSpeakerMode(true); 
     call.toggleMute(); 
    } 
    @Override 
    public void onCallEnded(SipAudioCall call) { 
     // Do something. 
    } 
}; 

public void createManager(Context context) { 
    if (manager == null) { 
     manager = SipManager.newInstance(context); 
    } 
} 

public boolean createProfile(String uname, String domain, String pass){ 

    try { 
     SipProfile.Builder builder = new SipProfile.Builder(uname, domain); 
     builder.setPassword(pass); 
     builder.setProtocol("TCP"); 
     builder.setPort(5060); 
     me = builder.build(); 
     setMe(me); 
     System.out.println("+++ User Profile = CREATED"); 
     return true; 
    } catch (ParseException e) { 
     e.printStackTrace(); 
     System.out.println("+++ User Profile = FAILED"); 

    } catch (java.text.ParseException e) { 
     e.printStackTrace(); 
    } 
    return false; 
} 

public void openProfile(Context context){ 
    try { 
     System.out.println("+++ ATTEMPTING TO OPEN PROFILE: " + me.getUriString()); 

     Intent intent = new Intent(); 
     intent.setAction("android.SipDemo.INCOMING_CALL"); 
     pendingIntent = PendingIntent.getBroadcast(context, 0, intent, Intent.FILL_IN_DATA); 
     manager.open(getMe(),pendingIntent,srl); 
     System.out.println("+++ IS OPEN IN CC: " +manager.isOpened(getMe().getUriString())); 

    } catch (SipException e) { 
     e.printStackTrace(); 
     System.out.println("+++ Profile Registration = FAILED"); 
    } 
} 

public void createRegistrationListener(){ 
    System.out.println("+++ CREATING REG LISTENER..."); 

    srl = new SipRegistrationListener() { 

     @Override 
     public void onRegistering(String localProfileUri) { 
      System.out.println("+++ REGISTERING..."); 
     } 

     @Override 
     public void onRegistrationDone(String localProfileUri, long expiryTime) { 
      System.out.println("+++ READY"); 
     } 

     @Override 
     public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { 
      System.out.println("+++ REGISTRATION FAILED. CHECK SETTINGS. ERROR: "+ errorCode + " MESSAGE: " +errorMessage); 
     } 
    }; 

} 
public SipRegistrationListener getSrl(){ 
    return srl; 
} 

public void closeProfile(SipProfile toClose){ 
    if(manager==null){ 
     return; 
    } 
    try { 
     if (manager != null) { 
      manager.close(toClose.getUriString()); 
      System.out.println("PROFILE CLOSED: " +toClose.getUriString()); 
     } 
    } catch (Exception ee) { 
     ee.printStackTrace(); 
     System.out.println("FAILED TO CLOSE LOCAL PROFILE: "+ toClose.toString()); 
    } 

} 

public void logOut(){ 
    try { 
     System.out.println("+++ DEREGISTERING..."); 
     manager.close(me.getUriString()); 
    }catch(SipException se){ 
     System.out.println("+++ DEREGISTRATION FAILED"); 
     se.printStackTrace(); 
    } 
} 

public void makeCall(String toCall){ 
    try { 
     call = manager.makeAudioCall(me.getUriString(), toCall, listener, 30); 
    } catch (SipException e) { 
     e.printStackTrace(); 
    } 
} 

public void setMe(SipProfile me) { 
    this.me = me; 
} 

public SipProfile getMe() { 
    return me; 
} 

public SipManager getManager() { 
    return manager; 
} 

public void setManager(SipManager manager) { 
    this.manager = manager; 
} 

}ありますそれはデバッグの問題ではない問題であるbecuase

出力

I/System.out: +++ User Profile = CREATED 
I/System.out: +++ ATTEMPTING TO OPEN PROFILE: sip:[email protected];transport=tcp 
I/System.out: +++ IS OPEN IN CC: true 
I/System.out: +++ IS API SUPPORTED: true 
I/System.out: +++ IS VOIP SUPORTED: true 
I/System.out: +++ MANAGER INSTANCE: [email protected] 
I/System.out: +++ IS OPENED: true 
I/System.out: +++ CREATING REG LISTENER... 
D/OpenGLRenderer: Enabling debug mode 0 
I/System.out: +++ REGISTRATION FAILED. CHECK SETTINGS. ERROR: -4 MESSAGE: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out) 

が私を助けてください...

答えて

1

は、この手立てのANSWERはありません。デバッグの

案方法は以下の通りです:

  1. は、例えばZOIPERのために、100%ワーキングソフトフォンを取得または
  2. はアスタリスクに接続しxlite。
  3. 取得のwiresharkやtcpdumpをして、プロジェクトのためのSIPパケット
  4. ゲットダンプのダンプを取得
  5. を比較してください。
関連する問題