#endif
-#define __IS_VP8_KEY_FRAME(byte) (((byte) & 0x01) ^ 0x01)
+#define __IS_VP8_KEY_FRAME(byte) !(((byte) & 0x01))
static inline int IS_VP8_KEY_FRAME(uint8_t *data)
{
uint8_t S;
uint8_t decoder_init;
switch_buffer_t *vpx_packet_buffer;
int got_key_frame;
+ int got_start_frame;
uint32_t last_received_timestamp;
switch_bool_t last_received_complete_picture;
int need_key_frame;
context->last_received_complete_picture = 0;
context->decoder_init = 1;
context->got_key_frame = 0;
+ context->got_start_frame = 0;
// the types of post processing to be done, should be combination of "vp8_postproc_level"
ppcfg.post_proc_flag = VP8_DEBLOCK;//VP8_DEMACROBLOCK | VP8_DEBLOCK;
// the strength of deblocking, valid range [0, 16]
uint8_t *data = frame->data;
uint8_t S;
uint8_t DES;
- //uint8_t PID;
+ uint8_t PID;
int len;
+ int key = 0;
+
+#if 0
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ "VIDEO VPX: seq: %d ts: %u len: %ld %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
+ frame->seq, frame->timestamp, frame->datalen,
+ *((uint8_t *)data), *((uint8_t *)data + 1),
+ *((uint8_t *)data + 2), *((uint8_t *)data + 3),
+ *((uint8_t *)data + 4), *((uint8_t *)data + 5),
+ *((uint8_t *)data + 6), *((uint8_t *)data + 7),
+ *((uint8_t *)data + 8), *((uint8_t *)data + 9),
+ *((uint8_t *)data + 10), frame->m);
+#endif
+
DES = *data;
data++;
- S = DES & 0x10;
- //PID = DES & 0x07;
+ S = (DES & 0x10);
+ PID = DES & 0x07;
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DATA LEN %d S BIT %d PID: %d\n", frame->datalen, S, PID);
+
if (DES & 0x80) { // X
uint8_t X = *data;
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "X BIT SET\n");
data++;
if (X & 0x80) { // I
uint8_t M = (*data) & 0x80;
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "I BIT SET\n");
data++;
- if (M) data++;
+ if (M) {
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "M BIT SET\n");
+ data++;
+ }
+ }
+ if (X & 0x40) {
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "L BIT SET\n");
+ data++; // L
+ }
+ if (X & 0x30) {
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "T/K BIT SET\n");
+ data++; // T/K
}
- if (X & 0x40) data++; // L
- if (X & 0x30) data++; // T/K
}
if (!switch_buffer_inuse(context->vpx_packet_buffer) && !S) {
if (context->got_key_frame > 0) {
context->got_key_frame = 0;
+ context->got_start_frame = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG2, "packet loss?\n");
}
return SWITCH_STATUS_MORE_DATA;
if (S) {
switch_buffer_zero(context->vpx_packet_buffer);
context->last_received_timestamp = frame->timestamp;
+ if (PID == 0) {
+ key = __IS_VP8_KEY_FRAME(*data);
+ }
}
len = frame->datalen - (data - (uint8_t *)frame->data);
-
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "POST PARSE: DATA LEN %d KEY %d KEYBYTE = %0x\n", len, key, *data);
+
if (len <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid packet %d\n", len);
return SWITCH_STATUS_RESTART;
// context->last_received_timestamp = frame->timestamp;
context->last_received_complete_picture = frame->m ? SWITCH_TRUE : SWITCH_FALSE;
- if (is_keyframe || is_start) {
+ if (is_start) {
+ context->got_start_frame = 1;
+ }
+
+ if (is_keyframe) {
if (context->got_key_frame <= 0) {
context->got_key_frame = 1;
if (!is_keyframe) {
if ((--context->got_key_frame % 200) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Waiting for key frame %d\n", context->got_key_frame);
}
- switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
+ if (!context->got_start_frame) {
+ switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
+ }
}
uint8_t *data;
int corrupted = 0;
int err;
- //int keyframe = 0;
+ int keyframe = 0;
//printf("WTF %d %ld\n", frame->m, len);
switch_buffer_peek_zerocopy(context->vpx_packet_buffer, (void *)&data);
- //keyframe = (*data & 0x01) ? 0 : 1;
+ keyframe = (*data & 0x01) ? 0 : 1;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buffered: %" SWITCH_SIZE_T_FMT ", key: %d\n", len, keyframe);
switch_buffer_zero(context->vpx_packet_buffer);
if (!frame->img) {
- context->need_decoder_reset = 1;
+ //context->need_decoder_reset = 1;
context->got_key_frame = 0;
+ context->got_start_frame = 0;
status = SWITCH_STATUS_RESTART;
}
}
end:
- //if (status == SWITCH_STATUS_RESTART) {
- // context->need_decoder_reset = 1;
- //}
+ if (status == SWITCH_STATUS_RESTART) {
+ switch_buffer_zero(context->vpx_packet_buffer);
+ //context->need_decoder_reset = 1;
+ context->got_key_frame = 0;
+ context->got_start_frame = 0;
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "RESET VPX\n");
+ }
if (!frame->img || status == SWITCH_STATUS_RESTART) {
status = SWITCH_STATUS_MORE_DATA;
switch_channel_set_variable(channel, "recovered", "true");
}
+ if (flag == CF_VIDEO_ECHO) {
+ switch_core_session_start_video_thread(channel->session);
+ }
+
if (flag == CF_VIDEO_DECODED_READ) {
+ switch_core_session_request_video_refresh(channel->session);
+ switch_core_session_start_video_thread(channel->session);
if (!switch_core_session_in_video_thread(channel->session)) {
switch_channel_wait_for_flag(channel, CF_VIDEO_READY, SWITCH_TRUE, 10000, NULL);
}
engine->ice_in.cand_idx++;
for (i = 0; i < engine->cand_acl_count; i++) {
- if (!engine->ice_in.chosen[cid] && switch_check_network_list_ip(fields[4], engine->cand_acl[i])) {
+ if (!engine->ice_in.chosen[cid] && !strchr(fields[4], ':') && switch_check_network_list_ip(fields[4], engine->cand_acl[i])) {
engine->ice_in.chosen[cid] = engine->ice_in.cand_idx;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(smh->session), SWITCH_LOG_NOTICE,
"Choose %s Candidate cid: %d proto: %s type: %s addr: %s:%s\n",
switch_mutex_unlock(v_engine->mh.file_mutex);
+ switch_core_session_start_video_thread(session);
+
return SWITCH_STATUS_SUCCESS;
}
} else if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
send_blank = 1;
}
-
+
if ((send_blank || switch_channel_test_flag(channel, CF_VIDEO_BLANK)) &&
!session->video_read_callback && !switch_channel_test_flag(session->channel, CF_BRIDGED)) {
fr.img = blank_img;
smh->video_function = video_function;
smh->video_user_data = user_data;
switch_core_session_video_reset(session);
- switch_core_session_start_video_thread(session);
}
switch_mutex_unlock(smh->control_mutex);
}
!switch_channel_test_flag(session->channel, CF_AVPF)) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
- switch_core_session_start_video_thread(session);
}
if (switch_media_handle_test_media_flag(smh, SCMF_AUTOFIX_TIMING)) {
v_engine->check_frames = 0;
v_engine->local_sdp_ip, v_engine->local_sdp_port, v_engine->cur_payload_map->remote_sdp_ip,
v_engine->cur_payload_map->remote_sdp_port, v_engine->cur_payload_map->agreed_pt);
- switch_core_session_start_video_thread(session);
switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
}
}
!((val = switch_channel_get_variable(session->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
/* Reactivate the NAT buster flag. */
switch_rtp_set_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
- switch_core_session_start_video_thread(session);
}
}
}
switch_rtp_set_payload_map(v_engine->rtp_session, &v_engine->payload_map);
- switch_core_session_start_video_thread(session);
+ //switch_core_session_start_video_thread(session);
switch_channel_set_flag(session->channel, CF_VIDEO);
if ((ssrc = switch_channel_get_variable(session->channel, "rtp_use_video_ssrc"))) {
sp = " ";
}
- if (fir) {
+ if (!zstr(zfir) || !zstr(ztmmbr)) {
switch_snprintf(buf + strlen(buf), buflen - strlen(buf), "a=rtcp-fb:%d ccm %s%s%s\n", pt, zfir, sp, ztmmbr);
}
if (!zstr(a_engine->local_dtls_fingerprint.type)) {
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\n", a_engine->local_dtls_fingerprint.type,
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=fingerprint:%s %s\na=setup:%s\na=mid:audio\n",
+ a_engine->local_dtls_fingerprint.type,
a_engine->local_dtls_fingerprint.str, get_setup(session));
}
ice_out = &a_engine->ice_out;
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\n", a_engine->ssrc, smh->cname);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s a0\n", a_engine->ssrc, smh->msid);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\n", a_engine->ssrc, smh->msid);
- switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sa0\n", a_engine->ssrc, smh->msid);
-
-
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-ufrag:%s\n", ice_out->ufrag);
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-pwd:%s\n", ice_out->pwd);
);
}
}
-
+
+
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u cname:%s\n", a_engine->ssrc, smh->cname);
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u msid:%s a0\n", a_engine->ssrc, smh->msid);
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u mslabel:%s\n", a_engine->ssrc, smh->msid);
+ switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ssrc:%u label:%sa0\n", a_engine->ssrc, smh->msid);
+
#ifdef GOOGLE_ICE
switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=ice-options:google-ice\n");
case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
{
if (v_engine->rtp_session) {
- if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
- switch_rtp_video_loss(v_engine->rtp_session);
- }
-
if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_FIR)) {
switch_rtp_video_refresh(v_engine->rtp_session);
- }
+ }// else {
+ if (switch_rtp_test_flag(v_engine->rtp_session, SWITCH_RTP_FLAG_PLI)) {
+ switch_rtp_video_loss(v_engine->rtp_session);
+ }
+ // }
}
}
if (status == SWITCH_STATUS_INUSE) {
*frame = &runtime.dummy_cng_frame;
- switch_yield(20000);
+ switch_cond_next();
return SWITCH_STATUS_SUCCESS;
}
if (!(*frame)->img) {
*frame = &runtime.dummy_cng_frame;
- switch_yield(66000);
+ switch_cond_next();
return SWITCH_STATUS_SUCCESS;
}
}
int is_rtcp = ice == &rtp_session->rtcp_ice;
uint32_t elapsed;
+ //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+ // switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF OK %s CALL\n", rtp_type(rtp_session));
+ //}
if (!switch_rtp_ready(rtp_session) || zstr(ice->user_ice) || zstr(ice->ice_user)) {
return;
ok = 1;
}
+
+ //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+ // switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF OK %s %d\n", rtp_type(rtp_session), ok);
+ //}
+
if (ok) {
const char *host = NULL, *host2 = NULL;
switch_port_t port = 0, port2 = 0;
static int check_rtcp_and_ice(switch_rtp_t *rtp_session)
{
int ret = 0;
- int rtcp_ok = 0;
+ int rtcp_ok = 0, rtcp_fb = 0;
switch_time_t now = switch_micro_time_now();
int rate = 0;
rate = 4000;
} else {
if (rtp_session->pli_count || rtp_session->fir_count || rtp_session->cur_nack || rtp_session->tmmbr || rtp_session->tmmbn) {
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "MARK BW/FIR ETC %d %d\n", rtp_session->pli_count, rtp_session->fir_count);
rtcp_ok = 1;
+ rtcp_fb = 1;
}
}
+
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "TIME CHECK %d > %d\n", (int)((now - rtp_session->rtcp_last_sent) / 1000), rate);
if (!rtcp_ok && (!rtp_session->rtcp_last_sent || (int)((now - rtp_session->rtcp_last_sent) / 1000) > rate)) {
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "TIME UP\n");
rtcp_ok = 1;
}
if (rtcp_ok && using_ice(rtp_session)) {
if (rtp_session->flags[SWITCH_RTP_FLAG_RTCP_MUX]) {
if (!rtp_session->ice.rready) {
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "FUCK 1\n");
rtcp_ok = 0;
}
} else {
if (!rtp_session->rtcp_ice.rready) {
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "FUCK 2\n");
rtcp_ok = 0;
}
}
}
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "WTF %d %d %d\n", rate, rtp_session->rtcp_sent_packets, rtcp_ok);
+
if (rtp_session->flags[SWITCH_RTP_FLAG_NACK] && rtp_session->vb) {
rtp_session->cur_nack = switch_vb_pop_nack(rtp_session->vb);
}
uint32_t *ssrc;
switch_rtcp_sdes_unit_t *unit;
- rtp_session->rtcp_last_sent = now;
+ if (!rtcp_fb) {
+ rtp_session->rtcp_last_sent = now;
+ rtp_session->rtcp_sent_packets++;
+ }
+
rtp_session->rtcp_send_msg.header.version = 2;
rtp_session->rtcp_send_msg.header.p = 0;
rtp_session->rtcp_send_msg.header.count = 1;
- rtp_session->rtcp_sent_packets++;
+
if (!rtp_session->stats.rtcp.sent_pkt_count) {
rtp_session->rtcp_send_msg.header.type = RTCP_PT_RR; /* Receiver report */
sdes->length = htons((uint16_t)(sdes_bytes / 4) - 1);
rtcp_bytes += sdes_bytes;
-
+
/* Prepare next report */
+
stats->last_rpt_cycle = stats->cycle;
stats->last_rpt_ext_seq = stats->high_ext_seq_recv;
stats->last_rpt_ts = rtp_session->timer.samplecount;
stats->sent_pkt_count = 0;
+
#ifdef ENABLE_SRTP
if (rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND]) {
int sbytes = (int) rtcp_bytes;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Starting video timer.\n");
}
- //switch_vb_create(&rtp_session->vb, 5, 30, rtp_session->pool);
+ //switch_vb_create(&rtp_session->vb, 3, 10, rtp_session->pool);
//switch_vb_debug_level(rtp_session->vb, 10);
-
-
-
-
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Not using a timer\n");
switch_vb_set_frames(rtp_session->vb, frames, frames * 3);
}
- switch_rtp_flush(rtp_session);
- switch_core_session_request_video_refresh(rtp_session->session);
+ //switch_rtp_flush(rtp_session);
+ //switch_core_session_request_video_refresh(rtp_session->session);
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_DEBUG, "Setting video buffer %u Frames.\n", frames);
stfu_n_reset(rtp_session->jb);
}
- if (rtp_session->vb) {
- switch_vb_reset(rtp_session->vb);
- }
+ //if (rtp_session->vb) {
+ // switch_vb_reset(rtp_session->vb);
+ //}
if (rtp_session->vbw) {
switch_vb_reset(rtp_session->vbw);
}
-
+
if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session),
SWITCH_LOG_CONSOLE, "%s FLUSH\n",
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
}
- }
+
- if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->session) {
- int type = 1; // sum flags: 1 encoder; 2; decoder
- switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_READ, SCC_VIDEO_RESET, SCCT_INT, (void *)&type, NULL, NULL);
- switch_core_session_request_video_refresh(rtp_session->session);
+ if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->session) {
+ //int type = 1; // sum flags: 1 encoder; 2; decoder
+ //switch_core_media_codec_control(rtp_session->session, SWITCH_MEDIA_TYPE_VIDEO, SWITCH_IO_READ, SCC_VIDEO_RESET, SCCT_INT, (void *)&type, NULL, NULL);
+ switch_core_session_request_video_refresh(rtp_session->session);
+ }
}
-
+
READ_DEC(rtp_session);
}
}
if (check_rtcp_and_ice(rtp_session) == -1) {
+ //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+ //switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF CHECK FAIL\n");
+ //}
return SWITCH_STATUS_GENERR;
}
*flags &= ~SFF_PROXY_PACKET;
+ //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+ // switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF BYTES %ld b=%d\n", *bytes, *b);
+ //}
+
+
if (*b == 0 || *b == 1) {
if (rtp_session->ice.ice_user) {
handle_ice(rtp_session, &rtp_session->ice, (void *) &rtp_session->recv_msg, *bytes);
uint16_t seq = ntohs((uint16_t) rtp_session->recv_msg.header.seq);
ts = ntohl(rtp_session->recv_msg.header.ts);
- if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
- rtp_session->recv_msg.header.version == 2 && rtp_session->recv_msg.header.x) { /* header extensions */
- uint16_t length;
-
- rtp_session->recv_msg.ext = (switch_rtp_hdr_ext_t *) rtp_session->recv_msg.body;
- length = ntohs((uint16_t)rtp_session->recv_msg.ext->length);
-
- if (length < SWITCH_RTP_MAX_BUF_LEN_WORDS) {
- rtp_session->recv_msg.ebody = rtp_session->recv_msg.body + (length * 4) + 4;
- }
- }
-
-
#ifdef DEBUG_MISSED_SEQ
if (rtp_session->last_seq && rtp_session->last_seq+1 != seq) {
//2012-11-28 18:33:11.799070 [ERR] switch_rtp.c:2883 Missed -65536 RTP frames from sequence [65536] to [-1] (missed). Time since last read [20021]
}
if (*bytes) {
- rtp_session->stats.inbound.raw_bytes += *bytes;
-
- if (rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) {
- rtp_session->stats.inbound.dtmf_packet_count++;
- } else if (rtp_session->cng_pt && (rtp_session->recv_msg.header.pt == rtp_session->cng_pt || rtp_session->recv_msg.header.pt == 13)) {
- rtp_session->stats.inbound.cng_packet_count++;
- } else {
- rtp_session->stats.inbound.media_packet_count++;
- rtp_session->stats.inbound.media_bytes += *bytes;
- }
-
- rtp_session->stats.inbound.packet_count++;
-
if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
#ifdef ENABLE_ZRTP
/* ZRTP Recv */
if (rtp_session->recv_msg.header.version == 2) {
+ /* recalculate body length in case rtp extension used */
+ if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
+ rtp_session->recv_msg.header.version == 2 && rtp_session->recv_msg.header.x) { /* header extensions */
+ uint16_t length;
+
+ rtp_session->recv_msg.ext = (switch_rtp_hdr_ext_t *) rtp_session->recv_msg.body;
+ length = ntohs((uint16_t)rtp_session->recv_msg.ext->length);
+
+ if (length < SWITCH_RTP_MAX_BUF_LEN_WORDS) {
+ rtp_session->recv_msg.ebody = rtp_session->recv_msg.body + (length * 4) + 4;
+ if (*bytes > (length * 4 + 4)) {
+ *bytes -= (length * 4 + 4);
+ } else {
+ *bytes = 0;
+ }
+ }
+ }
+
+
+#ifdef DEBUG_CHROME
+
+ if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->recv_msg.header.version == 2) {
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+ "VIDEO: seq: %d ts: %u len: %ld %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x mark: %d\n",
+ ntohs(rtp_session->recv_msg.header.seq), ntohl(rtp_session->recv_msg.header.ts), *bytes,
+ *((uint8_t *)RTP_BODY(rtp_session)), *((uint8_t *)RTP_BODY(rtp_session) + 1),
+ *((uint8_t *)RTP_BODY(rtp_session) + 2), *((uint8_t *)RTP_BODY(rtp_session) + 3),
+ *((uint8_t *)RTP_BODY(rtp_session) + 4), *((uint8_t *)RTP_BODY(rtp_session) + 5),
+ *((uint8_t *)RTP_BODY(rtp_session) + 6), *((uint8_t *)RTP_BODY(rtp_session) + 7),
+ *((uint8_t *)RTP_BODY(rtp_session) + 8), *((uint8_t *)RTP_BODY(rtp_session) + 9),
+ *((uint8_t *)RTP_BODY(rtp_session) + 10), rtp_session->recv_msg.header.m);
+
+ }
+#endif
+
+
+
if (rtp_session->flags[SWITCH_RTP_FLAG_ENABLE_RTCP]) {
rtcp_stats(rtp_session);
}
}
+
+ rtp_session->stats.inbound.raw_bytes += *bytes;
+
+ if (rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) {
+ rtp_session->stats.inbound.dtmf_packet_count++;
+ } else if (rtp_session->cng_pt && (rtp_session->recv_msg.header.pt == rtp_session->cng_pt || rtp_session->recv_msg.header.pt == 13)) {
+ rtp_session->stats.inbound.cng_packet_count++;
+ } else {
+ rtp_session->stats.inbound.media_packet_count++;
+ rtp_session->stats.inbound.media_bytes += *bytes;
+ }
+
+ rtp_session->stats.inbound.packet_count++;
}
if ((rtp_session->recv_te && rtp_session->recv_msg.header.pt == rtp_session->recv_te) ||
}
}
- /* recalculate body length in case rtp extension used */
- if (!rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] && !rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] &&
- rtp_session->recv_msg.header.version == 2 && rtp_session->recv_msg.header.x) { /* header extensions */
- uint16_t length;
-
- rtp_session->recv_msg.ext = (switch_rtp_hdr_ext_t *) rtp_session->recv_msg.body;
- length = ntohs((uint16_t)rtp_session->recv_msg.ext->length);
-
- if (length < SWITCH_RTP_MAX_BUF_LEN_WORDS) {
- rtp_session->recv_msg.ebody = rtp_session->recv_msg.body + (length * 4) + 4;
- if (*bytes > (length * 4 + 4)) {
- *bytes -= (length * 4 + 4);
- } else {
- *bytes = 0;
- }
- }
- }
-
return status;
}
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
+
+ //if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
+ // switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, "WTF Poll %d\n", poll_status);
+ //}
+
if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->dtmf_data.out_digit_dur > 0) {
return_cng_frame();
}
{
if (!rtp_session) return 0;
- if (rtp_session->ice.ice_user && !(rtp_session->ice.rready && rtp_session->ice.ready)) {
+ if (rtp_session->ice.ice_user && !(rtp_session->ice.rready || rtp_session->ice.ready)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG3, "Skip sending %s packet %ld bytes (ice not ready @ line %d!)\n",
rtp_type(rtp_session), (long)bytes, line);
return 0;
if (rtp_session->flags[SWITCH_RTP_FLAG_NACK]) {
if (!rtp_session->vbw) {
- switch_vb_create(&rtp_session->vbw, 150, 150, rtp_session->pool);
+ switch_vb_create(&rtp_session->vbw, 10, 10, rtp_session->pool);
//switch_vb_debug_level(rtp_session->vbw, 10);
}
switch_vb_push_packet(rtp_session->vbw, (switch_rtp_packet_t *)send_msg, bytes);