Android Open Source - restcomm-android-sdk Sound Manager






From Project

Back to project page restcomm-android-sdk.

License

The source code is released under:

GNU General Public License

If you think the Android project restcomm-android-sdk listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.mobicents.restcomm.android.sdk.impl;
// w  w  w .  j av  a  2 s .  c om
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

import android.content.Context;
import android.media.AudioManager;
import android.net.rtp.AudioCodec;
import android.net.rtp.AudioGroup;
import android.net.rtp.AudioStream;
import android.net.rtp.RtpStream;

public class SoundManager {
  Context appContext;
  AudioManager audio;
  AudioStream audioStream;
  AudioGroup audioGroup;
  public SoundManager(Context appContext, String ip){
    this.appContext = appContext;
    audio = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);
    try {
      audioStream = new AudioStream(InetAddress.getByName(ip));
      audioStream.setCodec(AudioCodec.PCMU);
      audioStream.setMode(RtpStream.MODE_NORMAL);
      audioGroup = new AudioGroup();
      audioGroup.setMode(AudioGroup.MODE_ECHO_SUPPRESSION);
    
        
        
    } catch (SocketException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

  }
  public void releaseAudioResources() {
    
    audioStream.join(null);
    //audioStream.release();
    
    audioGroup.clear();
    audio.setMode(AudioManager.MODE_NORMAL);
    
      
  }
  public int setupAudioStream(String localIp) {
    audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
  
  
    return audioStream.getLocalPort();
  }
  public void setupAudio(int remoteRtpPort, String remoteIp) {

    try {
      audioStream.associate(
          InetAddress.getByName(remoteIp),
          remoteRtpPort);
    } catch (UnknownHostException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    audioStream.join(audioGroup);

  }
}




Java Source Code List

com.example.sipmessagetest.MainActivity.java
com.example.sipmessagetest.SettingsActivity.java
org.mobicents.restcomm.android.sdk.IDevice.java
org.mobicents.restcomm.android.sdk.ISipEventListener.java
org.mobicents.restcomm.android.sdk.ISipManager.java
org.mobicents.restcomm.android.sdk.NotInitializedException.java
org.mobicents.restcomm.android.sdk.SipManagerState.java
org.mobicents.restcomm.android.sdk.SipProfile.java
org.mobicents.restcomm.android.sdk.impl.AccountManagerImpl.java
org.mobicents.restcomm.android.sdk.impl.DeviceImpl.java
org.mobicents.restcomm.android.sdk.impl.SipEvent.java
org.mobicents.restcomm.android.sdk.impl.SipManager.java
org.mobicents.restcomm.android.sdk.impl.SoundManager.java
org.mobicents.restcomm.android.sdk.impl.UserCredentialsImpl.java
org.mobicents.restcomm.android.sdk.impl.sipmessages.Invite.java
org.mobicents.restcomm.android.sdk.impl.sipmessages.Message.java
org.mobicents.restcomm.android.sdk.impl.sipmessages.Register.java
org.mobicents.restcomm.android.sdk.ui.IncomingCall.java