Browse Source

Share call session ownership with the video transport

stream-multiview
evgeny 1 week ago
parent
commit
dffde9691d
  1. 52
      src/call/call.c
  2. 37
      src/call/call_priv.h

52
src/call/call.c

@ -12,6 +12,7 @@
// коллбэков conn_mgr/таймеров.
#include "call.h"
#include "call_priv.h"
#include "call_proto.h"
#include "../dm/dm_core.h"
#include "../utun_instance.h"
@ -35,55 +36,6 @@
#define CALL_ID "call"
enum call_state {
CALL_ST_IDLE = 0,
CALL_ST_OUTGOING, /* caller: INVITE отправлен */
CALL_ST_RINGING, /* caller: получил RINGING; callee: отправил RINGING */
CALL_ST_ACTIVE, /* вызов принят; доставка через роутер независимо от готовности CM */
CALL_ST_ENDED,
};
enum call_role { CALL_ROLE_CALLER = 0, CALL_ROLE_CALLEE };
struct call_session {
struct ll_entry ll; /* dummy-заголовок; структура хранится в entry->data */
uint64_t call_id; /* hash-индекс (8 байт) */
uint64_t group_id;
uint64_t peer_node_id;
uint8_t role; /* CALL_ROLE_* */
uint8_t state; /* CALL_ST_* */
uint8_t reason; /* CALL_REASON_* (при ENDED) */
struct call_ctx* ctx; /* обратная ссылка (для коллбэков conn_mgr/таймеров) */
struct CONN_MGR_HANDLE* cm_handle;
void* ring_timer; /* caller: 45с ожидания ответа; callee: 2с watchdog кодограмм */
void* invite_timer; /* caller: кодограмма INVITE каждые 300мс (OUTGOING+RINGING) */
uint8_t no_route_strikes; /* caller: подряд ретрансмитов без маршрута (fail-fast) */
void* traffic_timer; /* ACTIVE: 20с без медиа (запускается по первому медиа) */
void* teardown_timer; /* отложенный разрыв conn_mgr (500мс после завершения) */
void* stats_timer; /* Раз в 1с — путь подключения; в ACTIVE также CALL_STATS. */
uint8_t connection_reported, connection_type;
uint64_t connection_next_hop;
uint64_t last_media_tb; /* время последнего CALL_MEDIA (0.1ms) */
uint16_t tx_media_seq; /* seq следующего исходящего CALL_MEDIA */
struct ll_queue* tx_q; /* FIFO закодированных CALL_MEDIA (backpressure) */
struct queue_waiter_handle send_waiter; /* waiter на send_q роутера */
uint32_t c_tx_frames; /* отправлено медиа-кадров */
uint32_t c_rx_frames; /* принято медиа-кадров */
uint32_t c_tx_dropped; /* дропнуто при переполнении tx_q */
uint32_t c_rx_dropped; /* дропнуто при переполнении jitter-буфера */
};
struct call_ctx {
struct UTUN_INSTANCE* inst;
int initialized;
struct ll_queue* sessions; /* struct call_session, hash по call_id */
uint32_t c_calls_started; /* суммарно начато звонков */
uint32_t c_calls_ended; /* суммарно завершено звонков */
call_media_recv_fn media_recv_fn; /* приём Opus-кадров пира */
void* media_recv_arg;
const struct call_audio_ops* audio_ops; /* аудио-движок (GUI-сборки), NULL в демоне */
};
/* ───────────────────────────────────────────────────────────────────────── */
static struct call_ctx* call_of(struct UTUN_INSTANCE* inst) {
@ -156,7 +108,7 @@ static int call_send_invite(struct call_ctx* ctx, struct call_session* s) {
/* ─────────────────── реестр сессий ─────────────────── */
static struct call_session* call_session_find(struct call_ctx* ctx, uint64_t call_id) {
struct call_session* call_session_find(struct call_ctx* ctx, uint64_t call_id) {
if (!ctx || !ctx->sessions) return NULL;
struct ll_entry* e = queue_find_data_by_index(ctx->sessions, &call_id);
return e ? (struct call_session*)e->data : NULL;

37
src/call/call_priv.h

@ -0,0 +1,37 @@
/* Внутреннее состояние call.c/call_video_transport.c; доступ только из uasync. */
#ifndef CALL_PRIV_H
#define CALL_PRIV_H
#include "call.h"
#include "../../lib/ll_queue.h"
enum call_state { CALL_ST_IDLE, CALL_ST_OUTGOING, CALL_ST_RINGING, CALL_ST_ACTIVE, CALL_ST_ENDED };
enum call_role { CALL_ROLE_CALLER, CALL_ROLE_CALLEE };
struct call_video_transport;
struct call_session {
struct ll_entry ll;
uint64_t call_id, group_id, peer_node_id;
uint8_t role, state, reason;
struct call_ctx *ctx;
struct CONN_MGR_HANDLE *cm_handle;
void *ring_timer, *invite_timer;
uint8_t no_route_strikes;
void *traffic_timer, *teardown_timer, *stats_timer;
uint8_t connection_reported, connection_type;
uint64_t connection_next_hop, last_media_tb;
uint16_t tx_media_seq;
struct ll_queue *tx_q;
struct queue_waiter_handle send_waiter;
uint32_t c_tx_frames, c_rx_frames, c_tx_dropped, c_rx_dropped;
struct call_video_transport *video;
};
struct call_ctx {
struct UTUN_INSTANCE *inst;
int initialized;
struct ll_queue *sessions;
uint32_t c_calls_started, c_calls_ended;
call_media_recv_fn media_recv_fn;
void *media_recv_arg;
const struct call_audio_ops *audio_ops;
};
struct call_session *call_session_find(struct call_ctx *ctx, uint64_t call_id);
#endif
Loading…
Cancel
Save