switch_buffer_zero(context->audio_buffer);
switch_mutex_unlock(context->mutex);
- if (context->eh.video_queue) {
- flush_video_queue(context->eh.video_queue, 0);
- }
+
// if (context->has_audio) stream_id = context->audio_st.st->index;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "seeking to %" SWITCH_INT64_T_FMT "\n", context->seek_ts);
avformat_seek_file(context->fc, stream_id, 0, context->seek_ts, INT64_MAX, 0);
if (context->has_video) {
vid_frames = switch_queue_size(context->eh.video_queue);
}
+
+ if (vid_frames > context->read_fps) {
+ switch_yield(250000);
+ }
if (switch_buffer_inuse(context->audio_buffer) > AUDIO_BUF_SEC * context->audio_st.sample_rate * context->audio_st.channels * 2 &&
(!context->has_video || vid_frames > 5)) {
continue;
}
+
+
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
if (!context->has_video || context->closed) return SWITCH_STATUS_FALSE;
-
if ((flags & SVR_CHECK)) {
return SWITCH_STATUS_BREAK;
}
frame->img = (switch_image_t *) pop;
- if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
- if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
- switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
+ if (frame->img) {
+ if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
+ if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
+ switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
+ }
}
- }
-
+ context->vid_ready = 1;
+ }
+
return SWITCH_STATUS_SUCCESS;
}
}
if (frame->img) {
+ if (frame->img && context->handle->mm.scale_w && context->handle->mm.scale_h) {
+ if (frame->img->d_w != context->handle->mm.scale_w || frame->img->d_h != context->handle->mm.scale_h) {
+ switch_img_fit(&frame->img, context->handle->mm.scale_w, context->handle->mm.scale_h, SWITCH_FIT_SIZE);
+ }
+ }
context->vid_ready = 1;
}
typedef struct chromakey_context_s {
int threshold;
switch_image_t *bgimg;
+ switch_image_t *backup_img;
switch_image_t *bgimg_scaled;
switch_file_handle_t vfh;
switch_rgb_color_t bgcolor;
return SWITCH_STATUS_SUCCESS;
}
- switch_mutex_lock(context->command_mutex);
+ if (switch_mutex_trylock(context->command_mutex) != SWITCH_STATUS_SUCCESS) {
+ switch_img_patch(frame->img, context->backup_img, 0, 0);
+ return SWITCH_STATUS_SUCCESS;
+ }
data = malloc(frame->img->d_w * frame->img->d_h * 4);
switch_assert(data);
}
switch_img_patch(frame->img, img, 0, 0);
+ switch_img_free(&context->backup_img);
+ switch_img_copy(frame->img, &context->backup_img);
switch_img_free(&img);
free(data);