Estoy intentando desarrollar un cliente SIP usando las clases que para ello provee android: android.net.sip.* android.net.rtp.*
El caso es que actualmente, se establece la comunicación SIP correctamente, cuando hago una llamada a un número de teléfono, este suena y se aceptan las llamadas correctamente, peeeeero, mi desarrollo es mudo!! es decir, cuando se ha establecido la llamada y supuestamente se tendrían que comunicar el llamador y el llamante, pues no se oye nada!! la comunicación SIP es totalmente correcta, pero lo RTP se envían vacíos... y ya no sé a qué se puede deber.
Alguna idea??
Código HTML:
public class SipUtil { SharedPreferences prefs; MainActivity mActivity; //Para SIP public String sipAddress = null; public SipManager manager = null; public SipProfile me = null; public SipAudioCall mCall = null; Toast toast; String username; String domain; int conPort; String password; static SipUtil mSip; AudioStream audioStream; AudioGroup audioGroup; AudioManager audio; RtpStream rtpStream; SoundPool soundPool; int idAudioMarcacion; int idAudioTono; int idAudioComunica; public SipUtil (MainActivity activity) { manager = null; me = null; mCall = null; this.mActivity = activity; prefs = mActivity.getSharedPreferences(Constants.SHARE_PREFERENCES, Context.MODE_PRIVATE); mSip=this; } public void initializeManager() { if(manager == null) { manager = SipManager.newInstance(mActivity); } initializeLocalProfile(); } public void initializeLocalProfile() { if (manager == null) { return; } if (me != null) { closeLocalProfile(); } soundPool = new SoundPool(3, AudioManager.STREAM_MUSIC , 0); idAudioMarcacion = soundPool.load(mActivity, R.raw.phoning, 0); idAudioTono = soundPool.load(mActivity, R.raw.phone_calling, 0); idAudioComunica = soundPool.load(mActivity, R.raw.phone_interruption, 0); username = prefs.getString("user", ""); domain = prefs.getString("domain", "XXX.XXX.XXX.XXX"); //TODO poner el servidor conPort = prefs.getInt("conPort", 5060); password = prefs.getString("pass", ""); try { SipProfile.Builder builder = new SipProfile.Builder(username, domain); builder.setPassword(password); me = builder.build(); Intent i = new Intent(); i.setAction("MyApp.INCOMING_CALL"); PendingIntent pi = PendingIntent.getBroadcast(mActivity, 0, i, Intent.FILL_IN_DATA); manager.open(me, pi, null); manager.setRegistrationListener(me.getUriString(), new SipRegistrationListener() { public void onRegistering(String localProfileUri) { toast.setText(R.string.conectando); toast.show(); Log.d("/SipUtil", "Conectando"); } public void onRegistrationDone(String localProfileUri, long expiryTime) { Log.d("/SipUtil", "Conectado!!"); toast.setText(R.string.conectado); toast.show(); } public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) { Log.d("/SipUtil", "Error Autenticacion: " + errorMessage); toast.setText(R.string.error_autenticacion); toast.show(); } }); } catch (ParseException pe) { toast.setText(R.string.error_conexion_SIP); toast.show(); } catch (SipException se) { toast.setText(R.string.error_conexion_SIP); toast.show(); } } public void destroySipUtil() { if (mCall != null) { mCall.close(); } closeLocalProfile(); } public void closeLocalProfile() { if (manager == null) { return; } try { if (me != null) { manager.close(me.getUriString()); } } catch (Exception ee) { Log.d("/onDestroy", "Failed to close local profile.", ee); } } public void initiateCall(String destino) { this.sipAddress = "sip:"+destino+"@"+domain; llamar(); } public void colgar() { try { mCall.endCall(); if(audioGroup != null) audioGroup.clear(); soundPool.stop(idAudioTono); soundPool.stop(idAudioComunica); soundPool.stop(idAudioMarcacion); Log.d("/SipUtil", "Llamada finalizada"); } catch (SipException e) { Log.d("/SipUtil", "Llamada MAL finalizada"); } } public static SipUtil getSip() { return mSip; } private void llamar() { try { SipAudioCall.Listener listener = new SipAudioCall.Listener() { @Override public void onCallEstablished(SipAudioCall call) { soundPool.stop(idAudioMarcacion); soundPool.stop(idAudioTono); Log.d("/SipUtil", "onCallEstablished"); mCall = call; try { byte ip[] = null; try { for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf .getInetAddresses(); enumIpAddr .hasMoreElements();) { InetAddress inetAddress = enumIpAddr .nextElement(); if (!inetAddress.isLoopbackAddress()) { ip = inetAddress.getAddress(); } } } } catch (SocketException ex) { Log.i("SocketException ", ex.toString()); } audio = (AudioManager) mActivity.getSystemService(Context.AUDIO_SERVICE); audio.setMode(AudioManager.MODE_IN_CALL); audioGroup = new AudioGroup(); audioGroup.setMode(AudioGroup.MODE_NORMAL); audioStream = new AudioStream(InetAddress.getByAddress(ip)); audioStream.setCodec(AudioCodec.GSM); audioStream.setMode(RtpStream.MODE_NORMAL); audioStream.associate(InetAddress.getByName(mCall.getPeerProfile().getSipDomain()), 11234); audioStream.join(audioGroup); mCall.startAudio(); if (mCall.isMuted()) { mCall.toggleMute(); } Log.d("/SipUtil", "HABLANDO... "+mCall.getPeerProfile().getSipDomain()); Log.d("/SipUtil", "Codec"); } catch (SocketException e) { toast.setText(R.string.error_codec); toast.show(); Log.d("/SipUtil", "Error Codec"); } catch (IOException e) { toast.setText(R.string.error_codec); toast.show(); Log.d("/SipUtil", "Error Codec"); } } @Override public void onCalling(SipAudioCall call) { Log.d("/SipUtil", "onCalling"); mCall = call; soundPool.play(idAudioMarcacion, 1, 1, 0, 0, 1); } @Override public void onCallEnded(SipAudioCall call) { mCall = call; Log.d("/SipUtil", "onCallEnded"); try { mCall.endCall(); colgar(); Log.d("/SipUtil", "Llamada finalizada"); } catch (SipException e) { Log.d("/SipUtil", "Llamada MAL finalizada"); } } @Override public void onRingingBack (SipAudioCall call){ Log.d("/SipUtil", "onRingingBack"); mCall = call; soundPool.play(idAudioTono, 1, 1, 1, -1, 1); } @Override public void onCallBusy(SipAudioCall call) { Log.d("/SipUtil", "onCallBusy"); mCall = call; soundPool.play(idAudioComunica, 1, 1, 1, 0, 1); colgar(); } @Override public void onCallHeld(SipAudioCall call) { Log.d("/SipUtil", "onCallHeld"); mCall = call; soundPool.play(idAudioComunica, 1, 1, 1, 0, 1); colgar(); } public void onChanged (SipAudioCall call){ Log.d("/SipUtil", "onChanged"); mCall = call; } }; String origen = "sip:"+username+":"+password+"@"+domain; mCall = manager.makeAudioCall(origen, sipAddress, listener, 0); } catch (Exception e) { Log.i("/InitiateCall", "Error when trying to close manager.", e); if (me != null) { try { manager.close(me.getUriString()); } catch (Exception ee) { Log.i("/InitiateCall", "Error when trying to close manager.", ee); ee.printStackTrace(); } } if (mCall != null) { mCall.close(); } } } }
Si alguien puede darme una idea, o algo, me haría muy feliz!!!