mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-09 17:26:03 +00:00
fix random issues
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10566 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
cef087ba8b
commit
4369876e57
@ -451,7 +451,8 @@ typedef enum {
|
|||||||
SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 << 16),
|
SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 << 16),
|
||||||
SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17),
|
SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17),
|
||||||
SWITCH_RTP_FLAG_PROXY_MEDIA = (1 << 18),
|
SWITCH_RTP_FLAG_PROXY_MEDIA = (1 << 18),
|
||||||
SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19)
|
SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19),
|
||||||
|
SWITCH_RTP_FLAG_FLUSH = (1 << 20)
|
||||||
} switch_rtp_flag_enum_t;
|
} switch_rtp_flag_enum_t;
|
||||||
typedef uint32_t switch_rtp_flag_t;
|
typedef uint32_t switch_rtp_flag_t;
|
||||||
|
|
||||||
|
@ -710,14 +710,21 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tech_pvt->last_ts && tech_pvt->read_frame.datalen != tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
|
if (tech_pvt->last_ts && tech_pvt->read_frame.datalen != tech_pvt->read_codec.implementation->encoded_bytes_per_packet) {
|
||||||
if (++tech_pvt->mismatch_count >= MAX_MISMATCH_FRAMES) {
|
|
||||||
switch_size_t codec_ms = (int)(tech_pvt->read_frame.timestamp -
|
switch_size_t codec_ms = (int)(tech_pvt->read_frame.timestamp -
|
||||||
tech_pvt->last_ts) / (tech_pvt->read_codec.implementation->samples_per_second / 1000);
|
tech_pvt->last_ts) / (tech_pvt->read_codec.implementation->samples_per_second / 1000);
|
||||||
|
|
||||||
if ((codec_ms % 10) != 0) {
|
if ((codec_ms % 10) != 0) {
|
||||||
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
|
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
|
||||||
goto skip;
|
goto skip;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (tech_pvt->last_codec_ms && tech_pvt->last_codec_ms == codec_ms) {
|
||||||
|
tech_pvt->mismatch_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
tech_pvt->last_codec_ms = codec_ms;
|
||||||
|
|
||||||
|
if (tech_pvt->mismatch_count > MAX_MISMATCH_FRAMES) {
|
||||||
if (switch_rtp_ready(tech_pvt->rtp_session) && codec_ms != tech_pvt->codec_ms) {
|
if (switch_rtp_ready(tech_pvt->rtp_session) && codec_ms != tech_pvt->codec_ms) {
|
||||||
const char *val;
|
const char *val;
|
||||||
int rtp_timeout_sec = 0;
|
int rtp_timeout_sec = 0;
|
||||||
@ -775,7 +782,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tech_pvt->mismatch_count = 0;
|
tech_pvt->mismatch_count = 0;
|
||||||
}
|
}
|
||||||
|
@ -547,6 +547,7 @@ struct private_object {
|
|||||||
switch_size_t last_ts;
|
switch_size_t last_ts;
|
||||||
uint32_t check_frames;
|
uint32_t check_frames;
|
||||||
uint32_t mismatch_count;
|
uint32_t mismatch_count;
|
||||||
|
uint32_t last_codec_ms;
|
||||||
nua_event_t want_event;
|
nua_event_t want_event;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -608,11 +608,15 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
|||||||
switch_mutex_lock(session->codec_write_mutex);
|
switch_mutex_lock(session->codec_write_mutex);
|
||||||
|
|
||||||
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
|
if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
|
||||||
need_codec = TRUE;
|
|
||||||
if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
|
if (session->write_codec->implementation->codec_id == frame->codec->implementation->codec_id) {
|
||||||
ptime_mismatch = TRUE;
|
ptime_mismatch = TRUE;
|
||||||
|
if (!need_codec) {
|
||||||
|
status = perform_write(session, frame, flags, stream_id);
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
need_codec = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (session->write_codec && !frame->codec) {
|
if (session->write_codec && !frame->codec) {
|
||||||
need_codec = TRUE;
|
need_codec = TRUE;
|
||||||
|
@ -1264,6 +1264,11 @@ static void do_2833(switch_rtp_t *rtp_session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session)
|
SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session)
|
||||||
|
{
|
||||||
|
switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void do_flush(switch_rtp_t *rtp_session)
|
||||||
{
|
{
|
||||||
int was_blocking = 0;
|
int was_blocking = 0;
|
||||||
switch_size_t bytes;
|
switch_size_t bytes;
|
||||||
@ -1338,6 +1343,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH)) {
|
||||||
|
do_flush(rtp_session);
|
||||||
|
switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (rtp_session->max_missed_packets) {
|
if (rtp_session->max_missed_packets) {
|
||||||
if (bytes) {
|
if (bytes) {
|
||||||
rtp_session->missed_count = 0;
|
rtp_session->missed_count = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user