Changeset 6005 for pjproject/trunk/pjmedia/src/pjmedia/stream.c
- Timestamp:
- May 26, 2019 1:18:02 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/stream.c
r5982 r6005 75 75 /* Number of DTMF E bit transmissions */ 76 76 #define DTMF_EBIT_RETRANSMIT_CNT 3 77 78 /* Number of send error before repeat the report. */ 79 #define SEND_ERR_COUNT_TO_REPORT 50 77 80 78 81 /** … … 234 237 pj_sockaddr rem_rtp_addr; /**< Remote RTP address */ 235 238 unsigned rem_rtp_flag; /**< Indicator flag about 236 packet from this addr. 237 0=no pkt, 1=good ssrc, 239 packet from this addr. 240 0=no pkt, 1=good ssrc, 238 241 2=bad ssrc pkts */ 239 242 unsigned rtp_src_cnt; /**< How many pkt from … … 245 248 #endif 246 249 247 pj_uint32_t rtp_rx_last_ts; /**< Last received RTP timestamp*/ 248 pj_status_t rtp_rx_last_err; /**< Last RTP recv() error */ 249 pj_status_t rtp_tx_last_err; /**< Last RTP send() error */ 250 pj_status_t rtcp_tx_last_err; /**< Last RTCP send() error */ 250 pj_uint32_t rtp_rx_last_ts; /**< Last received RTP 251 timestamp */ 252 pj_uint32_t rtp_tx_err_cnt; /**< The number of RTP 253 send() error */ 254 pj_uint32_t rtcp_tx_err_cnt; /**< The number of RTCP 255 send() error */ 251 256 252 257 /* RTCP Feedback */ … … 263 268 '4', '5', '6', '7', 264 269 '8', '9', '*', '#', 265 'A', 'B', 'C', 'D', 270 'A', 'B', 'C', 'D', 266 271 'R'}; 267 272 … … 462 467 /* Send RTCP */ 463 468 send_rtcp(stream, PJ_TRUE, PJ_FALSE, PJ_FALSE, PJ_FALSE); 464 469 465 470 /* Update stats in case the stream is paused */ 466 471 stream->rtcp.stat.rtp_tx_last_seq = pj_ntohs(stream->enc->rtp.out_hdr.seq); … … 538 543 stream->dec_buf_pos; 539 544 unsigned nsamples_copy = PJ_MIN(nsamples_req, nsamples_avail); 540 545 541 546 pjmedia_copy_samples(p_out_samp + samples_count, 542 547 stream->dec_buf + stream->dec_buf_pos, … … 1013 1018 1014 1019 1020 /** 1021 * Publish transport error event. 1022 */ 1023 static void publish_tp_event(pjmedia_event_type event_type, 1024 pj_status_t status, 1025 pj_bool_t is_rtp, 1026 pjmedia_dir dir, 1027 pjmedia_stream *stream) 1028 { 1029 pjmedia_event ev; 1030 pj_timestamp ts_now; 1031 1032 pj_get_timestamp(&ts_now); 1033 pj_bzero(&ev.data.med_tp_err, sizeof(ev.data.med_tp_err)); 1034 1035 /* Publish event. */ 1036 pjmedia_event_init(&ev, event_type, 1037 &ts_now, stream); 1038 ev.data.med_tp_err.type = PJMEDIA_TYPE_AUDIO; 1039 ev.data.med_tp_err.is_rtp = is_rtp; 1040 ev.data.med_tp_err.dir = dir; 1041 ev.data.med_tp_err.status = status; 1042 1043 pjmedia_event_publish(NULL, stream, &ev, 0); 1044 } 1045 1046 1015 1047 static pj_status_t send_rtcp(pjmedia_stream *stream, 1016 1048 pj_bool_t with_sdes, … … 1134 1166 status = pjmedia_transport_send_rtcp(stream->transport, pkt, len); 1135 1167 if (status != PJ_SUCCESS) { 1136 if (stream->rtcp_tx_last_err != status) { 1137 PJ_PERROR(4,(stream->port.info.name.ptr, status, 1138 "Error sending RTCP")); 1139 stream->rtcp_tx_last_err = status; 1140 } 1141 } else { 1142 if (stream->rtcp_tx_last_err != PJ_SUCCESS) { 1143 PJ_LOG(4,(stream->port.info.name.ptr, "Sending RTCP resumed")); 1144 stream->rtcp_tx_last_err = PJ_SUCCESS; 1168 if (stream->rtcp_tx_err_cnt++ == 0) { 1169 LOGERR_((stream->port.info.name.ptr, status, 1170 "Error sending RTCP")); 1171 } 1172 if (stream->rtcp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) { 1173 stream->rtcp_tx_err_cnt = 0; 1145 1174 } 1146 1175 } … … 1484 1513 frame_out.size + 1485 1514 sizeof(pjmedia_rtp_hdr)); 1515 1486 1516 if (status != PJ_SUCCESS) { 1487 if (stream->rtp_tx_last_err != status) { 1488 PJ_PERROR(4,(stream->port.info.name.ptr, status, 1489 "Error sending RTP")); 1490 stream->rtp_tx_last_err = status; 1517 if (stream->rtp_tx_err_cnt++ == 0) { 1518 LOGERR_((stream->port.info.name.ptr, status, "Error sending RTP")); 1519 } 1520 if (stream->rtp_tx_err_cnt > SEND_ERR_COUNT_TO_REPORT) { 1521 stream->rtp_tx_err_cnt = 0; 1491 1522 } 1492 1523 return PJ_SUCCESS; 1493 } else {1494 if (stream->rtp_tx_last_err != PJ_SUCCESS) {1495 PJ_LOG(4,(stream->port.info.name.ptr, "Sending RTP resumed"));1496 stream->rtp_tx_last_err = PJ_SUCCESS;1497 }1498 1524 } 1499 1525 … … 1680 1706 #else 1681 1707 if (event->event > 15) { 1682 #endif 1708 #endif 1683 1709 PJ_LOG(5,(stream->port.info.name.ptr, 1684 1710 "Ignored RTP pkt with bad DTMF event %d", … … 1744 1770 return; 1745 1771 } 1746 if (stream->rtp_rx_last_err != status) { 1747 char errmsg[PJ_ERR_MSG_SIZE]; 1748 pj_strerror(status, errmsg, sizeof(errmsg)); 1749 PJ_LOG(4,(stream->port.info.name.ptr, 1750 "Unable to receive RTP packet, recv() returned %d: %s", 1751 status, errmsg)); 1752 stream->rtp_rx_last_err = status; 1772 1773 LOGERR_((stream->port.info.name.ptr, status, 1774 "Unable to receive RTP packet")); 1775 1776 if (status == PJ_ESOCKETSTOP) { 1777 /* Publish receive error event. */ 1778 publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_TRUE, 1779 PJMEDIA_DIR_DECODING, stream); 1753 1780 } 1754 1781 return; 1755 } else {1756 stream->rtp_rx_last_err = PJ_SUCCESS;1757 1782 } 1758 1783 … … 1769 1794 return; 1770 1795 } 1771 1796 1772 1797 /* Check if multiplexing is allowed and the payload indicates RTCP. */ 1773 1798 if (stream->si.rtcp_mux && hdr->pt >= 64 && hdr->pt <= 95) { … … 1838 1863 } 1839 1864 1840 /* See if source address of RTP packet is different than the 1865 /* See if source address of RTP packet is different than the 1841 1866 * configured address, and check if we need to tell the 1842 1867 * media transport to switch RTP remote address. … … 1852 1877 } else { 1853 1878 stream->rtp_src_cnt++; 1854 1879 1855 1880 if (stream->rtp_src_cnt < PJMEDIA_RTP_NAT_PROBATION_CNT) { 1856 1881 if (stream->rem_rtp_flag == 1 || … … 1865 1890 pkt_discarded = PJ_TRUE; 1866 1891 goto on_return; 1867 } 1892 } 1868 1893 if (stream->si.has_rem_ssrc && !seq_st.status.flag.badssrc && 1869 1894 stream->rem_rtp_flag != 1) … … 1927 1952 { 1928 1953 unsigned dec_ptime; 1929 1954 1930 1955 PJ_LOG(4, (stream->port.info.name.ptr, "codec decode " 1931 1956 "ptime change detected")); … … 2106 2131 { 2107 2132 pjmedia_stream *stream = (pjmedia_stream*) data; 2133 pj_status_t status; 2108 2134 2109 2135 /* Check for errors */ 2110 2136 if (bytes_read < 0) { 2111 if (bytes_read != -PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 2112 LOGERR_((stream->port.info.name.ptr, (pj_status_t)-bytes_read, 2113 "RTCP recv() error")); 2137 status = (pj_status_t)-bytes_read; 2138 if (status == PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK)) { 2139 return; 2140 } 2141 LOGERR_((stream->port.info.name.ptr, status, 2142 "Unable to receive RTCP packet")); 2143 2144 if (status == PJ_ESOCKETSTOP) { 2145 /* Publish receive error event. */ 2146 publish_tp_event(PJMEDIA_EVENT_MEDIA_TP_ERR, status, PJ_FALSE, 2147 PJMEDIA_DIR_DECODING, stream); 2114 2148 } 2115 2149 return; … … 2220 2254 if (stream->rtcp_fb_nack_cap_idx < 0) 2221 2255 return PJ_SUCCESS; 2222 2256 2223 2257 data->cap = stream->si.loc_rtcp_fb.caps[stream->rtcp_fb_nack_cap_idx]; 2224 2258 } … … 2636 2670 pj_sockaddr_cp(&stream->rem_rtp_addr, &info->rem_addr); 2637 2671 if (stream->si.rtcp_mux) { 2638 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr); 2672 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_addr); 2639 2673 } else if (pj_sockaddr_has_addr(&info->rem_rtcp.addr)) { 2640 2674 pj_sockaddr_cp(&att_param.rem_rtcp, &info->rem_rtcp); … … 3128 3162 pt = 11; 3129 3163 } 3130 #if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 3164 #if defined(PJMEDIA_HAS_DTMF_FLASH) && PJMEDIA_HAS_DTMF_FLASH!= 0 3131 3165 else if (dig == 'r') 3132 3166 {
Note: See TracChangeset
for help on using the changeset viewer.