Files
utun2/src/stream/stream_publisher.h
T

37 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Общий publisher Android/desktop: принимает полные access units и Opus, публикует uAV2/RS.
* create/destroy выполняются в uasync вне callbacks, внешний bridge сериализует destroy с producers.
* open/feed/stop/snapshot потокобезопасны; вызывающие используют session ID, не pointers ядра.
* Один publisher на контекст. Snapshot содержит состояние и 100ms телеметрию, callbacks не устанавливаются.
* TX ограничен 2MiB/128 records/250ms; потеря видео требует KEY. Stop завершает очередь и держит FIN 2s. */
#ifndef STREAM_PUBLISHER_H
#define STREAM_PUBLISHER_H
#include "stream_media.h"
#ifdef __cplusplus
extern "C" {
#endif
struct UTUN_INSTANCE;
struct stream_publisher;
enum stream_publisher_state { STREAM_PUBLISHER_OPENING = 1, STREAM_PUBLISHER_LIVE, STREAM_PUBLISHER_STOPPING,
STREAM_PUBLISHER_DRAINING, STREAM_PUBLISHER_ENDED, STREAM_PUBLISHER_FAILED };
struct stream_publisher_status {
uint64_t id, epoch, sample_us, video_bytes, audio_bytes, stream_bytes, transport_bytes, inflight_bytes, acked_1s, total_bytes;
unsigned connections;
int state, reason, need_key;
int compressor_enabled, compressor_max_gain_db, compressor_rise_rate;
int audio_enabled;
};
int stream_publisher_create(struct stream_publisher **out, struct UTUN_INSTANCE *inst);
void stream_publisher_destroy(struct stream_publisher *publisher);
int stream_publisher_open(struct stream_publisher *publisher, uint64_t id, uint64_t group, const struct stream_media_format *format);
/* Producer заглушает свою копию PCM; actor публикует состояние без смены аудиотрека/эпохи. */
int stream_publisher_set_audio_enabled(struct stream_publisher *publisher, uint64_t id, int enabled);
/* 1 принято, 0 требуется KEY/перегрузка, -1 ошибка или старый/закрытый session ID. */
int stream_publisher_feed(struct stream_publisher *publisher, uint64_t id, int video, uint64_t pts, int key,
const uint8_t *data, size_t length, const struct stream_media_format *format);
void stream_publisher_stop(struct stream_publisher *publisher, uint64_t id);
int stream_publisher_snapshot(struct stream_publisher *publisher, uint64_t id, struct stream_publisher_status *status);
#ifdef __cplusplus
}
#endif
#endif