Revision a27e90d3

View differences:

plugins/janus_videoroom.c
464 464
	guint8 playout_delay_extmap_id;	/* Playout delay extmap ID */
465 465
	gboolean audio_active;
466 466
	gboolean video_active;
467
	int audio_active_packets; /* number of packets received with audio_levl extmap sdp header */
468
	int audio_dBov_sum;
467 469
	gboolean firefox;	/* We send Firefox users a different kind of FIR */
468 470
	uint64_t bitrate;
469 471
	gint64 remb_startup;/* Incremental changes on REMB to reach the target at startup */
......
2292 2294
	if(!session || session->destroyed || !session->participant || session->participant_type != janus_videoroom_p_type_publisher)
2293 2295
		return;
2294 2296
	janus_videoroom_participant *participant = (janus_videoroom_participant *)session->participant;
2297
	if(participant->audio_level_extmap_id > 0) {
2298
	    int level = 0;
2299
	    int audio_level = janus_rtp_header_extension_parse_audio_level_and_return(buf, len, participant->audio_level_extmap_id, &level);
2300
	    participant->audio_dBov_sum = participant->audio_dBov_sum + audio_level;
2301
	    participant->audio_active_packets = participant->audio_active_packets + 1;
2302
	        if(participant->audio_active_packets == 60) {
2303
	            if(participant->audio_dBov_sum < 1200) {
2304
	               float avg = (float)participant->audio_dBov_sum / participant->audio_active_packets;
2305
	               if(notify_events && gateway->events_is_enabled()) {
2306
	                  json_t *info = json_object();
2307
                      json_object_set_new(info, "event", json_string("talking"));
2308
                      json_object_set_new(info, "room", json_string(participant->room));
2309
                      json_object_set_new(info, "user", json_integer(participant->user_id));
2310
                      gateway->notify_event(&janus_videoroom_plugin, handle, info);
2311
                      json_decref(info);
2312
                   }
2313
	               JANUS_LOG(LOG_ERR, "Got audio_active_packets of 30 pkts from user: %" G_GUINT64_FORMAT" with average audio_dBov of: %f \n", participant->user_id, avg);
2314
	            }
2315
                participant->audio_active_packets = 0;
2316
                participant->audio_dBov_sum = 0;
2317
	        }
2318
    }
2295 2319
	if((!video && participant->audio_active) || (video && participant->video_active)) {
2296 2320
		/* Update payload type and SSRC */
2297 2321
		janus_mutex_lock(&participant->rtp_forwarders_mutex);
rtp.c
158 158
	return 0;
159 159
}
160 160

  
161
int janus_rtp_header_extension_parse_audio_level_and_return(char *buf, int len, int id, int *level) {
162
	uint8_t byte = 0;
163
	if(janus_rtp_header_extension_find(buf, len, id, &byte, NULL) < 0)
164
		return 0;
165
	/* a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level */
166
	// int v = (byte & 0x80) >> 7;
167
	int value = byte & 0x7F;
168
	// JANUS_LOG(LOG_DBG, "%02x --> v=%d, level=%d\n", byte, v, value);
169
	if(level)
170
		*level = value;
171
	return value;
172
}
173

  
161 174
int janus_rtp_header_extension_parse_video_orientation(char *buf, int len, int id,
162 175
		gboolean *c, gboolean *f, gboolean *r1, gboolean *r0) {
163 176
	uint8_t byte = 0;
rtp.h
107 107
 * @returns 0 if found, -1 otherwise */
108 108
int janus_rtp_header_extension_parse_audio_level(char *buf, int len, int id, int *level);
109 109

  
110
/*! \brief Helper to parse a ssrc-audio-level RTP extension (https://tools.ietf.org/html/rfc6464)
111
 * @param[in] buf The packet data
112
 * @param[in] len The packet data length in bytes
113
 * @param[in] id The extension ID to look for
114
 * @param[out] level The level value in dBov (0=max, 127=min)
115
 * @returns dBov level of audio, 0 otherwise */
116
int janus_rtp_header_extension_parse_audio_level_and_return(char *buf, int len, int id, int *level);
117

  
110 118
/*! \brief Helper to parse a video-orientation RTP extension (http://www.3gpp.org/ftp/Specs/html-info/26114.htm)
111 119
 * @param[in] buf The packet data
112 120
 * @param[in] len The packet data length in bytes

Also available in: Unified diff