#ifndef OMNI_VIDEO_PIPELINE_H #define OMNI_VIDEO_PIPELINE_H #include #include #include #include "gps_buffer.h" #include "peer_kcp_client.h" #ifdef __cplusplus extern "C" { #endif typedef struct video_pipeline_packet_metadata { uint64_t timestamp_ms; double latitude; double longitude; } video_pipeline_packet_metadata_t; typedef void (*video_pipeline_progress_fn)(void *context); #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L _Static_assert(sizeof(video_pipeline_packet_metadata_t) == 24, "video trailer metadata must be 24 bytes"); #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; int soft_backpressure_segments; int hard_backpressure_segments; int hard_backpressure_hold_ms; int frame_stall_reconnect_ms; kcp_session_stats_logger_t *stats_logger; int stats_interval_ms; video_pipeline_progress_fn progress_callback; void *progress_context; } 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 backpressure_drops; uint64_t backlog_resets; uint64_t last_frame_bytes; uint32_t last_backlog_segments; int connected; char last_error[256]; char last_backlog_reason[128]; kcp_runtime_stats_t transport; } video_pipeline_stats_t; #define VIDEO_PIPELINE_RUN_RETRY_IMMEDIATE 2 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