|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
Go to the source code of this file.
Macros | |
| #define | WASM_LOG(msg) EM_ASM({ console.error('[C] ' + UTF8ToString($0)); }, msg) |
| #define | WASM_LOG_INT(msg, val) EM_ASM({ console.error('[C] ' + UTF8ToString($0) + ': ' + $1); }, msg, val) |
| #define | WASM_ERROR(msg) EM_ASM({ console.error('[C] ERROR: ' + UTF8ToString($0)); }, msg) |
Enumerations | |
| enum | connection_state_t { CONNECTION_STATE_DISCONNECTED = 0 , CONNECTION_STATE_CONNECTING = 1 , CONNECTION_STATE_HANDSHAKE = 2 , CONNECTION_STATE_CONNECTED = 3 , CONNECTION_STATE_ERROR = 4 } |
Functions | |
| EM_JS (void, js_send_raw_packet,(const uint8_t *packet_data, size_t packet_len), { if(!Module.sendPacketCallback) { console.error('[WASM] sendPacketCallback not registered - cannot send packet');return;} const packetArray=new Uint8Array(HEAPU8.buffer, packet_data, packet_len);const packetCopy=new Uint8Array(packetArray);var pktType=packetCopy.length >=10 ?((packetCopy[8]<< 8)|packetCopy[9]) :-1;console.error('[WASM->JS] Sending raw packet:', packetCopy.length, 'bytes, type=0x'+pktType.toString(16));Module.sendPacketCallback(packetCopy);}) | |
| EMSCRIPTEN_KEEPALIVE int | client_init_with_args (const char *args_json) |
| EMSCRIPTEN_KEEPALIVE void | client_cleanup (void) |
| EMSCRIPTEN_KEEPALIVE int | client_generate_keypair (void) |
| EMSCRIPTEN_KEEPALIVE int | client_set_server_address (const char *server_host, int server_port) |
| EMSCRIPTEN_KEEPALIVE char * | client_get_public_key_hex (void) |
| EMSCRIPTEN_KEEPALIVE int | client_handle_key_exchange_init (const uint8_t *packet, size_t packet_len) |
| EMSCRIPTEN_KEEPALIVE int | client_handle_auth_challenge (const uint8_t *packet, size_t packet_len) |
| EMSCRIPTEN_KEEPALIVE int | client_handle_handshake_complete (const uint8_t *packet, size_t packet_len) |
| EMSCRIPTEN_KEEPALIVE int | client_encrypt_packet (const uint8_t *plaintext, size_t plaintext_len, uint8_t *ciphertext, size_t ciphertext_size, size_t *out_len) |
| EMSCRIPTEN_KEEPALIVE int | client_decrypt_packet (const uint8_t *ciphertext, size_t ciphertext_len, uint8_t *plaintext, size_t plaintext_size, size_t *out_len) |
| EMSCRIPTEN_KEEPALIVE char * | client_parse_packet (const uint8_t *raw_packet, size_t packet_len) |
| EMSCRIPTEN_KEEPALIVE int | client_serialize_packet (uint16_t packet_type, const uint8_t *payload, size_t payload_len, uint32_t client_id, uint8_t *output, size_t *out_len) |
| EMSCRIPTEN_KEEPALIVE int | client_send_video_frame (const uint8_t *rgba_data, int width, int height) |
| EMSCRIPTEN_KEEPALIVE int | client_get_connection_state (void) |
| EMSCRIPTEN_KEEPALIVE void | client_free_string (char *ptr) |
| EMSCRIPTEN_KEEPALIVE int | client_opus_encoder_init (int sample_rate, int channels, int bitrate) |
| EMSCRIPTEN_KEEPALIVE int | client_opus_decoder_init (int sample_rate, int channels) |
| EMSCRIPTEN_KEEPALIVE int | client_opus_encode (const int16_t *pcm_data, int frame_size, uint8_t *opus_data, int max_opus_bytes) |
| EMSCRIPTEN_KEEPALIVE int | client_opus_decode (const uint8_t *opus_data, int opus_bytes, int16_t *pcm_data, int frame_size, int decode_fec) |
| EMSCRIPTEN_KEEPALIVE void | client_opus_encoder_cleanup (void) |
| EMSCRIPTEN_KEEPALIVE void | client_opus_decoder_cleanup (void) |
| EMSCRIPTEN_KEEPALIVE const char * | get_help_text (int mode, const char *option_name) |
| #define WASM_ERROR | ( | msg | ) | EM_ASM({ console.error('[C] ERROR: ' + UTF8ToString($0)); }, msg) |
Definition at line 14 of file src/web/client.c.
| #define WASM_LOG | ( | msg | ) | EM_ASM({ console.error('[C] ' + UTF8ToString($0)); }, msg) |
Definition at line 12 of file src/web/client.c.
| #define WASM_LOG_INT | ( | msg, | |
| val | |||
| ) | EM_ASM({ console.error('[C] ' + UTF8ToString($0) + ': ' + $1); }, msg, val) |
Definition at line 13 of file src/web/client.c.
| enum connection_state_t |
| Enumerator | |
|---|---|
| CONNECTION_STATE_DISCONNECTED | |
| CONNECTION_STATE_CONNECTING | |
| CONNECTION_STATE_HANDSHAKE | |
| CONNECTION_STATE_CONNECTED | |
| CONNECTION_STATE_ERROR | |
Definition at line 121 of file src/web/client.c.
| EMSCRIPTEN_KEEPALIVE void client_cleanup | ( | void | ) |
Definition at line 206 of file src/web/client.c.
References CONNECTION_STATE_DISCONNECTED, crypto_handshake_destroy(), options_state_destroy(), platform_destroy(), WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_decrypt_packet | ( | const uint8_t * | ciphertext, |
| size_t | ciphertext_len, | ||
| uint8_t * | plaintext, | ||
| size_t | plaintext_size, | ||
| size_t * | out_len | ||
| ) |
Decrypt a ciphertext packet
| ciphertext | Input ciphertext data |
| ciphertext_len | Length of ciphertext |
| plaintext | Output buffer (allocated by caller, must be at least ciphertext_len) |
| plaintext_size | Size of plaintext buffer |
| out_len | Output parameter for plaintext length |
Definition at line 582 of file src/web/client.c.
References crypto_decrypt(), and WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE int client_encrypt_packet | ( | const uint8_t * | plaintext, |
| size_t | plaintext_len, | ||
| uint8_t * | ciphertext, | ||
| size_t | ciphertext_size, | ||
| size_t * | out_len | ||
| ) |
Encrypt a plaintext packet
| plaintext | Input plaintext data |
| plaintext_len | Length of plaintext |
| ciphertext | Output buffer (allocated by caller, must be at least plaintext_len + crypto_aead_overhead) |
| ciphertext_size | Size of ciphertext buffer |
| out_len | Output parameter for ciphertext length |
Definition at line 552 of file src/web/client.c.
References crypto_encrypt(), and WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE void client_free_string | ( | char * | ptr | ) |
Definition at line 725 of file src/web/client.c.
| EMSCRIPTEN_KEEPALIVE int client_generate_keypair | ( | void | ) |
Generate client keypair for handshake
Definition at line 234 of file src/web/client.c.
References CONNECTION_STATE_DISCONNECTED, crypto_handshake_destroy(), crypto_handshake_init(), WASM_ERROR, WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_get_connection_state | ( | void | ) |
Get current connection state
Definition at line 716 of file src/web/client.c.
| EMSCRIPTEN_KEEPALIVE char * client_get_public_key_hex | ( | void | ) |
Get client public key as hex string
Definition at line 302 of file src/web/client.c.
References WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE int client_handle_auth_challenge | ( | const uint8_t * | packet, |
| size_t | packet_len | ||
| ) |
Handle CRYPTO_AUTH_CHALLENGE packet from server
| packet | Raw packet data including header |
| packet_len | Total packet length |
Definition at line 426 of file src/web/client.c.
References buffer_pool_alloc(), CONNECTION_STATE_ERROR, crypto_handshake_client_auth_response(), WASM_ERROR, WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_handle_handshake_complete | ( | const uint8_t * | packet, |
| size_t | packet_len | ||
| ) |
Handle CRYPTO_HANDSHAKE_COMPLETE packet from server
| packet | Raw packet data including header |
| packet_len | Total packet length |
Definition at line 485 of file src/web/client.c.
References buffer_pool_alloc(), CONNECTION_STATE_CONNECTED, CONNECTION_STATE_ERROR, crypto_handshake_client_complete(), WASM_ERROR, WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_handle_key_exchange_init | ( | const uint8_t * | packet, |
| size_t | packet_len | ||
| ) |
Handle CRYPTO_KEY_EXCHANGE_INIT packet from server This is the first step of the crypto handshake
| packet | Raw packet data including header |
| packet_len | Total packet length |
Definition at line 339 of file src/web/client.c.
References buffer_pool_alloc(), CONNECTION_STATE_ERROR, CONNECTION_STATE_HANDSHAKE, crypto_handshake_client_key_exchange(), crypto_handshake_destroy(), crypto_handshake_init(), WASM_ERROR, WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_init_with_args | ( | const char * | args_json | ) |
Initialize client mode with command-line style arguments
| args_json | Space-separated string of argument strings, e.g. "client --width 80 --height 40" |
Definition at line 141 of file src/web/client.c.
References ansi_fast_init(), CONNECTION_STATE_DISCONNECTED, log_init(), options_init(), platform_init(), WASM_ERROR, WASM_LOG, and WASM_LOG_INT.
| EMSCRIPTEN_KEEPALIVE int client_opus_decode | ( | const uint8_t * | opus_data, |
| int | opus_bytes, | ||
| int16_t * | pcm_data, | ||
| int | frame_size, | ||
| int | decode_fec | ||
| ) |
Decode Opus audio to PCM
| opus_data | Input Opus data |
| opus_bytes | Length of Opus data |
| pcm_data | Output buffer for PCM samples (Int16) |
| frame_size | Maximum number of samples per channel |
| decode_fec | Whether to use FEC |
Definition at line 819 of file src/web/client.c.
References WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE void client_opus_decoder_cleanup | ( | void | ) |
Cleanup Opus decoder
Definition at line 850 of file src/web/client.c.
References WASM_LOG.
| EMSCRIPTEN_KEEPALIVE int client_opus_decoder_init | ( | int | sample_rate, |
| int | channels | ||
| ) |
Initialize Opus decoder
| sample_rate | Sample rate (8000, 16000, 24000, or 48000) |
| channels | Number of channels (1=mono, 2=stereo) |
Definition at line 768 of file src/web/client.c.
References WASM_ERROR, and WASM_LOG.
| EMSCRIPTEN_KEEPALIVE int client_opus_encode | ( | const int16_t * | pcm_data, |
| int | frame_size, | ||
| uint8_t * | opus_data, | ||
| int | max_opus_bytes | ||
| ) |
Encode PCM audio to Opus
| pcm_data | Input PCM data (Int16 samples) |
| frame_size | Number of samples per channel |
| opus_data | Output buffer for Opus data |
| max_opus_bytes | Maximum size of output buffer |
Definition at line 794 of file src/web/client.c.
References WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE void client_opus_encoder_cleanup | ( | void | ) |
Cleanup Opus encoder
Definition at line 838 of file src/web/client.c.
References WASM_LOG.
| EMSCRIPTEN_KEEPALIVE int client_opus_encoder_init | ( | int | sample_rate, |
| int | channels, | ||
| int | bitrate | ||
| ) |
Initialize Opus encoder
| sample_rate | Sample rate (8000, 16000, 24000, or 48000) |
| channels | Number of channels (1=mono, 2=stereo) |
| bitrate | Target bitrate in bits/sec |
Definition at line 741 of file src/web/client.c.
References WASM_ERROR, and WASM_LOG.
| EMSCRIPTEN_KEEPALIVE char * client_parse_packet | ( | const uint8_t * | raw_packet, |
| size_t | packet_len | ||
| ) |
Parse a raw packet and return JSON metadata
| raw_packet | Raw packet bytes including header |
| packet_len | Length of raw packet |
Definition at line 609 of file src/web/client.c.
References WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE int client_send_video_frame | ( | const uint8_t * | rgba_data, |
| int | width, | ||
| int | height | ||
| ) |
Process a video frame and prepare it for sending
| rgba_data | RGBA pixel data from canvas |
| width | Frame width |
| height | Frame height |
Definition at line 691 of file src/web/client.c.
References WASM_ERROR, and WASM_LOG.
| EMSCRIPTEN_KEEPALIVE int client_serialize_packet | ( | uint16_t | packet_type, |
| const uint8_t * | payload, | ||
| size_t | payload_len, | ||
| uint32_t | client_id, | ||
| uint8_t * | output, | ||
| size_t * | out_len | ||
| ) |
Serialize a packet structure to raw bytes
| packet_type | Type of packet |
| payload | Packet payload data |
| payload_len | Length of payload |
| client_id | Client ID to include in header |
| output | Output buffer (allocated by caller) |
| out_len | Output parameter for total packet length |
Definition at line 654 of file src/web/client.c.
References asciichat_crc32_sw(), and WASM_ERROR.
| EMSCRIPTEN_KEEPALIVE int client_set_server_address | ( | const char * | server_host, |
| int | server_port | ||
| ) |
Set server address for known_hosts verification
| server_host | Server hostname or IP address |
| server_port | Server port number |
Definition at line 278 of file src/web/client.c.
References WASM_ERROR, and WASM_LOG.
| EM_JS | ( | void | , |
| js_send_raw_packet | , | ||
| (const uint8_t *packet_data, size_t packet_len) | , | ||
| { if(!Module.sendPacketCallback) { console.error('[WASM] sendPacketCallback not registered - cannot send packet');return;} const packetArray=new Uint8Array(HEAPU8.buffer, packet_data, packet_len);const packetCopy=new Uint8Array(packetArray);var pktType=packetCopy.length >=10 ?((packetCopy[8]<< 8)|packetCopy[9]) :-1;console.error('[WASM->JS] Sending raw packet:', packetCopy.length, 'bytes, type=0x'+pktType.toString(16));Module.sendPacketCallback(packetCopy);} | |||
| ) |
| EMSCRIPTEN_KEEPALIVE const char * get_help_text | ( | int | mode, |
| const char * | option_name | ||
| ) |
Get help text for an option in a specific mode Exported for web client to retrieve tooltips for settings
| mode | The mode (0=server, 1=client, 2=mirror, etc.) |
| option_name | The long name of the option (e.g., "color-mode", "fps") |
Definition at line 866 of file src/web/client.c.
References options_get_help_text().