- Timestamp:
- Jan 18, 2017 10:55:35 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk merged: 5516-5525,5527,5530-5531
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/src/pjmedia/transport_ice.c
r5513 r5532 672 672 pj_ice_sess_cand *cand) 673 673 { 674 pj_str_t input; 675 char *token, *host; 676 int af; 677 pj_str_t s; 674 pj_str_t token, delim, host; 675 int af, found_idx; 678 676 pj_status_t status = PJNATH_EICEINCANDSDP; 679 677 680 678 pj_bzero(cand, sizeof(*cand)); 681 pj_strdup_with_null(pool, &input, orig_input);682 679 683 680 PJ_UNUSED_ARG(obj_name); 684 681 685 682 /* Foundation */ 686 token = strtok(input.ptr, " "); 687 if (!token) { 683 delim = pj_str(" "); 684 found_idx = pj_strtok(orig_input, &delim, &token, 0); 685 if (found_idx == orig_input->slen) { 688 686 TRACE__((obj_name, "Expecting ICE foundation in candidate")); 689 687 goto on_return; 690 688 } 691 pj_strdup 2(pool, &cand->foundation,token);689 pj_strdup(pool, &cand->foundation, &token); 692 690 693 691 /* Component ID */ 694 token = strtok(NULL, " ");695 if ( !token) {692 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + token.slen); 693 if (found_idx == orig_input->slen) { 696 694 TRACE__((obj_name, "Expecting ICE component ID in candidate")); 697 695 goto on_return; 698 696 } 699 cand->comp_id = (pj_uint8_t) atoi(token);697 cand->comp_id = (pj_uint8_t)pj_strtoul(&token); 700 698 701 699 /* Transport */ 702 token = strtok(NULL, " ");703 if ( !token) {700 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + token.slen); 701 if (found_idx == orig_input->slen) { 704 702 TRACE__((obj_name, "Expecting ICE transport in candidate")); 705 703 goto on_return; 706 704 } 707 if (pj_ ansi_stricmp(token, "UDP") != 0) {705 if (pj_stricmp2(&token, "UDP") != 0) { 708 706 TRACE__((obj_name, 709 707 "Expecting ICE UDP transport only in candidate")); … … 712 710 713 711 /* Priority */ 714 token = strtok(NULL, " ");715 if ( !token) {712 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + token.slen); 713 if (found_idx == orig_input->slen) { 716 714 TRACE__((obj_name, "Expecting ICE priority in candidate")); 717 715 goto on_return; 718 716 } 719 cand->prio = atoi(token);717 cand->prio = pj_strtoul(&token); 720 718 721 719 /* Host */ 722 host = strtok(NULL, " ");723 if ( !host) {720 found_idx = pj_strtok(orig_input, &delim, &host, found_idx + token.slen); 721 if (found_idx == orig_input->slen) { 724 722 TRACE__((obj_name, "Expecting ICE host in candidate")); 725 723 goto on_return; 726 724 } 727 725 /* Detect address family */ 728 if (pj_ ansi_strchr(host, ':'))726 if (pj_strchr(&host, ':')) 729 727 af = pj_AF_INET6(); 730 728 else 731 729 af = pj_AF_INET(); 732 730 /* Assign address */ 733 if (pj_sockaddr_init(af, &cand->addr, pj_cstr(&s, host), 0)) {731 if (pj_sockaddr_init(af, &cand->addr, &host, 0)) { 734 732 TRACE__((obj_name, "Invalid ICE candidate address")); 735 733 goto on_return; … … 737 735 738 736 /* Port */ 739 token = strtok(NULL, " ");740 if ( !token) {737 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + host.slen); 738 if (found_idx == orig_input->slen) { 741 739 TRACE__((obj_name, "Expecting ICE port number in candidate")); 742 740 goto on_return; 743 741 } 744 pj_sockaddr_set_port(&cand->addr, (pj_uint16_t) atoi(token));742 pj_sockaddr_set_port(&cand->addr, (pj_uint16_t)pj_strtoul(&token)); 745 743 746 744 /* typ */ 747 token = strtok(NULL, " ");748 if ( !token) {745 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + token.slen); 746 if (found_idx == orig_input->slen) { 749 747 TRACE__((obj_name, "Expecting ICE \"typ\" in candidate")); 750 748 goto on_return; 751 749 } 752 if (pj_ ansi_stricmp(token, "typ") != 0) {750 if (pj_stricmp2(&token, "typ") != 0) { 753 751 TRACE__((obj_name, "Expecting ICE \"typ\" in candidate")); 754 752 goto on_return; … … 756 754 757 755 /* candidate type */ 758 token = strtok(NULL, " ");759 if ( !token) {756 found_idx = pj_strtok(orig_input, &delim, &token, found_idx + token.slen); 757 if (found_idx == orig_input->slen) { 760 758 TRACE__((obj_name, "Expecting ICE candidate type in candidate")); 761 759 goto on_return; 762 760 } 763 761 764 if (pj_ ansi_stricmp(token, "host") == 0) {762 if (pj_stricmp2(&token, "host") == 0) { 765 763 cand->type = PJ_ICE_CAND_TYPE_HOST; 766 764 767 } else if (pj_ ansi_stricmp(token, "srflx") == 0) {765 } else if (pj_stricmp2(&token, "srflx") == 0) { 768 766 cand->type = PJ_ICE_CAND_TYPE_SRFLX; 769 767 770 } else if (pj_ ansi_stricmp(token, "relay") == 0) {768 } else if (pj_stricmp2(&token, "relay") == 0) { 771 769 cand->type = PJ_ICE_CAND_TYPE_RELAYED; 772 770 773 } else if (pj_ ansi_stricmp(token, "prflx") == 0) {771 } else if (pj_stricmp2(&token, "prflx") == 0) { 774 772 cand->type = PJ_ICE_CAND_TYPE_PRFLX; 775 773 776 774 } else { 777 PJ_LOG(5,(obj_name, "Invalid ICE candidate type % s in candidate",778 token ));775 PJ_LOG(5,(obj_name, "Invalid ICE candidate type %.*s in candidate", 776 token.slen, token.ptr)); 779 777 goto on_return; 780 778 } … … 1839 1837 tp_ice = (struct transport_ice*) pj_ice_strans_get_user_data(ice_st); 1840 1838 1839 pj_perror(5, tp_ice->base.name, result, "ICE operation complete" 1840 " (op=%d%s)", op, 1841 (op==PJ_ICE_STRANS_OP_INIT? "/initialization" : 1842 (op==PJ_ICE_STRANS_OP_NEGOTIATION? "/negotiation":""))); 1843 1841 1844 /* Notify application */ 1842 1845 if (tp_ice->cb.on_ice_complete)
Note: See TracChangeset
for help on using the changeset viewer.