switch_memory_pool_t *pool;
switch_mutex_t *mutex;
uint32_t fps;
+ uint32_t synced;
} core_video_globals_t;
static core_video_globals_t video_globals = { 0 };
return 0;
}
- fps = switch_round_to_step(smh->vid_frames / (now - smh->vid_started), 5);
- if (fps < 15) fps = 15;
+ fps = switch_round_to_step(smh->vid_frames / (now - smh->vid_started), 5);
- smh->vid_started = switch_epoch_time_now(NULL);
- smh->vid_frames = 1;
+ if (smh->vid_frames > 1000) {
+ smh->vid_started = switch_epoch_time_now(NULL);
+ smh->vid_frames = 1;
+ }
+
+ if (fps > 0) {
+ video_globals.fps = fps;
+
+ if (smh->vid_params.fps != fps) {
+ switch_channel_set_variable_printf(session->channel, "video_fps", "%d", fps);
+ smh->vid_params.fps = fps;
+ }
+ }
return fps;
}
}
}
- if (smh->vid_frames < 10) {
- fps = 30;
- } else {
- fps = switch_core_media_get_video_fps(session);
- }
+ fps = switch_core_media_get_video_fps(session);
- if (fps < 15) return;
-
switch_rtp_get_video_buffer_size(v_engine->rtp_session, &min_frames, &max_frames, &cur_frames, NULL);
if (!frames) {
sync_video = 1;
}
- if (fps) {
- video_globals.fps = fps;
-
- if (smh->vid_params.fps != fps) {
- switch_channel_set_variable_printf(session->channel, "video_fps", "%d", fps);
- smh->vid_params.fps = fps;
- }
- }
-
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
SWITCH_LOG_DEBUG1, "%s %s \"%s\" Sync A/V JB to %dms %u VFrames FPS %u a:%s v:%s\n",
switch_core_session_get_uuid(session),
if (sync_audio) {
check_jb(session, NULL, jb_sync_msec, 0, SWITCH_TRUE);
}
+
+ video_globals.synced++;
}
}
if (type == SWITCH_MEDIA_TYPE_VIDEO && engine->read_frame.m) {
+
if (!smh->vid_started) {
smh->vid_started = switch_epoch_time_now(NULL);
}
smh->vid_frames++;
+ if ((smh->vid_frames % 15) == 0) {
+ switch_core_media_get_video_fps(session);
+ }
+
if (smh->vid_frames == 1 || ((smh->vid_frames % 300) == 0)) {
check_jb_sync(session);
}
if (switch_channel_test_flag(channel, CF_VIDEO_READY) && !switch_test_flag(read_frame, SFF_CNG)) {
switch_mutex_lock(mh->file_read_mutex);
if (smh->video_read_fh && switch_test_flag(smh->video_read_fh, SWITCH_FILE_OPEN) && read_frame->img) {
+ smh->video_read_fh->mm.fps = smh->vid_params.fps;
switch_core_file_write_video(smh->video_read_fh, read_frame);
}
switch_mutex_unlock(mh->file_read_mutex);
switch_frame_t *read_frame;
switch_status_t status;
- if (switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width && smh->vid_params.height && smh->vid_params.fps) {
+ if (video_globals.synced &&
+ switch_channel_test_flag(session->channel, CF_VIDEO_READY) && smh->vid_params.width && smh->vid_params.height && smh->vid_params.fps) {
return SWITCH_STATUS_SUCCESS;
}