feat: 视频与控制程序合并

This commit is contained in:
2026-04-04 23:25:43 +08:00
parent 9ffc36f50d
commit 70e835ed49
19 changed files with 1674 additions and 706 deletions

View File

@@ -0,0 +1,7 @@
#ifndef OMNI_CONTROL_PROTOCOL_H
#define OMNI_CONTROL_PROTOCOL_H
#define OMNI_CONTROL_PACKET_FLOATS 6
#define OMNI_CONTROL_PACKET_SIZE (OMNI_CONTROL_PACKET_FLOATS * sizeof(float))
#endif

View File

@@ -27,6 +27,7 @@ int kcp_client_receive_timed(kcp_client_t *client, message_t *out_msg, int timeo
int kcp_client_receive(kcp_client_t *client, message_t *out_msg);
int kcp_client_receive_binary_into(kcp_client_t *client, void *buffer, size_t buffer_len, kcp_client_recv_meta_t *out_meta, int timeout_ms);
int kcp_client_persist_message(kcp_client_t *client, const message_t *msg, const char *inbox_dir, char *out_path, size_t out_path_len);
void kcp_client_runtime_stats_snapshot(kcp_client_t *client, kcp_runtime_stats_t *out_stats);
int kcp_client_close(kcp_client_t *client);
void kcp_client_free(kcp_client_t *client);

View File

@@ -43,6 +43,17 @@ extern "C" {
typedef struct kcp_conn kcp_conn_t;
typedef struct kcp_listener kcp_listener_t;
typedef struct kcp_runtime_stats {
int connected;
uint32_t conv;
uint32_t rto_ms;
int32_t srtt_ms;
int32_t srttvar_ms;
uint32_t snd_queue;
uint32_t rcv_queue;
uint32_t snd_buffer;
uint32_t xmit_total;
} kcp_runtime_stats_t;
typedef struct kcp_conn_options {
int nodelay;
int interval_ms;
@@ -68,6 +79,7 @@ int kcp_conn_close(kcp_conn_t *conn);
void kcp_conn_free(kcp_conn_t *conn);
uint32_t kcp_conn_conv(const kcp_conn_t *conn);
int kcp_conn_local_addr(const kcp_conn_t *conn, struct sockaddr_storage *addr, socklen_t *addr_len);
void kcp_conn_runtime_stats_snapshot(kcp_conn_t *conn, kcp_runtime_stats_t *out_stats);
kcp_listener_t *kcp_listener_listen(const char *listen_addr, const char *bind_device, kcp_packet_debug_logger_t *packet_logger, const char *node_role, const char *node_id);
kcp_conn_t *kcp_listener_accept(kcp_listener_t *listener);

52
include/video_pipeline.h Normal file
View File

@@ -0,0 +1,52 @@
#ifndef OMNI_VIDEO_PIPELINE_H
#define OMNI_VIDEO_PIPELINE_H
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include "peer_kcp_client.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct video_pipeline_config {
const char *camera_device;
const char *server_addr;
const char *relay_via;
const char *bind_ip;
const char *bind_device;
const char *peer_id;
const char *target_peer;
int capture_width;
int capture_height;
int output_width;
int output_height;
int max_frames;
int enable_timing_logs;
} video_pipeline_config_t;
typedef struct video_pipeline_stats {
pthread_mutex_t mutex;
uint64_t frames_sent;
uint64_t bytes_sent;
uint64_t send_errors;
uint64_t last_frame_bytes;
int connected;
char last_error[256];
kcp_runtime_stats_t transport;
} video_pipeline_stats_t;
void video_pipeline_config_init(video_pipeline_config_t *config);
void video_pipeline_config_load_env(video_pipeline_config_t *config);
int video_pipeline_stats_init(video_pipeline_stats_t *stats);
void video_pipeline_stats_destroy(video_pipeline_stats_t *stats);
void video_pipeline_stats_snapshot(video_pipeline_stats_t *stats, video_pipeline_stats_t *out_stats);
int video_pipeline_run(const video_pipeline_config_t *config, video_pipeline_stats_t *stats, volatile sig_atomic_t *stop_requested);
#ifdef __cplusplus
}
#endif
#endif