You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
3.2 KiB
44 lines
3.2 KiB
/* Android-очереди live media: attach/detach только в uasync, вне callbacks. |
|
* UI/кодировщики используют только session_id, никогда не сохраняют inst/ua. |
|
* Один publisher и один viewer, TX <=2MB/128 records, RX <=4MB/256 records. |
|
* Data принимает полные access units пяти кодеков uAV2 (KEY: config_length:4/config/frame) и Opus 48k mono/stereo/20ms. |
|
* pull передаёт u_malloc-буфер: kind:1,flags:1,width:2,height:2,rotation:2,PTS_us:8,length:4,revision:4,codec:1,reserved:3,data. |
|
* kinds: video=1,audio=2,gap=3,opened=4,ended=5,error=6; error.flags = stream_close_reason. Числа big-endian. |
|
* Медиаданные передаются через pull, не через общий чатовый event bus. */ |
|
#ifndef ANDROID_STREAM_BRIDGE_H |
|
#define ANDROID_STREAM_BRIDGE_H |
|
|
|
#include <stddef.h> |
|
#include <stdint.h> |
|
|
|
struct UTUN_INSTANCE; |
|
struct stream_media_format; |
|
struct stream_media_status; |
|
#define ANDROID_STREAM_HEADER_SIZE 28 |
|
struct android_stream_tx_stats { |
|
uint64_t id, sample_us, video_bytes, audio_bytes, stream_bytes, transport_bytes, inflight_bytes, acked_1s, total_bytes; |
|
unsigned connections; |
|
}; |
|
/* Снимок обновляется в uasync каждые 100ms; getter копирует его под bridge mutex. */ |
|
int android_stream_tx_snapshot(uint64_t id, struct android_stream_tx_stats *stats); |
|
/* 0 attached, -1 invalid/busy: нельзя передать singleton другому ядру до detach старого. */ |
|
int android_stream_attach(struct UTUN_INSTANCE *inst); |
|
void android_stream_detach(struct UTUN_INSTANCE *inst); |
|
/* source=0 — publisher; source!=0 — viewer с обязательным expected_epoch. Команда принята=0, результат через pull. */ |
|
int android_stream_open(uint64_t id, uint64_t group, uint64_t source, unsigned width, unsigned height, |
|
unsigned rotation, int audio, uint64_t expected_epoch, unsigned codec); |
|
/* Наблюдение выбранного канала через CHAT_EVT_STREAM_SOURCES; group=0 снимает его. */ |
|
int android_stream_watch(uint64_t group); |
|
/* Видео содержит revision/размер/поворот; новая revision принимается атомарно с KEY. Для аудио format=NULL. */ |
|
int android_stream_feed(uint64_t id, int video, uint64_t pts, int key, const uint8_t *data, size_t length, |
|
const struct stream_media_format *format); |
|
/* feed: 1 accepted, 0 dropped (video: запросить KEY), -1 detached/stopped/invalid. */ |
|
void android_stream_stop(uint64_t id); |
|
uint8_t *android_stream_pull(uint64_t id, size_t *length); |
|
/* Один ответ на запрос: следующий кадр при want_video=1, звук до position_us+audio_ahead_us. |
|
* Повторные запросы до получения ответа не создают дополнительные записи. Указатели кольца остаются в uasync. */ |
|
int android_stream_read_request(uint64_t id, int64_t position_us, int want_video, int64_t audio_ahead_us); |
|
int android_stream_get_status(uint64_t id, struct stream_media_status *status); |
|
int android_stream_resync(uint64_t id); |
|
|
|
#endif
|
|
|