FS-9808 #resolve [mod_png issue when used with ivr as video input]

This commit is contained in:
Brian West 2016-12-13 09:32:02 -06:00
parent 6522572104
commit 4d71ed84db
2 changed files with 18 additions and 0 deletions

View File

@ -50,6 +50,7 @@ struct png_file_context {
int max; int max;
int samples; int samples;
switch_file_handle_t *audio_fh; switch_file_handle_t *audio_fh;
int done;
}; };
typedef struct png_file_context png_file_context_t; typedef struct png_file_context png_file_context_t;
@ -144,6 +145,8 @@ static switch_status_t png_file_close(switch_file_handle_t *handle)
if (context->audio_fh) switch_core_file_close(context->audio_fh); if (context->audio_fh) switch_core_file_close(context->audio_fh);
context->done = 1;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -152,6 +155,10 @@ static switch_status_t png_file_read(switch_file_handle_t *handle, void *data, s
png_file_context_t *context = (png_file_context_t *)handle->private_info; png_file_context_t *context = (png_file_context_t *)handle->private_info;
if (context->done) {
return SWITCH_STATUS_FALSE;
}
if (context->audio_fh) { if (context->audio_fh) {
return switch_core_file_read(context->audio_fh, data, len); return switch_core_file_read(context->audio_fh, data, len);
} }
@ -183,6 +190,10 @@ static switch_status_t png_file_read_video(switch_file_handle_t *handle, switch_
switch_image_t *dup = NULL; switch_image_t *dup = NULL;
int have_frame = 0; int have_frame = 0;
if (context->done) {
return SWITCH_STATUS_FALSE;
}
if ((flags & SVR_CHECK)) { if ((flags & SVR_CHECK)) {
return SWITCH_STATUS_BREAK; return SWITCH_STATUS_BREAK;
} }

View File

@ -6081,7 +6081,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses
switch_mutex_unlock(v_engine->mh.file_read_mutex); switch_mutex_unlock(v_engine->mh.file_read_mutex);
} else { } else {
if (!fh && smh->video_write_thread) {
if (smh->video_write_thread_running > 0) {
smh->video_write_thread_running = -1;
}
}
switch_mutex_lock(v_engine->mh.file_write_mutex); switch_mutex_lock(v_engine->mh.file_write_mutex);
if (fh && smh->video_write_fh) { if (fh && smh->video_write_fh) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "File is already open\n");
smh->video_write_fh = fh; smh->video_write_fh = fh;