summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2023-05-28 16:53:07 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2023-05-28 16:53:07 -0400
commitb5f2b7171f7c0a19d4c4a2974cd8977fd4955464 (patch)
tree4291e292711e2d37645fcc67526f52902c421166 /src/audio
parent7f021a78522c53ce122ad38a57f541c9ff2e7839 (diff)
downloadabaddon-portaudio-b5f2b7171f7c0a19d4c4a2974cd8977fd4955464.tar.gz
abaddon-portaudio-b5f2b7171f7c0a19d4c4a2974cd8977fd4955464.zip
make RTP timestamp strictly linear
this should fix some artificial delay
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/manager.cpp13
-rw-r--r--src/audio/manager.hpp4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/audio/manager.cpp b/src/audio/manager.cpp
index 6e85ed8..ce20940 100644
--- a/src/audio/manager.cpp
+++ b/src/audio/manager.cpp
@@ -50,6 +50,15 @@ void capture_data_callback(ma_device *pDevice, void *pOutput, const void *pInput
if (mgr == nullptr) return;
mgr->OnCapturedPCM(static_cast<const int16_t *>(pInput), frameCount);
+
+ /*
+ * You can simply increment it by 480 in UDPSocket::SendEncrypted but this is wrong
+ * The timestamp is supposed to be strictly linear eg. if there's discontinuous
+ * transmission for 1 second then the timestamp should be 48000 greater than the
+ * last packet. So it's incremented here because this is fired 100x per second
+ * and is always called in sync with UDPSocket::SendEncrypted
+ */
+ mgr->m_rtp_timestamp += 480;
}
AudioManager::AudioManager() {
@@ -473,6 +482,10 @@ AudioDevices &AudioManager::GetDevices() {
return m_devices;
}
+uint32_t AudioManager::GetRTPTimestamp() const noexcept {
+ return m_rtp_timestamp;
+}
+
AudioManager::type_signal_opus_packet AudioManager::signal_opus_packet() {
return m_signal_opus_packet;
}
diff --git a/src/audio/manager.hpp b/src/audio/manager.hpp
index 9cd7f42..ed40f35 100644
--- a/src/audio/manager.hpp
+++ b/src/audio/manager.hpp
@@ -63,6 +63,8 @@ public:
[[nodiscard]] AudioDevices &GetDevices();
+ [[nodiscard]] uint32_t GetRTPTimestamp() const noexcept;
+
private:
void OnCapturedPCM(const int16_t *pcm, ma_uint32 frames);
@@ -113,6 +115,8 @@ private:
AudioDevices m_devices;
+ std::atomic<uint32_t> m_rtp_timestamp = 0;
+
public:
using type_signal_opus_packet = sigc::signal<void(int payload_size)>;
type_signal_opus_packet signal_opus_packet();