Revision 5de69b28 plugins/janus_audiobridge.c

View differences:

plugins/janus_audiobridge.c
2324 2324
						participant->audio_active_packets = 0;
2325 2325
						participant->audio_dBov_sum = 0;
2326 2326
					}
2327
				} else {
2328
					JANUS_LOG(LOG_ERR, "Room audiolevel_event %d\n", participant->room->audiolevel_event);
2329 2327
				}
2330 2328
			}
2331 2329
		}
......
3349 3347
				JANUS_LOG(LOG_ERR, "Offer doesn't contain Opus..?\n");
3350 3348
			}
3351 3349
			JANUS_LOG(LOG_VERB, "Opus payload type is %d\n", participant->opus_pt);
3350
			/* Check if the audio level extension was offered */
3351
			int extmap_id = -1;
3352
			janus_sdp_mdirection extmap_mdir = JANUS_SDP_SENDRECV;
3353
			GList *temp = offer->m_lines;
3354
			while(temp) {
3355
				janus_sdp_mline *m = (janus_sdp_mline *)temp->data;
3356
				if(m->type == JANUS_SDP_AUDIO) {
3357
					GList *ma = m->attributes;
3358
					while(ma) {
3359
						janus_sdp_attribute *a = (janus_sdp_attribute *)ma->data;
3360
						if(a->value) {
3361
							if(strstr(a->value, JANUS_RTP_EXTMAP_AUDIO_LEVEL)) {
3362
								extmap_id = atoi(a->value);
3363
								extmap_mdir = a->direction;
3364
							}
3365
						}
3366
						ma = ma->next;
3367
					}
3368
				}
3369
				temp = temp->next;
3370
			}
3352 3371
			janus_sdp *answer = janus_sdp_generate_answer(offer,
3353 3372
				/* Reject video and data channels, if offered */
3354 3373
				JANUS_SDP_OA_VIDEO, FALSE,
......
3365 3384
			/* Is the audio level extension negotiated? */
3366 3385
			participant->extmap_id = 0;
3367 3386
			participant->dBov_level = 0;
3368
			int extmap_id = -1;
3369
			if(participant->room && participant->room->audiolevel_ext)
3370
				extmap_id = janus_rtp_header_extension_get_id(msg_sdp, JANUS_RTP_EXTMAP_AUDIO_LEVEL);
3371
			if(extmap_id > -1) {
3387
			if(extmap_id > -1 && participant->room && participant->room->audiolevel_ext) {
3372 3388
				/* Add an extmap attribute too */
3373 3389
				participant->extmap_id = extmap_id;
3390
				/* Let's check if the extmap attribute had a direction */
3391
				const char *direction = NULL;
3392
				switch(extmap_mdir) {
3393
					case JANUS_SDP_SENDONLY:
3394
						direction = "/recvonly";
3395
						break;
3396
					case JANUS_SDP_RECVONLY:
3397
					case JANUS_SDP_INACTIVE:
3398
						direction = "/inactive";
3399
						break;
3400
					default:
3401
						direction = "";
3402
						break;
3403
				}
3374 3404
				janus_sdp_attribute *a = janus_sdp_attribute_create("extmap",
3375
					"%d %s\r\n", extmap_id, JANUS_RTP_EXTMAP_AUDIO_LEVEL);
3405
					"%d%s %s\r\n", extmap_id, direction, JANUS_RTP_EXTMAP_AUDIO_LEVEL);
3376 3406
				janus_sdp_attribute_add_to_mline(janus_sdp_mline_find(answer, JANUS_SDP_AUDIO), a);
3377 3407
			}
3378 3408
			/* Prepare the response */

Also available in: Unified diff