diff --git a/html5/verto/video_demo/index.html b/html5/verto/video_demo/index.html index 0ea88cf843..4fe4626732 100644 --- a/html5/verto/video_demo/index.html +++ b/html5/verto/video_demo/index.html @@ -120,8 +120,20 @@



+ + +
- + + + + + + + + + +
diff --git a/html5/verto/video_demo/js/verto-min.js b/html5/verto/video_demo/js/verto-min.js index 4718b16a03..8bc97845ea 100644 --- a/html5/verto/video_demo/js/verto-min.js +++ b/html5/verto/video_demo/js/verto-min.js @@ -6,16 +6,14 @@ function getCodecPayloadType(sdpLine){var pattern=new RegExp('a=rtpmap:(\\d+) \\ function setDefaultCodec(mLine,payload){var elements=mLine.split(' ');var newLine=[];var index=0;for(var i=0;i=28)TURN={url:'turn:turn.bistri.com:80',credential:'homeo',username:'homeo'};iceServers.iceServers=[STUN];}} var optional={optional:[]};if(!moz){optional.optional=[{DtlsSrtpKeyAgreement:true},{RtpDataChannels:options.onChannelMessage?true:false}];} @@ -57,7 +58,7 @@ function onSdpSuccess(){} function onSdpError(e){if(options.onChannelError){options.onChannelError(e);} console.error('sdp error:',e);} return{addAnswerSDP:function(sdp,cbSuccess,cbError){peer.setRemoteDescription(new SessionDescription(sdp),cbSuccess?cbSuccess:onSdpSuccess,cbError?cbError:onSdpError);},addICE:function(candidate){peer.addIceCandidate(new IceCandidate({sdpMLineIndex:candidate.sdpMLineIndex,candidate:candidate.candidate}));},peer:peer,channel:channel,sendData:function(message){if(channel){channel.send(message);}},stop:function(){peer.close();if(options.attachStream){options.attachStream.stop();}}};} -var video_constraints={mandatory:{},optional:[]};function getUserMedia(options){var n=navigator,media;n.getMedia=n.webkitGetUserMedia||n.mozGetUserMedia;n.getMedia(options.constraints||{audio:true,video:video_constraints},streaming,options.onerror||function(e){console.error(e);});function streaming(stream){var video=options.video;if(video){video[moz?'mozSrcObject':'src']=moz?stream:window.webkitURL.createObjectURL(stream);} +var video_constraints={mandatory:{},optional:[]};function getUserMedia(options){var n=navigator,media;n.getMedia=n.webkitGetUserMedia||n.mozGetUserMedia;n.getMedia(options.constraints||{audio:true,video:video_constraints},streaming,options.onerror||function(e){console.error(e);});function streaming(stream){if(options.localVideo){options.localVideo[moz?'mozSrcObject':'src']=moz?stream:window.webkitURL.createObjectURL(stream);} if(options.onsuccess){options.onsuccess(stream);} media=stream;} return media;}})(jQuery);(function($){$.JsonRpcClient=function(options){var self=this;this.options=$.extend({ajaxUrl:null,socketUrl:null,onmessage:null,login:null,passwd:null,sessid: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.call=function(method,params,success_cb,error_cb){if(!params){params={};} @@ -93,7 +94,7 @@ for(i=0;i$.verto.enum.state.new.val&&dialog.state.val<$.verto.enum.state.hangup.val){dialog.setState($.verto.enum.state.hangup);}else if(dialog.state.val<$.verto.enum.state.destroy){dialog.setState($.verto.enum.state.destroy);}};$.verto.dialog.prototype.stopRinging=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.stop();}};$.verto.dialog.prototype.indicateRing=function(){var dialog=this;if(dialog.verto.ringer){dialog.verto.ringer.attr("src",dialog.verto.options.ringFile)[0].play();setTimeout(function(){dialog.stopRinging();if(dialog.state==$.verto.enum.state.ringing){dialog.indicateRing();}},dialog.verto.options.ringSleep);}};$.verto.dialog.prototype.ring=function(){var dialog=this;dialog.setState($.verto.enum.state.ringing);dialog.indicateRing();};$.verto.dialog.prototype.useVideo=function(on){var dialog=this;dialog.params.useVideo=on;if(on){dialog.videoStream=dialog.audioStream;}else{dialog.videoStream=null;} -dialog.rtc.useVideo(dialog.videoStream);};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){cur_call.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;} +dialog.rtc.useVideo(dialog.videoStream,dialog.localVideo);};$.verto.dialog.prototype.useStereo=function(on){var dialog=this;dialog.params.useStereo=on;dialog.rtc.useStereo(on);};$.verto.dialog.prototype.dtmf=function(digits){var dialog=this;if(digits){dialog.sendMethod("verto.info",{dtmf:digits});}};$.verto.dialog.prototype.transfer=function(dest,params){var dialog=this;if(dest){cur_call.sendMethod("verto.modify",{action:"transfer",destination:dest,params:params});}};$.verto.dialog.prototype.hold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"hold",params:params});};$.verto.dialog.prototype.unhold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"unhold",params:params});};$.verto.dialog.prototype.toggleHold=function(params){var dialog=this;cur_call.sendMethod("verto.modify",{action:"toggleHold",params:params});};$.verto.dialog.prototype.message=function(msg){var dialog=this;var err=0;msg.from=dialog.params.login;if(!msg.to){console.error("Missing To");err++;} if(!msg.body){console.error("Missing Body");err++;} if(err){return false;} dialog.sendMethod("verto.info",{msg:msg});return true;};$.verto.dialog.prototype.answer=function(params){var dialog=this;if(!dialog.answered){if(params){if(params.useVideo){dialog.useVideo(true);} diff --git a/html5/verto/video_demo/verto.js b/html5/verto/video_demo/verto.js index 705f9a0014..dc0e91041b 100644 --- a/html5/verto/video_demo/verto.js +++ b/html5/verto/video_demo/verto.js @@ -9,6 +9,9 @@ var chatting_with = false; var vid_width = 320; var vid_height = 180; +var local_vid_width = 320; +var local_vid_height = 180; + $( ".selector" ).pagecontainer({ "theme": "a" }); @@ -75,34 +78,95 @@ function setupChat() { } +function full_screen(name) { + var elem = document.getElementById(name); + if (!elem) return; + if (elem.requestFullscreen) { + elem.requestFullscreen(); + } else if (elem.msRequestFullscreen) { + elem.msRequestFullscreen(); + } else if (elem.mozRequestFullScreen) { + elem.mozRequestFullScreen(); + } else if (elem.webkitRequestFullscreen) { + elem.webkitRequestFullscreen(); + } +} + +$("#webcam").resize(function(e) { + console.log("video size changed to " + $("#webcam").width() + "x" + $("#webcam").height()); + + if ($("#webcam").width() > $(window).width()) { + //resize(false); + $("#webcam").width("100%"); + $("#webcam").height("100%"); + } + +}); + + +function resize(up) { + var width = $("#webcam").width(); + var height = $("#webcam").height(); + + if (up) { + $("#webcam").width(width * 1.20); + $("#webcam").height(height * 1.20); + } else { + $("#webcam").width(width * .80); + $("#webcam").height(height * .80); + } + + console.log("video size changed to " + $("#webcam").width() + "x" + $("#webcam").height()); + +} + +function real_size() { + + + $("#webcam").width(""); + $("#webcam").height(""); + + console.log("video size changed to natural default"); + +} + function check_vid_res() { if ($("#vqual_qvga").is(':checked')) { vid_width = 320; vid_height = 240; + local_vid_width = 160; + local_vid_height = 120; } else if ($("#vqual_vga").is(':checked')) { vid_width = 640; vid_height = 480; + local_vid_width = 160; + local_vid_height = 120; } else if ($("#vqual_hd").is(':checked')) { vid_width = 1280; vid_height = 720; + local_vid_width = 320; + local_vid_height = 180; } else if ($("#vqual_hhd").is(':checked')) { vid_width = 1920; vid_height = 1080; + local_vid_width = 320; + local_vid_height = 180; } - $("#webcam").width(vid_width); - $("#webcam").height(vid_height); + $("#local_webcam").width(local_vid_width); + $("#local_webcam").height(local_vid_height); + + real_size(); if (verto) { - verto.videoParams({"minWidth": vid_width, - "minHeight": vid_height, - "maxWidth": vid_width, - "maxHeight": vid_height, - "minFrameRate": 30, - //chromeMediaSource: 'screen', - //mediaSource: 'screen' - }); + verto.videoParams({ + "minWidth": vid_width, + "minHeight": vid_height, + "minFrameRate": 30, + //chromeMediaSource: 'screen', + //mediaSource: 'screen' + }); } } @@ -304,7 +368,7 @@ var callbacks = { case $.verto.enum.state.destroy: $("#hangup_cause").html(""); clearConfMan(); - + real_size(); cur_call = null; break; case $.verto.enum.state.held: @@ -403,6 +467,18 @@ $("#hupbtn").click(function() { cur_call = null; }); +$("#fullbtn").click(function() { + full_screen("webcam"); +}); + +$("#biggerbtn").click(function() { + resize(true); +}); + +$("#smallerbtn").click(function() { + resize(false); +}); + $("#webcam").click(function() { check_vid(); }); @@ -556,12 +632,11 @@ function init() { passwd: $("#passwd").val(), socketUrl: $("#wsURL").val(), tag: "webcam", + localTag: "local_webcam", ringFile: "sounds/bell_ring2.wav", videoParams: { "minWidth": vid_width, "minHeight": vid_height, - "maxWidth": vid_width, - "maxHeight": vid_height, "minFrameRate": 30, //chromeMediaSource: 'screen', //mediaSource: 'screen' @@ -605,7 +680,7 @@ function init() { }); $("#xferdiv").hide(); - $("#webcam").hide(); +// $("#webcam").hide(); online(false);