]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7585 add bandwidth settings to flash video
authorSeven Du <dujinfang@gmail.com>
Thu, 4 Jun 2015 15:32:38 +0000 (23:32 +0800)
committerSeven Du <dujinfang@gmail.com>
Thu, 4 Jun 2015 15:33:00 +0000 (23:33 +0800)
clients/flex/freeswitch-video.html
src/mod/endpoints/mod_rtmp/mod_rtmp.c
src/mod/endpoints/mod_rtmp/mod_rtmp.h

index ee99192e3a16228aeb9a1ebcb4f0a72227f1cbd3..7823deea5aae129020521ece1b4588ae6abd3db9 100644 (file)
@@ -42,7 +42,7 @@
                }
 
                function makeCall() {
-                               flash.makeCall($('#dest').val(), '', {want_video: "true"});
+                               flash.makeCall($('#dest').val(), '', {wantVideo: "true", incomingBandwidth: "1mb"});
                }
 
                function hangup() {
index d48df21076ecbfc2fb0f14918981e45e4b57ba7f..d4e0c218c92f9ce2816cd9c72c8e5bfd1b3f3a64 100644 (file)
@@ -139,6 +139,8 @@ switch_status_t rtmp_tech_init(rtmp_private_t *tech_pvt, rtmp_session_t *rsessio
        tech_pvt->audio_codec = 0xB2; //rtmp_audio_codec(1, 16, 0 /* speex is always 8000  */, RTMP_AUDIO_SPEEX);
 
        if (tech_pvt->has_video) {
+               switch_codec_settings_t codec_settings = {{ 0 }};
+
                /* Initialize video read & write codecs */
                if (switch_core_codec_init(&tech_pvt->video_read_codec, /* name */ "H264", /* modname */ NULL,
                        /* fmtp */ NULL,  /* rate */ 90000, /* ms */ 0, /* channels */ 1,
@@ -149,10 +151,16 @@ switch_status_t rtmp_tech_init(rtmp_private_t *tech_pvt, rtmp_session_t *rsessio
                        return SWITCH_STATUS_FALSE;
                }
 
+               if (!zstr(tech_pvt->video_max_bandwidth_out)) {
+                       codec_settings.video.bandwidth = switch_parse_bandwidth_string(tech_pvt->video_max_bandwidth_out);
+               } else {
+                       codec_settings.video.bandwidth = switch_parse_bandwidth_string("1mb");
+               }
+
                if (switch_core_codec_init(&tech_pvt->video_write_codec, /* name */ "H264", /* modname */ NULL,
                        /* fmtp */ NULL,  /* rate */ 90000, /* ms */ 0, /* channels */ 1,
                        /* flags */ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                       /* codec settings */ NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+                       /* codec settings */ &codec_settings, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't initialize write codec\n");
 
                        return SWITCH_STATUS_FALSE;
@@ -1102,12 +1110,18 @@ switch_call_cause_t rtmp_session_create_call(rtmp_session_t *rsession, switch_co
        switch_core_session_add_stream(*newsession, NULL);
 
        if (event) {
-               const char *want_video = switch_event_get_header(event, "want_video");
+               const char *want_video = switch_event_get_header(event, "wantVideo");
+               const char *bandwidth = switch_event_get_header(event, "incomingBandwidth");
 
                if (want_video && switch_true(want_video)) {
                        tech_pvt->has_video = 1;
                        switch_channel_set_variable(channel, "video_possible", "true");
                }
+
+               if (!zstr(bandwidth)) {
+                       tech_pvt->video_max_bandwidth_out = switch_core_strdup(pool, bandwidth);
+               }
+
        }
 
        if (rtmp_tech_init(tech_pvt, rsession, *newsession) != SWITCH_STATUS_SUCCESS) {
index 8571aedafa3b65650b2cbd02926fe3452a5c5d10..8c398d76d7a787ea6e73e631b6e8f56a0da1f672 100644 (file)
@@ -559,6 +559,7 @@ struct rtmp_private {
 
        //video
        int has_video;
+       char *video_max_bandwidth_out;
        switch_codec_t video_read_codec;
        switch_codec_t video_write_codec;
        rtp2rtmp_helper_t video_write_helper;