是什么在iOS的音频使用循环缓冲APP调用的原因是什么? [英] What's the reason of using Circular Buffer in iOS Audio Calling APP?

查看:217
本文介绍了是什么在iOS的音频使用循环缓冲APP调用的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是pretty多的自我解释。很抱歉,如果这似乎太愚蠢。

My question is pretty much self explanatory. Sorry if it seems too dumb.

我写一个iOS的网络电话拨号器和检查了一些开源$ C ​​$ C(iOS版音频通话应用程序)。而几乎所有这些使用循环缓冲器,用于存储记录和接收的PCM音频数据。所以我想知道为什么我们需要在这种情况下,使用循环缓冲。什么是使用这种音频缓冲的确切原因。

I am writing a iOS VoIP dialer and have checked some open-source code(iOS audio calling app). And almost all of those use Circular Buffer for storing recorded and received PCM audio data. SO i am wondering why we need to use a Circular Buffer in this case. What's the exact reason for using such audio buffer.

先谢谢了。

推荐答案

好问题。还有另外一个很好的理由使用循环缓冲。

Good question. There is another good reason for using Circular Buffer.

在iOS上,如果你使用的录音回调(音频单元)和播放音频(IN-其实你需要的,如果你想创建一个实时音频传输应用程序来使用它),那么你会得到数据的一大块特定的时间量(假设20毫秒)从记录回调。而在iOS上,你将永远不会总是得到数据的固定长度(如果你设置回调的时间间隔为20毫秒,那么你将获得370或372字节的数据。你永远不会知道什么时候你会得到370个字节或372字节。纠正我,如果我错了)。然后,通过你需要使用数据编码和解码的codeC(G729通常用于VoIP的应用程序)的UDP数据包传输音频。但是,G729由乘法器取数据8.假设,你带code 368(8×46)个字节每20毫秒。所以,你有什么打算与数据的其余部分呢?您需要通过序列作为下一大块来处理存储它的

In iOS, if you use callbacks(Audio unit) for recording and playing audio(In-fact you need to use it if you want to create a real-time audio transferring app) then you will get a chunk of data for a specific amount of time(let's say 20 milliseconds) from the recorder callback. And in iOS, you will never get fixed length of data always(If you set the callback interval as 20ms then you will get 370 or 372 bytes of data. And you will never know when you will get 370 bytes or 372 bytes. Correct me if i am wrong). Then, to transfer the audio through UDP packets you need to use a codec for data encoding and decoding(G729 is generally used for VoIP apps). But g729 takes data by the multiplier of 8. Assume, you encode 368(8*46) bytes per 20ms. So what are you going to do with rest of the data ? You need to store it by sequence for the next chunk to process.

这就是原因。还有其他一些细节的事情,但我kapt简单为您更好的了解。如果你有任何问题,只是下面的评论。

SO that's the reason. There are some other details thing but i kapt it simple for your better understanding. Just comment below if you have any question.

这篇关于是什么在iOS的音频使用循环缓冲APP调用的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