fix bad audio quality & save_to_disk example (#64)

- save_to_disk example: write raw pcm frames into a wav file
This commit is contained in:
Théo Monnom
2023-05-12 00:27:07 +02:00
committed by GitHub
parent e8d1c7ee73
commit f6954e3faa
8 changed files with 182 additions and 12 deletions
+5 -4
View File
@@ -16,7 +16,7 @@
#include "livekit/audio_device.h"
const int kBitsPerSample = 16;
const int kBytesPerSample = 2;
const int kSampleRate = 48000;
const int kChannels = 2;
const int kSamplesPer10Ms = kSampleRate / 100;
@@ -54,13 +54,14 @@ int32_t AudioDevice::Init() {
if (playing_) {
int64_t elapsed_time_ms = -1;
int64_t ntp_time_ms = -1;
size_t n_samples_out = 0;
void* data = data_.data();
// Request the AudioData, otherwise WebRTC will ignore the packets.
// 10ms of audio data.
audio_transport_->PullRenderData(kBitsPerSample, kSampleRate,
kChannels, kSamplesPer10Ms, data,
&elapsed_time_ms, &ntp_time_ms);
audio_transport_->NeedMorePlayData(
kSamplesPer10Ms, kBytesPerSample, kChannels, kSampleRate, data,
n_samples_out, &elapsed_time_ms, &ntp_time_ms);
}
return webrtc::TimeDelta::Millis(10);