提交 aea974a9 authored 作者: Anthony Minessale's avatar Anthony Minessale

MILESTONE: audio and video working inbound

上级 03e5b366
差异被折叠。
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#define WRITE_DEC(rtp_session) switch_mutex_unlock(rtp_session->write_mutex); rtp_session->writing-- #define WRITE_DEC(rtp_session) switch_mutex_unlock(rtp_session->write_mutex); rtp_session->writing--
#define RTP_DEFAULT_STUNCOUNT 100; #define RTP_DEFAULT_STUNCOUNT 25;
#define rtp_header_len 12 #define rtp_header_len 12
#define RTP_START_PORT 16384 #define RTP_START_PORT 16384
#define RTP_END_PORT 32768 #define RTP_END_PORT 32768
...@@ -351,6 +351,11 @@ typedef enum { ...@@ -351,6 +351,11 @@ typedef enum {
static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session); static void do_2833(switch_rtp_t *rtp_session, switch_core_session_t *session);
#define rtp_type(rtp_session) rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] ? "video" : "audio"
static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_size_t bytes, int *do_cng) static handle_rfc2833_result_t handle_rfc2833(switch_rtp_t *rtp_session, switch_size_t bytes, int *do_cng)
{ {
...@@ -794,6 +799,8 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d ...@@ -794,6 +799,8 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
ok = !strcmp(ice->user_ice, username); ok = !strcmp(ice->user_ice, username);
} }
//printf("ICE %s %d\n", rtp_type(rtp_session), ok);
if ((packet->header.type == SWITCH_STUN_BINDING_REQUEST) && ok) { if ((packet->header.type == SWITCH_STUN_BINDING_REQUEST) && ok) {
uint8_t stunbuf[512]; uint8_t stunbuf[512];
switch_stun_packet_t *rpacket; switch_stun_packet_t *rpacket;
...@@ -891,7 +898,7 @@ static void zrtp_event_callback(zrtp_stream_t *stream, unsigned event) ...@@ -891,7 +898,7 @@ static void zrtp_event_callback(zrtp_stream_t *stream, unsigned event)
switch_event_t *fsevent = NULL; switch_event_t *fsevent = NULL;
const char *type; const char *type;
type = rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] ? "video" : "audio"; type = rtp_type(rtp_session)
switch (event) { switch (event) {
case ZRTP_EVENT_IS_SECURE: case ZRTP_EVENT_IS_SECURE:
...@@ -2450,6 +2457,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio ...@@ -2450,6 +2457,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
{ {
char ice_user[80]; char ice_user[80];
char user_ice[80]; char user_ice[80];
switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
if ((type & ICE_VANILLA)) { if ((type & ICE_VANILLA)) {
switch_snprintf(ice_user, sizeof(ice_user), "%s:%s", login, rlogin); switch_snprintf(ice_user, sizeof(ice_user), "%s:%s", login, rlogin);
...@@ -2459,6 +2467,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio ...@@ -2459,6 +2467,9 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_ice(switch_rtp_t *rtp_sessio
switch_snprintf(user_ice, sizeof(user_ice), "%s%s", rlogin, login); switch_snprintf(user_ice, sizeof(user_ice), "%s%s", rlogin, login);
} }
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Activating %s ICE: %s\n", rtp_type(rtp_session), ice_user);
rtp_session->ice.ice_user = switch_core_strdup(rtp_session->pool, ice_user); rtp_session->ice.ice_user = switch_core_strdup(rtp_session->pool, ice_user);
rtp_session->ice.user_ice = switch_core_strdup(rtp_session->pool, user_ice); rtp_session->ice.user_ice = switch_core_strdup(rtp_session->pool, user_ice);
rtp_session->ice.type = type; rtp_session->ice.type = type;
...@@ -3208,7 +3219,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t ...@@ -3208,7 +3219,8 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
#endif #endif
#ifdef ENABLE_SRTP #ifdef ENABLE_SRTP
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && (!rtp_session->ice.ice_user || rtp_session->recv_msg.header.version == 2)) { if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && rtp_session->recv_msg.header.version == 2) {
//if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_RECV] && (!rtp_session->ice.ice_user || rtp_session->recv_msg.header.version == 2)) {
int sbytes = (int) *bytes; int sbytes = (int) *bytes;
err_status_t stat = 0; err_status_t stat = 0;
...@@ -3235,7 +3247,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t ...@@ -3235,7 +3247,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) { if (++rtp_session->srtp_errs >= MAX_SRTP_ERRS) {
switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session"); switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
"Error: SRTP unprotect failed with code %d%s\n", stat, "Error: SRTP %s unprotect failed with code %d%s\n", rtp_type(rtp_session), stat,
stat == err_status_replay_fail ? " (replay check failed)" : stat == stat == err_status_replay_fail ? " (replay check failed)" : stat ==
err_status_auth_fail ? " (auth check failed)" : ""); err_status_auth_fail ? " (auth check failed)" : "");
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
...@@ -4544,11 +4556,12 @@ static int rtp_common_write(switch_rtp_t *rtp_session, ...@@ -4544,11 +4556,12 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
send = 0; send = 0;
} }
#if 0
if (rtp_session->ice.ice_user && !rtp_session->ice.ready) { if (rtp_session->ice.ice_user && !rtp_session->ice.ready) {
send = 0; //send = 0;
//printf("skip no stun love\n"); //printf("skip no stun love\n");
} }
#endif
if (send) { if (send) {
send_msg->header.seq = htons(++rtp_session->seq); send_msg->header.seq = htons(++rtp_session->seq);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论