Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/199.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无需访问互联网的Android VOIP应用程序_Android_Sip_Voip - Fatal编程技术网

无需访问互联网的Android VOIP应用程序

无需访问互联网的Android VOIP应用程序,android,sip,voip,Android,Sip,Voip,我需要在两台android设备之间开发VOIP应用程序。 据我所知,有一个SIP协议用于此目的,但它需要注册到SIP服务器并访问internet以进行SIP信令。 有没有办法在没有互联网接入的情况下在android中创建VOIP应用程序?这是不可能的,因为VOIP呼叫通过互联网和sip服务器 比如说。如果您想通过VOIP dailer从您的国家拨打外线电话,您必须需要互联网接入,因为无法通过蓝牙进行通信 谢谢 实际上,SIP客户端可以进行点对点通信,他们只需要知道他们的IP地址和UDP端口,在那

我需要在两台android设备之间开发VOIP应用程序。
据我所知,有一个SIP协议用于此目的,但它需要注册到SIP服务器并访问internet以进行SIP信令。

有没有办法在没有互联网接入的情况下在android中创建VOIP应用程序?

这是不可能的,因为VOIP呼叫通过互联网和sip服务器

比如说。如果您想通过VOIP dailer从您的国家拨打外线电话,您必须需要互联网接入,因为无法通过蓝牙进行通信


谢谢

实际上,SIP客户端可以进行点对点通信,他们只需要知道他们的IP地址和UDP端口,在那里他们可以侦听SIP消息

您可以在两台计算机(适用于Windows的X-Lite、适用于Linux的Twinkle和其他一些计算机)上使用普通SIP客户端,并尝试在它们之间建立调用,而无需服务器注册。很有可能


您还可以在本地局域网的某个地方运行一个简单的SIP服务器。例如,FreeSWITCH可以最小化到非常小的占地面积。

好的,因此如果您正在寻找一些对等通信,我认为wifi是一种方式(更好的距离和速度)。如果你只能为Android的更新版本进行开发,那么这是一个不错的选择,但这只适用于Android 4.0及以上版本

为了在4.0以下运行,您必须使用第三方库。我知道高通公司有一个名为的库,但不确定它有多好。

我认为您可以在包括Andriod在内的多个平台上使用p2p voip服务

