ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
connection_internal.h
Go to the documentation of this file.
1#pragma once
2
3/* Existing buffer budgets in bytes, including NUL for text storage. */
4#define MAX_BATCH_FRAMES 16
5
8#include <ascii-chat/otel.h>
9#include "connection.h"
10#include "session/connection.h"
11#include "session/protocol.h"
12#include "session/capture.h"
13#include "session/display.h"
15
16#include <ascii-chat/common.h>
17#include <ascii-chat/buffer.h>
18#include <libplatform/atomic.h>
19#include <libplatform/compiler.h>
20#include <libplatform/system.h>
21#include <libplatform/terminal.h>
23#include <libplatform/lifecycle.h>
24#include <ascii-chat/util/fps.h>
29
30typedef struct {
31 uint8_t data[MAX_BATCH_FRAMES * CLIENT_AUDIO_PIPELINE_MAX_OPUS_PACKET]; // Queue storage permits the pipeline packet
32 // budget for each frame.
33 size_t size;
36 gotel_context_t telemetry_context;
43
45#define AUDIO_SEND_QUEUE_SIZE 32
46
47/* Mutable state belongs to one attempt. Application devices and UI outlive it. */
50 atomic_ptr_t transport;
51 // Application resources are borrowed explicitly by this connection.
72 atomic_t remote_error;
78 mutex_t send_mutex;
79 crypto_handshake_context_t *crypto_ctx; // Borrowed from network until its users join.
81 buffer_workspace_t encoded_video_workspace; // Owned exclusively by the capture worker.
82 buffer_workspace_t decoded_ascii_workspace; // Owned exclusively by the receive worker.
87 terminal_size_t advertised_dimensions; // Last dimensions successfully sent to this server.
99 bool audio_send_direct; // The transport already owns an asynchronous outbound queue.
107};
108
109// Zero means no outstanding ping; the clock itself may return zero at startup.
110static inline void client_connection_mark_ping_sent(client_connection_t *connection, uint64_t timestamp_ns) {
111 uint64_t empty = 0;
112 if (!timestamp_ns)
113 timestamp_ns = 1;
114 if (!atomic_cas_u64(&connection->telemetry_ping_ns, &empty, timestamp_ns))
115 atomic_store_u64(&connection->telemetry_ping_ns, UINT64_MAX);
116}
#define CLIENT_AUDIO_PIPELINE_MAX_OPUS_PACKET
Unified client-side audio processing pipeline.
Application limits and constraints.
๐Ÿ“น Unified media capture abstraction for session-based video sources
โš™๏ธ Common definitions, error codes, macros, and types shared throughout the application
#define MAX_BATCH_FRAMES
#define AUDIO_SEND_QUEUE_SIZE
Common declarations and data structures for cryptographic handshake.
struct h265_encoder h265_encoder_t
h265 encoder is intentionally a small, concrete record. Fields such as codec_ctx, codec,...
HEVC/H.265 encoder for ASCII art frames using libx265.
โฑ๏ธ FPS tracking utility for monitoring frame throughput across all threads
unsigned short uint16_t
Definition common.h:61
unsigned int uint32_t
Definition common.h:62
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
#define HOSTNAME_BUFFER_SIZE
struct session_display_ctx session_display_ctx_t
session display config is intentionally a small, concrete record. Fields such as snapshot_mode,...
struct session_capture_ctx session_capture_ctx_t
session capture config keeps the values that move through the subsystem: type, path,...
๐Ÿ”Š Audio Capture and Playback Interface for ascii-chat
struct network_connection network_connection_t
struct thread_pool thread_pool_t
One queued function call waiting for a thread-pool worker.
struct client_connection client_connection_t
๐Ÿ–ฅ๏ธ Unified terminal display abstraction for session-based rendering
When code needs to work with audio device info, it keeps index, max_input_channels,...
uint8_t data[16 *CLIENT_AUDIO_PIPELINE_MAX_OPUS_PACKET]
gotel_context_t telemetry_context
Owns the temporary storage used by buffer workspace. The data pointers and size or cursor fields desc...
Definition buffer.h:102
Client audio pipeline state.
network_connection_t * network
client_audio_pipeline_t * audio_pipeline
crypto_handshake_context_t * crypto_ctx
thread_pool_t * client_worker_pool
char server_ip[HOSTNAME_BUFFER_SIZE]
atomic_t snapshot_first_frame_time_ns
buffer_workspace_t encoded_video_workspace
session_protocol_t protocol
audio_send_packet_t audio_send_queue[32]
session_capture_ctx_t * capture_context
atomic_t audio_capture_thread_exited
session_display_ctx_t * display_context
buffer_workspace_t decoded_ascii_workspace
h265_encoder_t *volatile video_encoder
lifecycle_t audio_send_queue_lc
terminal_size_t advertised_dimensions
audio_context_t * audio_context
session_connection_t lifecycle
Cryptographic handshake context structure.
Counters and timestamps used to calculate and report frame rate.
Definition fps.h:53
Groups the callbacks and caller data for session connection ops. The owner invokes these function poi...
session protocol media keeps the values that move through the subsystem: context, terminal_output,...
๐Ÿงต Generic thread pool abstraction for managing worker threads