Revision cd5a86e5 plugins/janus_videoroom.c

View differences:

plugins/janus_videoroom.c
2269 2269
	if(!session || session->destroyed || !session->participant || session->participant_type != janus_videoroom_p_type_publisher)
2270 2270
		return;
2271 2271
	janus_videoroom_participant *participant = (janus_videoroom_participant *)session->participant;
2272
	if(participant->audio_level_extmap_id > 0) {
2273
	    int level = 0;
2274
	    int audio_level = janus_rtp_header_extension_parse_audio_level_and_return(buf, len, participant->audio_level_extmap_id, &level);
2275
	    participant->audio_dBov_sum = participant->audio_dBov_sum + audio_level;
2276
	    participant->audio_active_packets = participant->audio_active_packets + 1;
2277
	        if(participant->audio_active_packets == 60) {
2278
	            if(participant->audio_dBov_sum < 1200) {
2279
	               float avg = (float)participant->audio_dBov_sum / participant->audio_active_packets;
2280
	               // Notify participants
2281
	               json_t *event = json_object();
2282
                   json_object_set_new(event, "event", json_string("talking"));
2283
                   json_object_set_new(event, "user", json_string(participant->display));
2284
                   gateway->push_event(session->handle, &janus_videoroom_plugin, NULL, event, NULL);
2285
                   json_decref(event);
2286
	            }
2287
                participant->audio_active_packets = 0;
2288
                participant->audio_dBov_sum = 0;
2289
	        }
2290
    }
2272
	if(participant->audio_level_extmap_id > 0 && participant->audio_active) {
2273
		int level = 0;
2274
		int audio_level = janus_rtp_header_extension_parse_audio_level_and_return(buf, len, participant->audio_level_extmap_id, &level);
2275
		participant->audio_dBov_sum = participant->audio_dBov_sum + audio_level;
2276
		participant->audio_active_packets = participant->audio_active_packets + 1;
2277
		if(participant->audio_active_packets == 150) {
2278
			if(participant->audio_dBov_sum < 3000) {
2279
				// Notify participants
2280
				json_t *event = json_object();
2281
				json_object_set_new(event, "event", json_string("talking"));
2282
				json_object_set_new(event, "user", json_string(participant->display));
2283
				gateway->push_event(session->handle, &janus_videoroom_plugin, NULL, event, NULL);
2284
				json_decref(event);
2285
				JANUS_LOG(LOG_ERR, "AVG audio_level %f\n", (float)participant->audio_dBov_sum/(float)participant->audio_active_packets);
2286
			}
2287
			participant->audio_active_packets = 0;
2288
			participant->audio_dBov_sum = 0;
2289
		}
2290
	}
2291 2291
	if((!video && participant->audio_active) || (video && participant->video_active)) {
2292 2292
		/* Update payload type and SSRC */
2293 2293
		janus_mutex_lock(&participant->rtp_forwarders_mutex);

Also available in: Unified diff