SWITCH_DECLARE(void) switch_channel_perform_audio_sync(switch_channel_t *channel, const char *file, const char *func, int line);
#define switch_channel_audio_sync(_c) switch_channel_perform_audio_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)
+SWITCH_DECLARE(void) switch_channel_perform_video_sync(switch_channel_t *channel, const char *file, const char *func, int line);
+#define switch_channel_video_sync(_c) switch_channel_perform_video_sync(_c, __FILE__, __SWITCH_FUNC__, __LINE__)
SWITCH_DECLARE(void) switch_channel_set_private_flag(switch_channel_t *channel, uint32_t flags);
SWITCH_DECLARE(void) switch_channel_clear_private_flag(switch_channel_t *channel, uint32_t flags);
SWITCH_MESSAGE_INDICATE_DISPLAY,
SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY,
SWITCH_MESSAGE_INDICATE_AUDIO_SYNC,
+ SWITCH_MESSAGE_INDICATE_VIDEO_SYNC,
SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA,
SWITCH_MESSAGE_INDICATE_UUID_CHANGE,
SWITCH_MESSAGE_INDICATE_SIMPLIFY,
if ((lsession = switch_core_session_locate(argv[0]))) {
switch_core_session_video_reinit(lsession);
+ switch_channel_video_sync(switch_core_session_get_channel(lsession));
status = SWITCH_STATUS_SUCCESS;
switch_core_session_rwunlock(lsession);
}
void *pop;
int r = 0;
+ if (!q) return 0;
+
while (switch_queue_trypop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) {
img = (switch_image_t *)pop;
switch_img_free(&img);
}
size = switch_queue_size(imember->video_queue);
} while(size > 0);
- if (!img) {
+ if (!img && switch_test_flag(imember, MFLAG_CAN_BE_SEEN)) {
imember->blanks++;
+
+ if (imember->blanks == conference->video_fps.fps || (imember->blanks % (int)(conference->video_fps.fps * 10)) == 0) {
+ switch_core_session_request_video_refresh(imember->session);
+ }
+
if (imember->blanks == conference->video_fps.fps * 2) {
check_avatar(imember, SWITCH_TRUE);
if (layer && imember->avatar_png_img) {
if (flushed && imember->blanks) {
switch_img_free(&imember->avatar_png_img);
imember->blanks = 0;
+ switch_core_session_request_video_refresh(imember->session);
+ switch_channel_video_sync(imember->channel);
}
img = imember->avatar_png_img;
if (switch_test_flag(member->conference, CFLAG_VIDEO_MUXING)) {
switch_image_t *img_copy = NULL;
- if (frame->img && !member->conference->playing_video_file) {
+ if (frame->img && !member->conference->playing_video_file && switch_queue_size(member->video_queue) < 3) {
switch_img_copy(frame->img, &img_copy);
switch_queue_push(member->video_queue, img_copy);
}
if (member->channel) {
switch_channel_set_flag(member->channel, CF_VIDEO_PAUSE_READ);
+ switch_core_session_request_video_refresh(member->session);
+ switch_channel_video_sync(member->channel);
}
if (!(data) || !strstr((char *) data, "quiet")) {
if (member->channel) {
switch_channel_clear_flag(member->channel, CF_VIDEO_PAUSE_READ);
+ switch_core_session_request_video_refresh(member->session);
+ switch_channel_video_sync(member->channel);
}
if (!(data) || !strstr((char *) data, "quiet")) {
if (context->is_vp9) {
is_keyframe = IS_VP9_KEY_FRAME(*(unsigned char *)frame->data);
} else { // vp8
- is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
+ is_keyframe = (*(unsigned char *)frame->data & 0x10) || IS_VP8_KEY_FRAME((uint8_t *)frame->data);
}
// if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
err = vpx_codec_decode(decoder, data, (unsigned int)len, NULL, 0);
if (err != VPX_CODEC_OK) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error decoding %" SWITCH_SIZE_T_FMT " bytes, [%d:%s:%s]\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Error decoding %" SWITCH_SIZE_T_FMT " bytes, [%d:%s:%s]\n",
len, err, vpx_codec_error(decoder), vpx_codec_error_detail(decoder));
switch_goto_status(SWITCH_STATUS_RESTART, end);
}
end:
- if (status == SWITCH_STATUS_RESTART) {
- context->need_decoder_reset = 1;
- }
+ //if (status == SWITCH_STATUS_RESTART) {
+ // context->need_decoder_reset = 1;
+ //}
if (!frame->img || status == SWITCH_STATUS_RESTART) {
status = SWITCH_STATUS_MORE_DATA;
}
+SWITCH_DECLARE(void) switch_channel_perform_video_sync(switch_channel_t *channel, const char *file, const char *func, int line)
+{
+ if (switch_channel_media_up(channel)) {
+ switch_core_session_message_t msg = { 0 };
+ msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_SYNC;
+ msg.from = channel->name;
+ msg._file = file;
+ msg._func = func;
+ msg._line = line;
+ switch_core_session_receive_message(channel->session, &msg);
+ }
+}
+
+
SWITCH_DECLARE(switch_call_cause_t) switch_channel_cause_q850(switch_call_cause_t cause)
{
}
goto end;
+ case SWITCH_MESSAGE_INDICATE_VIDEO_SYNC:
+ if (switch_rtp_ready(v_engine->rtp_session)) {
+ switch_rtp_flush(v_engine->rtp_session);
+ }
+ goto end;
+
case SWITCH_MESSAGE_INDICATE_MEDIA:
{
return;
}
- if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
- switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
- }
+ switch_rtp_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
}
SWITCH_DECLARE(void) switch_rtp_video_refresh(switch_rtp_t *rtp_session)
SWITCH_DECLARE(void) switch_rtp_set_flag(switch_rtp_t *rtp_session, switch_rtp_flag_t flag)
{
- if (flag == SWITCH_RTP_FLAG_FLUSH && rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
- return;
- }
-
switch_mutex_lock(rtp_session->flag_mutex);
rtp_session->flags[flag] = 1;
switch_mutex_unlock(rtp_session->flag_mutex);
}
}
}
+
+
rtp_flush_read_buffer(rtp_session, SWITCH_RTP_FLUSH_ONCE);
+
+
if (rtp_session->jb) {
stfu_n_reset(rtp_session->jb);
}
{
if (rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] ||
- rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] ||
rtp_session->flags[SWITCH_RTP_FLAG_UDPTL]) {
return;
}
if (!switch_rtp_ready(rtp_session)) {
return;
}
+
reset_jitter_seq(rtp_session);
if (!force) {
if (rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA] ||
- rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] ||
rtp_session->flags[SWITCH_RTP_FLAG_UDPTL] ||
rtp_session->flags[SWITCH_RTP_FLAG_DTMF_ON]
) {
if (switch_rtp_ready(rtp_session) ) {
if (rtp_session->jb && !rtp_session->pause_jb && jb_valid(rtp_session)) {
- goto end;
+ stfu_n_reset(rtp_session->jb);
+ }
+
+ 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",
- rtp_session->session ? switch_channel_get_name(switch_core_session_get_channel(rtp_session->session)) : "NoName"
- );
+ SWITCH_LOG_CONSOLE, "%s FLUSH\n",
+ rtp_session->session ? switch_channel_get_name(switch_core_session_get_channel(rtp_session->session)) : "NoName"
+ );
}
if (!rtp_session->flags[SWITCH_RTP_FLAG_NOBLOCK]) {
}
}
- end:
-
READ_DEC(rtp_session);
}
check = !bytes;
if (rtp_session->flags[SWITCH_RTP_FLAG_FLUSH]) {
- if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO]) {
- do_flush(rtp_session, SWITCH_FALSE);
- bytes = 0;
- }
+ do_flush(rtp_session, SWITCH_FALSE);
+ bytes = 0;
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
}
}
if (bytes && rtp_session->recv_msg.header.m && rtp_session->recv_msg.header.pt != rtp_session->recv_te &&
- !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !(rtp_session->rtp_bugs & RTP_BUG_IGNORE_MARK_BIT)) {
+ !rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] &&
+ !(rtp_session->rtp_bugs & RTP_BUG_IGNORE_MARK_BIT)) {
rtp_flush_read_buffer(rtp_session, SWITCH_RTP_FLUSH_ONCE);
}