简体   繁体   English

Twilio 语音时间戳

[英]Twilio Voice Timestamps

Our application uses the Twilio voice SDKs for iOS, Android, and Web.我们的应用程序使用适用于 iOS、Android 和 Web 的 Twilio 语音 SDK。 Our use case relies on precise device synchronization and time stamping.我们的用例依赖于精确的设备同步和时间戳。 We are playing an audio stream on multiple adjacent devices (in a Twilio conference call) and we need that audio playback to be in sync.我们正在多个相邻设备上播放音频流(在 Twilio 电话会议中),我们需要音频播放同步。 Most of the time, it works great, but every now-and-then, one of the devices falls a little bit behind and throws off the whole experience.在大多数情况下,它运行良好,但时不时地,其中一个设备会落后一点并破坏整个体验。 We want to detect when a device is falling behind (receiving packets late) so we can temporarily mute it so it does not throw off the user experience we are going for.我们想要检测设备何时落后(接收数据包延迟),以便我们可以暂时将其静音,这样它就不会影响我们想要的用户体验。

We believe that Twilio voice uses real time communication (web RTC) and real-time transport protocol (RTP) under the hood.我们相信 Twilio 语音在幕后使用实时通信 (web RTC) 和实时传输协议 (RTP)。 We also believe RTP has time stamping information for when packets are sent out and when packets are received.我们还相信 RTP 具有关于何时发送数据包和何时接收数据包的时间戳信息。

We are looking for any suggestions for how we might read this timestamp information (both sent & received) to detect device synchronization issues.我们正在寻找有关如何读取此时间戳信息(发送和接收)以检测设备同步问题的任何建议。

Our iOS and Android clients are built using Flutter & Dart, so any way to look at this packet information using Dart would be great.我们的 iOS 和 Android 客户端是使用 Flutter 和 Dart 构建的,因此任何使用 Dart 查看此数据包信息的方式都会很棒。 If not, we can use native channels through Swift and Kotlin.如果没有,我们可以通过 Swift 和 Kotlin 使用原生渠道。 For the web, we would need a way to look at this timestamp data using javascript.对于 Web,我们需要一种使用 javascript 查看此时间戳数据的方法。

If possible, we'd like to access this information through the SDK.如果可能,我们希望通过 SDK 访问此信息。 I don't see anything about timestamps in Twilio's voice documentation.我在 Twilio 的语音文档中没有看到任何关于时间戳的信息。 So, if not possible, we might have to sniff for packets on the devices?那么,如果不可能,我们可能不得不嗅探设备上的数据包? This way, we could look at the RTP packets coming from Twilio to see what information is available.通过这种方式,我们可以查看来自 Twilio 的 RTP 数据包,以了解哪些信息可用。 As long as this does not break Twilio terms of service, of course :)只要这不违反 Twilio 的服务条款,当然:)

Even if you could get this information I don't think it will be useful.即使你能得到这些信息,我也不认为它会有用。 The timestamp field in RTP has little to do with real time. RTP 中的timestamp字段与实时时间关系不大。 In voice it's actually a sample offset into the audio stream.在语音中,它实际上是音频流中的样本偏移。 With a typical narrowband codec with a fixed bit rate and no silence suppression it's completely predictable from the RTP sequence number.使用具有固定比特率且没有静音抑制的典型窄带编解码器,它完全可以从 RTP 序列号预测。 For example, with 20ms packets of G.711 it will increment by exactly 160 each packet.例如,对于 G.711 的 20ms 数据包,每个数据包将精确增加 160。

RTP receivers expect there to be random variation between the receipt time of a packet and its timestamp - known as jitter. RTP 接收器期望数据包的接收时间与其时间戳之间存在随机变化 - 称为抖动。 This is introduced by delays at the sender, in the network and at the receiver.这是由发送方、网络和接收方的延迟引起的。 This is why receivers use jitter buffers to reduce the likelihood of buffer underrun on playing.这就是为什么接收器使用抖动缓冲区来减少播放时缓冲区欠载的可能性。 The definition of jitter for RTCP - the interarrival jitter - is a calculation that measures this. RTCP 抖动的定义 -到达间隔抖动- 是一种衡量这一点的计算。 That is - the variation between the (predictable) RTP timestamp and the measured wallclock time at the receiver.即 -(可预测的)RTP 时间戳与接收器处测量的挂钟时间之间的变化。

Maybe you need something more like an NTP protocol between your client and your server.也许您需要更像客户端和服务器之间的 NTP 协议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM