Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

User talking #2158

Merged
merged 57 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d00d5a7
initial commit
Sep 18, 2019
61c5378
again :D
Nov 29, 2019
495474a
sample config file
Nov 29, 2019
8f6b68e
test
Dec 4, 2019
7344ea8
working UDP chunking
Dec 4, 2019
99a7e28
Merge pull request #4 from mirkobrankovic/feature/gelf-udp-support
do-not-set-2fa Dec 4, 2019
e85064f
desc + exceeding limit of chunks
Dec 4, 2019
2e1c930
first try
Dec 4, 2019
b5a5358
Pretty printed
Dec 12, 2019
493e701
Final working version TCP/UDP(chunking and compressing)
Dec 12, 2019
ce8420a
Merge branch 'master' into feature/gelf
do-not-set-2fa Jan 25, 2020
f7ddbc2
Merge pull request #6 from mirkobrankovic/feature/gelf
do-not-set-2fa Jan 25, 2020
f31d8b5
Fixing comments
Feb 4, 2020
2b3a909
Merge branch 'master' into feature/gelf-compression
do-not-set-2fa Feb 4, 2020
144fbed
Merge pull request #7 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 4, 2020
b7b273d
review part 2
Feb 6, 2020
6f7604d
resolving comments
Feb 17, 2020
a5d9940
new line
Feb 17, 2020
a24261d
no need for new line :/
Feb 17, 2020
5fa8154
Merge pull request #8 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 17, 2020
fd434e4
\detail
Feb 17, 2020
3a68101
Merge pull request #9 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 17, 2020
f5665ff
First connect then start thread
Feb 17, 2020
972caa3
Merge pull request #10 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 17, 2020
f10e3df
bug for rest of events, only first was ok
Feb 18, 2020
ffd28d9
ful_message should contain full event, so that handle_id or session_i…
Feb 18, 2020
17e2f20
Merge pull request #11 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 18, 2020
c910819
Code style and removals
Feb 26, 2020
90a4097
Merge pull request #12 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 26, 2020
067bef4
enum socket_type
Feb 28, 2020
707ff34
Merge pull request #13 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Feb 28, 2020
b9544bf
Merge branch 'master' into feature/gelf-compression
Apr 1, 2020
69c9794
improved description and formatting
Apr 1, 2020
8bfbcd9
Merge pull request #14 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 1, 2020
c53f265
remove +
Apr 1, 2020
c1439a9
Merge pull request #15 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 1, 2020
82b7f18
easy ones
Apr 8, 2020
2ac064e
Merge pull request #16 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 8, 2020
a5ed9a9
refactored TCP
Apr 24, 2020
cc9d086
Merge branch 'master' into feature/gelf-compression
Apr 24, 2020
9ca5a67
Merge pull request #17 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 24, 2020
c032a82
atio was wrong
Apr 24, 2020
0d5815a
=/==
Apr 24, 2020
7f39286
Merge pull request #18 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 24, 2020
58935bb
fix style
Apr 24, 2020
befd071
compress TCP check
Apr 24, 2020
1d00575
Merge pull request #19 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa Apr 24, 2020
4142b52
tcp send in while
Apr 24, 2020
e10e16b
Make sure all bytes are sent
May 1, 2020
6022185
Merge pull request #20 from mirkobrankovic/feature/gelf-compression
do-not-set-2fa May 1, 2020
e2ee3a8
Merge remote-tracking branch 'upstream/master' into user-talking
May 18, 2020
87f9999
init
May 18, 2020
f012d9c
desc
May 18, 2020
ef9d7e9
Remove my muster changes
May 18, 2020
47ed07c
one more
May 18, 2020
a1c1a6f
typo
May 18, 2020
578ea3c
video also
May 19, 2020
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
18 changes: 17 additions & 1 deletion plugins/janus_audiobridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ room-<unique room ID>: {
"quality" : <0-10, Opus-related complexity to use, the higher the value, the better the quality (but more CPU); optional, default is 4>,
"volume" : <percent value, <100 reduces volume, >100 increases volume; optional, default is 100 (no volume change)>,
"secret" : "<room management password; optional, if provided the user is an admin and can't be globally muted with mute_room>",
"audio_level_average" : "<overwrite, only for this user, global room value of average level of microphone activity>",
"audio_active_packets" : "<overwrite, only for this user, global room value of number of packets to be evaluated>",
}
\endverbatim
*
Expand Down Expand Up @@ -960,7 +962,9 @@ static struct janus_json_parameter join_parameters[] = {
{"prebuffer", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"quality", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"volume", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"secret", JSON_STRING, 0}
{"secret", JSON_STRING, 0},
{"audio_level_average", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"audio_active_packets", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE}
};
static struct janus_json_parameter configure_parameters[] = {
{"muted", JANUS_JSON_BOOL, 0},
Expand Down Expand Up @@ -1256,6 +1260,8 @@ typedef struct janus_audiobridge_participant {
int dBov_level; /* Value in dBov of the audio level (last value from extension) */
int audio_active_packets; /* Participant's number of audio packets to accumulate */
int audio_dBov_sum; /* Participant's accumulated dBov value for audio level */
int user_audio_active_packets; /* Participant's number of audio packets to evaluate */
int user_audio_level_average; /* Participant's average level of dBov value */
gboolean talking; /* Whether this participant is currently talking (uses audio levels extension) */
janus_rtp_switching_context context; /* Needed in case the participant changes room */
janus_audiocodec codec; /* Codec this participant is using (most often Opus, but G.711 is supported too) */
Expand Down Expand Up @@ -4602,6 +4608,12 @@ void janus_audiobridge_incoming_rtp(janus_plugin_session *handle, janus_plugin_r
/* We also need to detect who's talking: update our monitoring stuff */
int audio_active_packets = participant->room ? participant->room->audio_active_packets : 100;
int audio_level_average = participant->room ? participant->room->audio_level_average : 25;
/* Override with user join parameters*/
if (participant->user_audio_active_packets && participant->user_audio_active_packets > 0)
audio_active_packets = participant->user_audio_active_packets;
if (participant->user_audio_level_average && participant->user_audio_level_average > 0)
audio_level_average = participant->user_audio_level_average;
JANUS_LOG(LOG_ERR, "audio_active_packets: %d\n", audio_active_packets);
participant->audio_dBov_sum += level;
participant->audio_active_packets++;
participant->dBov_level = level;
Expand Down Expand Up @@ -5112,6 +5124,8 @@ static void *janus_audiobridge_handler(void *data) {
json_t *gain = json_object_get(root, "volume");
json_t *quality = json_object_get(root, "quality");
json_t *acodec = json_object_get(root, "codec");
json_t *user_audio_level_average = json_object_get(root, "audio_level_average");
json_t *user_audio_active_packets = json_object_get(root, "audio_active_packets");
uint prebuffer_count = prebuffer ? json_integer_value(prebuffer) : audiobridge->default_prebuffering;
if(prebuffer_count > MAX_PREBUFFERING) {
prebuffer_count = audiobridge->default_prebuffering;
Expand Down Expand Up @@ -5223,6 +5237,8 @@ static void *janus_audiobridge_handler(void *data) {
participant->prebuffer_count = prebuffer_count;
participant->volume_gain = volume;
participant->opus_complexity = complexity;
participant->user_audio_active_packets = json_integer_value(user_audio_active_packets);
participant->user_audio_level_average = json_integer_value(user_audio_level_average);
if(participant->outbuf == NULL)
participant->outbuf = g_async_queue_new();
g_atomic_int_set(&participant->active, g_atomic_int_get(&session->started));
Expand Down
59 changes: 53 additions & 6 deletions plugins/janus_videoroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ room-<unique room ID>: {
"record" : <true|false, whether this publisher should be recorded or not; optional>,
"filename" : "<if recording, the base path/file to use for the recording files; optional>",
"display" : "<new display name to use in the room; optional>"
"audio_active_packets" : "<audio_active_packets to overwrite in the room one; optional>",
"audio_level_average" : "<audio_level_average to overwrite the room one; optional>",
}
\endverbatim
*
Expand Down Expand Up @@ -623,7 +625,9 @@ room-<unique room ID>: {
"keyframe" : <true|false, whether we should send this publisher a keyframe request>,
"record" : <true|false, whether this publisher should be recorded or not; optional>,
"filename" : "<if recording, the base path/file to use for the recording files; optional>",
"display" : "<new display name to use in the room; optional>"
"display" : "<new display name to use in the room; optional>",
"audio_active_packets" : "<new audio_active_packets to overwrite in the room one; optional>",
"audio_level_average" : "<new audio_level_average to overwrite the room one; optional>",
}
\endverbatim
*
Expand Down Expand Up @@ -1001,7 +1005,9 @@ room-<unique room ID>: {
"temporal" : <temporal layers to receive (0-2), in case simulcasting is enabled; optional>,
"fallback" : <How much time (in us, default 250000) without receiving packets will make us drop to the substream below>,
"spatial_layer" : <spatial layer to receive (0-2), in case VP9-SVC is enabled; optional>,
"temporal_layer" : <temporal layers to receive (0-2), in case VP9-SVC is enabled; optional>
"temporal_layer" : <temporal layers to receive (0-2), in case VP9-SVC is enabled; optional>,
"audio_level_average" : "<overwrite, only for this publisher, global room value of average level of microphone activity>",
"audio_active_packets" : "<overwrite, only for this publisher, global room value of number of packets to be evaluated>"
}
\endverbatim
*
Expand Down Expand Up @@ -1281,6 +1287,8 @@ static struct janus_json_parameter publish_parameters[] = {
{"filename", JSON_STRING, 0},
{"display", JSON_STRING, 0},
{"secret", JSON_STRING, 0},
{"audio_level_averge", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"audio_active_packets", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
/* The following are just to force a renegotiation and/or an ICE restart */
{"update", JANUS_JSON_BOOL, 0},
{"restart", JANUS_JSON_BOOL, 0}
Expand Down Expand Up @@ -1329,6 +1337,8 @@ static struct janus_json_parameter configure_parameters[] = {
{"temporal_layer", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
/* The following is to handle a renegotiation */
{"update", JANUS_JSON_BOOL, 0},
{"audio_level_averge", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
{"audio_active_packets", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE}
};
static struct janus_json_parameter subscriber_parameters[] = {
{"private_id", JSON_INTEGER, JANUS_JSON_PARAM_POSITIVE},
Expand Down Expand Up @@ -1546,7 +1556,9 @@ typedef struct janus_videoroom_publisher {
int audio_dBov_level; /* Value in dBov of the audio level (last value from extension) */
int audio_active_packets; /* Participant's number of audio packets to accumulate */
int audio_dBov_sum; /* Participant's accumulated dBov value for audio level*/
gboolean talking; /* Whether this participant is currently talking (uses audio levels extension) */
int user_audio_active_packets; /* Participant's audio_active_packets overwriting global room setting */
int user_audio_level_average; /* Participant's audio_level_average overwriting global room setting */
gboolean talking; /* Whether this participant is currently talking (uses audio levels extension) */
gboolean data_active;
gboolean firefox; /* We send Firefox users a different kind of FIR */
uint32_t bitrate;
Expand Down Expand Up @@ -4816,10 +4828,12 @@ void janus_videoroom_incoming_rtp(janus_plugin_session *handle, janus_plugin_rtp
participant->audio_dBov_sum += level;
participant->audio_active_packets++;
participant->audio_dBov_level = level;
if(participant->audio_active_packets > 0 && participant->audio_active_packets == videoroom->audio_active_packets) {
int audio_active_packets = participant->user_audio_active_packets ? participant->user_audio_active_packets : videoroom->audio_active_packets;
int audio_level_average = participant->user_audio_level_average ? participant->user_audio_level_average : videoroom->audio_level_average;
if(participant->audio_active_packets > 0 && participant->audio_active_packets == audio_active_packets) {
gboolean notify_talk_event = FALSE;
float audio_dBov_avg = (float)participant->audio_dBov_sum/(float)participant->audio_active_packets;
if(audio_dBov_avg < videoroom->audio_level_average) {
if(audio_dBov_avg < audio_level_average) {
/* Participant talking, should we notify all participants? */
if(!participant->talking)
notify_talk_event = TRUE;
Expand Down Expand Up @@ -5408,6 +5422,8 @@ static void janus_videoroom_hangup_media_internal(janus_plugin_session *handle)
participant->video_active = FALSE;
participant->data_active = FALSE;
participant->audio_active_packets = 0;
participant->user_audio_active_packets = 0;
participant->user_audio_level_average = 0;
participant->audio_dBov_sum = 0;
participant->audio_dBov_level = 0;
participant->talking = FALSE;
Expand Down Expand Up @@ -5648,7 +5664,8 @@ static void *janus_videoroom_handler(void *data) {
}
/* Process the request */
json_t *audio = NULL, *video = NULL, *data = NULL,
*bitrate = NULL, *record = NULL, *recfile = NULL;
*bitrate = NULL, *record = NULL, *recfile = NULL,
*user_audio_active_packets = NULL, *user_audio_level_average = NULL;
if(!strcasecmp(request_text, "joinandconfigure")) {
/* Also configure (or publish a new feed) audio/video/bitrate for this new publisher */
/* join_parameters were validated earlier. */
Expand All @@ -5659,6 +5676,8 @@ static void *janus_videoroom_handler(void *data) {
record = json_object_get(root, "record");
recfile = json_object_get(root, "filename");
}
user_audio_active_packets = json_object_get(root, "audio_active_packets");
user_audio_level_average = json_object_get(root, "audio_level_average");
janus_videoroom_publisher *publisher = g_malloc0(sizeof(janus_videoroom_publisher));
publisher->session = session;
publisher->room_id = videoroom->room_id;
Expand Down Expand Up @@ -5746,6 +5765,16 @@ static void *janus_videoroom_handler(void *data) {
JANUS_LOG(LOG_VERB, "Setting recording basename: %s (room %s, user %s)\n",
publisher->recording_base, publisher->room_id_str, publisher->user_id_str);
}
if(user_audio_active_packets) {
publisher->user_audio_active_packets = json_integer_value(user_audio_active_packets);
JANUS_LOG(LOG_ERR, "Setting user audio_active_packets: %d (room %s, user %s)\n",
publisher->user_audio_active_packets, publisher->room_id_str, publisher->user_id_str);
}
if(user_audio_level_average) {
publisher->user_audio_level_average = json_integer_value(user_audio_level_average);
JANUS_LOG(LOG_ERR, "Setting user audio_level_average: %d (room %s, user %s)\n",
publisher->user_audio_level_average, publisher->room_id_str, publisher->user_id_str);
}
/* Done */
janus_mutex_lock(&session->mutex);
session->participant_type = janus_videoroom_p_type_publisher;
Expand Down Expand Up @@ -5797,6 +5826,10 @@ static void *janus_videoroom_handler(void *data) {
json_object_set_new(event, "id", string_ids ? json_string(user_id_str) : json_integer(user_id));
json_object_set_new(event, "private_id", json_integer(publisher->pvt_id));
json_object_set_new(event, "publishers", list);
if (publisher->user_audio_active_packets)
json_object_set_new(event, "audio_active_packets", json_integer(publisher->user_audio_active_packets));
if (publisher->user_audio_level_average)
json_object_set_new(event, "audio_level_average", json_integer(publisher->user_audio_level_average));
if(attendees != NULL)
json_object_set_new(event, "attendees", attendees);
/* See if we need to notify about a new participant joined the room (by default, we don't). */
Expand All @@ -5812,6 +5845,10 @@ static void *janus_videoroom_handler(void *data) {
json_object_set_new(info, "private_id", json_integer(publisher->pvt_id));
if(display_text != NULL)
json_object_set_new(info, "display", json_string(display_text));
if (publisher->user_audio_active_packets)
json_object_set_new(info, "audio_active_packets", json_integer(publisher->user_audio_active_packets));
if (publisher->user_audio_level_average)
json_object_set_new(info, "audio_level_average", json_integer(publisher->user_audio_level_average));
gateway->notify_event(&janus_videoroom_plugin, session->handle, info);
}
janus_mutex_unlock(&publisher->room->mutex);
Expand Down Expand Up @@ -6123,6 +6160,8 @@ static void *janus_videoroom_handler(void *data) {
json_t *recfile = json_object_get(root, "filename");
json_t *display = json_object_get(root, "display");
json_t *update = json_object_get(root, "update");
json_t *user_audio_active_packets = json_object_get(root, "audio_active_packets");
json_t *user_audio_level_average = json_object_get(root, "audio_level_average");
if(audio) {
gboolean audio_active = json_is_true(audio);
if(session->started && audio_active && !participant->audio_active) {
Expand Down Expand Up @@ -6214,6 +6253,14 @@ static void *janus_videoroom_handler(void *data) {
/* Send a FIR */
janus_videoroom_reqpli(participant, "Keyframe request");
}
if(user_audio_active_packets) {
participant->user_audio_active_packets = json_integer_value(user_audio_active_packets);
JANUS_LOG(LOG_ERR, "user_audio_active_packets: %llu \n", json_integer_value(user_audio_active_packets));
}
if(user_audio_level_average) {
participant->user_audio_level_average = json_integer_value(user_audio_level_average);
JANUS_LOG(LOG_ERR, "user_audio_level_average: %llu \n", json_integer_value(user_audio_level_average));
}
gboolean record_locked = FALSE;
if((record || recfile) && participant->room->lock_record && participant->room->room_secret) {
JANUS_CHECK_SECRET(participant->room->room_secret, root, "secret", error_code, error_cause,
Expand Down