Files
tactility_apps/Apps/PipecatVoice/main/Source/voice_protocol.h
T
2026-09-07 23:01:26 -04:00

32 lines
907 B
C

#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define PV_PROTOCOL_VERSION 1
#define PV_PCM_CHUNK_MAX 16384U
#define PV_DOWNSTREAM_MAX 65536U
typedef enum {
PV_CONNECTING,
PV_STREAMING,
PV_RECONNECTING,
PV_FAILED,
} PvState;
typedef struct {
char host[64];
char path[96];
uint16_t port;
} PvEndpoint;
bool pv_parse_endpoint(const char* url, PvEndpoint* endpoint);
bool pv_make_start_json(char* out, size_t out_size, const char* session_id, const char* device_id);
bool pv_valid_pcm_chunk(size_t bytes);
bool pv_valid_downstream_audio(const char* format, int sample_rate, int channels, int sample_width, size_t byte_length);
bool pv_binary_matches_metadata(size_t expected_bytes, size_t received_bytes);
uint32_t pv_retry_delay_seconds(unsigned attempt);
PvState pv_disconnect_state(bool endpoint_valid);
const char* pv_state_label(PvState state);