Page 1 of 1

Receiving streaming raw audio

Posted: Tue Feb 19, 2019 4:15 pm
by JPMJPM
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.

Re: Receiving streaming raw audio

Posted: Tue Feb 19, 2019 7:40 pm
by fly135
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. :D

Re: Receiving streaming raw audio

Posted: Wed Feb 20, 2019 10:02 am
by JPMJPM
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.

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

Posted: Wed Feb 20, 2019 2:33 pm
by JPMJPM
Problem solved enabling "reassembly incoming fragmented IP packets" in LWIP (menuconfig).

Re: Receiving streaming raw audio

Posted: Wed Feb 20, 2019 5:10 pm
by fly135
JPMJPM wrote:
Wed Feb 20, 2019 2:33 pm
Problem solved enabling "reassembly incoming fragmented IP packets" in LWIP (menuconfig).
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