Hi.
ESP32 is receiving streaming raw audio (wav file without headers) over UDP.
In orden to capture UDP packets I use recvfrom() but it does not work.
Any alternative ?.
Regards.
Receiving streaming raw audio
Re: Receiving streaming raw audio
My guess is that it doesn't work because you are doing it wrong. Tell us what you are doing wrong and we can tell you what to fix.
Re: Receiving streaming raw audio
The problem is recvfrom() never returns.
With "echo "Hello from PC" | nc -w1 -u 192.168.1.18 6000"
recvfrom() works fine and LEN = 14.
With "echo "Hello from PC" | nc -w1 -u 192.168.1.18 6000"
recvfrom() works fine and LEN = 14.
Code: Select all
void audio_spe_udp() {
mysocket_audio = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in server_addr;
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(6000);
server_addr.sin_addr.s_addr = inet_addr("192.168.1.18");
bind(mysocket_audio, (struct sockaddr *)&server_addr, sizeof(server_addr));
struct sockaddr_in sourceAddr;
socklen_t socklen = sizeof(sourceAddr);
uint16_t buf_len = 5000;
char *buf = calloc(buf_len, sizeof(char));
int len;
while (1) {
len = recvfrom(mysocket_audio, buf, buf_len - 1, 0, (struct sockaddr *)&sourceAddr, &socklen);
printf("LEN = %i\n", len);
}
}
void app_main() {
xTaskCreatePinnedToCore(&audio_spe_udp, "audio_spe_udp", 2048, NULL, 10, NULL, 1);
}
Re: Receiving streaming raw audio
Problem solved enabling "reassembly incoming fragmented IP packets" in LWIP (menuconfig).
Re: Receiving streaming raw audio
That is enabled by default on my 3.1.1 IDF. I recall doing some UDP streaming on an earlier IDF. But the data packets were smaller than the MTU, so that may not mean much.
John A
Who is online
Users browsing this forum: Bing [Bot] and 97 guests