Changeset 3982 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Mar 22, 2012 9:56:52 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r3966 r3982 1390 1390 1391 1391 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 1404 1392 /* Acquire lock to the specified call_id */ 1405 1393 pj_status_t acquire_call(const char *title, … … 1476 1464 return PJ_SUCCESS; 1477 1465 } 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/13711493 */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 1508 1466 1509 1467 … … 1736 1694 *p_type = pjsua_var.calls[call_id].rem_nat_type; 1737 1695 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 #endif1778 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 #endif1830 default:1831 status = PJMEDIA_EINVALIMEDIATYPE;1832 break;1833 }1834 1835 PJSUA_UNLOCK();1836 return status;1837 1696 } 1838 1697 … … 2526 2385 on_error: 2527 2386 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);2565 2387 pj_log_pop_indent(); 2566 2388 return status;
Note: See TracChangeset
for help on using the changeset viewer.