mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 16:39:14 +00:00
WIP not shabby auto vid settings
This commit is contained in:
parent
828d6eaf01
commit
aa0b28e235
@ -97,8 +97,21 @@
|
|||||||
if (socket !== null) {
|
if (socket !== null) {
|
||||||
this.speedCB = cb;
|
this.speedCB = cb;
|
||||||
this.speedBytes = bytes;
|
this.speedBytes = bytes;
|
||||||
socket.send("#SPU");
|
socket.send("#SPU " + bytes);
|
||||||
socket.send("#SPB\n" + new Array(bytes).join("."));
|
|
||||||
|
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");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
4
html5/verto/video_demo/js/verto-min.js
vendored
4
html5/verto/video_demo/js/verto-min.js
vendored
@ -95,7 +95,9 @@ $.FSRTC.getValidRes=function(cam,func){var used=[];var cached=localStorage.getIt
|
|||||||
return func?func(cache):null;}
|
return func?func(cache):null;}
|
||||||
$.FSRTC.validRes=[];resI=0;checkRes(cam,func);}
|
$.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);}
|
$.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;i<loops;i++){socket.send("#SPB "+data);}
|
||||||
|
if(rem){socket.send("#SPB "+data);}
|
||||||
|
socket.send("#SPE");}};$.JsonRpcClient.prototype.call=function(method,params,success_cb,error_cb){if(!params){params={};}
|
||||||
if(this.options.sessid){params.sessid=this.options.sessid;}
|
if(this.options.sessid){params.sessid=this.options.sessid;}
|
||||||
var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
|
var request={jsonrpc:'2.0',method:method,params:params,id:this._current_id++};if(!success_cb){success_cb=function(e){console.log("Success: ",e);};}
|
||||||
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
|
if(!error_cb){error_cb=function(e){console.log("Error: ",e);};}
|
||||||
|
@ -561,17 +561,30 @@ var callbacks = {
|
|||||||
if (success) {
|
if (success) {
|
||||||
vertoHandle.rpcClient.speedTest(1024 * 256, function(e, obj) {
|
vertoHandle.rpcClient.speedTest(1024 * 256, function(e, obj) {
|
||||||
//console.error("Up: " + obj.upKPS, "Down: ", obj.downKPS);
|
//console.error("Up: " + obj.upKPS, "Down: ", obj.downKPS);
|
||||||
|
var vid = "default";
|
||||||
if (outgoingBandwidth === "default") {
|
if (outgoingBandwidth === "default") {
|
||||||
outgoingBandwidth = obj.upKPS * .75;
|
outgoingBandwidth = Math.ceil(obj.upKPS * .75).toString();
|
||||||
|
|
||||||
|
$("#vqual_hd").prop("checked", true);
|
||||||
|
vid = "1280x720";
|
||||||
|
|
||||||
|
if (outgoingBandwidth < 1024) {
|
||||||
|
$("#vqual_vga").prop("checked", true);
|
||||||
|
vid = "640x480";
|
||||||
}
|
}
|
||||||
|
if (outgoingBandwidth < 512) {
|
||||||
|
$("#vqual_qvga").prop("checked", true);
|
||||||
|
vid = "320x240";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (incomingBandwidth === "default") {
|
if (incomingBandwidth === "default") {
|
||||||
incomingBandwidth = obj.downKPS * .75;
|
incomingBandwidth = Math.ceil(obj.downKPS * .75).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.error(outgoingBandwidth, incomingBandwidth);
|
console.info(outgoingBandwidth, incomingBandwidth);
|
||||||
|
|
||||||
$("#bwinfo").html("<b>Bandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + "</b>");
|
$("#bwinfo").html("<b>Bandwidth: " + "Up: " + obj.upKPS + " Down: " + obj.downKPS + " Vid: " + vid + "</b>");
|
||||||
online(true);
|
online(true);
|
||||||
goto_page("main");
|
goto_page("main");
|
||||||
$("input[type='radio']").checkboxradio("refresh");
|
$("input[type='radio']").checkboxradio("refresh");
|
||||||
@ -782,7 +795,7 @@ function docall() {
|
|||||||
$("#main_info").html("Trying");
|
$("#main_info").html("Trying");
|
||||||
|
|
||||||
check_vid_res();
|
check_vid_res();
|
||||||
|
console.error(outgoingBandwidth, incomingBandwidth);
|
||||||
cur_call = vertoHandle.newCall({
|
cur_call = vertoHandle.newCall({
|
||||||
destination_number: $("#ext").val(),
|
destination_number: $("#ext").val(),
|
||||||
caller_id_name: $("#cidname").val(),
|
caller_id_name: $("#cidname").val(),
|
||||||
|
@ -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_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_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_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
|
SWITCH_END_EXTERN_C
|
||||||
#endif
|
#endif
|
||||||
|
@ -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);
|
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_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_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");
|
switch_channel_set_variable_printf(channel, "conference_ghost", "%s", conference_utils_member_test_flag(member, MFLAG_GHOST) ? "true" : "false");
|
||||||
|
@ -761,6 +761,7 @@ struct conference_member {
|
|||||||
switch_image_t *pcanvas_img;
|
switch_image_t *pcanvas_img;
|
||||||
int max_bw_in;
|
int max_bw_in;
|
||||||
int force_bw_in;
|
int force_bw_in;
|
||||||
|
int max_bw_out;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -1856,30 +1856,49 @@ static void client_run(jsock_t *jsock)
|
|||||||
char *s = (char *) data;
|
char *s = (char *) data;
|
||||||
|
|
||||||
if (*s == '#') {
|
if (*s == '#') {
|
||||||
char repl[80] = "", *s = (char *) data;
|
char repl[2048] = "";
|
||||||
switch_time_t a, b;
|
switch_time_t a, b;
|
||||||
|
|
||||||
if (s[1] == 'S' && s[2] == 'P') {
|
if (s[1] == 'S' && s[2] == 'P') {
|
||||||
|
|
||||||
if (s[3] == 'U') {
|
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();
|
a = switch_time_now();
|
||||||
|
do {
|
||||||
bytes = ws_read_frame(&jsock->ws, &oc, &data);
|
bytes = ws_read_frame(&jsock->ws, &oc, &data);
|
||||||
|
s = (char *) data;
|
||||||
|
} while (bytes && data && s[0] == '#' && s[3] == 'B');
|
||||||
b = switch_time_now();
|
b = switch_time_now();
|
||||||
|
|
||||||
if (!bytes || !data) continue;
|
if (!bytes || !data) continue;
|
||||||
|
|
||||||
|
if (s[0] != '#') goto nm;
|
||||||
|
|
||||||
switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000);
|
switch_snprintf(repl, sizeof(repl), "#SPU %ld", (b - a) / 1000);
|
||||||
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
|
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
|
||||||
|
|
||||||
|
loops = size / 1024;
|
||||||
s = (char *) data;
|
rem = size % 1024;
|
||||||
s[3] = 'B';
|
switch_snprintf(repl, sizeof(repl), "#SPB ");
|
||||||
|
memset(repl+4, '.', 1024);
|
||||||
a = switch_time_now();
|
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();
|
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));
|
ws_write_frame(&jsock->ws, WSOC_TEXT, repl, strlen(repl));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1887,6 +1906,7 @@ static void client_run(jsock_t *jsock)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nm:
|
||||||
|
|
||||||
if (process_input(jsock, data, bytes) != SWITCH_STATUS_SUCCESS) {
|
if (process_input(jsock, data, bytes) != SWITCH_STATUS_SUCCESS) {
|
||||||
die("Input Error\n");
|
die("Input Error\n");
|
||||||
|
@ -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)
|
SWITCH_DECLARE(switch_status_t) switch_core_media_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user