Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow optional acap property - sampling_rate #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions janus/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "config.h"

#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Expand All @@ -36,6 +37,7 @@


static char *_get_value(janus_config *jcfg, const char *section, const char *option);
static uint _get_uint(janus_config *jcfg, const char *section, const char *option, bool def);
// static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def);


Expand Down Expand Up @@ -65,6 +67,7 @@ us_config_s *us_config_init(const char *config_dir_path) {
US_JLOG_INFO("config", "Missing config value: acap.tc358743");
goto error;
}
config->acap_sampling_rate = _get_uint(jcfg, "acap", "sampling_rate", 0);
if ((config->aplay_dev_name = _get_value(jcfg, "aplay", "device")) != NULL) {
char *path = _get_value(jcfg, "aplay", "check");
if (path != NULL) {
Expand Down Expand Up @@ -105,6 +108,20 @@ static char *_get_value(janus_config *jcfg, const char *section, const char *opt
return us_strdup(option_obj->value);
}

static uint _get_uint(janus_config *jcfg, const char *section, const char *option, bool def) {
char *const tmp = _get_value(jcfg, section, option);
uint value = def;
if (tmp != NULL) {
errno = 0;
value = (uint) strtoul(tmp, NULL, 10);
if (errno != 0) {
value = def;
}
free(tmp);
}
return value;
}

/*static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def) {
char *const tmp = _get_value(jcfg, section, option);
bool value = def;
Expand Down
2 changes: 2 additions & 0 deletions janus/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ typedef struct {
char *video_sink_name;

char *acap_dev_name;
unsigned int acap_sampling_rate;
char *tc358743_dev_path;

char *aplay_dev_name;

} us_config_s;


Expand Down
8 changes: 5 additions & 3 deletions janus/src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,18 @@ static void *_acap_thread(void *arg) {
continue;
}

uint hz = 0;
uint hz = _g_config->acap_sampling_rate;
us_acap_s *acap = NULL;

if (_check_tc358743_acap(&hz) < 0) {
US_ONCE({ US_JLOG_INFO("acap", "Configured acap_sampling_rate : %d", _g_config->acap_sampling_rate); });
if (hz == 0 && _check_tc358743_acap(&hz) < 0) {
goto close_acap;
}
if (hz == 0) {
US_ONCE({ US_JLOG_INFO("acap", "No audio presented from the host"); });
goto close_acap;
}

US_ONCE({ US_JLOG_INFO("acap", "Detected host audio"); });
if ((acap = us_acap_init(_g_config->acap_dev_name, hz)) == NULL) {
goto close_acap;
Expand All @@ -265,7 +267,7 @@ static void *_acap_thread(void *arg) {
once = 0;

while (!_STOP && _HAS_WATCHERS && _HAS_LISTENERS) {
if (_check_tc358743_acap(&hz) < 0 || acap->pcm_hz != hz) {
if (_g_config->acap_sampling_rate == 0 && (_check_tc358743_acap(&hz) < 0 || acap->pcm_hz != hz)) {
goto close_acap;
}
uz size = US_RTP_DATAGRAM_SIZE - US_RTP_HEADER_SIZE;
Expand Down