janus: separate audio of mic

This commit is contained in:
Maxim Devaev
2026-05-31 05:33:42 +03:00
parent ef59c52a83
commit 3750a22091
3 changed files with 29 additions and 11 deletions

View File

@@ -68,8 +68,8 @@ us_config_s *us_config_init(const char *config_dir_path) {
US_JLOG_ERROR("config", "Either acap.sampling_rate or acap.tc358743 required");
goto error;
}
config->aplay_dev_name = _get_value(jcfg, "aplay", "device");
}
config->aplay_dev_name = _get_value(jcfg, "aplay", "device");
goto ok;

View File

@@ -443,10 +443,10 @@ static int _plugin_init(janus_callbacks *gw, const char *config_dir_path) {
if (_g_config->acap_dev_name != NULL) {
_g_rtpa = us_rtpa_init(_relay_rtp_clients);
US_THREAD_CREATE(_g_acap_tid, _acap_thread, NULL);
}
if (_g_config->aplay_dev_name != NULL) {
US_THREAD_CREATE(_g_aplay_tid, _aplay_thread, NULL);
}
}
US_THREAD_CREATE(_g_video_rtp_tid, _video_rtp_thread, NULL);
US_THREAD_CREATE(_g_video_sink_tid, _video_sink_thread, NULL);
@@ -644,7 +644,7 @@ static struct janus_plugin_result *_plugin_handle_message(
char *const sdp = us_sdp_create(
_g_rtpv,
(with_acap ? _g_rtpa : NULL),
(with_acap && with_aplay));
with_aplay);
json_t *const offer_jsep = json_pack("{ssss}", "type", "offer", "sdp", sdp);
PUSH_STATUS("started", NULL, offer_jsep);
json_decref(offer_jsep);
@@ -671,11 +671,10 @@ static struct janus_plugin_result *_plugin_handle_message(
} else if (!strcmp(request_str, "features")) {
const char *const ice_url = getenv("JANUS_USTREAMER_WEB_ICE_URL");
const bool acap_avail = us_au_probe(_g_config->acap_dev_name);
json_t *const features = json_pack(
"{s:b, s:b, s:{s:s?}}",
"audio", acap_avail,
"mic", (acap_avail && us_au_probe(_g_config->aplay_dev_name)),
"audio", us_au_probe(_g_config->acap_dev_name),
"mic", us_au_probe(_g_config->aplay_dev_name),
"ice", "url", (ice_url != NULL ? ice_url : default_ice_url)
);
PUSH_STATUS("features", features, NULL);

View File

@@ -65,7 +65,26 @@ char *us_sdp_create(us_rtpv_s *rtpv, us_rtpa_s *rtpa, bool mic) {
if (rtpa == NULL) {
audio_sdp = us_strdup("");
} else {
const uint pl = rtpa->rtp->payload;
if (rtpa != NULL || mic) {
uint pl;
u32 ssrc;
if (rtpa != NULL) {
pl = rtpa->rtp->payload;
ssrc = rtpa->rtp->ssrc;
} else {
pl = US_RTP_OPUS_PAYLOAD;
ssrc = us_triple_u32(us_get_now_monotonic_u64());
}
char *dir = "sendrecv";
if (rtpa == NULL) {
dir = "recvonly";
} else if (!mic) {
dir = "sendonly";
}
US_ASPRINTF(
audio_sdp,
"m=audio 1 RTP/SAVPF %u" RN
@@ -79,8 +98,8 @@ char *us_sdp_create(us_rtpv_s *rtpv, us_rtpa_s *rtpa, bool mic) {
pl, pl,
US_RTP_OPUS_HZ, US_RTP_OPUS_CH,
pl,
rtpa->rtp->ssrc,
(mic ? "sendrecv" : "sendonly"));
ssrc,
dir);
}
char *sdp;