]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add some params to control rate and channels
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 11 Jul 2017 17:45:57 +0000 (12:45 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 11 Aug 2017 18:23:15 +0000 (13:23 -0500)
src/mod/applications/mod_av/avformat.c
src/switch_core_file.c
src/switch_event.c

index f35b03e336be4d534f8aa313ffbdca46b0d19ed0..4fd2e1b655dd9e3177ce74c9c5da7560c7d505db 100644 (file)
@@ -1957,6 +1957,19 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
                        fmt->audio_codec = context->audio_codec->id;
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "specified audio codec %s %s [%s]\n", 
                                                          tmp, context->audio_codec->name, context->audio_codec->long_name);
+
+                       if (!strcasecmp(tmp, "pcm_mulaw")) {
+                               handle->mm.samplerate = 8000;
+                               handle->mm.ab = 64;
+                       }
+               }
+       }
+
+       if (handle->params && (tmp = switch_event_get_header(handle->params, "av_video_codec"))) {
+               if ((context->video_codec = avcodec_find_encoder_by_name(tmp))) {
+                       fmt->video_codec = context->video_codec->id;
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "specified video codec %s %s [%s]\n",
+                                                         tmp, context->video_codec->name, context->video_codec->long_name);
                }
        }
 
@@ -1977,9 +1990,17 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
        }
 
        if (handle->mm.samplerate) {
+               handle->samplerate = handle->mm.samplerate;
+       } else {
                handle->mm.samplerate = handle->samplerate;
        }
 
+       if (handle->mm.channels) {
+               handle->channels = handle->mm.channels;
+       } else {
+               handle->mm.channels = handle->channels;
+       }
+
        if (!handle->mm.ab) {
                handle->mm.ab = 128;
        }
@@ -1988,10 +2009,10 @@ static switch_status_t av_file_open(switch_file_handle_t *handle, const char *pa
                handle->mm.vb = switch_calc_bitrate(handle->mm.vw, handle->mm.vh, 1, handle->mm.fps);
        }
 
-       if (fmt->video_codec != AV_CODEC_ID_NONE) {
+       if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && fmt->video_codec != AV_CODEC_ID_NONE) {
                const AVCodecDescriptor *desc;
 
-               if ((handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "rtsp") || !strcasecmp(handle->stream_name, "youtube")))) {
+               if ((handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "youtube")))) {
 
                        if (fmt->video_codec != AV_CODEC_ID_H264 ) {
                                fmt->video_codec = AV_CODEC_ID_H264; // force H264
index 834d8c88cab982067d3e0ede5e55cc24ffe9ae08..a0a80e1dd40587e66f2b0ca246bbc3fa795f3f20 100644 (file)
@@ -123,7 +123,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_perform_file_open(const char *file,
 
                if ((val = switch_event_get_header(fh->params, "samplerate"))) {
                        tmp = atoi(val);
-                       if (tmp > 8000) {
+                       if (tmp >= 8000) {
                                fh->mm.samplerate = tmp;
                        }
                }
index f3b0566ac0d8a755bea5c31508bf1b294873528b..7911d155d49147465fb2d7f000161b23e3772ad2 100644 (file)
@@ -1663,6 +1663,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
 
        if (!e) {
                switch_event_create_plain(&e, SWITCH_EVENT_CHANNEL_DATA);
+               e->flags |= EF_UNIQ_HEADERS;
        }
 
 
@@ -1696,7 +1697,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
 
                                if ((inner_var_count = switch_separate_string(var_array[x], '=',
                                                                                                                          inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]);
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]);
                                        switch_event_add_header_string(e, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
                                }
                        }