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_call.c

    r3966 r3982  
    13901390 
    13911391 
    1392 /* 
    1393  * Check if call has an active media session. 
    1394  */ 
    1395 PJ_DEF(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id) 
    1396 { 
    1397     pjsua_call *call = &pjsua_var.calls[call_id]; 
    1398     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,  
    1399                      PJ_EINVAL); 
    1400     return call->audio_idx >= 0 && call->media[call->audio_idx].strm.a.stream; 
    1401 } 
    1402  
    1403  
    14041392/* Acquire lock to the specified call_id */ 
    14051393pj_status_t acquire_call(const char *title, 
     
    14761464    return PJ_SUCCESS; 
    14771465} 
    1478  
    1479  
    1480 /* 
    1481  * Get the conference port identification associated with the call. 
    1482  */ 
    1483 PJ_DEF(pjsua_conf_port_id) pjsua_call_get_conf_port(pjsua_call_id call_id) 
    1484 { 
    1485     pjsua_call *call; 
    1486     pjsua_conf_port_id port_id = PJSUA_INVALID_ID; 
    1487  
    1488     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,  
    1489                      PJ_EINVAL); 
    1490  
    1491     /* Use PJSUA_LOCK() instead of acquire_call(): 
    1492      *  https://trac.pjsip.org/repos/ticket/1371 
    1493      */ 
    1494     PJSUA_LOCK(); 
    1495  
    1496     if (!pjsua_call_is_active(call_id)) 
    1497         goto on_return; 
    1498  
    1499     call = &pjsua_var.calls[call_id]; 
    1500     port_id = call->media[call->audio_idx].strm.a.conf_slot; 
    1501  
    1502 on_return: 
    1503     PJSUA_UNLOCK(); 
    1504  
    1505     return port_id; 
    1506 } 
    1507  
    15081466 
    15091467 
     
    17361694    *p_type = pjsua_var.calls[call_id].rem_nat_type; 
    17371695    return PJ_SUCCESS; 
    1738 } 
    1739  
    1740  
    1741 /* 
    1742  * Get media stream info for the specified media index. 
    1743  */ 
    1744 PJ_DEF(pj_status_t) pjsua_call_get_stream_info( pjsua_call_id call_id, 
    1745                                                 unsigned med_idx, 
    1746                                                 pjsua_stream_info *psi) 
    1747 { 
    1748     pjsua_call *call; 
    1749     pjsua_call_media *call_med; 
    1750     pj_status_t status; 
    1751  
    1752     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    1753                      PJ_EINVAL); 
    1754     PJ_ASSERT_RETURN(psi, PJ_EINVAL); 
    1755  
    1756     PJSUA_LOCK(); 
    1757  
    1758     call = &pjsua_var.calls[call_id]; 
    1759      
    1760     if (med_idx >= call->med_cnt) { 
    1761         PJSUA_UNLOCK(); 
    1762         return PJ_EINVAL; 
    1763     } 
    1764  
    1765     call_med = &call->media[med_idx]; 
    1766     psi->type = call_med->type; 
    1767     switch (call_med->type) { 
    1768     case PJMEDIA_TYPE_AUDIO: 
    1769         status = pjmedia_stream_get_info(call_med->strm.a.stream, 
    1770                                          &psi->info.aud); 
    1771         break; 
    1772 #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) 
    1773     case PJMEDIA_TYPE_VIDEO: 
    1774         status = pjmedia_vid_stream_get_info(call_med->strm.v.stream, 
    1775                                              &psi->info.vid); 
    1776         break; 
    1777 #endif 
    1778     default: 
    1779         status = PJMEDIA_EINVALIMEDIATYPE; 
    1780         break; 
    1781     } 
    1782      
    1783     PJSUA_UNLOCK(); 
    1784     return status; 
    1785 } 
    1786  
    1787  
    1788 /* 
    1789  *  Get media stream statistic for the specified media index. 
    1790  */ 
    1791 PJ_DEF(pj_status_t) pjsua_call_get_stream_stat( pjsua_call_id call_id, 
    1792                                                 unsigned med_idx, 
    1793                                                 pjsua_stream_stat *stat) 
    1794 { 
    1795     pjsua_call *call; 
    1796     pjsua_call_media *call_med; 
    1797     pj_status_t status; 
    1798  
    1799     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    1800                      PJ_EINVAL); 
    1801     PJ_ASSERT_RETURN(stat, PJ_EINVAL); 
    1802  
    1803     PJSUA_LOCK(); 
    1804  
    1805     call = &pjsua_var.calls[call_id]; 
    1806      
    1807     if (med_idx >= call->med_cnt) { 
    1808         PJSUA_UNLOCK(); 
    1809         return PJ_EINVAL; 
    1810     } 
    1811  
    1812     call_med = &call->media[med_idx]; 
    1813     switch (call_med->type) { 
    1814     case PJMEDIA_TYPE_AUDIO: 
    1815         status = pjmedia_stream_get_stat(call_med->strm.a.stream, 
    1816                                          &stat->rtcp); 
    1817         if (status == PJ_SUCCESS) 
    1818             status = pjmedia_stream_get_stat_jbuf(call_med->strm.a.stream, 
    1819                                                   &stat->jbuf); 
    1820         break; 
    1821 #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) 
    1822     case PJMEDIA_TYPE_VIDEO: 
    1823         status = pjmedia_vid_stream_get_stat(call_med->strm.v.stream, 
    1824                                              &stat->rtcp); 
    1825         if (status == PJ_SUCCESS) 
    1826             status = pjmedia_vid_stream_get_stat_jbuf(call_med->strm.v.stream, 
    1827                                                   &stat->jbuf); 
    1828         break; 
    1829 #endif 
    1830     default: 
    1831         status = PJMEDIA_EINVALIMEDIATYPE; 
    1832         break; 
    1833     } 
    1834      
    1835     PJSUA_UNLOCK(); 
    1836     return status; 
    18371696} 
    18381697 
     
    25262385on_error: 
    25272386    if (dest_dlg) pjsip_dlg_dec_lock(dest_dlg); 
    2528     pj_log_pop_indent(); 
    2529     return status; 
    2530 } 
    2531  
    2532  
    2533 /* 
    2534  * Send DTMF digits to remote using RFC 2833 payload formats. 
    2535  */ 
    2536 PJ_DEF(pj_status_t) pjsua_call_dial_dtmf( pjsua_call_id call_id,  
    2537                                           const pj_str_t *digits) 
    2538 { 
    2539     pjsua_call *call; 
    2540     pjsip_dialog *dlg = NULL; 
    2541     pj_status_t status; 
    2542  
    2543     PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
    2544                      PJ_EINVAL); 
    2545      
    2546     PJ_LOG(4,(THIS_FILE, "Call %d dialing DTMF %.*s", 
    2547                          call_id, (int)digits->slen, digits->ptr)); 
    2548     pj_log_push_indent(); 
    2549  
    2550     status = acquire_call("pjsua_call_dial_dtmf()", call_id, &call, &dlg); 
    2551     if (status != PJ_SUCCESS) 
    2552         goto on_return; 
    2553  
    2554     if (!pjsua_call_has_media(call_id)) { 
    2555         PJ_LOG(3,(THIS_FILE, "Media is not established yet!")); 
    2556         status = PJ_EINVALIDOP; 
    2557         goto on_return; 
    2558     } 
    2559  
    2560     status = pjmedia_stream_dial_dtmf( 
    2561                 call->media[call->audio_idx].strm.a.stream, digits); 
    2562  
    2563 on_return: 
    2564     if (dlg) pjsip_dlg_dec_lock(dlg); 
    25652387    pj_log_pop_indent(); 
    25662388    return status; 
Note: See TracChangeset for help on using the changeset viewer.