Organize host and robot streaming releases
This commit is contained in:
57
robot/ros2/OmniSocketGo_robot_ros/include/cli_parse.h
Normal file
57
robot/ros2/OmniSocketGo_robot_ros/include/cli_parse.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef OMNI_CLI_PARSE_H
|
||||
#define OMNI_CLI_PARSE_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
static int cli_parse_bool_text(const char *raw, int *out_value) {
|
||||
if (raw == NULL || out_value == NULL) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(raw, "1") == 0 || strcmp(raw, "true") == 0 || strcmp(raw, "yes") == 0 || strcmp(raw, "on") == 0) {
|
||||
*out_value = 1;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(raw, "0") == 0 || strcmp(raw, "false") == 0 || strcmp(raw, "no") == 0 || strcmp(raw, "off") == 0) {
|
||||
*out_value = 0;
|
||||
return 0;
|
||||
}
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int cli_parse_value_flag(int argc, char **argv, int *index, const char *arg, const char *flag, const char **out_value) {
|
||||
size_t flag_len = strlen(flag);
|
||||
|
||||
if (strcmp(arg, flag) == 0) {
|
||||
if (*index + 1 >= argc) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*out_value = argv[++(*index)];
|
||||
return 1;
|
||||
}
|
||||
if (strncmp(arg, flag, flag_len) == 0 && arg[flag_len] == '=') {
|
||||
*out_value = arg + flag_len + 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cli_parse_bool_flag(const char *arg, const char *flag, int *out_value) {
|
||||
size_t flag_len = strlen(flag);
|
||||
|
||||
if (strcmp(arg, flag) == 0) {
|
||||
*out_value = 1;
|
||||
return 1;
|
||||
}
|
||||
if (strncmp(arg, flag, flag_len) == 0 && arg[flag_len] == '=') {
|
||||
if (cli_parse_bool_text(arg + flag_len + 1, out_value) != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
16
robot/ros2/OmniSocketGo_robot_ros/include/gps_buffer.h
Normal file
16
robot/ros2/OmniSocketGo_robot_ros/include/gps_buffer.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef GPS_BUFFER_H
|
||||
#define GPS_BUFFER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct gps_video_sample {
|
||||
double latitude;
|
||||
double longitude;
|
||||
} gps_video_sample_t;
|
||||
|
||||
gps_video_sample_t get_latest_gps_for_video(void);
|
||||
|
||||
|
||||
int gps_buffer_init(const char* host);
|
||||
void gps_buffer_cleanup(void);
|
||||
#endif
|
||||
30
robot/ros2/OmniSocketGo_robot_ros/include/interactive.h
Normal file
30
robot/ros2/OmniSocketGo_robot_ros/include/interactive.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef OMNI_INTERACTIVE_H
|
||||
#define OMNI_INTERACTIVE_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum interactive_command_type {
|
||||
INTERACTIVE_CMD_HELP = 0,
|
||||
INTERACTIVE_CMD_QUIT = 1,
|
||||
INTERACTIVE_CMD_TEXT = 2,
|
||||
INTERACTIVE_CMD_FILE = 3
|
||||
} interactive_command_type_t;
|
||||
|
||||
typedef struct interactive_command {
|
||||
interactive_command_type_t type;
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char value[1024];
|
||||
} interactive_command_t;
|
||||
|
||||
int interactive_parse_command(const char *line, interactive_command_t *command, char *err, size_t err_len);
|
||||
void interactive_print_help(FILE *out, const char *transport_name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
49
robot/ros2/OmniSocketGo_robot_ros/include/kcp_packet_debug.h
Normal file
49
robot/ros2/OmniSocketGo_robot_ros/include/kcp_packet_debug.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef OMNI_KCP_PACKET_DEBUG_H
|
||||
#define OMNI_KCP_PACKET_DEBUG_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct kcp_packet_debug_segment {
|
||||
uint8_t cmd;
|
||||
uint32_t sn;
|
||||
uint32_t una;
|
||||
uint8_t frg;
|
||||
uint16_t wnd;
|
||||
uint32_t len;
|
||||
} kcp_packet_debug_segment_t;
|
||||
|
||||
typedef struct kcp_packet_debug_record {
|
||||
char event[OMNI_MAX_EVENT_NAME];
|
||||
char node_role[OMNI_MAX_NODE_ROLE];
|
||||
char node_id[OMNI_MAX_PEER_ID];
|
||||
char local_addr[OMNI_MAX_ADDR_TEXT];
|
||||
char remote_addr[OMNI_MAX_ADDR_TEXT];
|
||||
int packet_bytes;
|
||||
int has_udp_tx_id;
|
||||
uint32_t udp_tx_id;
|
||||
int has_kcp_conv;
|
||||
uint32_t kcp_conv;
|
||||
int64_t ts_unix_nano;
|
||||
kcp_packet_debug_segment_t *segments;
|
||||
size_t segment_count;
|
||||
} kcp_packet_debug_record_t;
|
||||
|
||||
typedef struct kcp_packet_debug_logger {
|
||||
omni_file_logger_t file_logger;
|
||||
int enabled;
|
||||
} kcp_packet_debug_logger_t;
|
||||
|
||||
kcp_packet_debug_logger_t *kcp_packet_debug_open_jsonl(const char *path);
|
||||
void kcp_packet_debug_close(kcp_packet_debug_logger_t *logger);
|
||||
int kcp_packet_debug_log(kcp_packet_debug_logger_t *logger, const kcp_packet_debug_record_t *record);
|
||||
void kcp_packet_debug_record_clear(kcp_packet_debug_record_t *record);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
#ifndef OMNI_KCP_SESSION_STATS_H
|
||||
#define OMNI_KCP_SESSION_STATS_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KCP_SESSION_STATS_RECORD_SESSION_SAMPLE "session_sample"
|
||||
#define KCP_SESSION_STATS_RECORD_PROCESS_SAMPLE "process_snmp_sample"
|
||||
|
||||
typedef struct kcp_session_stats_record {
|
||||
char record_type[32];
|
||||
char node_role[OMNI_MAX_NODE_ROLE];
|
||||
char node_id[OMNI_MAX_PEER_ID];
|
||||
char local_addr[OMNI_MAX_ADDR_TEXT];
|
||||
char remote_addr[OMNI_MAX_ADDR_TEXT];
|
||||
int has_conv;
|
||||
uint32_t conv;
|
||||
int64_t ts_unix_nano;
|
||||
char sample_reason[32];
|
||||
int has_rto_ms;
|
||||
uint32_t rto_ms;
|
||||
int has_srtt_ms;
|
||||
int32_t srtt_ms;
|
||||
int has_min_srtt_ms;
|
||||
int32_t min_srtt_ms;
|
||||
int has_srttvar_ms;
|
||||
int32_t srttvar_ms;
|
||||
int has_last_feedback_age_ms;
|
||||
uint32_t last_feedback_age_ms;
|
||||
int has_snd_wnd;
|
||||
uint32_t snd_wnd;
|
||||
int has_rmt_wnd;
|
||||
uint32_t rmt_wnd;
|
||||
int has_inflight;
|
||||
uint32_t inflight;
|
||||
int has_window_limit;
|
||||
uint32_t window_limit;
|
||||
int has_window_pressure_pct;
|
||||
double window_pressure_pct;
|
||||
int has_bytes_sent;
|
||||
uint64_t bytes_sent;
|
||||
int has_bytes_received;
|
||||
uint64_t bytes_received;
|
||||
int has_in_pkts;
|
||||
uint64_t in_pkts;
|
||||
int has_out_pkts;
|
||||
uint64_t out_pkts;
|
||||
int has_in_segs;
|
||||
uint64_t in_segs;
|
||||
int has_out_segs;
|
||||
uint64_t out_segs;
|
||||
int has_retrans_segs;
|
||||
uint64_t retrans_segs;
|
||||
int has_fast_retrans_segs;
|
||||
uint64_t fast_retrans_segs;
|
||||
int has_early_retrans_segs;
|
||||
uint64_t early_retrans_segs;
|
||||
int has_lost_segs;
|
||||
uint64_t lost_segs;
|
||||
int has_repeat_segs;
|
||||
uint64_t repeat_segs;
|
||||
int has_in_errs;
|
||||
uint64_t in_errs;
|
||||
int has_kcp_in_errs;
|
||||
uint64_t kcp_in_errs;
|
||||
int has_ring_buffer_snd_queue;
|
||||
uint64_t ring_buffer_snd_queue;
|
||||
int has_ring_buffer_rcv_queue;
|
||||
uint64_t ring_buffer_rcv_queue;
|
||||
int has_ring_buffer_snd_buffer;
|
||||
uint64_t ring_buffer_snd_buffer;
|
||||
int has_curr_estab;
|
||||
uint64_t curr_estab;
|
||||
} kcp_session_stats_record_t;
|
||||
|
||||
typedef struct kcp_session_stats_logger {
|
||||
omni_file_logger_t file_logger;
|
||||
int enabled;
|
||||
} kcp_session_stats_logger_t;
|
||||
|
||||
kcp_session_stats_logger_t *kcp_session_stats_open_jsonl(const char *path);
|
||||
void kcp_session_stats_close(kcp_session_stats_logger_t *logger);
|
||||
int kcp_session_stats_log(kcp_session_stats_logger_t *logger, const kcp_session_stats_record_t *record);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
51
robot/ros2/OmniSocketGo_robot_ros/include/latencylog.h
Normal file
51
robot/ros2/OmniSocketGo_robot_ros/include/latencylog.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef OMNI_LATENCYLOG_H
|
||||
#define OMNI_LATENCYLOG_H
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define EVENT_A_APP_PREP_BEGIN "A_APP_PREP_BEGIN"
|
||||
#define EVENT_A_TX_SCHED "A_TX_SCHED"
|
||||
#define EVENT_A_TX_SOFTWARE "A_TX_SOFTWARE"
|
||||
#define EVENT_A_TX_HARDWARE "A_TX_HARDWARE"
|
||||
#define EVENT_B_RX_HARDWARE "B_RX_HARDWARE"
|
||||
#define EVENT_B_RX_SOFTWARE "B_RX_SOFTWARE"
|
||||
#define EVENT_B_APP_RECV "B_APP_RECV"
|
||||
#define EVENT_B_PERSIST_BEGIN "B_PERSIST_BEGIN"
|
||||
#define EVENT_B_PERSIST_END "B_PERSIST_END"
|
||||
#define EVENT_SEND_HANDOFF_BEGIN "send_handoff_begin"
|
||||
#define EVENT_SEND_HANDOFF_END "send_handoff_end"
|
||||
|
||||
typedef struct latency_event {
|
||||
int64_t ts_unix_nano;
|
||||
char node_role[OMNI_MAX_NODE_ROLE];
|
||||
char node_id[OMNI_MAX_PEER_ID];
|
||||
char event[OMNI_MAX_EVENT_NAME];
|
||||
message_type_t message_type;
|
||||
uint64_t message_id;
|
||||
char from[OMNI_MAX_PEER_ID];
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char file_name[OMNI_MAX_FILE_NAME];
|
||||
int body_size;
|
||||
} latency_event_t;
|
||||
|
||||
typedef struct latency_logger {
|
||||
omni_file_logger_t file_logger;
|
||||
int enabled;
|
||||
} latency_logger_t;
|
||||
|
||||
latency_logger_t *latencylog_open_jsonl(const char *path);
|
||||
void latencylog_close(latency_logger_t *logger);
|
||||
int latencylog_log_event(latency_logger_t *logger, const latency_event_t *event);
|
||||
int latencylog_is_business_message(const message_t *msg);
|
||||
void latencylog_log_message_event(latency_logger_t *logger, const char *node_role, const char *node_id, const char *event_name, const message_t *msg);
|
||||
void latencylog_log_message_event_at(latency_logger_t *logger, const char *node_role, const char *node_id, const char *event_name, int64_t ts_unix_nano, const message_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef OMNI_LINUX_TIMESTAMPING_H
|
||||
#define OMNI_LINUX_TIMESTAMPING_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct omni_tx_timestamp_event {
|
||||
char event_name[OMNI_MAX_EVENT_NAME];
|
||||
int64_t ts_unix_nano;
|
||||
uint32_t ee_info;
|
||||
uint32_t ee_data;
|
||||
} omni_tx_timestamp_event_t;
|
||||
|
||||
int linux_timestamping_enable_udp_socket(int fd, int enable_rx);
|
||||
int64_t linux_timestamping_parse_rx_timestamp(const struct msghdr *msg);
|
||||
int linux_timestamping_parse_tx_timestamp(const struct msghdr *msg, omni_tx_timestamp_event_t *out_event);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
78
robot/ros2/OmniSocketGo_robot_ros/include/omni_common.h
Normal file
78
robot/ros2/OmniSocketGo_robot_ros/include/omni_common.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef OMNI_COMMON_H
|
||||
#define OMNI_COMMON_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
#include <limits.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
#define OMNI_NODE_ROLE_PEER "peer"
|
||||
#define OMNI_NODE_ROLE_SERVER "server"
|
||||
|
||||
#define OMNI_MAX_PEER_ID 64
|
||||
#define OMNI_MAX_NODE_ROLE 16
|
||||
#define OMNI_MAX_EVENT_NAME 64
|
||||
#define OMNI_MAX_FILE_NAME 256
|
||||
#define OMNI_MAX_ADDR_TEXT 128
|
||||
#define OMNI_MAX_FRAME_SIZE (8U * 1024U * 1024U)
|
||||
|
||||
#define OMNI_ARRAY_LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
typedef struct omni_file_logger {
|
||||
FILE *file;
|
||||
pthread_mutex_t mutex;
|
||||
char path[PATH_MAX];
|
||||
size_t current_bytes;
|
||||
size_t buffered_bytes;
|
||||
size_t flush_bytes;
|
||||
size_t max_bytes;
|
||||
int flush_interval_ms;
|
||||
int max_files;
|
||||
int immediate_flush;
|
||||
uint64_t last_flush_monotonic_ms;
|
||||
} omni_file_logger_t;
|
||||
|
||||
int64_t omni_now_unix_nano(void);
|
||||
uint32_t omni_now_millis32(void);
|
||||
|
||||
int omni_set_nonblocking(int fd, int enabled);
|
||||
int omni_parse_sockaddr(const char *raw, int passive, struct sockaddr_storage *addr, socklen_t *addr_len, int *family_out);
|
||||
int omni_clone_sockaddr(const struct sockaddr *src, socklen_t src_len, struct sockaddr_storage *dst, socklen_t *dst_len);
|
||||
const char *omni_sockaddr_to_string(const struct sockaddr *addr, socklen_t addr_len, char *buffer, size_t buffer_len);
|
||||
|
||||
int omni_bind_device(int fd, const char *device);
|
||||
int omni_ensure_dir(const char *path);
|
||||
int omni_ensure_parent_dir(const char *path);
|
||||
int omni_read_file(const char *path, uint8_t **out, size_t *out_len);
|
||||
int omni_write_full_fd(int fd, const uint8_t *data, size_t len);
|
||||
int omni_append_file(const char *path, const uint8_t *data, size_t len);
|
||||
int omni_write_file(const char *path, const uint8_t *data, size_t len);
|
||||
int omni_random_u32(uint32_t *out);
|
||||
|
||||
char *omni_strdup(const char *src);
|
||||
char *omni_strdup_printf(const char *fmt, ...);
|
||||
char *omni_json_escape(const char *src);
|
||||
char *omni_json_escape_bytes(const uint8_t *src, size_t len);
|
||||
int omni_utf8_valid(const uint8_t *data, size_t len);
|
||||
void omni_trim_newline(char *line);
|
||||
int omni_parse_duration_ms(const char *raw, int default_ms, int *out_ms);
|
||||
double omni_duration_ms_to_ns(double ms);
|
||||
const char *omni_path_base_name(const char *path);
|
||||
|
||||
void omni_file_logger_init(omni_file_logger_t *logger, FILE *file);
|
||||
void omni_file_logger_init_path(omni_file_logger_t *logger, FILE *file, const char *path, int immediate_flush);
|
||||
void omni_file_logger_destroy(omni_file_logger_t *logger);
|
||||
int omni_file_logger_write_line(omni_file_logger_t *logger, const char *line);
|
||||
|
||||
#endif
|
||||
46
robot/ros2/OmniSocketGo_robot_ros/include/peer_kcp_client.h
Normal file
46
robot/ros2/OmniSocketGo_robot_ros/include/peer_kcp_client.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef OMNI_PEER_KCP_CLIENT_H
|
||||
#define OMNI_PEER_KCP_CLIENT_H
|
||||
|
||||
#include "transport_kcp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct kcp_client kcp_client_t;
|
||||
typedef struct kcp_client_recv_meta {
|
||||
message_type_t type;
|
||||
uint64_t id;
|
||||
char from[OMNI_MAX_PEER_ID];
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char file_name[OMNI_MAX_FILE_NAME];
|
||||
size_t body_len;
|
||||
} kcp_client_recv_meta_t;
|
||||
typedef struct kcp_client_state {
|
||||
int connected;
|
||||
int registered;
|
||||
uint32_t server_idle_ms;
|
||||
char last_server_error[256];
|
||||
} kcp_client_state_t;
|
||||
|
||||
kcp_client_t *kcp_client_dial_with_options(const char *server_addr, const char *dial_addr, const char *peer_id, const char *bind_ip, const char *bind_device, const kcp_conn_options_t *options, latency_logger_t *logger, kcp_packet_debug_logger_t *packet_logger, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
kcp_client_t *kcp_client_dial(const char *server_addr, const char *dial_addr, const char *peer_id, const char *bind_ip, const char *bind_device, latency_logger_t *logger, kcp_packet_debug_logger_t *packet_logger, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
const char *kcp_client_id(const kcp_client_t *client);
|
||||
int kcp_client_send_text(kcp_client_t *client, const char *to, const char *text);
|
||||
int kcp_client_send_binary(kcp_client_t *client, const char *to, const void *data, size_t data_len);
|
||||
int kcp_client_send_binary_with_id(kcp_client_t *client, const char *to, const void *data, size_t data_len, uint64_t *out_id);
|
||||
int kcp_client_send_file_path(kcp_client_t *client, const char *to, const char *path);
|
||||
int kcp_client_receive_timed(kcp_client_t *client, message_t *out_msg, int timeout_ms);
|
||||
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_state_snapshot(kcp_client_t *client, kcp_client_state_t *out_state);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
37
robot/ros2/OmniSocketGo_robot_ros/include/peer_udp_client.h
Normal file
37
robot/ros2/OmniSocketGo_robot_ros/include/peer_udp_client.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef OMNI_PEER_UDP_CLIENT_H
|
||||
#define OMNI_PEER_UDP_CLIENT_H
|
||||
|
||||
#include "transport_udp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct udp_client udp_client_t;
|
||||
typedef struct udp_client_recv_meta {
|
||||
message_type_t type;
|
||||
uint64_t id;
|
||||
char from[OMNI_MAX_PEER_ID];
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char file_name[OMNI_MAX_FILE_NAME];
|
||||
size_t body_len;
|
||||
} udp_client_recv_meta_t;
|
||||
|
||||
udp_client_t *udp_client_dial_with_options(const char *server_addr, const char *peer_id, const char *bind_ip, const char *bind_device, latency_logger_t *logger, tx_timestamp_debug_logger_t *debug_logger, int enable_timestamping);
|
||||
udp_client_t *udp_client_dial(const char *server_addr, const char *peer_id, const char *bind_ip, latency_logger_t *logger, tx_timestamp_debug_logger_t *debug_logger, int enable_timestamping);
|
||||
const char *udp_client_id(const udp_client_t *client);
|
||||
int udp_client_send_text(udp_client_t *client, const char *to, const char *text);
|
||||
int udp_client_send_binary(udp_client_t *client, const char *to, const void *data, size_t data_len);
|
||||
int udp_client_send_file_path(udp_client_t *client, const char *to, const char *path);
|
||||
int udp_client_receive_timed(udp_client_t *client, message_t *out_msg, int timeout_ms);
|
||||
int udp_client_receive(udp_client_t *client, message_t *out_msg);
|
||||
int udp_client_receive_into(udp_client_t *client, void *buffer, size_t buffer_len, udp_client_recv_meta_t *out_meta, int timeout_ms);
|
||||
int udp_client_persist_message(udp_client_t *client, const message_t *msg, const char *inbox_dir, char *out_path, size_t out_path_len);
|
||||
int udp_client_close(udp_client_t *client);
|
||||
void udp_client_free(udp_client_t *client);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
62
robot/ros2/OmniSocketGo_robot_ros/include/protocol.h
Normal file
62
robot/ros2/OmniSocketGo_robot_ros/include/protocol.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef OMNI_PROTOCOL_H
|
||||
#define OMNI_PROTOCOL_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum message_type {
|
||||
MSG_TYPE_TEXT = 0,
|
||||
MSG_TYPE_FILE = 1,
|
||||
MSG_TYPE_REGISTER = 2,
|
||||
MSG_TYPE_ERROR = 3,
|
||||
MSG_TYPE_BINARY = 4,
|
||||
MSG_TYPE_INVALID = 255
|
||||
} message_type_t;
|
||||
|
||||
#define SERVER_PEER_ID "server"
|
||||
|
||||
typedef struct message {
|
||||
message_type_t type;
|
||||
uint64_t id;
|
||||
char from[OMNI_MAX_PEER_ID];
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char file_name[OMNI_MAX_FILE_NAME];
|
||||
uint8_t *body;
|
||||
size_t body_len;
|
||||
} message_t;
|
||||
|
||||
typedef struct protocol_frame_decoder {
|
||||
uint8_t *buffer;
|
||||
size_t len;
|
||||
size_t cap;
|
||||
} protocol_frame_decoder_t;
|
||||
|
||||
const char *protocol_message_type_name(message_type_t type);
|
||||
int protocol_message_type_from_name(const char *raw, message_type_t *out);
|
||||
|
||||
void protocol_message_init(message_t *msg);
|
||||
void protocol_message_clear(message_t *msg);
|
||||
int protocol_message_copy(message_t *dst, const message_t *src);
|
||||
|
||||
int protocol_validate_message(const message_t *msg, char *err, size_t err_len);
|
||||
|
||||
int protocol_encode_message_datagram(const message_t *msg, uint8_t **out, size_t *out_len);
|
||||
int protocol_decode_message_datagram(const uint8_t *data, size_t data_len, message_t *out_msg, char *err, size_t err_len);
|
||||
|
||||
int protocol_encode_message_stream(const message_t *msg, uint8_t **out, size_t *out_len);
|
||||
int protocol_decode_message_stream_payload(const uint8_t *payload, size_t payload_len, message_t *out_msg, char *err, size_t err_len);
|
||||
|
||||
void protocol_frame_decoder_init(protocol_frame_decoder_t *decoder);
|
||||
void protocol_frame_decoder_reset(protocol_frame_decoder_t *decoder);
|
||||
void protocol_frame_decoder_destroy(protocol_frame_decoder_t *decoder);
|
||||
int protocol_frame_decoder_feed(protocol_frame_decoder_t *decoder, const uint8_t *data, size_t data_len);
|
||||
int protocol_frame_decoder_next(protocol_frame_decoder_t *decoder, uint8_t **payload, size_t *payload_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
77
robot/ros2/OmniSocketGo_robot_ros/include/ros_image_shm.h
Normal file
77
robot/ros2/OmniSocketGo_robot_ros/include/ros_image_shm.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef OMNI_ROS_IMAGE_SHM_H
|
||||
#define OMNI_ROS_IMAGE_SHM_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ROS_IMAGE_SHM_MAGIC 0x52494d47U /* "RIMG" */
|
||||
#define ROS_IMAGE_SHM_VERSION 1U
|
||||
#define ROS_IMAGE_SHM_HEADER_BYTES 64U
|
||||
#define ROS_IMAGE_SHM_DEFAULT_MAX_FRAME_BYTES (1920U * 1080U * 4U)
|
||||
|
||||
enum ros_image_encoding {
|
||||
ROS_IMAGE_ENCODING_RGB8 = 1,
|
||||
ROS_IMAGE_ENCODING_BGR8 = 2,
|
||||
ROS_IMAGE_ENCODING_RGBA8 = 3,
|
||||
ROS_IMAGE_ENCODING_BGRA8 = 4,
|
||||
ROS_IMAGE_ENCODING_MONO8 = 5
|
||||
};
|
||||
|
||||
/* This layout is also used by the Python ROS2 bridge (struct format <Q8I3Q). */
|
||||
typedef struct ros_image_shm_header {
|
||||
uint64_t sequence; /* odd while writing, even when ready */
|
||||
uint32_t magic;
|
||||
uint32_t version;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
uint32_t encoding;
|
||||
uint32_t data_bytes;
|
||||
uint32_t reserved;
|
||||
uint64_t timestamp_ns;
|
||||
uint64_t reserved2;
|
||||
uint64_t reserved3;
|
||||
} ros_image_shm_header_t;
|
||||
|
||||
typedef struct ros_image_shm_source {
|
||||
int fd;
|
||||
void *mapping;
|
||||
size_t mapping_bytes;
|
||||
size_t max_frame_bytes;
|
||||
uint64_t last_sequence;
|
||||
char path[512];
|
||||
} ros_image_shm_source_t;
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
_Static_assert(sizeof(ros_image_shm_header_t) == ROS_IMAGE_SHM_HEADER_BYTES, "ROS image SHM header size mismatch");
|
||||
#endif
|
||||
|
||||
int ros_image_shm_open(
|
||||
ros_image_shm_source_t *source,
|
||||
const char *path,
|
||||
size_t max_frame_bytes
|
||||
);
|
||||
|
||||
void ros_image_shm_close(ros_image_shm_source_t *source);
|
||||
|
||||
/*
|
||||
* Wait for a newer frame and copy it into caller-owned storage.
|
||||
* Returns 1 for a frame, 0 for timeout, and -1 for an invalid/error frame.
|
||||
*/
|
||||
int ros_image_shm_read_latest(
|
||||
ros_image_shm_source_t *source,
|
||||
uint8_t *destination,
|
||||
size_t destination_bytes,
|
||||
ros_image_shm_header_t *header,
|
||||
int timeout_ms
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
27
robot/ros2/OmniSocketGo_robot_ros/include/server_kcp_hub.h
Normal file
27
robot/ros2/OmniSocketGo_robot_ros/include/server_kcp_hub.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef OMNI_SERVER_KCP_HUB_H
|
||||
#define OMNI_SERVER_KCP_HUB_H
|
||||
|
||||
#include "transport_kcp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct kcp_hub kcp_hub_t;
|
||||
|
||||
kcp_hub_t *kcp_hub_new(latency_logger_t *logger, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
int kcp_hub_serve_listener(kcp_hub_t *hub, kcp_listener_t *listener);
|
||||
int kcp_hub_serve_session(kcp_hub_t *hub, kcp_conn_t *conn);
|
||||
|
||||
int kcp_hub_set_relay(kcp_hub_t *hub, int relay_fd, const struct sockaddr *peer_addr, socklen_t peer_addr_len, int learn_peer);
|
||||
int kcp_hub_set_telemetry(kcp_hub_t *hub, const char *peer_id, int interval_ms);
|
||||
int kcp_hub_serve_relay(kcp_hub_t *hub);
|
||||
|
||||
int kcp_hub_close(kcp_hub_t *hub);
|
||||
void kcp_hub_free(kcp_hub_t *hub);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
21
robot/ros2/OmniSocketGo_robot_ros/include/server_udp_hub.h
Normal file
21
robot/ros2/OmniSocketGo_robot_ros/include/server_udp_hub.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef OMNI_SERVER_UDP_HUB_H
|
||||
#define OMNI_SERVER_UDP_HUB_H
|
||||
|
||||
#include "transport_udp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct udp_hub udp_hub_t;
|
||||
|
||||
udp_hub_t *udp_hub_open(const char *listen_addr, latency_logger_t *logger, tx_timestamp_debug_logger_t *debug_logger, int enable_timestamping);
|
||||
int udp_hub_serve(udp_hub_t *hub);
|
||||
int udp_hub_close(udp_hub_t *hub);
|
||||
void udp_hub_free(udp_hub_t *hub);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
21
robot/ros2/OmniSocketGo_robot_ros/include/server_udp_relay.h
Normal file
21
robot/ros2/OmniSocketGo_robot_ros/include/server_udp_relay.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef OMNI_SERVER_UDP_RELAY_H
|
||||
#define OMNI_SERVER_UDP_RELAY_H
|
||||
|
||||
#include "omni_common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct udp_relay udp_relay_t;
|
||||
|
||||
udp_relay_t *udp_relay_open(const char *listen_addr, const char *upstream_addr);
|
||||
int udp_relay_serve(udp_relay_t *relay);
|
||||
int udp_relay_close(udp_relay_t *relay);
|
||||
void udp_relay_free(udp_relay_t *relay);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
117
robot/ros2/OmniSocketGo_robot_ros/include/transport_kcp.h
Normal file
117
robot/ros2/OmniSocketGo_robot_ros/include/transport_kcp.h
Normal file
@@ -0,0 +1,117 @@
|
||||
#ifndef OMNI_TRANSPORT_KCP_H
|
||||
#define OMNI_TRANSPORT_KCP_H
|
||||
|
||||
#include "kcp_packet_debug.h"
|
||||
#include "kcp_session_stats.h"
|
||||
#include "latencylog.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KCP_DEFAULT_NODELAY 1
|
||||
#define KCP_DEFAULT_INTERVAL_MS 10
|
||||
#define KCP_DEFAULT_RESEND 2
|
||||
#define KCP_DEFAULT_NC 1
|
||||
#define KCP_DEFAULT_SND_WND 256
|
||||
#define KCP_DEFAULT_RCV_WND 256
|
||||
#define KCP_DEFAULT_MTU 1400
|
||||
#define KCP_DEFAULT_STATS_INTERVAL_MS 100
|
||||
|
||||
#define KCP_CONTROL_NODELAY 1
|
||||
#define KCP_CONTROL_INTERVAL_MS 5
|
||||
#define KCP_CONTROL_RESEND 2
|
||||
#define KCP_CONTROL_NC 1
|
||||
#define KCP_CONTROL_SND_WND 32
|
||||
#define KCP_CONTROL_RCV_WND 32
|
||||
#define KCP_CONTROL_MTU 1400
|
||||
|
||||
#define KCP_VIDEO_NODELAY 1
|
||||
#define KCP_VIDEO_INTERVAL_MS 10
|
||||
#define KCP_VIDEO_RESEND 2
|
||||
#define KCP_VIDEO_NC 1
|
||||
#define KCP_VIDEO_SND_WND 256
|
||||
#define KCP_VIDEO_RCV_WND 256
|
||||
#define KCP_VIDEO_MTU 1400
|
||||
|
||||
#define KCP_TELEMETRY_NODELAY 0
|
||||
#define KCP_TELEMETRY_INTERVAL_MS 50
|
||||
#define KCP_TELEMETRY_RESEND 0
|
||||
#define KCP_TELEMETRY_NC 0
|
||||
#define KCP_TELEMETRY_SND_WND 64
|
||||
#define KCP_TELEMETRY_RCV_WND 64
|
||||
#define KCP_TELEMETRY_MTU 1400
|
||||
|
||||
#define KCP_NODELAY KCP_DEFAULT_NODELAY
|
||||
#define KCP_INTERVAL KCP_DEFAULT_INTERVAL_MS
|
||||
#define KCP_RESEND KCP_DEFAULT_RESEND
|
||||
#define KCP_NC KCP_DEFAULT_NC
|
||||
#define KCP_WND_SIZE KCP_DEFAULT_SND_WND
|
||||
#define KCP_MTU KCP_DEFAULT_MTU
|
||||
|
||||
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 min_srtt_ms;
|
||||
int32_t srttvar_ms;
|
||||
uint32_t last_feedback_age_ms;
|
||||
uint32_t snd_wnd;
|
||||
uint32_t rmt_wnd;
|
||||
uint32_t inflight;
|
||||
uint32_t window_limit;
|
||||
double window_pressure_pct;
|
||||
uint32_t snd_queue;
|
||||
uint32_t rcv_queue;
|
||||
uint32_t snd_buffer;
|
||||
uint64_t out_segs_total;
|
||||
uint64_t retrans_total;
|
||||
uint64_t fast_retrans_total;
|
||||
uint64_t lost_total;
|
||||
uint64_t repeat_total;
|
||||
uint32_t xmit_total;
|
||||
} kcp_runtime_stats_t;
|
||||
typedef struct kcp_conn_options {
|
||||
int nodelay;
|
||||
int interval_ms;
|
||||
int resend;
|
||||
int nc;
|
||||
int sndwnd;
|
||||
int rcvwnd;
|
||||
int mtu;
|
||||
} kcp_conn_options_t;
|
||||
|
||||
void kcp_conn_options_init(kcp_conn_options_t *options);
|
||||
void kcp_conn_options_set_control_defaults(kcp_conn_options_t *options);
|
||||
void kcp_conn_options_set_video_defaults(kcp_conn_options_t *options);
|
||||
void kcp_conn_options_set_telemetry_defaults(kcp_conn_options_t *options);
|
||||
|
||||
kcp_conn_t *kcp_conn_dial_with_options(const char *server_addr, const char *bind_ip, const char *bind_device, const kcp_conn_options_t *options, kcp_packet_debug_logger_t *packet_logger, latency_logger_t *logger, const char *node_role, const char *node_id, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
kcp_conn_t *kcp_conn_dial(const char *server_addr, const char *bind_ip, const char *bind_device, kcp_packet_debug_logger_t *packet_logger, latency_logger_t *logger, const char *node_role, const char *node_id, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
int kcp_conn_configure_runtime(kcp_conn_t *conn, latency_logger_t *logger, const char *node_role, const char *node_id, kcp_session_stats_logger_t *stats_logger, int stats_interval_ms);
|
||||
int kcp_conn_apply_options(kcp_conn_t *conn, const kcp_conn_options_t *options);
|
||||
int kcp_conn_send(kcp_conn_t *conn, const message_t *msg);
|
||||
int kcp_conn_receive_timed(kcp_conn_t *conn, message_t *out_msg, int timeout_ms);
|
||||
int kcp_conn_receive(kcp_conn_t *conn, message_t *out_msg);
|
||||
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);
|
||||
int kcp_conn_remote_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);
|
||||
int kcp_listener_close(kcp_listener_t *listener);
|
||||
void kcp_listener_free(kcp_listener_t *listener);
|
||||
|
||||
int kcp_session_stats_parse_interval_ms(const char *raw, int *out_ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
30
robot/ros2/OmniSocketGo_robot_ros/include/transport_udp.h
Normal file
30
robot/ros2/OmniSocketGo_robot_ros/include/transport_udp.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef OMNI_TRANSPORT_UDP_H
|
||||
#define OMNI_TRANSPORT_UDP_H
|
||||
|
||||
#include "latencylog.h"
|
||||
#include "linux_timestamping.h"
|
||||
#include "tx_timestamp_debug.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct udp_conn udp_conn_t;
|
||||
|
||||
udp_conn_t *udp_conn_dial(const char *server_addr, const char *bind_ip, const char *bind_device, int enable_timestamping, latency_logger_t *logger, const char *node_role, const char *node_id, tx_timestamp_debug_logger_t *debug_logger);
|
||||
udp_conn_t *udp_conn_bind(const char *listen_addr, const char *bind_device, int enable_timestamping, latency_logger_t *logger, const char *node_role, const char *node_id, tx_timestamp_debug_logger_t *debug_logger);
|
||||
|
||||
int udp_conn_send(udp_conn_t *conn, const message_t *msg);
|
||||
int udp_conn_send_to(udp_conn_t *conn, const message_t *msg, const struct sockaddr *addr, socklen_t addr_len);
|
||||
int udp_conn_receive(udp_conn_t *conn, message_t *out_msg, struct sockaddr_storage *addr, socklen_t *addr_len);
|
||||
|
||||
int udp_conn_fd(const udp_conn_t *conn);
|
||||
int udp_conn_local_addr(const udp_conn_t *conn, struct sockaddr_storage *addr, socklen_t *addr_len);
|
||||
int udp_conn_close(udp_conn_t *conn);
|
||||
void udp_conn_free(udp_conn_t *conn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef OMNI_TX_TIMESTAMP_DEBUG_H
|
||||
#define OMNI_TX_TIMESTAMP_DEBUG_H
|
||||
|
||||
#include "protocol.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TX_TIMESTAMP_DEBUG_RECORD_SEND_CHUNK "send_chunk"
|
||||
#define TX_TIMESTAMP_DEBUG_RECORD_ERRQUEUE_EVENT "errqueue_event"
|
||||
|
||||
typedef struct tx_timestamp_debug_record {
|
||||
char record_type[32];
|
||||
char node_role[OMNI_MAX_NODE_ROLE];
|
||||
char node_id[OMNI_MAX_PEER_ID];
|
||||
message_type_t message_type;
|
||||
uint64_t message_id;
|
||||
char from[OMNI_MAX_PEER_ID];
|
||||
char to[OMNI_MAX_PEER_ID];
|
||||
char file_name[OMNI_MAX_FILE_NAME];
|
||||
int body_size;
|
||||
char phase[32];
|
||||
int send_call_index;
|
||||
int frame_offset_start;
|
||||
int frame_offset_end;
|
||||
int bytes_written;
|
||||
uint32_t expected_tx_id;
|
||||
int read_index;
|
||||
char event_name[OMNI_MAX_EVENT_NAME];
|
||||
int64_t ts_unix_nano;
|
||||
uint32_t ee_info;
|
||||
uint32_t ee_data;
|
||||
int matched_send_call_index;
|
||||
int selected_for_latency;
|
||||
} tx_timestamp_debug_record_t;
|
||||
|
||||
typedef struct tx_timestamp_debug_logger {
|
||||
omni_file_logger_t file_logger;
|
||||
int enabled;
|
||||
} tx_timestamp_debug_logger_t;
|
||||
|
||||
tx_timestamp_debug_logger_t *tx_timestamp_debug_open_jsonl(const char *path);
|
||||
void tx_timestamp_debug_close(tx_timestamp_debug_logger_t *logger);
|
||||
int tx_timestamp_debug_log(tx_timestamp_debug_logger_t *logger, const tx_timestamp_debug_record_t *record);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
115
robot/ros2/OmniSocketGo_robot_ros/include/video_pipeline.h
Normal file
115
robot/ros2/OmniSocketGo_robot_ros/include/video_pipeline.h
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef OMNI_VIDEO_PIPELINE_H
|
||||
#define OMNI_VIDEO_PIPELINE_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "gps_buffer.h"
|
||||
#include "omni_common.h"
|
||||
#include "peer_kcp_client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
typedef struct __attribute__((packed)) video_pipeline_packet_metadata {
|
||||
#else
|
||||
typedef struct video_pipeline_packet_metadata {
|
||||
#endif
|
||||
uint64_t timestamp_ms;
|
||||
double latitude;
|
||||
double longitude;
|
||||
uint32_t capture_to_send_ms;
|
||||
} video_pipeline_packet_metadata_t;
|
||||
|
||||
typedef struct video_stage_logger {
|
||||
omni_file_logger_t file_logger;
|
||||
int enabled;
|
||||
uint64_t sample_mod;
|
||||
} video_stage_logger_t;
|
||||
|
||||
typedef void (*video_pipeline_progress_fn)(void *context);
|
||||
|
||||
typedef enum video_input_mode {
|
||||
VIDEO_INPUT_ROS2 = 0,
|
||||
VIDEO_INPUT_V4L2 = 1
|
||||
} video_input_mode_t;
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
|
||||
_Static_assert(sizeof(video_pipeline_packet_metadata_t) == 28, "video trailer metadata must be 28 bytes");
|
||||
#endif
|
||||
|
||||
typedef struct video_pipeline_config {
|
||||
video_input_mode_t input_mode;
|
||||
const char *camera_device;
|
||||
const char *camera_head_device;
|
||||
const char *camera_waist_device;
|
||||
const char *ros_head_shm;
|
||||
const char *ros_waist_shm;
|
||||
size_t ros_max_frame_bytes;
|
||||
atomic_int *active_camera;
|
||||
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;
|
||||
video_stage_logger_t *stage_logger;
|
||||
int stats_interval_ms;
|
||||
video_pipeline_progress_fn progress_callback;
|
||||
void *progress_context;
|
||||
} video_pipeline_config_t;
|
||||
|
||||
enum {
|
||||
VIDEO_CAMERA_HEAD = 0,
|
||||
VIDEO_CAMERA_WAIST = 1
|
||||
};
|
||||
|
||||
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;
|
||||
uint32_t last_capture_to_send_ms;
|
||||
double avg_capture_to_send_ms;
|
||||
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);
|
||||
video_stage_logger_t *video_stage_logger_open_jsonl(const char *path, uint64_t sample_mod);
|
||||
void video_stage_logger_close(video_stage_logger_t *logger);
|
||||
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
|
||||
Reference in New Issue
Block a user