Carry capture timestamps and Opus delay in call media protocol
This commit is contained in:
1 parent
fe2fa73cc0
commit
ab04b14237
3 files changed
+17
-4
No files matched your search
+5
-2
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "call_jitter.h"
|
#include "call_jitter.h"
|
||||||
|
#include "call_clock.h"
|
||||||
|
|
||||||
struct UTUN_INSTANCE;
|
struct UTUN_INSTANCE;
|
||||||
|
|
||||||
@@ -42,7 +43,8 @@ int call_is_online(struct UTUN_INSTANCE* inst, const char* ch_id, uint64_t peer
|
|||||||
|
|
||||||
/* Отправить закодированный Opus-кадр пиру (оборачивает в CALL_MEDIA).
|
/* Отправить закодированный Opus-кадр пиру (оборачивает в CALL_MEDIA).
|
||||||
* Только когда звонок ACTIVE. seq/ts выставляются автоматически. */
|
* Только когда звонок ACTIVE. seq/ts выставляются автоматически. */
|
||||||
int call_send_media(struct UTUN_INSTANCE* inst, uint64_t call_id, const uint8_t* opus, int len);
|
int call_send_media(struct UTUN_INSTANCE* inst, uint64_t call_id, const uint8_t* opus, int len,
|
||||||
|
const struct call_capture_time* timing);
|
||||||
|
|
||||||
/* Коллбэк приёма медиа: вызывается в uasync-потоке на каждый Opus-кадр пира.
|
/* Коллбэк приёма медиа: вызывается в uasync-потоке на каждый Opus-кадр пира.
|
||||||
* Используется headless-аудио-сокетом (и в фазе 3 — декодером GUI). */
|
* Используется headless-аудио-сокетом (и в фазе 3 — декодером GUI). */
|
||||||
@@ -58,7 +60,7 @@ void call_set_media_recv_cb(struct UTUN_INSTANCE* inst, call_media_recv_fn fn, v
|
|||||||
struct call_audio_ops {
|
struct call_audio_ops {
|
||||||
/* uasync-поток: принятый Opus-кадр пира (декод + jitter-буфер). */
|
/* uasync-поток: принятый Opus-кадр пира (декод + jitter-буфер). */
|
||||||
void (*on_media)(struct UTUN_INSTANCE* inst, uint64_t call_id,
|
void (*on_media)(struct UTUN_INSTANCE* inst, uint64_t call_id,
|
||||||
uint16_t seq, uint32_t ts_ms, const uint8_t* opus, int len);
|
uint16_t seq, uint32_t ts_ms, const uint8_t* opus, int len, const struct call_capture_time* timing);
|
||||||
/* uasync-поток: текущие метрики джиттер-буфера (buffer_ms, tempo_x100,
|
/* uasync-поток: текущие метрики джиттер-буфера (buffer_ms, tempo_x100,
|
||||||
* dropped/underruns — опционально, NULL допустим). */
|
* dropped/underruns — опционально, NULL допустим). */
|
||||||
int (*get_stats)(uint64_t call_id, int* buffer_ms, int* tempo_x100,
|
int (*get_stats)(uint64_t call_id, int* buffer_ms, int* tempo_x100,
|
||||||
@@ -71,6 +73,7 @@ struct call_media_arg {
|
|||||||
struct UTUN_INSTANCE* inst;
|
struct UTUN_INSTANCE* inst;
|
||||||
uint64_t call_id;
|
uint64_t call_id;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
|
struct call_capture_time timing;
|
||||||
uint8_t opus[256];
|
uint8_t opus[256];
|
||||||
};
|
};
|
||||||
void call_send_media_trampoline(void* arg);
|
void call_send_media_trampoline(void* arg);
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
#ifndef CALL_CLOCK_H
|
#ifndef CALL_CLOCK_H
|
||||||
#define CALL_CLOCK_H
|
#define CALL_CLOCK_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
/* pts_us — первый захваченный сэмпл; INT64_MIN означает отсутствие метки.
|
||||||
|
* delay_samples — задержка Opus от encoder. epoch меняется при разрыве захвата. */
|
||||||
|
struct call_capture_time {
|
||||||
|
int64_t pts_us;
|
||||||
|
uint64_t epoch;
|
||||||
|
uint32_t delay_samples;
|
||||||
|
};
|
||||||
struct call_clock_snapshot {
|
struct call_clock_snapshot {
|
||||||
uint64_t epoch, source_epoch, played_samples, written_samples;
|
uint64_t epoch, source_epoch, played_samples, written_samples;
|
||||||
int64_t pts_us;
|
int64_t pts_us;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ enum {
|
|||||||
CALL_SUBCMD_BUSY = 0x05, /* {call_id:8} */
|
CALL_SUBCMD_BUSY = 0x05, /* {call_id:8} */
|
||||||
CALL_SUBCMD_CANCEL = 0x06, /* {call_id:8} */
|
CALL_SUBCMD_CANCEL = 0x06, /* {call_id:8} */
|
||||||
CALL_SUBCMD_HANGUP = 0x07, /* {call_id:8, reason:1} */
|
CALL_SUBCMD_HANGUP = 0x07, /* {call_id:8, reason:1} */
|
||||||
CALL_SUBCMD_MEDIA = 0x10, /* {call_id:8, track_id:1, seq:2, ts_ms:4, payload[]} */
|
CALL_SUBCMD_MEDIA = 0x10, /* call_pkt_media + payload[] */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ── треки и кодеки (модель расширяема под видео) ── */
|
/* ── треки и кодеки (модель расширяема под видео) ── */
|
||||||
@@ -71,12 +71,15 @@ struct call_pkt_media {
|
|||||||
uint8_t track_id;
|
uint8_t track_id;
|
||||||
uint16_t seq;
|
uint16_t seq;
|
||||||
uint32_t ts_ms;
|
uint32_t ts_ms;
|
||||||
|
int64_t capture_pts_us; /* INT64_MIN — источник не предоставляет capture clock. */
|
||||||
|
uint64_t capture_epoch;
|
||||||
|
uint32_t codec_delay_samples;
|
||||||
/* payload[] */
|
/* payload[] */
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define CALL_MEDIA_HDR_SIZE sizeof(struct call_pkt_media) /* 16 */
|
#define CALL_MEDIA_HDR_SIZE sizeof(struct call_pkt_media) /* 36 */
|
||||||
|
|
||||||
/* ── параметры аудио (Opus 48kHz mono, 20ms) ── */
|
/* ── параметры аудио (Opus 48kHz mono, 20ms) ── */
|
||||||
#define CALL_OPUS_SAMPLE_RATE 48000
|
#define CALL_OPUS_SAMPLE_RATE 48000
|
||||||
|
|||||||
Reference in new issue
Block a user