Android AudioRecord 通过 RTP 发送

发布于 2024-12-14 18:43:43 字数 817 浏览 7 评论 0原文

背景

我正在创建一个 VoIP 应用程序。我知道已经有很多了,但我有我的理由。由于商业影响,我不能直接分叉 SipDroid,尽管它是一个高质量的应用程序。这个应用程序针对的是 Level 10 Gingerbread 2.3.3。

问题

我创建了一个简单的活动,它创建一个AudioRecord实例,然后开始循环:

int timestamp = 0;
int seqNr = 12;
while(true) {
    byte[] buffer = new byte[bufferSize];

    int num = recorder.read(buffer, 0, bufferSize);
    try {
        byte[] pcm = new byte[bufferSize];
        //
        // presumably here I convert the byte[] from PCM into G711??
        //
        RTPStream.Write(pcm,seqNr,timestamp);
        timestamp += num;
        seqNr++;
    } catch (IOException e) {
        e.printStackTrace();
    }
}

问题

如何将PCM 44KHz 16位单声道byte[]< /code> 到 G711u/a byte[] 的?

Background

I am creating a VoIP app. I know that there are plenty of ones out already, but I have my reasons. Due to commercial implications I cannot just fork SipDroid, although it is a quality app. This app is aimed at Level 10 Gingerbread 2.3.3.

Problem

I have created a simple Activity which creates an AudioRecord instance, and then begins a loop:

int timestamp = 0;
int seqNr = 12;
while(true) {
    byte[] buffer = new byte[bufferSize];

    int num = recorder.read(buffer, 0, bufferSize);
    try {
        byte[] pcm = new byte[bufferSize];
        //
        // presumably here I convert the byte[] from PCM into G711??
        //
        RTPStream.Write(pcm,seqNr,timestamp);
        timestamp += num;
        seqNr++;
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Question

How do I turn the PCM 44KHz 16bit Mono byte[]'s into G711u/a byte[]'s??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱给你人给你 2024-12-21 18:43:45

尝试使用 AudioStram 代替。通过setCodec(AudioCodec)设置编解码器并通过AudioGroup获取音频。

Try using AudioStram instead. Set codec via setCodec(AudioCodec) and acquire audio via AudioGroup.

刘备忘录 2024-12-21 18:43:44

AudioGroup 在内部可用。这就是 Native SipAudioCall 所使用的。有一种方法可以使用内部 API。知道该类将在 API 12 中可用。您应该使用它。

AudioGroup is available internally. That is what Native SipAudioCall is using. There is a a way to use internal API. Knowing that the class will be available in API 12. You should use it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文