typedef struct av_file_context av_file_context_t;
+static void mod_avformat_destroy_output_context(av_file_context_t *context)
+{
+
+ if (context->has_video) close_stream(context->fc, &context->video_st);
+ if (context->has_audio) close_stream(context->fc, &context->audio_st);
+
+ if (context->audio_st.resample_ctx) {
+ avresample_free(&context->audio_st.resample_ctx);
+ }
+
+ avformat_close_input(&context->fc);
+}
static switch_status_t open_input_file(av_file_context_t *context, switch_file_handle_t *handle, const char *filename)
{
end:
- if (handle && context) {
- av_file_close(handle);
+ if (context && context->fc) {
+ mod_avformat_destroy_output_context(context);
}
if (context->timer.interval) {
av_file_context_t *context = (av_file_context_t *)handle->private_info;
switch_status_t status;
-
if (context->eh.video_queue) {
switch_queue_push(context->eh.video_queue, NULL);
}
if (context->fc) {
if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) av_write_trailer(context->fc);
- if (context->has_video) close_stream(context->fc, &context->video_st);
- if (context->has_audio) close_stream(context->fc, &context->audio_st);
-
- if (context->audio_st.resample_ctx) {
- avresample_free(&context->audio_st.resample_ctx);
- }
-
- avformat_close_input(&context->fc);
+ mod_avformat_destroy_output_context(context);
}
if (context->timer.interval) {