janus: sendonly/sendrecv audio flag

This commit is contained in:
Maxim Devaev 2025-01-13 17:10:42 +02:00
parent a727c9b7c5
commit 8c31af2f03
3 changed files with 14 additions and 6 deletions

View File

@ -458,8 +458,9 @@ static struct janus_plugin_result *_plugin_handle_message(
PUSH_STATUS("stopped", NULL, NULL);
} else if (!strcmp(request_str, "watch")) {
bool with_audio = false;
uint video_orient = 0;
bool with_audio = false;
bool with_mic = false;
{
json_t *const params = json_object_get(msg, "params");
if (params != NULL) {
@ -469,6 +470,12 @@ static struct janus_plugin_result *_plugin_handle_message(
with_audio = (_g_rtpa != NULL && json_boolean_value(obj));
}
}
{
json_t *const obj = json_object_get(params, "microphone");
if (obj != NULL && json_is_boolean(obj)) {
with_mic = (with_audio && json_boolean_value(obj)); // FIXME: also check playback
}
}
{
json_t *const obj = json_object_get(params, "orientation");
if (obj != NULL && json_is_integer(obj)) {
@ -485,7 +492,7 @@ static struct janus_plugin_result *_plugin_handle_message(
{
char *sdp;
char *const video_sdp = us_rtpv_make_sdp(_g_rtpv);
char *const audio_sdp = (with_audio ? us_rtpa_make_sdp(_g_rtpa) : us_strdup(""));
char *const audio_sdp = (with_audio ? us_rtpa_make_sdp(_g_rtpa, with_mic) : us_strdup(""));
US_ASPRINTF(sdp,
"v=0" RN
"o=- %" PRIu64 " 1 IN IP4 0.0.0.0" RN

View File

@ -43,7 +43,7 @@ void us_rtpa_destroy(us_rtpa_s *rtpa) {
free(rtpa);
}
char *us_rtpa_make_sdp(us_rtpa_s *rtpa) {
char *us_rtpa_make_sdp(us_rtpa_s *rtpa, bool mic) {
const uint pl = rtpa->rtp->payload;
char *sdp;
US_ASPRINTF(sdp,
@ -55,9 +55,10 @@ char *us_rtpa_make_sdp(us_rtpa_s *rtpa) {
"a=rtcp-fb:%u nack pli" RN
"a=rtcp-fb:%u goog-remb" RN
"a=ssrc:%" PRIu32 " cname:ustreamer" RN
"a=sendonly" RN,
"a=%s" RN,
pl, pl, pl, pl, pl, pl,
rtpa->rtp->ssrc
rtpa->rtp->ssrc,
(mic ? "sendrecv" : "sendonly")
);
return sdp;
}

View File

@ -36,5 +36,5 @@ typedef struct {
us_rtpa_s *us_rtpa_init(us_rtp_callback_f callback);
void us_rtpa_destroy(us_rtpa_s *rtpa);
char *us_rtpa_make_sdp(us_rtpa_s *rtpa);
char *us_rtpa_make_sdp(us_rtpa_s *rtpa, bool mic);
void us_rtpa_wrap(us_rtpa_s *rtpa, const u8 *data, uz size, u32 pts);