|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
ACIP protocol packet sending functions (transport-agnostic) More...
Go to the source code of this file.
Functions | |
| asciichat_error_t | packet_send_via_transport (acip_transport_t *transport, packet_type_t type, const void *payload, size_t payload_len) |
| Send packet via transport with proper header (exported for generic wrappers) | |
| asciichat_error_t | acip_send_audio_batch (acip_transport_t *transport, const float *samples, uint32_t num_samples, uint32_t batch_count) |
| Send audio batch packet. | |
| asciichat_error_t | acip_send_audio_opus (acip_transport_t *transport, const void *opus_data, size_t opus_len) |
| Send Opus-encoded audio packet. | |
| asciichat_error_t | acip_send_audio_opus_batch (acip_transport_t *transport, const void *opus_data, size_t opus_len, const uint16_t *frame_sizes, uint32_t frame_count, uint32_t sample_rate, uint32_t frame_duration) |
| Send batched Opus-encoded audio frames. | |
| asciichat_error_t | acip_send_ping (acip_transport_t *transport) |
| Send ping packet. | |
| asciichat_error_t | acip_send_pong (acip_transport_t *transport) |
| Send pong packet. | |
| asciichat_error_t | acip_send_error (acip_transport_t *transport, uint32_t error_code, const char *message) |
| Send error message packet. | |
| asciichat_error_t | acip_send_remote_log (acip_transport_t *transport, uint8_t log_level, uint8_t direction, const char *message) |
| Send remote log packet. | |
| asciichat_error_t | acip_send_session_created (acip_transport_t *transport, const acip_session_created_t *response) |
| Send SESSION_CREATED response packet. | |
| asciichat_error_t | acip_send_session_info (acip_transport_t *transport, const acip_session_info_t *info) |
| Send SESSION_INFO response packet. | |
| asciichat_error_t | acip_send_session_joined (acip_transport_t *transport, const acip_session_joined_t *response) |
| Send SESSION_JOINED response packet. | |
ACIP protocol packet sending functions (transport-agnostic)
Implementation of send functions that work with any transport. Refactored from lib/network/av.c to use transport abstraction.
Definition in file send.c.
| asciichat_error_t acip_send_audio_batch | ( | acip_transport_t * | transport, |
| const float * | samples, | ||
| uint32_t | num_samples, | ||
| uint32_t | batch_count | ||
| ) |
Send audio batch packet.
| transport | Transport instance |
| samples | Audio samples (float array) |
| num_samples | Number of samples |
| batch_count | Number of batches aggregated |
Definition at line 90 of file send.c.
References AUDIO_SAMPLE_RATE, audio_batch_packet_t::batch_count, buffer_pool_alloc(), buffer_pool_free(), audio_batch_packet_t::channels, ERROR_INVALID_PARAM, ERROR_MEMORY, packet_send_via_transport(), PACKET_TYPE_AUDIO_BATCH, audio_batch_packet_t::sample_rate, SET_ERRNO, and audio_batch_packet_t::total_samples.
| asciichat_error_t acip_send_audio_opus | ( | acip_transport_t * | transport, |
| const void * | opus_data, | ||
| size_t | opus_len | ||
| ) |
Send Opus-encoded audio packet.
| transport | Transport instance |
| opus_data | Opus-encoded audio data |
| opus_len | Length of encoded data |
Definition at line 122 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_AUDIO_OPUS, and SET_ERRNO.
Referenced by client_send_thread_func().
| asciichat_error_t acip_send_audio_opus_batch | ( | acip_transport_t * | transport, |
| const void * | opus_data, | ||
| size_t | opus_len, | ||
| const uint16_t * | frame_sizes, | ||
| uint32_t | frame_count, | ||
| uint32_t | sample_rate, | ||
| uint32_t | frame_duration | ||
| ) |
Send batched Opus-encoded audio frames.
| transport | Transport instance |
| opus_data | Opus-encoded data (multiple frames concatenated) |
| opus_len | Total length of encoded data |
| frame_sizes | Array of individual frame sizes |
| frame_count | Number of frames in batch |
| sample_rate | Sample rate in Hz |
| frame_duration | Duration per frame in milliseconds |
Definition at line 130 of file send.c.
References buffer_pool_alloc(), buffer_pool_free(), ERROR_INVALID_PARAM, ERROR_MEMORY, HOST_TO_NET_U16, HOST_TO_NET_U32, packet_send_via_transport(), PACKET_TYPE_AUDIO_OPUS_BATCH, and SET_ERRNO.
Referenced by threaded_send_audio_opus_batch().
| asciichat_error_t acip_send_error | ( | acip_transport_t * | transport, |
| uint32_t | error_code, | ||
| const char * | message | ||
| ) |
Send error message packet.
| transport | Transport instance |
| error_code | Error code from asciichat_error_t |
| message | Error message (will be truncated to MAX_ERROR_MESSAGE_LENGTH) |
Definition at line 205 of file send.c.
References buffer_pool_alloc(), buffer_pool_free(), error_code, error_packet_t::error_code, ERROR_INVALID_PARAM, ERROR_MEMORY, HOST_TO_NET_U32, MAX_ERROR_MESSAGE_LENGTH, error_packet_t::message_length, packet_send_via_transport(), PACKET_TYPE_ERROR_MESSAGE, and SET_ERRNO.
| asciichat_error_t acip_send_ping | ( | acip_transport_t * | transport | ) |
Send ping packet.
| transport | Transport instance |
Definition at line 175 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_PING, and SET_ERRNO.
| asciichat_error_t acip_send_pong | ( | acip_transport_t * | transport | ) |
Send pong packet.
| transport | Transport instance |
Definition at line 184 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_PONG, and SET_ERRNO.
Referenced by process_decrypted_packet().
| asciichat_error_t acip_send_remote_log | ( | acip_transport_t * | transport, |
| uint8_t | log_level, | ||
| uint8_t | direction, | ||
| const char * | message | ||
| ) |
Send remote log packet.
| transport | Transport instance |
| log_level | Log level (0=DEBUG, 1=INFO, 2=WARN, 3=ERROR) |
| direction | Direction hint (0=client->server, 1=server->client) |
| message | Log message |
Definition at line 242 of file send.c.
References buffer_pool_alloc(), buffer_pool_free(), remote_log_packet_t::direction, ERROR_INVALID_PARAM, ERROR_MEMORY, remote_log_packet_t::flags, HOST_TO_NET_U32, remote_log_packet_t::log_level, remote_log_packet_t::message_length, packet_send_via_transport(), PACKET_TYPE_REMOTE_LOG, and SET_ERRNO.
| asciichat_error_t acip_send_session_created | ( | acip_transport_t * | transport, |
| const acip_session_created_t * | response | ||
| ) |
Send SESSION_CREATED response packet.
| transport | Transport instance |
| response | Session created response structure |
Definition at line 277 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_ACIP_SESSION_CREATED, and SET_ERRNO.
| asciichat_error_t acip_send_session_info | ( | acip_transport_t * | transport, |
| const acip_session_info_t * | info | ||
| ) |
Send SESSION_INFO response packet.
| transport | Transport instance |
| info | Session info structure |
Definition at line 285 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_ACIP_SESSION_INFO, and SET_ERRNO.
| asciichat_error_t acip_send_session_joined | ( | acip_transport_t * | transport, |
| const acip_session_joined_t * | response | ||
| ) |
Send SESSION_JOINED response packet.
| transport | Transport instance |
| response | Session joined response structure |
Definition at line 293 of file send.c.
References ERROR_INVALID_PARAM, packet_send_via_transport(), PACKET_TYPE_ACIP_SESSION_JOINED, and SET_ERRNO.
| asciichat_error_t packet_send_via_transport | ( | acip_transport_t * | transport, |
| packet_type_t | type, | ||
| const void * | payload, | ||
| size_t | payload_len | ||
| ) |
Send packet via transport with proper header (exported for generic wrappers)
Send arbitrary packet via transport (generic packet sender)
Wraps payload in ACIP packet header and sends via transport. Handles CRC32 calculation and network byte order conversion.
| transport | Transport instance |
| type | Packet type |
| payload | Payload data (may be NULL if payload_len is 0) |
| payload_len | Payload length |
Definition at line 40 of file send.c.
References asciichat_crc32, buffer_pool_alloc(), buffer_pool_free(), packet_header_t::client_id, packet_header_t::crc32, ERROR_INVALID_PARAM, ERROR_MEMORY, HOST_TO_NET_U16, HOST_TO_NET_U32, packet_header_t::length, packet_header_t::magic, PACKET_MAGIC, SET_ERRNO, and packet_header_t::type.
Referenced by acip_send_ascii_frame(), acip_send_audio_batch(), acip_send_audio_opus(), acip_send_audio_opus_batch(), acip_send_capabilities(), acip_send_clear_console(), acip_send_client_join(), acip_send_client_leave(), acip_send_error(), acip_send_image_frame(), acip_send_ping(), acip_send_pong(), acip_send_protocol_version(), acip_send_remote_log(), acip_send_server_state(), acip_send_session_created(), acip_send_session_info(), acip_send_session_joined(), acip_send_stream_start(), acip_send_stream_stop(), client_send_thread_func(), threaded_send_audio_opus(), and threaded_send_packet().