Files
Karl Osterseher 79991d51fa Merge branch 'master' into fix_20ms_chunk_size_bug
# Conflicts:
#	.project
#	components/audio_board/CMakeLists.txt
#	components/audio_board/Kconfig.projbuild
#	components/audio_board/component.mk
#	components/audio_board/esp32_s2_kaluga_1_v1_2/board.c
#	components/audio_board/esp32_s2_kaluga_1_v1_2/board.h
#	components/audio_hal/driver/es8388/es8388.c
#	components/audio_hal/driver/es8388/headphone_detect.c
#	components/audio_hal/driver/tas5805m/tas5805m.c
#	components/custom_board/Kconfig.projbuild
#	components/esp_peripherals/driver/i2c_bus/i2c_bus.c
#	components/esp_peripherals/esp_peripherals.c
#	components/esp_peripherals/periph_button.c
#	components/esp_peripherals/periph_console.c
#	components/esp_peripherals/periph_led.c
#	components/esp_peripherals/periph_sdcard.c
#	components/esp_peripherals/periph_wifi.c
#	components/esp_peripherals/periph_ws2812.c
#	components/esp_peripherals/test/esp_peripherals_test.c
#	components/eth_interface/CMakeLists.txt
#	components/eth_interface/eth_interface.c
#	components/lightsnapcast/include/snapcast.h
#	components/lightsnapcast/player.c
#	components/wifi_interface/CMakeLists.txt
#	components/wifi_interface/wifi_interface.c
#	dependencies.lock
#	main/CMakeLists.txt
#	main/main.c
#	sdkconfig_PCM5102A
#	sdkconfig_TAS5805M

Signed-off-by: Karl Osterseher <karli_o@gmx.at>
2025-01-19 00:05:24 +01:00

119 lines
2.7 KiB
C

#ifndef __SNAPCAST_H__
#define __SNAPCAST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
enum message_type {
SNAPCAST_MESSAGE_BASE = 0,
SNAPCAST_MESSAGE_CODEC_HEADER = 1,
SNAPCAST_MESSAGE_WIRE_CHUNK = 2,
SNAPCAST_MESSAGE_SERVER_SETTINGS = 3,
SNAPCAST_MESSAGE_TIME = 4,
SNAPCAST_MESSAGE_HELLO = 5,
SNAPCAST_MESSAGE_STREAM_TAGS = 6,
SNAPCAST_MESSAGE_FIRST = SNAPCAST_MESSAGE_BASE,
SNAPCAST_MESSAGE_LAST = SNAPCAST_MESSAGE_STREAM_TAGS,
SNAPCAST_MESSAGE_INVALID
};
typedef struct tv {
int32_t sec;
int32_t usec;
} tv_t;
typedef struct base_message {
uint16_t type;
uint16_t id;
uint16_t refersTo;
tv_t sent;
tv_t received;
uint32_t size;
} base_message_t;
#define BASE_MESSAGE_SIZE 26
#define TIME_MESSAGE_SIZE 8
int base_message_serialize(base_message_t *msg, char *data, uint32_t size);
int base_message_deserialize(base_message_t *msg, const char *data,
uint32_t size);
/* Sample Hello message
{
"Arch": "x86_64",
"ClientName": "Snapclient",
"HostName": "my_hostname",
"ID": "00:11:22:33:44:55",
"Instance": 1,
"MAC": "00:11:22:33:44:55",
"OS": "Arch Linux",
"SnapStreamProtocolVersion": 2,
"Version": "0.17.1"
}
*/
typedef struct hello_message {
char *mac;
char *hostname;
char *version;
char *client_name;
char *os;
char *arch;
int instance;
char *id;
int protocol_version;
} hello_message_t;
char *hello_message_serialize(hello_message_t *msg, size_t *size);
typedef struct server_settings_message {
int32_t buffer_ms;
int32_t latency;
uint32_t volume;
bool muted;
} server_settings_message_t;
int server_settings_message_deserialize(server_settings_message_t *msg,
const char *json_str);
typedef struct codec_header_message {
char *codec;
uint32_t size;
char *payload;
} codec_header_message_t;
int codec_header_message_deserialize(codec_header_message_t *msg,
const char *data, uint32_t size);
void codec_header_message_free(codec_header_message_t *msg);
typedef struct wire_chunk_message {
tv_t timestamp;
size_t size;
char *payload;
} wire_chunk_message_t;
// TODO currently copies, could be made to not copy probably
int wire_chunk_message_deserialize(wire_chunk_message_t *msg, const char *data,
uint32_t size);
void wire_chunk_message_free(wire_chunk_message_t *msg);
typedef struct time_message {
tv_t latency;
} time_message_t;
int time_message_serialize(time_message_t *msg, char *data, uint32_t size);
int time_message_deserialize(time_message_t *msg, const char *data,
uint32_t size);
#ifdef __cplusplus
}
#endif
#endif // __SNAPCAST_H__