tc358743 hacks

This commit is contained in:
Maxim Devaev
2022-06-06 19:32:49 +03:00
parent 054748234e
commit 2e0a19c1cb
6 changed files with 137 additions and 4 deletions

View File

@@ -46,6 +46,7 @@
#include "jlogging.h"
#include "audio.h"
#include "tc358743.h"
#include "rtpv.h"
#include "rtpa.h"
@@ -122,6 +123,7 @@ const useconds_t _g_lock_polling = 1000;
const useconds_t _g_watchers_polling = 100000;
static char *_g_audio_dev = NULL;
static char *_g_tc358743_dev = NULL;
static _client_s *_g_clients = NULL;
static janus_callbacks *_g_gw = NULL;
@@ -273,6 +275,7 @@ static void *_clients_audio_thread(UNUSED void *arg) {
A_THREAD_RENAME("us_a_clients");
atomic_store(&_g_audio_tid_created, true);
assert(_g_audio_dev);
assert(_g_tc358743_dev);
while (!STOP) {
if (!HAS_WATCHERS) {
@@ -280,12 +283,26 @@ static void *_clients_audio_thread(UNUSED void *arg) {
continue;
}
tc358743_info_s info = {0};
audio_s *audio = NULL;
if ((audio = audio_init(_g_audio_dev)) == NULL) {
if (
tc358743_read_info(_g_tc358743_dev, &info) < 0
|| !info.has_audio
|| (audio = audio_init(_g_audio_dev, info.audio_hz)) == NULL
) {
goto close_audio;
}
while (!STOP && HAS_WATCHERS) {
if (
tc358743_read_info(_g_tc358743_dev, &info) < 0
|| !info.has_audio
|| audio->pcm_hz != info.audio_hz
) {
goto close_audio;
}
size_t size = RTP_DATAGRAM_SIZE - RTP_HEADER_SIZE;
uint8_t data[size];
uint64_t pts;
@@ -337,6 +354,10 @@ static int _read_config(const char *config_dir_path) {
}
if ((_g_audio_dev = _get_config_value(config, "audio", "device")) != NULL) {
JLOG_INFO("main", "Enabled the experimental AUDIO feature");
if ((_g_tc358743_dev = _get_config_value(config, "audio", "tc358743")) == NULL) {
JLOG_INFO("main", "Missing config value: audio.tc358743");
goto error;
}
}
int retval = 0;
@@ -396,6 +417,7 @@ static void _plugin_destroy(void) {
DEL(rtpa_destroy, _g_rtpa);
DEL(rtpv_destroy, _g_rtpv);
_g_gw = NULL;
DEL(free, _g_tc358743_dev);
DEL(free, _g_audio_dev);
DEL(free, _g_memsink_obj);
# undef DEL