以下是我对该项目的调查结果:-

  • 不需要任何服务器或internet连接
  • 用户必须在同一网络下
  • 开源
  • 安卓apk是可用的,很可能你们可以在网站上找到它的代码,或者你们可以反编译它

  • 当然有可能!你为什么需要互联网?只要你们都连接到同一个网络就可以了!下面是一个工作应用程序的java和xml

    启动时,它将为您提供自己的本地端口,例如“52022”。。这每次都是随机的,不幸的是,这是无法帮助的。然后输入另一部手机的IP地址和随机生成的端口号,然后按connect。他们做的完全一样,万岁,你被连接了!此测试应用程序显然要求您靠近exchange端口号,但在我的适当应用程序中,我可以轻松地在连接之前请求每个端口号。希望这有帮助

    public class MainActivity extends Activity {
    
    AudioGroup m_AudioGroup;
    AudioStream m_AudioStream;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy);
          try {   
              AudioManager audio =  (AudioManager) getSystemService(Context.AUDIO_SERVICE); 
              audio.setMode(AudioManager.MODE_IN_COMMUNICATION);
              m_AudioGroup = new AudioGroup();
              m_AudioGroup.setMode(AudioGroup.MODE_NORMAL);
              m_AudioStream = new AudioStream(InetAddress.getByAddress(getLocalIPAddress ()));
              int localPort = m_AudioStream.getLocalPort();
              m_AudioStream.setCodec(AudioCodec.PCMU);
              m_AudioStream.setMode(RtpStream.MODE_NORMAL);
    
              ((TextView)findViewById(R.id.lblLocalPort)).setText(String.valueOf(localPort));
    
              ((Button) findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    String remoteAddress = ((EditText)findViewById(R.id.editText2)).getText().toString();
                    String remotePort = ((EditText)findViewById(R.id.editText1)).getText().toString();
    
                      try {
                        m_AudioStream.associate(InetAddress.getByName(remoteAddress), Integer.parseInt(remotePort));
                    } catch (NumberFormatException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (UnknownHostException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                      m_AudioStream.join(m_AudioGroup);
                }
            });
    
              ((Button) findViewById(R.id.button2)).setOnClickListener(new OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
                          m_AudioStream.release();
                    }
                });
    
          } catch (Exception e) {
           Log.e("----------------------", e.toString());
           e.printStackTrace();
          }
    }
    
    public static byte[] getLocalIPAddress () {
        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());
           }
           return ip;
        }
    }
    


    但是,如果我只想要两部使用WIFI连接的手机在没有互联网连接的情况下相互通话?这是不可能的,因为,您必须需要一个服务器来相互通信……但它仅用于SIP。也许有一些方法可以在Java中构建VOIP应用程序,而不是SIP?VOIP可以在没有SIP的情况下构建。您只需要创建自己的语音数据传输协议。根据定义,所有SIP用户代理都是服务器。除了SIP用户代理本身之外,协议中没有任何要求。FreeSWITCH可以安装在Android上吗?不,我不这么认为。它是用C编写的,android是基于java的,Roid是基于LINUX C的,java是在Cyes上添加的,但是你不能在无根电话上安装原生C应用程序来进行点对多点通信,我绝对建议在同一局域网的服务器上安装FreeSWITCH。如果您的Wifi接入点足够强大,您也可以尝试在那里安装。嗯,无论如何,学习这个平台还需要一周的时间……你是说像对讲机一样?有很多方法可以通过wifi和蓝牙实现点对点,这能满足您的需求吗?是的。实际上我需要一对多的无线对讲机。这种不需要访问internet的会议SIP不需要访问internet,它只需要用户代理本身。(这些东西是有用的,但不是必需的。)@Frankshearr可以描述一下这是怎么可能的吗?看看我的问题:@CostaMirkin现在怎么样了?很好,但我需要VOIP应用程序:)一旦你建立了连接,你就可以通过它运行任何你想要的服务。如果您正在寻找内置p2p功能的voip,那么我认为您不会找到它。事实上,我需要点对多点功能:)@CostaMirkin wifi direct解决方案应允许您拥有任意数量的连接。你阅读了链接另一端的参考资料了吗?我收到了这个异常E/-------------------------:java.net.SocketException:Invalid arguments我已经有一段时间没有使用它了,我知道在最近的android更新中获取ip地址的方式已经改变了。你能指导我如何通过本地wifi进行语音呼叫吗android设备切换到其他设备?查看编辑后的代码,切换出新设备的ip地址方法。它现在正在工作,但按connect后什么也没有发生。我应该怎么做才能在按下connect之后连接到另一个设备并能够传输语音。
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
    
        <TextView
            android:id="@+id/lblLocalPort"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/localPort" />
    
        <EditText
            android:id="@+id/editText2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:ems="10"
            android:hint="@string/iPHint"
            android:inputType="phone" />
    
        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:ems="10"
            android:hint="@string/portHint"
            android:inputType="number" >
    
            <requestFocus />
        </EditText>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            android:layout_marginTop="20dp">
    
            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/connect" />
    
            <Button
                android:id="@+id/button2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/Disconnect" />
        </LinearLayout>
    </LinearLayout>
    
    private byte[] getLocalIPAddress() {   
        byte[] bytes = null;
    
        try {
            // get the string ip
            WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE);
            String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());
    
            // convert to bytes
            InetAddress inetAddress = null;
            try {
                inetAddress = InetAddress.getByName(ip);
            } catch (UnknownHostException e) {
                e.printStackTrace();
            }
    
            bytes = new byte[0];
            if (inetAddress != null) {
                bytes = inetAddress.getAddress();
            }
    
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(this, R.string.phone_voip_incompatible, Toast.LENGTH_SHORT).show();
        }
    
        return bytes;
    }