Revision 5de69b28

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 */
plugins/janus_videoroom.c
3502 3502
					goto error;
3503 3503
				}
3504 3504
				gboolean audio_level_extmap = FALSE, video_orient_extmap = FALSE, playout_delay_extmap = FALSE;
3505
				janus_sdp_mdirection audio_level_mdir = JANUS_SDP_SENDRECV,
3506
					video_orient_mdir = JANUS_SDP_SENDRECV,
3507
					playout_delay_mdir = JANUS_SDP_SENDRECV;
3505 3508
				GList *temp = offer->m_lines;
3506 3509
				while(temp) {
3507 3510
					/* Which media are available? */
......
3522 3525
								if(videoroom->audiolevel_ext && m->type == JANUS_SDP_AUDIO && strstr(a->value, JANUS_RTP_EXTMAP_AUDIO_LEVEL)) {
3523 3526
									participant->audio_level_extmap_id = atoi(a->value);
3524 3527
									audio_level_extmap = TRUE;
3528
									audio_level_mdir = a->direction;
3525 3529
								} else if(videoroom->videoorient_ext && m->type == JANUS_SDP_VIDEO && strstr(a->value, JANUS_RTP_EXTMAP_VIDEO_ORIENTATION)) {
3526 3530
									participant->video_orient_extmap_id = atoi(a->value);
3527 3531
									video_orient_extmap = TRUE;
3532
									video_orient_mdir = a->direction;
3528 3533
								} else if(videoroom->playoutdelay_ext && m->type == JANUS_SDP_VIDEO && strstr(a->value, JANUS_RTP_EXTMAP_PLAYOUT_DELAY)) {
3529 3534
									participant->playout_delay_extmap_id = atoi(a->value);
3530 3535
									playout_delay_extmap = TRUE;
3536
									playout_delay_mdir = a->direction;
3531 3537
								}
3532 3538
							}
3533 3539
							ma = ma->next;
......
3578 3584
				}
3579 3585
				/* Add the extmap attributes, if needed */
3580 3586
				if(audio_level_extmap) {
3587
					/* First of all, let's check if the extmap attribute had a direction */
3588
					const char *direction = NULL;
3589
					switch(audio_level_mdir) {
3590
						case JANUS_SDP_SENDONLY:
3591
							direction = "/recvonly";
3592
							break;
3593
						case JANUS_SDP_RECVONLY:
3594
						case JANUS_SDP_INACTIVE:
3595
							direction = "/inactive";
3596
							break;
3597
						default:
3598
							direction = "";
3599
							break;
3600
					}
3581 3601
					janus_sdp_attribute *a = janus_sdp_attribute_create("extmap",
3582
						"%d %s\r\n", participant->audio_level_extmap_id, JANUS_RTP_EXTMAP_AUDIO_LEVEL);
3602
						"%d%s %s\r\n", participant->audio_level_extmap_id, direction, JANUS_RTP_EXTMAP_AUDIO_LEVEL);
3583 3603
					janus_sdp_attribute_add_to_mline(janus_sdp_mline_find(answer, JANUS_SDP_AUDIO), a);
3584 3604
				}
3585 3605
				if(video_orient_extmap) {
3606
					/* First of all, let's check if the extmap attribute had a direction */
3607
					const char *direction = NULL;
3608
					switch(video_orient_mdir) {
3609
						case JANUS_SDP_SENDONLY:
3610
							direction = "/recvonly";
3611
							break;
3612
						case JANUS_SDP_RECVONLY:
3613
						case JANUS_SDP_INACTIVE:
3614
							direction = "/inactive";
3615
							break;
3616
						default:
3617
							direction = "";
3618
							break;
3619
					}
3586 3620
					janus_sdp_attribute *a = janus_sdp_attribute_create("extmap",
3587
						"%d %s\r\n", participant->video_orient_extmap_id, JANUS_RTP_EXTMAP_VIDEO_ORIENTATION);
3621
						"%d%s %s\r\n", participant->video_orient_extmap_id, direction, JANUS_RTP_EXTMAP_VIDEO_ORIENTATION);
3588 3622
					janus_sdp_attribute_add_to_mline(janus_sdp_mline_find(answer, JANUS_SDP_VIDEO), a);
3589 3623
				}
3590 3624
				if(playout_delay_extmap) {
3625
					/* First of all, let's check if the extmap attribute had a direction */
3626
					const char *direction = NULL;
3627
					switch(playout_delay_mdir) {
3628
						case JANUS_SDP_SENDONLY:
3629
							direction = "/recvonly";
3630
							break;
3631
						case JANUS_SDP_RECVONLY:
3632
						case JANUS_SDP_INACTIVE:
3633
							direction = "/inactive";
3634
							break;
3635
						default:
3636
							direction = "";
3637
							break;
3638
					}
3591 3639
					janus_sdp_attribute *a = janus_sdp_attribute_create("extmap",
3592
						"%d %s\r\n", participant->playout_delay_extmap_id, JANUS_RTP_EXTMAP_PLAYOUT_DELAY);
3640
						"%d%s %s\r\n", participant->playout_delay_extmap_id, direction, JANUS_RTP_EXTMAP_PLAYOUT_DELAY);
3593 3641
					janus_sdp_attribute_add_to_mline(janus_sdp_mline_find(answer, JANUS_SDP_VIDEO), a);
3594 3642
				}
3595 3643
				/* Generate an SDP string we can send back to the publisher */
sdp-utils.c
100 100
		return NULL;
101 101
	janus_sdp_attribute *a = g_malloc0(sizeof(janus_sdp_attribute));
102 102
	a->name = g_strdup(name);
103
	a->direction = JANUS_SDP_DEFAULT;
103 104
	if(value) {
104 105
		char buffer[512];
105 106
		va_list ap;
......
308 309
							*semicolon = '\0';
309 310
							a->name = g_strdup(line);
310 311
							a->value = g_strdup(semicolon+1);
312
							a->direction = JANUS_SDP_DEFAULT;
311 313
							*semicolon = ':';
314
							if(strstr(line, "/sendonly"))
315
								a->direction = JANUS_SDP_SENDONLY;
316
							else if(strstr(line, "/recvonly"))
317
								a->direction = JANUS_SDP_RECVONLY;
318
							if(strstr(line, "/inactive"))
319
								a->direction = JANUS_SDP_INACTIVE;
312 320
						}
313 321
						imported->attributes = g_list_append(imported->attributes, a);
314 322
						break;
......
433 441
							*semicolon = '\0';
434 442
							a->name = g_strdup(line);
435 443
							a->value = g_strdup(semicolon+1);
444
							a->direction = JANUS_SDP_DEFAULT;
436 445
							*semicolon = ':';
446
							if(strstr(line, "/sendonly"))
447
								a->direction = JANUS_SDP_SENDONLY;
448
							else if(strstr(line, "/recvonly"))
449
								a->direction = JANUS_SDP_RECVONLY;
450
							if(strstr(line, "/inactive"))
451
								a->direction = JANUS_SDP_INACTIVE;
437 452
						}
438 453
						mline->attributes = g_list_append(mline->attributes, a);
439 454
						break;
sdp-utils.h
149 149
	char *name;
150 150
	/*! \brief Attribute value */
151 151
	char *value;
152
	/*! \brief Attribute direction (e.g., for extmap) */
153
	janus_sdp_mdirection direction;
152 154
} janus_sdp_attribute;
153 155
/*! \brief Helper method to quickly create a janus_sdp_attribute instance
154 156
 * @param[in] name Name of the attribute

Also available in: Unified diff