Revision 0351dafc ice.c

View differences:

ice.c
2181 2181
}
2182 2182

  
2183 2183
/* Helper: candidates */
2184
void janus_ice_candidates_to_sdp(janus_ice_handle *handle, char *sdp, guint stream_id, guint component_id)
2184
void janus_ice_candidates_to_sdp(janus_ice_handle *handle, janus_sdp_mline *mline, guint stream_id, guint component_id)
2185 2185
{
2186
	if(!handle || !handle->agent || !sdp)
2186
	if(!handle || !handle->agent || !mline)
2187 2187
		return;
2188 2188
	janus_ice_stream *stream = g_hash_table_lookup(handle->streams, GUINT_TO_POINTER(stream_id));
2189 2189
	if(!stream) {
......
2220 2220
		JANUS_LOG(LOG_VERB, "[%"SCNu64"]   Priority:   %d\n", handle->handle_id, c->priority);
2221 2221
		JANUS_LOG(LOG_VERB, "[%"SCNu64"]   Foundation: %s\n", handle->handle_id, c->foundation);
2222 2222
		/* SDP time */
2223
		gchar buffer[100];
2223
		gchar buffer[200];
2224 2224
		if(c->type == NICE_CANDIDATE_TYPE_HOST) {
2225 2225
			/* 'host' candidate */
2226 2226
			if(c->transport == NICE_CANDIDATE_TRANSPORT_UDP) {
2227
				g_snprintf(buffer, 100,
2228
					"a=candidate:%s %d %s %d %s %d typ host\r\n", 
2227
				g_snprintf(buffer, sizeof(buffer),
2228
					"%s %d %s %d %s %d typ host",
2229 2229
						c->foundation,
2230 2230
						c->component_id,
2231 2231
						"udp",
......
2265 2265
					nice_candidate_free(c);
2266 2266
					continue;
2267 2267
				} else {
2268
					g_snprintf(buffer, 100,
2269
						"a=candidate:%s %d %s %d %s %d typ host tcptype %s\r\n", 
2268
					g_snprintf(buffer, sizeof(buffer),
2269
						"%s %d %s %d %s %d typ host tcptype %s",
2270 2270
							c->foundation,
2271 2271
							c->component_id,
2272 2272
							"tcp",
......
2282 2282
			if(c->transport == NICE_CANDIDATE_TRANSPORT_UDP) {
2283 2283
				nice_address_to_string(&(c->base_addr), (gchar *)&base_address);
2284 2284
				gint base_port = nice_address_get_port(&(c->base_addr));
2285
				g_snprintf(buffer, 100,
2286
					"a=candidate:%s %d %s %d %s %d typ srflx raddr %s rport %d\r\n", 
2285
				g_snprintf(buffer, sizeof(buffer),
2286
					"%s %d %s %d %s %d typ srflx raddr %s rport %d",
2287 2287
						c->foundation,
2288 2288
						c->component_id,
2289 2289
						"udp",
......
2325 2325
					nice_candidate_free(c);
2326 2326
					continue;
2327 2327
				} else {
2328
					g_snprintf(buffer, 100,
2329
						"a=candidate:%s %d %s %d %s %d typ srflx raddr %s rport %d tcptype %s\r\n", 
2328
					g_snprintf(buffer, sizeof(buffer),
2329
						"%s %d %s %d %s %d typ srflx raddr %s rport %d tcptype %s",
2330 2330
							c->foundation,
2331 2331
							c->component_id,
2332 2332
							"tcp",
......
2347 2347
		} else if(c->type == NICE_CANDIDATE_TYPE_RELAYED) {
2348 2348
			/* 'relay' candidate */
2349 2349
			if(c->transport == NICE_CANDIDATE_TRANSPORT_UDP) {
2350
				g_snprintf(buffer, 100,
2351
					"a=candidate:%s %d %s %d %s %d typ relay raddr %s rport %d\r\n", 
2350
				g_snprintf(buffer, sizeof(buffer),
2351
					"%s %d %s %d %s %d typ relay raddr %s rport %d",
2352 2352
						c->foundation,
2353 2353
						c->component_id,
2354 2354
						"udp",
......
2390 2390
					nice_candidate_free(c);
2391 2391
					continue;
2392 2392
				} else {
2393
					g_snprintf(buffer, 100,
2394
						"a=candidate:%s %d %s %d %s %d typ relay raddr %s rport %d tcptype %s\r\n", 
2393
					g_snprintf(buffer, sizeof(buffer),
2394
						"%s %d %s %d %s %d typ relay raddr %s rport %d tcptype %s",
2395 2395
							c->foundation,
2396 2396
							c->component_id,
2397 2397
							"tcp",
......
2405 2405
#endif
2406 2406
			}
2407 2407
		}
2408
		g_strlcat(sdp, buffer, JANUS_BUFSIZE);
2408
#pragma GCC diagnostic ignored "-Wformat-security"
2409
		janus_sdp_attribute *a = janus_sdp_attribute_create("candidate", buffer);
2410
#pragma GCC diagnostic warning "-Wformat-security"
2411
		mline->attributes = g_list_append(mline->attributes, a);
2409 2412
		JANUS_LOG(LOG_VERB, "[%"SCNu64"]     %s", handle->handle_id, buffer); /* buffer already newline terminated */
2410 2413
		if(log_candidates) {
2411 2414
			/* Save for the summary, in case we need it */
2412
			component->local_candidates = g_slist_append(component->local_candidates, g_strdup(buffer+strlen("a=candidate:")));
2415
			component->local_candidates = g_slist_append(component->local_candidates, g_strdup(buffer));
2413 2416
		}
2414 2417
		nice_candidate_free(c);
2415 2418
	}

Also available in: Unified diff