int32_t timestamp_send;
int32_t timestamp_recv;
int32_t timestamp_dtmf;
+ uint32_t last_read;
char *codec_name;
uint8_t codec_num;
};
tech_pvt->codec_num,
tech_pvt->read_codec.implementation->encoded_bytes_per_frame,
tech_pvt->read_codec.implementation->microseconds_per_frame,
- 0,
+ SWITCH_RTP_FLAG_USE_TIMER,
NULL,
&err, switch_core_session_get_pool(tech_pvt->session)))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP ERROR %s\n", err);
}
}
-
+ if (switch_test_flag(&tech_pvt->read_frame, SFF_CNG)) {
+ tech_pvt->read_frame.datalen = tech_pvt->last_read;
+ }
+
if (tech_pvt->read_frame.datalen > 0) {
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
frames = (tech_pvt->read_frame.datalen / bytes);
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
tech_pvt->timestamp_recv += (int32_t) samples;
tech_pvt->read_frame.samples = (int) samples;
-
+ tech_pvt->last_read = tech_pvt->read_frame.datalen;
//printf("READ bytes=%d payload=%d frames=%d samples=%d ms=%d ts=%d sampcount=%d\n", (int)tech_pvt->read_frame.datalen, (int)payload, (int)frames, (int)samples, (int)ms, (int)tech_pvt->timestamp_recv, (int)tech_pvt->read_frame.samples);
break;
}
}
rtp_session->pool = pool;
+ rtp_session->flags = flags;
/* for from address on recvfrom calls */
switch_sockaddr_info_get(&rtp_session->from_addr, NULL, SWITCH_UNSPEC, 0, 0, rtp_session->pool);
}
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
-
if ((switch_time_now() - rtp_session->next_read) > 1000) {
/* We're late! We're Late!*/
- memset(&rtp_session->recv_msg, 0, 13);
+ memset(&rtp_session->recv_msg, 0, SWITCH_RTP_CNG_PAYLOAD);
rtp_session->recv_msg.header.pt = SWITCH_RTP_CNG_PAYLOAD;
*flags |= SFF_CNG;
- /* RE-Sync the clock and return a CNG frame */
- rtp_session->next_read = switch_time_now() + rtp_session->ms_per_packet;
- return 13;
+ /* Set the next waypoint and return a CNG frame */
+ rtp_session->next_read += rtp_session->ms_per_packet;
+ *payload_type = SWITCH_RTP_CNG_PAYLOAD;
+ return SWITCH_RTP_CNG_PAYLOAD;
}
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK) && status == SWITCH_STATUS_BREAK) {