3 Copyright (C) 2010 Simon MORLAT (simon.morlat@free.fr)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include "ortp/port.h"
23 #include "ortp/ortp_srtp.h"
25 #include <eXosip2/eXosip.h>
27 #define keywordcmp(key,b) strcmp(key,b)
31 static char *make_relay_session_id(const char *username, const char *relay){
32 /*ideally this should be a hash of the parameters with a random part*/
36 long long int res=((long long int)s1)<<32 | (long long int) s2;
38 b64_encode(src, sizeof(long long int), tmp, sizeof(tmp));
39 return osip_strdup(tmp);
43 static void add_relay_info(sdp_message_t *sdp, int mline, const char *relay, const char *relay_session_id){
45 if (relay) sdp_message_a_attribute_add(sdp, mline,
46 osip_strdup ("relay-addr"),osip_strdup(relay));
47 if (relay_session_id) sdp_message_a_attribute_add(sdp, mline,
48 osip_strdup ("relay-session-id"), osip_strdup(relay_session_id));
53 static char * int_2char(int a){
54 char *p=osip_malloc(16);
55 snprintf(p,16,"%i",a);
59 /* return the value of attr "field" for payload pt at line pos (field=rtpmap,fmtp...)*/
60 static const char *sdp_message_a_attr_value_get_with_pt(sdp_message_t *sdp,int pos,int pt,const char *field)
62 int i,tmppt=0,scanned=0;
64 sdp_attribute_t *attr;
65 for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){
66 if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
67 int nb = sscanf(attr->a_att_value,"%i %n",&tmppt,&scanned);
68 /* the return value may depend on how %n is interpreted by the libc: see manpage*/
69 if (nb == 1 || nb==2 ){
71 tmp=attr->a_att_value+scanned;
75 }else ms_warning("sdp has a strange a= line (%s) nb=%i",attr->a_att_value,nb);
82 /* return the value of attr "field" */
83 static const char *sdp_message_a_attr_value_get(sdp_message_t *sdp,int pos,const char *field)
86 sdp_attribute_t *attr;
87 for (i=0;(attr=sdp_message_attribute_get(sdp,pos,i))!=NULL;i++){
88 if (keywordcmp(field,attr->a_att_field)==0 && attr->a_att_value!=NULL){
89 return attr->a_att_value;
96 static int _sdp_message_get_a_ptime(sdp_message_t *sdp, int mline){
98 sdp_attribute_t *attr;
99 for (i=0;(attr=sdp_message_attribute_get(sdp,mline,i))!=NULL;i++){
100 if (keywordcmp("ptime",attr->a_att_field)==0){
101 int nb = sscanf(attr->a_att_value,"%i",&ret);
102 /* the return value may depend on how %n is interpreted by the libc: see manpage*/
105 }else ms_warning("sdp has a strange a=ptime line (%s) ",attr->a_att_value);
111 static char * _sdp_message_get_a_zrtp_hash(sdp_message_t *sdp, int mline){
113 sdp_attribute_t *attr;
114 for (i=0;(attr=sdp_message_attribute_get(sdp,mline,i))!=NULL;i++){
115 if (keywordcmp("zrtp-hash",attr->a_att_field)==0){
116 return attr->a_att_value;
122 static int _sdp_message_get_mline_dir(sdp_message_t *sdp, int mline){
124 sdp_attribute_t *attr;
125 for (i=0;(attr=sdp_message_attribute_get(sdp,mline,i))!=NULL;i++){
126 if (keywordcmp("sendrecv",attr->a_att_field)==0){
127 return SalStreamSendRecv;
128 }else if (keywordcmp("sendonly",attr->a_att_field)==0){
129 return SalStreamSendOnly;
130 }else if (keywordcmp("recvonly",attr->a_att_field)==0){
131 return SalStreamRecvOnly;
132 }else if (keywordcmp("inactive",attr->a_att_field)==0){
133 return SalStreamInactive;
136 return SalStreamSendRecv;
139 static sdp_message_t *create_generic_sdp(const SalMediaDescription *desc)
141 sdp_message_t *local;
145 const char *rtp_addr = desc->addr;
147 snprintf(sessid,16,"%i",desc->session_id);
148 snprintf(sessver,16,"%i",desc->session_ver);
149 sdp_message_init (&local);
150 if (strchr(desc->addr,':')!=NULL){
153 sdp_message_v_version_set (local, osip_strdup ("0"));
154 sdp_message_o_origin_set (local, osip_strdup (desc->username),
155 osip_strdup (sessid), osip_strdup (sessver),
156 osip_strdup ("IN"), inet6 ? osip_strdup("IP6") : osip_strdup ("IP4"),
157 osip_strdup (desc->addr));
158 sdp_message_s_name_set (local, osip_strdup ("Talk"));
159 /* Do not set the c= line to 0.0.0.0 if there is an ICE session. */
160 if((desc->ice_ufrag[0] != '\0') || !sal_media_description_has_dir (desc,SalStreamSendOnly))
162 sdp_message_c_connection_add (local, -1,
163 osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
164 osip_strdup (rtp_addr), NULL, NULL);
168 sdp_message_c_connection_add (local, -1,
169 osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
170 inet6 ? osip_strdup ("::0") : osip_strdup ("0.0.0.0"), NULL, NULL);
172 sdp_message_t_time_descr_add (local, osip_strdup ("0"), osip_strdup ("0"));
173 if (desc->bandwidth>0) sdp_message_b_bandwidth_add (local, -1, osip_strdup ("AS"),
174 int_2char(desc->bandwidth));
175 if (desc->ice_completed == TRUE) sdp_message_a_attribute_add(local, -1, osip_strdup("nortpproxy"), osip_strdup("yes"));
176 if (desc->ice_pwd[0] != '\0') sdp_message_a_attribute_add(local, -1, osip_strdup("ice-pwd"), osip_strdup(desc->ice_pwd));
177 if (desc->ice_ufrag[0] != '\0') sdp_message_a_attribute_add(local, -1, osip_strdup("ice-ufrag"), osip_strdup(desc->ice_ufrag));
183 static bool_t is_known_rtpmap(const PayloadType *pt){
184 switch(payload_type_get_number(pt)){
194 static void add_payload(sdp_message_t *msg, int line, const PayloadType *pt, bool_t strip_well_known_rtpmaps)
197 sdp_message_m_payload_add (msg,line, int_2char (payload_type_get_number(pt)));
199 if (!strip_well_known_rtpmaps || !is_known_rtpmap(pt)){
201 snprintf (attr,sizeof(attr),"%i %s/%i/%i", payload_type_get_number(pt),
202 pt->mime_type, pt->clock_rate,pt->channels);
204 snprintf (attr,sizeof(attr),"%i %s/%i", payload_type_get_number(pt),
205 pt->mime_type, pt->clock_rate);
206 sdp_message_a_attribute_add (msg, line,
207 osip_strdup ("rtpmap"), osip_strdup(attr));
210 if (pt->recv_fmtp != NULL)
212 snprintf (attr,sizeof(attr),"%i %s", payload_type_get_number(pt),pt->recv_fmtp);
213 sdp_message_a_attribute_add (msg, line, osip_strdup ("fmtp"),
218 static void add_ice_candidates(sdp_message_t *msg, int lineno, const SalStreamDescription *desc)
221 const SalIceCandidate *candidate;
225 for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES; i++) {
226 candidate = &desc->ice_candidates[i];
227 if ((candidate->addr[0] == '\0') || (candidate->port == 0)) break;
228 nb = snprintf(buffer, sizeof(buffer), "%s %u UDP %u %s %d typ %s",
229 candidate->foundation, candidate->componentID, candidate->priority, candidate->addr, candidate->port, candidate->type);
231 ms_error("Cannot add ICE candidate attribute!");
234 if (candidate->raddr[0] != '\0') {
235 nb = snprintf(buffer + nb, sizeof(buffer) - nb, " raddr %s rport %d", candidate->raddr, candidate->rport);
237 ms_error("Cannot add ICE candidate attribute!");
241 sdp_message_a_attribute_add(msg, lineno, osip_strdup("candidate"), osip_strdup(buffer));
245 static void add_ice_remote_candidates(sdp_message_t *msg, int lineno, const SalStreamDescription *desc)
249 const SalIceRemoteCandidate *candidate;
254 for (i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES; i++) {
255 candidate = &desc->ice_remote_candidates[i];
256 if ((candidate->addr[0] != '\0') && (candidate->port != 0)) {
257 offset = snprintf(ptr, buffer + sizeof(buffer) - ptr, "%s%d %s %d", (i > 0) ? " " : "", i + 1, candidate->addr, candidate->port);
259 ms_error("Cannot add ICE remote-candidates attribute!");
265 if (buffer[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("remote-candidates"), osip_strdup(buffer));
268 static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription *desc){
271 const char *rtp_addr;
272 const char *rtcp_addr;
273 const char *dir="sendrecv";
276 bool_t strip_well_known_rtpmaps;
277 bool_t different_rtp_and_rtcp_addr;
279 switch (desc->type) {
290 rtp_addr=desc->rtp_addr;
291 rtcp_addr=desc->rtcp_addr;
292 rtp_port=desc->rtp_port;
293 rtcp_port=desc->rtcp_port;
295 if (desc->proto == SalProtoRtpSavp) {
298 sdp_message_m_media_add (msg, osip_strdup (mt),
299 int_2char (rtp_port), NULL,
300 osip_strdup ("RTP/SAVP"));
302 /* add crypto lines */
303 for(i=0; i<SAL_CRYPTO_ALGO_MAX; i++) {
305 switch (desc->crypto[i].algo) {
306 case AES_128_SHA1_80:
307 snprintf(buffer, 1024, "%d %s inline:%s",
308 desc->crypto[i].tag, "AES_CM_128_HMAC_SHA1_80", desc->crypto[i].master_key);
309 sdp_message_a_attribute_add(msg, lineno, osip_strdup("crypto"),
310 osip_strdup(buffer));
312 case AES_128_SHA1_32:
313 snprintf(buffer, 1024, "%d %s inline:%s",
314 desc->crypto[i].tag, "AES_CM_128_HMAC_SHA1_32", desc->crypto[i].master_key);
315 sdp_message_a_attribute_add(msg, lineno, osip_strdup("crypto"),
316 osip_strdup(buffer));
318 case AES_128_NO_AUTH:
319 ms_warning("Unsupported crypto suite: AES_128_NO_AUTH");
321 case NO_CIPHER_SHA1_80:
322 ms_warning("Unsupported crypto suite: NO_CIPHER_SHA1_80");
325 i = SAL_CRYPTO_ALGO_MAX;
330 sdp_message_m_media_add (msg, osip_strdup (mt),
331 int_2char (rtp_port), NULL,
332 osip_strdup ("RTP/AVP"));
336 /*only add a c= line within the stream description if address are differents*/
337 if (rtp_addr[0]!='\0' && strcmp(rtp_addr,sdp_message_c_addr_get(msg, -1, 0))!=0){
339 if (strchr(rtp_addr,':')!=NULL){
342 sdp_message_c_connection_add (msg, lineno,
343 osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
344 osip_strdup (rtp_addr), NULL, NULL);
347 if (desc->bandwidth>0) sdp_message_b_bandwidth_add (msg, lineno, osip_strdup ("AS"),
348 int_2char(desc->bandwidth));
349 if (desc->ptime>0) sdp_message_a_attribute_add(msg,lineno,osip_strdup("ptime"),
350 int_2char(desc->ptime));
352 // if the ZRTP hello hash is available, create an a attribute for it
353 if (desc->zrtp_hello_hash[0])
354 sdp_message_a_attribute_add(msg,lineno,osip_strdup("zrtp-hash"), osip_strdup(desc->zrtp_hello_hash));
356 strip_well_known_rtpmaps=ms_list_size(desc->payloads)>5;
358 for(elem=desc->payloads;elem!=NULL;elem=elem->next){
359 add_payload(msg, lineno, (PayloadType*)elem->data,strip_well_known_rtpmaps);
362 /* to comply with SDP we cannot have an empty payload type number list */
363 /* as it happens only when mline is declined with a zero port, it does not matter to put whatever codec*/
364 sdp_message_m_payload_add (msg,lineno, int_2char (0));
367 case SalStreamSendRecv:
371 case SalStreamRecvOnly:
374 case SalStreamSendOnly:
377 case SalStreamInactive:
381 if (dir) sdp_message_a_attribute_add (msg, lineno, osip_strdup (dir),NULL);
383 different_rtp_and_rtcp_addr = (rtcp_addr[0] != '\0') && (strcmp(rtp_addr, rtcp_addr) != 0);
384 if ((rtcp_port != (rtp_port + 1)) || (different_rtp_and_rtcp_addr == TRUE)) {
385 if (different_rtp_and_rtcp_addr == TRUE) {
387 snprintf(buffer, sizeof(buffer), "%u IN IP4 %s", rtcp_port, rtcp_addr);
388 sdp_message_a_attribute_add(msg, lineno, osip_strdup("rtcp"), osip_strdup(buffer));
390 sdp_message_a_attribute_add(msg, lineno, osip_strdup("rtcp"), int_2char(rtcp_port));
394 if (desc->ice_completed == TRUE) {
395 sdp_message_a_attribute_add(msg, lineno, osip_strdup("nortpproxy"), osip_strdup("yes"));
397 if (desc->ice_mismatch == TRUE) {
398 sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-mismatch"), NULL);
400 if (desc->rtp_port != 0) {
401 if (desc->ice_pwd[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-pwd"), osip_strdup(desc->ice_pwd));
402 if (desc->ice_ufrag[0] != '\0') sdp_message_a_attribute_add(msg, lineno, osip_strdup("ice-ufrag"), osip_strdup(desc->ice_ufrag));
403 add_ice_candidates(msg, lineno, desc);
404 add_ice_remote_candidates(msg, lineno, desc);
410 sdp_message_t *media_description_to_sdp(const SalMediaDescription *desc){
412 sdp_message_t *msg=create_generic_sdp(desc);
413 for(i=0;i<desc->n_total_streams;++i){
414 add_line(msg,i,&desc->streams[i]);
419 static int payload_type_fill_from_rtpmap(PayloadType *pt, const char *rtpmap){
421 PayloadType *refpt=rtp_profile_get_payload(&av_profile,payload_type_get_number(pt));
423 pt->mime_type=ms_strdup(refpt->mime_type);
424 pt->clock_rate=refpt->clock_rate;
426 ms_error("payload number %i has no rtpmap and is unknown in AV Profile, ignored.",
427 payload_type_get_number(pt));
431 char *mime=ms_strdup(rtpmap);
432 char *p=strchr(mime,'/');
441 pt->channels=atoi(chans);
442 }else pt->channels=1;
443 pt->clock_rate=atoi(p);
450 int sdp_to_media_description(sdp_message_t *msg, SalMediaDescription *desc){
452 const char *mtype,*proto,*rtp_port,*rtp_addr,*number,*zrtp_info;
454 sdp_bandwidth_t *sbw=NULL;
455 sdp_attribute_t *attr;
456 int nb_ice_candidates;
458 /* Get session information. */
459 sess = sdp_message_o_sess_id_get(msg);
460 if (sess) desc->session_id = strtoul(sess, NULL, 10);
461 sess = sdp_message_o_sess_version_get(msg);
462 if (sess) desc->session_ver = strtoul(sess, NULL, 10);
464 rtp_addr=sdp_message_c_addr_get (msg, -1, 0);
466 strncpy(desc->addr,rtp_addr,sizeof(desc->addr));
467 for(j=0;(sbw=sdp_message_bandwidth_get(msg,-1,j))!=NULL;++j){
468 if (strcasecmp(sbw->b_bwtype,"AS")==0) desc->bandwidth=atoi(sbw->b_bandwidth);
471 /* Get ICE remote ufrag and remote pwd, and ice_lite flag */
472 for (i = 0; (i < SAL_MEDIA_DESCRIPTION_MAX_MESSAGE_ATTRIBUTES) && ((attr = sdp_message_attribute_get(msg, -1, i)) != NULL); i++) {
473 if ((keywordcmp("ice-ufrag", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
474 strncpy(desc->ice_ufrag, attr->a_att_value, sizeof(desc->ice_ufrag));
475 } else if ((keywordcmp("ice-pwd", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
476 strncpy(desc->ice_pwd, attr->a_att_value, sizeof(desc->ice_pwd));
477 } else if (keywordcmp("ice-lite", attr->a_att_field) == 0) {
478 desc->ice_lite = TRUE;
482 desc->n_active_streams = 0;
484 /* for each m= line */
485 for (i=0; !sdp_message_endof_media (msg, i) && i<SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++)
487 SalStreamDescription *stream=&desc->streams[i];
488 nb_ice_candidates = 0;
490 memset(stream,0,sizeof(*stream));
491 mtype = sdp_message_m_media_get(msg, i);
492 proto = sdp_message_m_proto_get (msg, i);
493 rtp_port = sdp_message_m_port_get(msg, i);
494 stream->proto=SalProtoUnknown;
496 if (strcasecmp(proto,"RTP/AVP")==0)
497 stream->proto=SalProtoRtpAvp;
498 else if (strcasecmp(proto,"RTP/SAVP")==0){
499 stream->proto=SalProtoRtpSavp;
502 rtp_addr = sdp_message_c_addr_get (msg, i, 0);
503 if (rtp_addr != NULL)
504 strncpy(stream->rtp_addr,rtp_addr,sizeof(stream->rtp_addr));
506 stream->rtp_port=atoi(rtp_port);
507 if (stream->rtp_port > 0)
508 desc->n_active_streams++;
510 // if the SDP contains a zrtp-hash, add it to the StreamDesc
511 zrtp_info = _sdp_message_get_a_zrtp_hash(msg, i);
512 if (zrtp_info != NULL)
513 strncpy(stream->zrtp_hello_hash, zrtp_info, sizeof(stream->zrtp_hello_hash));
515 stream->ptime=_sdp_message_get_a_ptime(msg,i);
516 if (strcasecmp("audio", mtype) == 0){
517 stream->type=SalAudio;
518 }else if (strcasecmp("video", mtype) == 0){
519 stream->type=SalVideo;
521 stream->type=SalOther;
522 strncpy(stream->typeother,mtype,sizeof(stream->typeother)-1);
524 for(j=0;(sbw=sdp_message_bandwidth_get(msg,i,j))!=NULL;++j){
525 if (strcasecmp(sbw->b_bwtype,"AS")==0) stream->bandwidth=atoi(sbw->b_bandwidth);
527 stream->dir=_sdp_message_get_mline_dir(msg,i);
528 /* for each payload type */
529 for (j=0;((number=sdp_message_m_payload_get (msg, i,j)) != NULL); j++){
530 const char *rtpmap,*fmtp;
531 int ptn=atoi(number);
532 PayloadType *pt=payload_type_new();
533 payload_type_set_number(pt,ptn);
534 /* get the rtpmap associated to this codec, if any */
535 rtpmap=sdp_message_a_attr_value_get_with_pt(msg, i,ptn,"rtpmap");
536 if (payload_type_fill_from_rtpmap(pt,rtpmap)==0){
537 /* get the fmtp, if any */
538 fmtp=sdp_message_a_attr_value_get_with_pt(msg, i, ptn,"fmtp");
539 payload_type_set_send_fmtp(pt,fmtp);
540 stream->payloads=ms_list_append(stream->payloads,pt);
541 ms_message("Found payload %s/%i fmtp=%s",pt->mime_type,pt->clock_rate,
542 pt->send_fmtp ? pt->send_fmtp : "");
546 /* Get media specific RTCP attribute */
547 stream->rtcp_port = stream->rtp_port + 1;
548 snprintf(stream->rtcp_addr, sizeof(stream->rtcp_addr), "%s", stream->rtp_addr);
549 for (j = 0; ((attr = sdp_message_attribute_get(msg, i, j)) != NULL); j++) {
550 if ((keywordcmp("rtcp", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
552 // added bounds check
553 int nb = sscanf(attr->a_att_value, "%d IN IP4 %256s", &stream->rtcp_port, tmp);
555 /* SDP rtcp attribute only contains the port */
556 } else if (nb == 2) {
557 strncpy(stream->rtcp_addr, tmp, sizeof(stream->rtcp_addr));
559 ms_warning("sdp has a strange a= line (%s) nb=%i", attr->a_att_value, nb);
564 /* read crypto lines if any */
565 if (stream->proto == SalProtoRtpSavp) {
566 int k, valid_count = 0;
568 memset(&stream->crypto, 0, sizeof(stream->crypto));
569 for (k=0;valid_count < SAL_CRYPTO_ALGO_MAX && (attr=sdp_message_attribute_get(msg,i,k))!=NULL;k++){
570 char tmp[256], tmp2[256];
571 if (keywordcmp("crypto",attr->a_att_field)==0 && attr->a_att_value!=NULL){
572 int nb = sscanf(attr->a_att_value, "%d %256s inline:%256s",
573 &stream->crypto[valid_count].tag,
576 ms_message("Found valid crypto line (tag:%d algo:'%s' key:'%s'",
577 stream->crypto[valid_count].tag,
581 if (strcmp(tmp, "AES_CM_128_HMAC_SHA1_80") == 0)
582 stream->crypto[valid_count].algo = AES_128_SHA1_80;
583 else if (strcmp(tmp, "AES_CM_128_HMAC_SHA1_32") == 0)
584 stream->crypto[valid_count].algo = AES_128_SHA1_32;
586 ms_warning("Failed to parse crypto-algo: '%s'", tmp);
587 stream->crypto[valid_count].algo = 0;
589 if (stream->crypto[valid_count].algo) {
590 strncpy(stream->crypto[valid_count].master_key, tmp2, 41);
591 stream->crypto[valid_count].master_key[40] = '\0';
592 ms_message("Found valid crypto line (tag:%d algo:'%s' key:'%s'",
593 stream->crypto[valid_count].tag,
595 stream->crypto[valid_count].master_key);
599 ms_warning("sdp has a strange a= line (%s) nb=%i",attr->a_att_value,nb);
603 ms_message("Found: %d valid crypto lines", valid_count);
606 /* Get ICE candidate attributes if any */
607 for (j = 0; (attr = sdp_message_attribute_get(msg, i, j)) != NULL; j++) {
608 if ((keywordcmp("candidate", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
609 SalIceCandidate *candidate = &stream->ice_candidates[nb_ice_candidates];
610 int nb = sscanf(attr->a_att_value, "%s %u UDP %u %s %d typ %s raddr %s rport %d",
611 candidate->foundation, &candidate->componentID, &candidate->priority, candidate->addr, &candidate->port,
612 candidate->type, candidate->raddr, &candidate->rport);
613 if ((nb == 6) || (nb == 8)) nb_ice_candidates++;
614 else memset(candidate, 0, sizeof(*candidate));
615 } else if ((keywordcmp("remote-candidates", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
616 SalIceRemoteCandidate candidate;
617 unsigned int componentID;
619 char *ptr = attr->a_att_value;
620 while (3 == sscanf(ptr, "%u %s %u%n", &componentID, candidate.addr, &candidate.port, &offset)) {
621 if ((componentID > 0) && (componentID <= SAL_MEDIA_DESCRIPTION_MAX_ICE_REMOTE_CANDIDATES)) {
622 SalIceRemoteCandidate *remote_candidate = &stream->ice_remote_candidates[componentID - 1];
623 strncpy(remote_candidate->addr, candidate.addr, sizeof(remote_candidate->addr));
624 remote_candidate->port = candidate.port;
627 if (ptr[offset] == ' ') ptr += 1;
629 } else if ((keywordcmp("ice-ufrag", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
630 strncpy(stream->ice_ufrag, attr->a_att_value, sizeof(stream->ice_ufrag));
631 } else if ((keywordcmp("ice-pwd", attr->a_att_field) == 0) && (attr->a_att_value != NULL)) {
632 strncpy(stream->ice_pwd, attr->a_att_value, sizeof(stream->ice_pwd));
633 } else if (keywordcmp("ice-mismatch", attr->a_att_field) == 0) {
634 stream->ice_mismatch = TRUE;
638 desc->n_total_streams=i;