Changeset 3585
- Timestamp:
- Jun 16, 2011 5:10:45 AM (13 years ago)
- Location:
- pjproject/branches/1.x/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjsip/include/pjsua-lib/pjsua.h
r3570 r3585 419 419 registration callback. */ 420 420 } pjsua_reg_info; 421 422 423 /** 424 * This enumeration specifies the options for custom media transport creation. 425 */ 426 typedef enum pjsua_create_media_transport_flag 427 { 428 /** 429 * This flag indicates that the media transport must also close its 430 * "member" or "child" transport when pjmedia_transport_close() is 431 * called. If this flag is not specified, then the media transport 432 * must not call pjmedia_transport_close() of its member transport. 433 */ 434 PJSUA_MED_TP_CLOSE_MEMBER = 1 435 436 } pjsua_create_media_transport_flag; 421 437 422 438 … … 919 935 pj_status_t status, void *param); 920 936 937 /** 938 * This callback can be used by application to implement custom media 939 * transport adapter for the call, or to replace the media transport 940 * with something completely new altogether. 941 * 942 * This callback is called when a new call is created. The library has 943 * created a media transport for the call, and it is provided as the 944 * \a base_tp argument of this callback. Upon returning, the callback 945 * must return an instance of media transport to be used by the call. 946 * 947 * @param call_id Call ID 948 * @param media_idx The media index in the SDP for which this media 949 * transport will be used. 950 * @param base_tp The media transport which otherwise will be 951 * used by the call has this callback not been 952 * implemented. 953 * @param flags Bitmask from pjsua_create_media_transport_flag. 954 * 955 * @return The callback must return an instance of media 956 * transport to be used by the call. 957 */ 958 pjmedia_transport* (*on_create_media_transport)(pjsua_call_id call_id, 959 unsigned media_idx, 960 pjmedia_transport *base_tp, 961 unsigned flags); 962 921 963 } pjsua_callback; 922 964 -
pjproject/branches/1.x/pjsip/src/pjsua-lib/pjsua_media.c
r3571 r3585 1175 1175 pjsua_call *call = &pjsua_var.calls[call_id]; 1176 1176 pj_status_t status; 1177 pj_bool_t use_custom_med_tp = PJ_FALSE; 1178 unsigned custom_med_tp_flags = 0; 1177 1179 1178 1180 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) … … 1193 1195 } 1194 1196 1197 if (!call->med_orig && 1198 pjsua_var.ua_cfg.cb.on_create_media_transport) 1199 { 1200 use_custom_med_tp = PJ_TRUE; 1201 } 1202 1195 1203 #if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0) 1196 1204 /* This function may be called when SRTP transport already exists 1197 1205 * (e.g: in re-invite, update), don't need to destroy/re-create. 1198 1206 */ 1199 if (!call->med_orig || call->med_tp == call->med_orig) {1207 if (!call->med_orig) { 1200 1208 1201 1209 /* Check if SRTP requires secure signaling */ … … 1211 1219 pjmedia_srtp_setting_default(&srtp_opt); 1212 1220 srtp_opt.close_member_tp = PJ_FALSE; 1221 if (use_custom_med_tp) 1222 custom_med_tp_flags |= PJSUA_MED_TP_CLOSE_MEMBER; 1213 1223 /* If media session has been ever established, let's use remote's 1214 1224 * preference in SRTP usage policy, especially when it is stricter. … … 1268 1278 PJ_LOG(4,(THIS_FILE, "Media index %d selected for call %d", 1269 1279 call->audio_idx, call->index)); 1280 1281 if (use_custom_med_tp) { 1282 /* Use custom media transport returned by the application */ 1283 call->med_tp = (*pjsua_var.ua_cfg.cb.on_create_media_transport)( 1284 call_id, call->audio_idx, call->med_tp, 1285 custom_med_tp_flags); 1286 if (!call->med_tp) { 1287 if (sip_err_code) *sip_err_code = PJSIP_SC_NOT_ACCEPTABLE; 1288 pjsua_media_channel_deinit(call_id); 1289 return PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_NOT_ACCEPTABLE); 1290 } 1291 } 1270 1292 1271 1293 /* Create the media transport */ … … 1544 1566 pjmedia_transport_close(call->med_tp); 1545 1567 call->med_tp = call->med_orig; 1568 call->med_orig = NULL; 1546 1569 } 1547 1570
Note: See TracChangeset
for help on using the changeset viewer.