提交 0d626bc7 authored 作者: Anthony Minessale's avatar Anthony Minessale 提交者: Michael Jerris

FS-7501: more factoring on vid buffer

上级 0e991e7d
...@@ -513,6 +513,7 @@ SWITCH_DECLARE(char *) get_addr6(char *buf, switch_size_t len, struct sockaddr_i ...@@ -513,6 +513,7 @@ SWITCH_DECLARE(char *) get_addr6(char *buf, switch_size_t len, struct sockaddr_i
SWITCH_DECLARE(int) get_addr_int(switch_sockaddr_t *sa); SWITCH_DECLARE(int) get_addr_int(switch_sockaddr_t *sa);
SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2); SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2);
SWITCH_DECLARE(int) switch_cp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2);
/*! /*!
\brief get the port number of an ip address \brief get the port number of an ip address
......
...@@ -517,6 +517,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t * ...@@ -517,6 +517,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
(!frame->m) && (!context->last_received_complete_picture)) { (!frame->m) && (!context->last_received_complete_picture)) {
// possible packet loss // possible packet loss
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Packet Loss, skip previous received frame (to avoid crash?)\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Packet Loss, skip previous received frame (to avoid crash?)\n");
usleep(500000);abort();
switch_goto_status(SWITCH_STATUS_RESTART, end); switch_goto_status(SWITCH_STATUS_RESTART, end);
} }
...@@ -563,7 +564,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t * ...@@ -563,7 +564,7 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
frame->img = (switch_image_t *) vpx_codec_get_frame(decoder, &iter); frame->img = (switch_image_t *) vpx_codec_get_frame(decoder, &iter);
if (!(frame->img) || corrupted) { if (!(frame->img) || corrupted) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "VPX invalid packet\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "VPX invalid packet image: %d corrupted: %d\n", !!frame->img, corrupted);
switch_goto_status(SWITCH_STATUS_RESTART, end); switch_goto_status(SWITCH_STATUS_RESTART, end);
} }
......
...@@ -9831,10 +9831,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core ...@@ -9831,10 +9831,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
loops++; loops++;
if (switch_channel_down_nosig(session->channel)) { if (switch_channel_down_nosig(session->channel)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING DOWN\n");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
if (switch_channel_test_flag(session->channel, CF_VIDEO_PAUSE)) { if (switch_channel_test_flag(session->channel, CF_VIDEO_PAUSE)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING VID PAUSED\n");
*frame = &runtime.dummy_cng_frame; *frame = &runtime.dummy_cng_frame;
switch_yield(20000); switch_yield(20000);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
...@@ -9853,14 +9855,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core ...@@ -9853,14 +9855,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
if (status == SWITCH_STATUS_INUSE) { if (status == SWITCH_STATUS_INUSE) {
*frame = &runtime.dummy_cng_frame; *frame = &runtime.dummy_cng_frame;
switch_yield(20000); switch_yield(20000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING DUMMY\n");
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
if (status != SWITCH_STATUS_SUCCESS) { if (status != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING BAD STATUS %d\n", status);
goto done; goto done;
} }
if (!(*frame)) { if (!(*frame)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING NO FRAME\n");
goto done; goto done;
} }
...@@ -9882,6 +9887,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core ...@@ -9882,6 +9887,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
if (switch_test_flag(*frame, SFF_CNG)) { if (switch_test_flag(*frame, SFF_CNG)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "FUCKING CNG\n");
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
goto done; goto done;
} }
......
...@@ -5107,6 +5107,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t ...@@ -5107,6 +5107,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
rtp_session->recv_msg.header.pt = jb_frame->pt; rtp_session->recv_msg.header.pt = jb_frame->pt;
rtp_session->recv_msg.header.seq = htons(jb_frame->seq); rtp_session->recv_msg.header.seq = htons(jb_frame->seq);
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
switch_cp_addr(rtp_session->from_addr, rtp_session->remote_addr);
if (!xcheck_jitter) { if (!xcheck_jitter) {
check_jitter(rtp_session); check_jitter(rtp_session);
xcheck_jitter = *bytes; xcheck_jitter = *bytes;
...@@ -5121,18 +5122,22 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t ...@@ -5121,18 +5122,22 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
switch(vstatus) { switch(vstatus) {
case SWITCH_STATUS_RESTART: case SWITCH_STATUS_RESTART:
switch_core_session_request_video_refresh(rtp_session->session); switch_core_session_request_video_refresh(rtp_session->session);
*bytes = 0;
break; break;
case SWITCH_STATUS_MORE_DATA: case SWITCH_STATUS_MORE_DATA:
status = SWITCH_STATUS_FALSE; status = SWITCH_STATUS_FALSE;
*bytes = 0; *bytes = 0;
break; break;
default: case SWITCH_STATUS_SUCCESS:
status = SWITCH_STATUS_SUCCESS; status = SWITCH_STATUS_SUCCESS;
switch_cp_addr(rtp_session->from_addr, rtp_session->remote_addr);
if (!xcheck_jitter) { if (!xcheck_jitter) {
check_jitter(rtp_session); check_jitter(rtp_session);
xcheck_jitter = *bytes; xcheck_jitter = *bytes;
} }
break; break;
default:
break;
} }
} }
......
...@@ -1976,6 +1976,55 @@ SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *s ...@@ -1976,6 +1976,55 @@ SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *s
return 0; return 0;
} }
SWITCH_DECLARE(int) switch_cp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2)
{
struct sockaddr_in *s1;
struct sockaddr_in *s2;
struct sockaddr_in6 *s16;
struct sockaddr_in6 *s26;
struct sockaddr *ss1;
struct sockaddr *ss2;
if (!(sa1 && sa2))
return 0;
s1 = (struct sockaddr_in *) &sa1->sa;
s2 = (struct sockaddr_in *) &sa2->sa;
s16 = (struct sockaddr_in6 *) &sa1->sa;
s26 = (struct sockaddr_in6 *) &sa2->sa;
ss1 = (struct sockaddr *) &sa1->sa;
ss2 = (struct sockaddr *) &sa2->sa;
if (ss1->sa_family != ss2->sa_family)
return 0;
switch (ss1->sa_family) {
case AF_INET:
s1->sin_addr.s_addr = s2->sin_addr.s_addr;
s1->sin_port = s2->sin_port;
return 1;
case AF_INET6:
if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) {
int i;
s16->sin6_port = s26->sin6_port;
for (i = 0; i < 4; i++) {
*((int32_t *) s16->sin6_addr.s6_addr + i) = *((int32_t *) s26->sin6_addr.s6_addr + i);
}
return 1;
}
}
return 0;
}
SWITCH_DECLARE(char *) get_addr6(char *buf, switch_size_t len, struct sockaddr_in6 *sa, socklen_t salen) SWITCH_DECLARE(char *) get_addr6(char *buf, switch_size_t len, struct sockaddr_in6 *sa, socklen_t salen)
{ {
switch_assert(buf); switch_assert(buf);
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论