Receiving streaming raw audio

JPMJPM
Posts: 23
Joined: Fri Oct 13, 2017 4:35 pm

Receiving streaming raw audio

Postby JPMJPM » Tue Feb 19, 2019 4:15 pm

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.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Receiving streaming raw audio

Postby fly135 » Tue Feb 19, 2019 7:40 pm

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

JPMJPM
Posts: 23
Joined: Fri Oct 13, 2017 4:35 pm

Re: Receiving streaming raw audio

Postby JPMJPM » Wed Feb 20, 2019 10:02 am

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);
}

JPMJPM
Posts: 23
Joined: Fri Oct 13, 2017 4:35 pm

Re: Receiving streaming raw audio

Postby JPMJPM » Wed Feb 20, 2019 2:33 pm

Problem solved enabling "reassembly incoming fragmented IP packets" in LWIP (menuconfig).

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Receiving streaming raw audio

Postby fly135 » Wed Feb 20, 2019 5:10 pm

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

Who is online

Users browsing this forum: MicroController and 109 guests