- Timestamp:
- Oct 23, 2011 6:59:48 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/config.h
r3835 r3837 621 621 622 622 /** 623 * This specifies if the SDP negotiator should rewrite answer payload 624 * type numbers to use the same payload type numbers as the remote offer 625 * for all matched codecs. 626 * 627 * Default is 1 (yes) 628 */ 629 #ifndef PJMEDIA_SDP_NEG_ANSWER_SYMMETRIC_PT 630 # define PJMEDIA_SDP_NEG_ANSWER_SYMMETRIC_PT 1 631 #endif 632 633 634 /** 623 635 * Support for sending and decoding RTCP port in SDP (RFC 3605). 624 636 * Default is equal to PJMEDIA_ADVERTISE_RTCP setting. -
pjproject/trunk/pjmedia/include/pjmedia/stream.h
r3664 r3837 111 111 pjmedia_codec_param *param; /**< Optional codec param. */ 112 112 unsigned tx_pt; /**< Outgoing codec paylaod type. */ 113 unsigned rx_pt; /**< Incoming codec paylaod type. */ 113 114 unsigned tx_maxptime;/**< Outgoing codec max ptime. */ 114 115 int tx_event_pt;/**< Outgoing pt for telephone-events. */ -
pjproject/trunk/pjmedia/src/pjmedia/sdp_neg.c
r3714 r3837 1121 1121 } 1122 1122 1123 1124 /* Internal function to rewrite the format string in SDP attribute rtpmap 1125 * and fmtp. 1126 */ 1127 PJ_INLINE(void) rewrite_pt(pj_pool_t *pool, pj_str_t *attr_val, 1128 const pj_str_t *old_pt, const pj_str_t *new_pt) 1129 { 1130 int len_diff = new_pt->slen - old_pt->slen; 1131 1132 /* Note that attribute value should be null-terminated. */ 1133 if (len_diff > 0) { 1134 pj_str_t new_val; 1135 new_val.ptr = (char*)pj_pool_alloc(pool, attr_val->slen+len_diff+1); 1136 new_val.slen = attr_val->slen + len_diff; 1137 pj_memcpy(new_val.ptr + len_diff, attr_val->ptr, attr_val->slen + 1); 1138 *attr_val = new_val; 1139 } else if (len_diff < 0) { 1140 pj_memmove(attr_val->ptr, attr_val->ptr - len_diff, 1141 attr_val->slen + len_diff + 1); 1142 } 1143 pj_memcpy(attr_val->ptr, new_pt->ptr, new_pt->slen); 1144 } 1145 1146 1147 /* Internal function to apply symmetric PT for the local answer. */ 1148 static void apply_answer_symmetric_pt(pj_pool_t *pool, 1149 pjmedia_sdp_media *answer, 1150 unsigned pt_cnt, 1151 const pj_str_t pt_offer[], 1152 const pj_str_t pt_answer[]) 1153 { 1154 pjmedia_sdp_attr *a_tmp[PJMEDIA_MAX_SDP_ATTR]; 1155 unsigned i, a_tmp_cnt = 0; 1156 1157 /* Rewrite the payload types in the answer if different to 1158 * the ones in the offer. 1159 */ 1160 for (i = 0; i < pt_cnt; ++i) { 1161 pjmedia_sdp_attr *a; 1162 1163 /* Skip if the PTs are the same already, e.g: static PT. */ 1164 if (pj_strcmp(&pt_answer[i], &pt_offer[i]) == 0) 1165 continue; 1166 1167 /* Rewrite payload type in the answer to match to the offer */ 1168 pj_strdup(pool, &answer->desc.fmt[i], &pt_offer[i]); 1169 1170 /* Also update payload type in rtpmap */ 1171 a = pjmedia_sdp_media_find_attr2(answer, "rtpmap", &pt_answer[i]); 1172 if (a) { 1173 rewrite_pt(pool, &a->value, &pt_answer[i], &pt_offer[i]); 1174 /* Temporarily remove the attribute in case the new payload 1175 * type is being used by another format in the media. 1176 */ 1177 pjmedia_sdp_media_remove_attr(answer, a); 1178 a_tmp[a_tmp_cnt++] = a; 1179 } 1180 1181 /* Also update payload type in fmtp */ 1182 a = pjmedia_sdp_media_find_attr2(answer, "fmtp", &pt_answer[i]); 1183 if (a) { 1184 rewrite_pt(pool, &a->value, &pt_answer[i], &pt_offer[i]); 1185 /* Temporarily remove the attribute in case the new payload 1186 * type is being used by another format in the media. 1187 */ 1188 pjmedia_sdp_media_remove_attr(answer, a); 1189 a_tmp[a_tmp_cnt++] = a; 1190 } 1191 } 1192 1193 /* Return back 'rtpmap' and 'fmtp' attributes */ 1194 for (i = 0; i < a_tmp_cnt; ++i) 1195 pjmedia_sdp_media_add_attr(answer, a_tmp[i]); 1196 } 1197 1198 1123 1199 /* Try to match offer with answer. */ 1124 1200 static pj_status_t match_offer(pj_pool_t *pool, … … 1138 1214 unsigned pt_answer_count = 0; 1139 1215 pj_str_t pt_answer[PJMEDIA_MAX_SDP_FMT]; 1216 pj_str_t pt_offer[PJMEDIA_MAX_SDP_FMT]; 1140 1217 pjmedia_sdp_media *answer; 1141 1218 const pjmedia_sdp_media *master, *slave; … … 1202 1279 if (p == pt && pj_isdigit(*slave->desc.fmt[j].ptr)) { 1203 1280 found_matching_codec = 1; 1281 pt_offer[pt_answer_count] = slave->desc.fmt[j]; 1204 1282 pt_answer[pt_answer_count++] = slave->desc.fmt[j]; 1205 1283 break; … … 1301 1379 } 1302 1380 1381 pt_offer[pt_answer_count] = 1382 prefer_remote_codec_order? 1383 offer->desc.fmt[i]: 1384 offer->desc.fmt[j]; 1303 1385 pt_answer[pt_answer_count++] = 1304 1386 prefer_remote_codec_order? … … 1326 1408 /* Match */ 1327 1409 found_matching_other = 1; 1410 pt_offer[pt_answer_count] = prefer_remote_codec_order? 1411 offer->desc.fmt[i]: 1412 offer->desc.fmt[j]; 1328 1413 pt_answer[pt_answer_count++] = prefer_remote_codec_order? 1329 1414 preanswer->desc.fmt[j]: … … 1390 1475 } 1391 1476 answer->desc.fmt_count = pt_answer_count; 1477 1478 #if PJMEDIA_SDP_NEG_ANSWER_SYMMETRIC_PT 1479 apply_answer_symmetric_pt(pool, answer, pt_answer_count, 1480 pt_offer, pt_answer); 1481 #endif 1392 1482 1393 1483 /* Update media direction. */ -
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r3664 r3837 2221 2221 2222 2222 status = create_channel( pool, stream, PJMEDIA_DIR_DECODING, 2223 info-> fmt.pt, info, &stream->dec);2223 info->rx_pt, info, &stream->dec); 2224 2224 if (status != PJ_SUCCESS) 2225 2225 goto err_cleanup; … … 2835 2835 return PJMEDIA_EINVALIDPT; 2836 2836 2837 /* Get payload type for receiving direction */ 2838 si->rx_pt = pt; 2839 2837 2840 /* Get codec info. 2838 2841 * For static payload types, get the info from codec manager. … … 2894 2897 2895 2898 } else { 2899 pjmedia_codec_id codec_id; 2900 pj_str_t codec_id_st; 2901 const pjmedia_codec_info *p_info; 2896 2902 2897 2903 attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP, … … 2908 2914 si->fmt.type = si->type; 2909 2915 si->fmt.pt = pj_strtoul(&local_m->desc.fmt[fmti]); 2910 pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name);2916 si->fmt.encoding_name = rtpmap->enc_name; 2911 2917 si->fmt.clock_rate = rtpmap->clock_rate; 2912 2918 … … 2919 2925 si->fmt.channel_cnt = 1; 2920 2926 } 2927 2928 /* Normalize the codec info from codec manager. Note that the 2929 * payload type will be resetted to its default (it might have 2930 * been rewritten by the SDP negotiator to match to the remote 2931 * offer), this is intentional as currently some components may 2932 * prefer (or even require) the default PT in codec info. 2933 */ 2934 pjmedia_codec_info_to_id(&si->fmt, codec_id, sizeof(codec_id)); 2935 2936 i = 1; 2937 codec_id_st = pj_str(codec_id); 2938 status = pjmedia_codec_mgr_find_codecs_by_id(mgr, &codec_id_st, 2939 &i, &p_info, NULL); 2940 if (status != PJ_SUCCESS) 2941 return status; 2942 2943 pj_memcpy(&si->fmt, p_info, sizeof(pjmedia_codec_info)); 2921 2944 2922 2945 /* Determine payload type for outgoing channel, by finding … … 2966 2989 2967 2990 /* Get local fmtp for our decoder. */ 2968 pjmedia_stream_info_parse_fmtp(pool, local_m, si-> fmt.pt,2991 pjmedia_stream_info_parse_fmtp(pool, local_m, si->rx_pt, 2969 2992 &si->param->setting.dec_fmtp); 2970 2993 -
pjproject/trunk/pjmedia/src/pjmedia/vid_stream.c
r3835 r3837 1783 1783 pt = pj_strtoul(&local_m->desc.fmt[0]); 1784 1784 1785 /* Get codec info. */1786 status = pjmedia_vid_codec_mgr_get_codec_info(mgr, pt, &p_info);1787 if (status != PJ_SUCCESS)1788 return status;1789 1790 si->codec_info = *p_info;1791 1792 1785 /* Get payload type for receiving direction */ 1793 1786 si->rx_pt = pt; 1794 1787 1795 /* Get payload type for transmitting direction*/1788 /* Get codec info and payload type for transmitting direction. */ 1796 1789 if (pt < 96) { 1797 /* For static payload type, pt's are symetric */ 1790 /* For static payload types, get the codec info from codec manager. */ 1791 status = pjmedia_vid_codec_mgr_get_codec_info(mgr, pt, &p_info); 1792 if (status != PJ_SUCCESS) 1793 return status; 1794 1795 si->codec_info = *p_info; 1796 1797 /* Get payload type for transmitting direction. 1798 * For static payload type, pt's are symetric. 1799 */ 1798 1800 si->tx_pt = pt; 1799 1800 1801 } else { 1802 const pjmedia_sdp_attr *attr; 1803 pjmedia_sdp_rtpmap *rtpmap; 1804 pjmedia_codec_id codec_id; 1805 pj_str_t codec_id_st; 1801 1806 unsigned i; 1802 1807 … … 1819 1824 if (si->tx_pt == 0xFFFF) 1820 1825 return PJMEDIA_EMISSINGRTPMAP; 1826 1827 /* For dynamic payload types, get codec name from the rtpmap */ 1828 attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP, 1829 &local_m->desc.fmt[0]); 1830 if (attr == NULL) 1831 return PJMEDIA_EMISSINGRTPMAP; 1832 1833 status = pjmedia_sdp_attr_to_rtpmap(pool, attr, &rtpmap); 1834 if (status != PJ_SUCCESS) 1835 return status; 1836 1837 /* Then get the codec info from the codec manager */ 1838 pj_ansi_snprintf(codec_id, sizeof(codec_id), "%.*s/", 1839 rtpmap->enc_name.slen, rtpmap->enc_name.ptr); 1840 codec_id_st = pj_str(codec_id); 1841 i = 1; 1842 status = pjmedia_vid_codec_mgr_find_codecs_by_id(mgr, &codec_id_st, 1843 &i, &p_info, NULL); 1844 if (status != PJ_SUCCESS) 1845 return status; 1846 1847 si->codec_info = *p_info; 1821 1848 } 1822 1849 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_dump.c
r3667 r3837 308 308 info.fmt.clock_rate / 1000); 309 309 pj_ansi_snprintf(rx_info, sizeof(rx_info), "pt=%d,", 310 info. fmt.pt);310 info.rx_pt); 311 311 pj_ansi_snprintf(tx_info, sizeof(tx_info), "pt=%d, ptime=%d,", 312 312 info.tx_pt,
Note: See TracChangeset
for help on using the changeset viewer.