Android AudioRecord 通过 RTP 发送
背景
我正在创建一个 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用
AudioStram
代替。通过setCodec(AudioCodec)
设置编解码器并通过AudioGroup
获取音频。Try using
AudioStram
instead. Set codec viasetCodec(AudioCodec)
and acquire audio viaAudioGroup
.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.