diff --git a/html5/verto/js/src/jquery.jsonrpcclient.js b/html5/verto/js/src/jquery.jsonrpcclient.js index 58d9986aec..6f4f07c72b 100644 --- a/html5/verto/js/src/jquery.jsonrpcclient.js +++ b/html5/verto/js/src/jquery.jsonrpcclient.js @@ -97,8 +97,21 @@ if (socket !== null) { this.speedCB = cb; this.speedBytes = bytes; - socket.send("#SPU"); - socket.send("#SPB\n" + new Array(bytes).join(".")); + socket.send("#SPU " + bytes); + + var loops = bytes / 1024; + var rem = bytes % 1024; + var i; + var data = new Array(1024).join("."); + for (i = 0; i < loops; i++) { + socket.send("#SPB " + data); + } + + if (rem) { + socket.send("#SPB " + data); + } + + socket.send("#SPE"); } }; diff --git a/html5/verto/video_demo/js/verto-min.js b/html5/verto/video_demo/js/verto-min.js index c3bdff1854..fd9430ce4e 100644 --- a/html5/verto/video_demo/js/verto-min.js +++ b/html5/verto/video_demo/js/verto-min.js @@ -95,7 +95,9 @@ $.FSRTC.getValidRes=function(cam,func){var used=[];var cached=localStorage.getIt return func?func(cache):null;} $.FSRTC.validRes=[];resI=0;checkRes(cam,func);} $.FSRTC.checkPerms=function(runtime,check_audio,check_video){getUserMedia({constraints:{audio:check_audio,video:check_video,},onsuccess:function(e){e.getTracks().forEach(function(track){track.stop();});console.info("media perm init complete");if(runtime){setTimeout(runtime,100,true);}},onerror:function(e){if(check_video&&check_audio){console.error("error, retesting with audio params only");return $.FSRTC.checkPerms(runtime,check_audio,false);} -console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.speedTest=function(bytes,cb){var socket=this.options.getSocket(this.wsOnMessage);if(socket!==null){this.speedCB=cb;this.speedBytes=bytes;socket.send("#SPU");socket.send("#SPB\n"+new Array(bytes).join("."));}};$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};} +console.error("media perm init error");if(runtime){runtime(false)}}});}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid:null,loginParams:null,userVariables:null,getSocket:function(onmessage_cb){return self._getSocket(onmessage_cb);}},options);self.ws_cnt=0;this.wsOnMessage=function(event){self._wsOnMessage(event);};};$.JsonRpcClient.prototype._ws_socket=null;$.JsonRpcClient.prototype._ws_callbacks={};$.JsonRpcClient.prototype._current_id=1;$.JsonRpcClient.prototype.speedTest=function(bytes,cb){var socket=this.options.getSocket(this.wsOnMessage);if(socket!==null){this.speedCB=cb;this.speedBytes=bytes;socket.send("#SPU "+bytes);var loops=bytes/512;var rem=bytes%512;var i;var data=new Array(512).join(".");for(i=0;iBandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + ""); + $("#bwinfo").html("Bandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + " Vid: " + vid + ""); online(true); goto_page("main"); $("input[type='radio']").checkboxradio("refresh"); @@ -782,7 +795,7 @@ function docall() { $("#main_info").html("Trying"); check_vid_res(); - + console.error(outgoingBandwidth, incomingBandwidth); cur_call = vertoHandle.newCall({ destination_number: $("#ext").val(), caller_id_name: $("#cidname").val(), diff --git a/src/include/switch_core_media.h b/src/include/switch_core_media.h index 9a60b7a5d1..c8ddcf2c62 100644 --- a/src/include/switch_core_media.h +++ b/src/include/switch_core_media.h @@ -341,6 +341,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_file(switch_core_ses SWITCH_DECLARE(switch_file_handle_t *) switch_core_media_get_video_file(switch_core_session_t *session, switch_rw_t rw); SWITCH_DECLARE(switch_bool_t) switch_core_session_in_video_thread(switch_core_session_t *session); SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t *session, switch_media_type_t type); +SWITCH_DECLARE(switch_status_t) switch_core_media_set_outgoing_bitrate(switch_core_session_t *session, switch_media_type_t type, uint32_t bitrate); SWITCH_END_EXTERN_C #endif diff --git a/src/mod/applications/mod_conference/conference_member.c b/src/mod/applications/mod_conference/conference_member.c index 2114b9b0fd..a0adb17795 100644 --- a/src/mod/applications/mod_conference/conference_member.c +++ b/src/mod/applications/mod_conference/conference_member.c @@ -767,6 +767,28 @@ switch_status_t conference_member_add(conference_obj_t *conference, conference_m conference_utils_member_set_flag_locked(member, MFLAG_NO_MINIMIZE_ENCODING); } + if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_in"))) { + int tmp = atoi(var); + if (tmp > 0) { + member->max_bw_in = tmp; + } + printf("FORCE MAX %d\n", member->max_bw_in); + } + + if ((var = switch_channel_get_variable(member->channel, "rtp_video_max_bandwidth_out"))) { + int tmp = atoi(var); + if (tmp > 0) { + member->max_bw_out = tmp; + + if (member->max_bw_out < conference->video_codec_settings.video.bandwidth) { + printf("DED ENCODER for %d\n", member->max_bw_out); + conference_utils_member_set_flag_locked(member, MFLAG_NO_MINIMIZE_ENCODING); + switch_core_media_set_outgoing_bitrate(member->session, SWITCH_MEDIA_TYPE_VIDEO, member->max_bw_out); + } + } + } + + switch_channel_set_variable_printf(channel, "conference_member_id", "%d", member->id); switch_channel_set_variable_printf(channel, "conference_moderator", "%s", conference_utils_member_test_flag(member, MFLAG_MOD) ? "true" : "false"); switch_channel_set_variable_printf(channel, "conference_ghost", "%s", conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false"); diff --git a/src/mod/applications/mod_conference/mod_conference.h b/src/mod/applications/mod_conference/mod_conference.h index 482d7c14d3..842674a271 100644 --- a/src/mod/applications/mod_conference/mod_conference.h +++ b/src/mod/applications/mod_conference/mod_conference.h @@ -761,6 +761,7 @@ struct conference_member { switch_image_t *pcanvas_img; int max_bw_in; int force_bw_in; + int max_bw_out; }; typedef enum { diff --git a/src/mod/endpoints/mod_verto/mod_verto.c b/src/mod/endpoints/mod_verto/mod_verto.c index 8f67776e31..02f1f0ebb8 100644 --- a/src/mod/endpoints/mod_verto/mod_verto.c +++ b/src/mod/endpoints/mod_verto/mod_verto.c @@ -1856,30 +1856,49 @@ static void client_run(jsock_t *jsock) char *s = (char *) data; if (*s == '#') { - char repl[80] = "", *s = (char *) data; + char repl[2048] = ""; switch_time_t a, b; - + if (s[1] == 'S' && s[2] == 'P') { if (s[3] == 'U') { + int i, size = 0; + char *p = s+4; + int loops = 0; + int rem = 0; + if (!(size = atoi(p))) { + continue; + } + a = switch_time_now(); - bytes = ws_read_frame(&jsock->ws, &oc, &data); + do { + bytes = ws_read_frame(&jsock->ws, &oc, &data); + s = (char *) data; + } while (bytes && data && s[0] == '#' && s[3] == 'B'); b = switch_time_now(); if (!bytes || !data) continue; + if (s[0] != '#') goto nm; + switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl)); - - s = (char *) data; - s[3] = 'B'; + loops = size / 1024; + rem = size % 1024; + switch_snprintf(repl, sizeof(repl), "#SPB "); + memset(repl+4, '.', 1024); a = switch_time_now(); - ws_write_frame(&jsock->ws, WSOC_TEXT, data, bytes); + for (i = 0; i < loops; i++) { + ws_write_frame(&jsock->ws, WSOC_TEXT, repl, 1024); + } + if (rem) { + ws_write_frame(&jsock->ws, WSOC_TEXT, repl, rem); + } b = switch_time_now(); - switch_snprintf(repl, sizeof(repl), "#SPD %ld", (b - a) / 1000); + switch_snprintf(repl, sizeof(repl), "#SPD %ld", ((b - a) / 1000) - 200); ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl)); } } @@ -1887,6 +1906,7 @@ static void client_run(jsock_t *jsock) continue; } + nm: if (process_input(jsock, data, bytes) != SWITCH_STATUS_SUCCESS) { die("Input Error\n"); diff --git a/src/switch_core_media.c b/src/switch_core_media.c index 5d6e9ae7c5..904da2e9e9 100644 --- a/src/switch_core_media.c +++ b/src/switch_core_media.c @@ -8890,6 +8890,30 @@ SWITCH_DECLARE(switch_bool_t) switch_core_media_check_dtls(switch_core_session_t } +SWITCH_DECLARE(switch_status_t) switch_core_media_set_outgoing_bitrate(switch_core_session_t *session, switch_media_type_t type, uint32_t bitrate) +{ + switch_media_handle_t *smh; + switch_rtp_engine_t *engine; + switch_status_t status = SWITCH_STATUS_FALSE; + + if (!(smh = session->media_handle)) { + return SWITCH_STATUS_FALSE; + } + + if (switch_channel_down(session->channel)) { + return SWITCH_STATUS_FALSE; + } + + engine = &smh->engines[type]; + + if (switch_core_codec_ready(&engine->write_codec)) { + status = switch_core_codec_control(&engine->write_codec, SCC_VIDEO_BANDWIDTH, + SCCT_INT, &bitrate, SCCT_NONE, NULL, NULL, NULL); + } + + return status; +} + //? SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) {