mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-07-18 01:31:54 +00:00
janus: separate audio of mic
This commit is contained in:
@@ -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");
|
US_JLOG_ERROR("config", "Either acap.sampling_rate or acap.tc358743 required");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
config->aplay_dev_name = _get_value(jcfg, "aplay", "device");
|
|
||||||
}
|
}
|
||||||
|
config->aplay_dev_name = _get_value(jcfg, "aplay", "device");
|
||||||
|
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
|
|||||||
@@ -443,9 +443,9 @@ static int _plugin_init(janus_callbacks *gw, const char *config_dir_path) {
|
|||||||
if (_g_config->acap_dev_name != NULL) {
|
if (_g_config->acap_dev_name != NULL) {
|
||||||
_g_rtpa = us_rtpa_init(_relay_rtp_clients);
|
_g_rtpa = us_rtpa_init(_relay_rtp_clients);
|
||||||
US_THREAD_CREATE(_g_acap_tid, _acap_thread, NULL);
|
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);
|
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_rtp_tid, _video_rtp_thread, NULL);
|
||||||
US_THREAD_CREATE(_g_video_sink_tid, _video_sink_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(
|
char *const sdp = us_sdp_create(
|
||||||
_g_rtpv,
|
_g_rtpv,
|
||||||
(with_acap ? _g_rtpa : NULL),
|
(with_acap ? _g_rtpa : NULL),
|
||||||
(with_acap && with_aplay));
|
with_aplay);
|
||||||
json_t *const offer_jsep = json_pack("{ssss}", "type", "offer", "sdp", sdp);
|
json_t *const offer_jsep = json_pack("{ssss}", "type", "offer", "sdp", sdp);
|
||||||
PUSH_STATUS("started", NULL, offer_jsep);
|
PUSH_STATUS("started", NULL, offer_jsep);
|
||||||
json_decref(offer_jsep);
|
json_decref(offer_jsep);
|
||||||
@@ -671,11 +671,10 @@ static struct janus_plugin_result *_plugin_handle_message(
|
|||||||
|
|
||||||
} else if (!strcmp(request_str, "features")) {
|
} else if (!strcmp(request_str, "features")) {
|
||||||
const char *const ice_url = getenv("JANUS_USTREAMER_WEB_ICE_URL");
|
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(
|
json_t *const features = json_pack(
|
||||||
"{s:b, s:b, s:{s:s?}}",
|
"{s:b, s:b, s:{s:s?}}",
|
||||||
"audio", acap_avail,
|
"audio", us_au_probe(_g_config->acap_dev_name),
|
||||||
"mic", (acap_avail && us_au_probe(_g_config->aplay_dev_name)),
|
"mic", us_au_probe(_g_config->aplay_dev_name),
|
||||||
"ice", "url", (ice_url != NULL ? ice_url : default_ice_url)
|
"ice", "url", (ice_url != NULL ? ice_url : default_ice_url)
|
||||||
);
|
);
|
||||||
PUSH_STATUS("features", features, NULL);
|
PUSH_STATUS("features", features, NULL);
|
||||||
|
|||||||
@@ -65,7 +65,26 @@ char *us_sdp_create(us_rtpv_s *rtpv, us_rtpa_s *rtpa, bool mic) {
|
|||||||
if (rtpa == NULL) {
|
if (rtpa == NULL) {
|
||||||
audio_sdp = us_strdup("");
|
audio_sdp = us_strdup("");
|
||||||
} else {
|
} 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(
|
US_ASPRINTF(
|
||||||
audio_sdp,
|
audio_sdp,
|
||||||
"m=audio 1 RTP/SAVPF %u" RN
|
"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,
|
pl, pl,
|
||||||
US_RTP_OPUS_HZ, US_RTP_OPUS_CH,
|
US_RTP_OPUS_HZ, US_RTP_OPUS_CH,
|
||||||
pl,
|
pl,
|
||||||
rtpa->rtp->ssrc,
|
ssrc,
|
||||||
(mic ? "sendrecv" : "sendonly"));
|
dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *sdp;
|
char *sdp;
|
||||||
|
|||||||
Reference in New Issue
Block a user