Ignore:
Timestamp:
Mar 22, 2012 9:56:52 AM (12 years ago)
Author:
bennylp
Message:

Re: #1463 (Third party media support). Tnitial work and it works, tested on Linux. Details:

  • add PJSUA_MEDIA_HAS_PJMEDIA macro
  • move pjmedia specific implementation in pjsua_media.c and pjsua_call.c into pjsua_aud.c
  • add pjsip-apps/src/third_party_media sample containing:
    • alt_pjsua_aud.c
    • alt_pjsua_vid.c
  • moved pjmedia_vid_stream_info_from_sdp() into pjmedia/vid_stream_info.c
  • moved pjmedia_stream_info_from_sdp() into pjmedia/stream_info.c
  • misc: fixed mips_test.c if codecs are disabled
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c

    r3956 r3982  
    2020#include <pjsua-lib/pjsua_internal.h> 
    2121 
     22#if defined(PJSUA_MEDIA_HAS_PJMEDIA) && PJSUA_MEDIA_HAS_PJMEDIA != 0 
     23 
    2224#define THIS_FILE       "pjsua_vid.c" 
    2325 
     
    668670} 
    669671 
     672/* Initialize video call media */ 
     673pj_status_t pjsua_vid_channel_init(pjsua_call_media *call_med) 
     674{ 
     675    pjsua_acc *acc = &pjsua_var.acc[call_med->call->acc_id]; 
     676 
     677    call_med->strm.v.rdr_dev = acc->cfg.vid_rend_dev; 
     678    call_med->strm.v.cap_dev = acc->cfg.vid_cap_dev; 
     679    if (call_med->strm.v.rdr_dev == PJMEDIA_VID_DEFAULT_RENDER_DEV) { 
     680        pjmedia_vid_dev_info info; 
     681        pjmedia_vid_dev_get_info(call_med->strm.v.rdr_dev, &info); 
     682        call_med->strm.v.rdr_dev = info.id; 
     683    } 
     684    if (call_med->strm.v.cap_dev == PJMEDIA_VID_DEFAULT_CAPTURE_DEV) { 
     685        pjmedia_vid_dev_info info; 
     686        pjmedia_vid_dev_get_info(call_med->strm.v.cap_dev, &info); 
     687        call_med->strm.v.cap_dev = info.id; 
     688    } 
     689 
     690    return PJ_SUCCESS; 
     691} 
    670692 
    671693/* Internal function: update video channel after SDP negotiation */ 
    672 pj_status_t video_channel_update(pjsua_call_media *call_med, 
    673                                  pj_pool_t *tmp_pool, 
    674                                  const pjmedia_sdp_session *local_sdp, 
    675                                  const pjmedia_sdp_session *remote_sdp) 
     694pj_status_t pjsua_vid_channel_update(pjsua_call_media *call_med, 
     695                                     pj_pool_t *tmp_pool, 
     696                                     pjmedia_vid_stream_info *si, 
     697                                     const pjmedia_sdp_session *local_sdp, 
     698                                     const pjmedia_sdp_session *remote_sdp) 
    676699{ 
    677700    pjsua_call *call = call_med->call; 
    678701    pjsua_acc  *acc  = &pjsua_var.acc[call->acc_id]; 
    679     pjmedia_vid_stream_info the_si, *si = &the_si; 
    680702    pjmedia_port *media_port; 
    681     unsigned strm_idx = call_med->idx; 
    682703    pj_status_t status; 
    683704     
     
    685706    pj_log_push_indent(); 
    686707 
    687     status = pjmedia_vid_stream_info_from_sdp(si, tmp_pool, pjsua_var.med_endpt, 
    688                                               local_sdp, remote_sdp, strm_idx); 
    689     if (status != PJ_SUCCESS) 
    690         goto on_error; 
    691  
    692708    /* Check if no media is active */ 
    693     if (si->dir == PJMEDIA_DIR_NONE) { 
    694         /* Call media state */ 
    695         call_med->state = PJSUA_CALL_MEDIA_NONE; 
    696  
    697         /* Call media direction */ 
    698         call_med->dir = PJMEDIA_DIR_NONE; 
    699  
    700     } else { 
    701         pjmedia_transport_info tp_info; 
    702  
    703         /* Start/restart media transport */ 
    704         status = pjmedia_transport_media_start(call_med->tp, 
    705                                                tmp_pool, local_sdp, 
    706                                                remote_sdp, strm_idx); 
    707         if (status != PJ_SUCCESS) 
    708             goto on_error; 
    709  
    710         set_media_tp_state(call_med, PJSUA_MED_TP_RUNNING); 
    711  
    712         /* Get remote SRTP usage policy */ 
    713         pjmedia_transport_info_init(&tp_info); 
    714         pjmedia_transport_get_info(call_med->tp, &tp_info); 
    715         if (tp_info.specific_info_cnt > 0) { 
    716             unsigned i; 
    717             for (i = 0; i < tp_info.specific_info_cnt; ++i) { 
    718                 if (tp_info.spc_info[i].type == PJMEDIA_TRANSPORT_TYPE_SRTP)  
    719                 { 
    720                     pjmedia_srtp_info *srtp_info =  
    721                                 (pjmedia_srtp_info*) tp_info.spc_info[i].buffer; 
    722  
    723                     call_med->rem_srtp_use = srtp_info->peer_use; 
    724                     break; 
    725                 } 
    726             } 
    727         } 
    728  
     709    if (si->dir != PJMEDIA_DIR_NONE) { 
    729710        /* Optionally, application may modify other stream settings here 
    730711         * (such as jitter buffer parameters, codec ptime, etc.) 
     
    926907        } 
    927908 
    928         /* Call media direction */ 
    929         call_med->dir = si->dir; 
    930  
    931         /* Call media state */ 
    932         if (call->local_hold) 
    933             call_med->state = PJSUA_CALL_MEDIA_LOCAL_HOLD; 
    934         else if (call_med->dir == PJMEDIA_DIR_DECODING) 
    935             call_med->state = PJSUA_CALL_MEDIA_REMOTE_HOLD; 
    936         else 
    937             call_med->state = PJSUA_CALL_MEDIA_ACTIVE; 
    938     } 
    939  
    940     /* Print info. */ 
    941     { 
    942         char info[80]; 
    943         int info_len = 0; 
    944         int len; 
    945         const char *dir; 
    946  
    947         switch (si->dir) { 
    948         case PJMEDIA_DIR_NONE: 
    949             dir = "inactive"; 
    950             break; 
    951         case PJMEDIA_DIR_ENCODING: 
    952             dir = "sendonly"; 
    953             break; 
    954         case PJMEDIA_DIR_DECODING: 
    955             dir = "recvonly"; 
    956             break; 
    957         case PJMEDIA_DIR_ENCODING_DECODING: 
    958             dir = "sendrecv"; 
    959             break; 
    960         default: 
    961             dir = "unknown"; 
    962             break; 
    963         } 
    964         len = pj_ansi_sprintf( info+info_len, 
    965                                ", stream #%d: %.*s (%s)", strm_idx, 
    966                                (int)si->codec_info.encoding_name.slen, 
    967                                si->codec_info.encoding_name.ptr, 
    968                                dir); 
    969         if (len > 0) 
    970             info_len += len; 
    971         PJ_LOG(4,(THIS_FILE,"Video updated%s", info)); 
    972909    } 
    973910 
     
    989926 
    990927/* Internal function to stop video stream */ 
    991 void stop_video_stream(pjsua_call_media *call_med) 
     928void pjsua_vid_stop_stream(pjsua_call_media *call_med) 
    992929{ 
    993930    pjmedia_vid_stream *strm = call_med->strm.v.stream; 
     
    15901527        goto on_error; 
    15911528 
    1592     set_media_tp_state(call_med, PJSUA_MED_TP_INIT); 
     1529    pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_INIT); 
    15931530 
    15941531    /* Get transport address info */ 
     
    17851722        // Don't close this here, as SDP negotiation has not been 
    17861723        // done and stream may be still active. 
    1787         set_media_tp_state(call_med, PJSUA_MED_TP_DISABLED); 
     1724        pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_DISABLED); 
    17881725 
    17891726        /* Deactivate the stream */ 
     
    21862123#endif /* PJSUA_HAS_VIDEO */ 
    21872124 
     2125#endif /* PJSUA_MEDIA_HAS_PJMEDIA */ 
Note: See TracChangeset for help on using the changeset viewer.