SFF_SAME_IMAGE = (1 << 15),
SFF_USE_VIDEO_TIMESTAMP = (1 << 16),
SFF_ENCODED = (1 << 17),
- SFF_TEXT_LINE_BREAK = (1 << 18)
+ SFF_TEXT_LINE_BREAK = (1 << 18),
+ SFF_IS_KEYFRAME = (1 << 19)
} switch_frame_flag_enum_t;
typedef uint32_t switch_frame_flag_t;
int mask_len;
switch_core_session_t *session;
switch_mutex_t *command_mutex;
+ int patch;
+ int mod;
} chromakey_context_t;
static void init_context(chromakey_context_t *context)
int n = argc - start;
int i = start;
- switch_core_session_request_video_refresh(context->session);
- switch_core_media_gen_key_frame(context->session);
-
switch_mutex_lock(context->command_mutex);
+ context->patch = 0;
+
if (n > 0 && argv[i]) { // color
int j = 0;
char *list[MAX_MASK];
if (!strcasecmp(argv[i], "patch")) {
*function = "patch:video";
*flags = SMBF_VIDEO_PATCH;
+ context->patch++;
}
i++;
}
-
+ switch_core_session_request_video_refresh(context->session);
+ context->mod++;
switch_mutex_unlock(context->command_mutex);
- switch_core_session_request_video_refresh(context->session);
- switch_core_media_gen_key_frame(context->session);
+
}
return SWITCH_STATUS_SUCCESS;
}
+ if (!context->patch && context->mod && !switch_test_flag(frame, SFF_IS_KEYFRAME)) {
+ switch_core_session_request_video_refresh(context->session);
+ return SWITCH_STATUS_SUCCESS;
+ }
+
+ context->mod = 0;
+
if (switch_mutex_trylock(context->command_mutex) != SWITCH_STATUS_SUCCESS) {
switch_img_patch(frame->img, context->last_img, 0, 0);
return SWITCH_STATUS_SUCCESS;
if (frames > 0) {
switch_rtp_set_video_buffer_size(v_engine->rtp_session, frames, max_frames);
+ } else {
+ switch_rtp_deactivate_jitter_buffer(v_engine->rtp_session);
}
return;
} else if (!strncasecmp(input, "vdebug:", 7)) {
uint32_t loops = 0;
switch_media_handle_t *smh;
int patchers = 0;
+ int is_keyframe = 0;
switch_assert(session != NULL);
(*frame)->img = NULL;
decode_status = switch_core_codec_decode_video((*frame)->codec, *frame);
-
+ if (switch_test_flag(*frame, SFF_IS_KEYFRAME)) {
+ is_keyframe++;
+ }
if ((*frame)->img && switch_channel_test_flag(session->channel, CF_VIDEO_DEBUG_READ)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "IMAGE %dx%d %dx%d\n",
(*frame)->img->w, (*frame)->img->h, (*frame)->img->d_w, (*frame)->img->d_h);
done:
+ if (*frame && is_keyframe) {
+ switch_set_flag(*frame, SFF_IS_KEYFRAME);
+ }
+
if (session->bugs) {
switch_media_bug_t *bp;
int prune = 0;
}
if (is_keyframe) {
+ switch_set_flag(frame, SFF_IS_KEYFRAME);
if (context->got_key_frame <= 0) {
context->got_key_frame = 1;
context->no_key_frame = 0;