ezuikit-js 0.6.6 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demos/EZUIKitHD/EZUIKitHD.html +171 -0
- package/demos/EZUIKitHD/js/jsWebControl-1.0.0.min.js +80 -0
- package/demos/base-demo/base.html +116 -116
- package/demos/base-demo/ezuikit.js +4405 -258
- package/demos/base-demo/ezuikit_static/v65/v1/js/SuperRender_10.js +394 -394
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/DecodeWorker.js +617 -617
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/JSPlaySDKInterface.js +2052 -2052
- package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/SuperRender_10.js +395 -395
- package/demos/base-demo/ezuikit_static/v65/v1/js/transform/SystemTransform.js +22 -22
- package/demos/base-demo/ezuikit_static/v65/v1/js/tts-v4.js +346 -346
- package/demos/base-demo/ezuikit_static/v65/v1/rec/jquery.min.js +1 -1
- package/demos/base-demo/ezuikit_static/v65/v1/talk/tts-v4.js +346 -346
- package/demos/base-demo/ezuikit_static/v65/v2/rec/jquery.min.js +1 -1
- package/demos/base-demo/ezuikit_static/v65/v2/talk/tts-v4.js +343 -343
- package/demos/base-demo/ezuikit_static/v66/v1/css/theme.css +121 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/AudioRenderer.js +225 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/SuperRender_10.js +395 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js +22 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +26 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +225 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +618 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/Decoder.js +1 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +2052 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +396 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +1 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js +22 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +1 -0
- package/demos/base-demo/ezuikit_static/v66/v1/js/tts-v4.js +346 -0
- package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.js +1522 -0
- package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.min.css +36 -0
- package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +19 -0
- package/demos/base-demo/ezuikit_static/v66/v1/rec/jquery.min.js +2 -0
- package/demos/base-demo/ezuikit_static/v66/v1/speed/speed.css +144 -0
- package/demos/base-demo/ezuikit_static/v66/v1/talk/adapeter.js +5497 -0
- package/demos/base-demo/ezuikit_static/v66/v1/talk/janus.js +3507 -0
- package/demos/base-demo/ezuikit_static/v66/v1/talk/tts-v4.js +346 -0
- package/demos/base-demo/ezuikit_static/v66/v2/css/theme.css +121 -0
- package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.js +9198 -0
- package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
- package/demos/base-demo/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +4662 -0
- package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.js +1522 -0
- package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.min.css +36 -0
- package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +19 -0
- package/demos/base-demo/ezuikit_static/v66/v2/rec/jquery.min.js +2 -0
- package/demos/base-demo/ezuikit_static/v66/v2/speed/speed.css +144 -0
- package/demos/base-demo/ezuikit_static/v66/v2/talk/adapeter.js +5497 -0
- package/demos/base-demo/ezuikit_static/v66/v2/talk/janus.js +3507 -0
- package/demos/base-demo/ezuikit_static/v66/v2/talk/tts-v4.js +343 -0
- package/demos/base-demo/hls.html +23 -23
- package/demos/base-demo/index.html +116 -116
- package/demos/base-demo/localDecoder.html +117 -117
- package/demos/base-demo/mobileLive.html +116 -116
- package/demos/base-demo/mobileRec.html +115 -115
- package/demos/base-demo/multi.html +128 -128
- package/demos/base-demo/pcLive.html +116 -116
- package/demos/base-demo/pcRec.html +115 -115
- package/demos/base-demo/template.html +123 -123
- package/demos/base-demo/themeData.html +231 -231
- package/demos/nginx-demo/conf/fastcgi.conf +26 -26
- package/demos/nginx-demo/conf/fastcgi_params +25 -25
- package/demos/nginx-demo/conf/koi-utf +109 -109
- package/demos/nginx-demo/conf/koi-win +103 -103
- package/demos/nginx-demo/conf/mime.types +95 -95
- package/demos/nginx-demo/conf/nginx.conf +121 -121
- package/demos/nginx-demo/conf/scgi_params +17 -17
- package/demos/nginx-demo/conf/uwsgi_params +17 -17
- package/demos/nginx-demo/conf/win-utf +126 -126
- package/demos/nginx-demo/contrib/README +21 -21
- package/demos/nginx-demo/contrib/geo2nginx.pl +58 -58
- package/demos/nginx-demo/contrib/unicode2nginx/koi-utf +131 -131
- package/demos/nginx-demo/contrib/unicode2nginx/unicode-to-nginx.pl +48 -48
- package/demos/nginx-demo/contrib/unicode2nginx/win-utf +130 -130
- package/demos/nginx-demo/contrib/vim/ftdetect/nginx.vim +4 -4
- package/demos/nginx-demo/contrib/vim/ftplugin/nginx.vim +1 -1
- package/demos/nginx-demo/contrib/vim/indent/nginx.vim +11 -11
- package/demos/nginx-demo/contrib/vim/syntax/nginx.vim +2268 -2268
- package/demos/nginx-demo/docs/CHANGES +8115 -8115
- package/demos/nginx-demo/docs/CHANGES.ru +8252 -8252
- package/demos/nginx-demo/docs/LICENSE +26 -26
- package/demos/nginx-demo/docs/OpenSSL.LICENSE +127 -127
- package/demos/nginx-demo/docs/PCRE.LICENCE +93 -93
- package/demos/nginx-demo/docs/README +3 -3
- package/demos/nginx-demo/docs/zlib.LICENSE +20 -20
- package/demos/nginx-demo/html/50x.html +21 -21
- package/demos/nginx-demo/html/ezuikit5/ezuikit.js +29 -29
- package/demos/nginx-demo/html/ezuikit5/index.html +116 -116
- package/demos/nginx-demo/html/ezuikit5/server.js +67 -67
- package/demos/nginx-demo/html/index.html +16 -16
- package/demos/nginx-demo/html/js/adapeter.js +5496 -5496
- package/demos/nginx-demo/html/js/janus.js +3507 -3507
- package/demos/nginx-demo/html/js/jquery.min.js +1 -1
- package/demos/nginx-demo/html/js/sts.js +340 -340
- package/demos/nginx-demo/logs/access.log +109 -109
- package/demos/nginx-demo/logs/error.log +15 -15
- package/demos/nginx-demo/logs/nginx.pid +1 -1
- package/demos/react-demo/README.md +68 -68
- package/demos/react-demo/package.json +36 -36
- package/demos/react-demo/public/index.html +43 -43
- package/demos/react-demo/public/manifest.json +25 -25
- package/demos/react-demo/public/robots.txt +3 -3
- package/demos/react-demo/src/App.css +38 -38
- package/demos/react-demo/src/App.js +114 -114
- package/demos/react-demo/src/App.test.js +9 -9
- package/demos/react-demo/src/index.css +13 -13
- package/demos/react-demo/src/index.js +17 -17
- package/demos/react-demo/src/logo.svg +7 -7
- package/demos/react-demo/src/serviceWorker.js +141 -141
- package/demos/react-demo/src/setupTests.js +5 -5
- package/demos/vue-demo/README.md +24 -24
- package/demos/vue-demo/babel.config.js +5 -5
- package/demos/vue-demo/package.json +43 -43
- package/demos/vue-demo/public/index.html +17 -17
- package/demos/vue-demo/src/App.vue +27 -27
- package/demos/vue-demo/src/components/EZUIKitJs.vue +115 -115
- package/demos/vue-demo/src/main.js +8 -8
- package/ezuikit.js +4343 -219
- package/ezuikit_static/v65/v1/js/SuperRender_10.js +394 -394
- package/ezuikit_static/v65/v1/js/playctrl/DecodeWorker.js +617 -617
- package/ezuikit_static/v65/v1/js/playctrl/JSPlaySDKInterface.js +2052 -2052
- package/ezuikit_static/v65/v1/js/playctrl/SuperRender_10.js +395 -395
- package/ezuikit_static/v65/v1/js/transform/SystemTransform.js +22 -22
- package/ezuikit_static/v65/v1/js/tts-v4.js +346 -346
- package/ezuikit_static/v65/v1/rec/jquery.min.js +1 -1
- package/ezuikit_static/v65/v1/talk/tts-v4.js +346 -346
- package/ezuikit_static/v65/v2/js/jsPluginV2-2.0.1.min.js +74 -11
- package/ezuikit_static/v65/v2/rec/jquery.min.js +1 -1
- package/ezuikit_static/v65/v2/talk/tts-v4.js +343 -343
- package/ezuikit_static/v66/v1/css/theme.css +121 -0
- package/ezuikit_static/v66/v1/js/AudioRenderer.js +225 -0
- package/ezuikit_static/v66/v1/js/SuperRender_10.js +395 -0
- package/ezuikit_static/v66/v1/js/SystemTransform.js +22 -0
- package/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
- package/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +26 -0
- package/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +225 -0
- package/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +618 -0
- package/ezuikit_static/v66/v1/js/playctrl/Decoder.js +1 -0
- package/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +2052 -0
- package/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +396 -0
- package/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +1 -0
- package/ezuikit_static/v66/v1/js/transform/SystemTransform.js +22 -0
- package/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
- package/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +1 -0
- package/ezuikit_static/v66/v1/js/tts-v4.js +346 -0
- package/ezuikit_static/v66/v1/rec/datepicker.js +1522 -0
- package/ezuikit_static/v66/v1/rec/datepicker.min.css +36 -0
- package/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +19 -0
- package/ezuikit_static/v66/v1/rec/jquery.min.js +2 -0
- package/ezuikit_static/v66/v1/speed/speed.css +144 -0
- package/ezuikit_static/v66/v1/talk/adapeter.js +5497 -0
- package/ezuikit_static/v66/v1/talk/janus.js +3507 -0
- package/ezuikit_static/v66/v1/talk/tts-v4.js +346 -0
- package/ezuikit_static/v66/v2/css/theme.css +121 -0
- package/ezuikit_static/v66/v2/js/Decoder.js +9198 -0
- package/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
- package/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +4662 -0
- package/ezuikit_static/v66/v2/rec/datepicker.js +1522 -0
- package/ezuikit_static/v66/v2/rec/datepicker.min.css +36 -0
- package/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +19 -0
- package/ezuikit_static/v66/v2/rec/jquery.min.js +2 -0
- package/ezuikit_static/v66/v2/speed/speed.css +144 -0
- package/ezuikit_static/v66/v2/talk/adapeter.js +5497 -0
- package/ezuikit_static/v66/v2/talk/janus.js +3507 -0
- package/ezuikit_static/v66/v2/talk/tts-v4.js +343 -0
- package/package.json +1 -1
|
@@ -1,340 +1,340 @@
|
|
|
1
|
-
// We make use of this 'server' variable to provide the address of the
|
|
2
|
-
// REST Janus API. By default, in this example we assume that Janus is
|
|
3
|
-
// co-located with the web server hosting the HTML pages but listening
|
|
4
|
-
// on a different port (8088, the default for HTTP in Janus), which is
|
|
5
|
-
// why we make use of the 'window.location.hostname' base address. Since
|
|
6
|
-
// Janus can also do HTTPS, and considering we don't really want to make
|
|
7
|
-
// use of HTTP for Janus if your demos are served on HTTPS, we also rely
|
|
8
|
-
// on the 'window.location.protocol' prefix to build the variable, in
|
|
9
|
-
// particular to also change the port used to contact Janus (8088 for
|
|
10
|
-
// HTTP and 8089 for HTTPS, if enabled).
|
|
11
|
-
// In case you place Janus behind an Apache frontend (as we did on the
|
|
12
|
-
// online demos at http://janus.conf.meetecho.com) you can just use a
|
|
13
|
-
// relative path for the variable, e.g.:
|
|
14
|
-
//
|
|
15
|
-
// var server = "/janus";
|
|
16
|
-
//
|
|
17
|
-
// which will take care of this on its own.
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// If you want to use the WebSockets frontend to Janus, instead, you'll
|
|
21
|
-
// have to pass a different kind of address, e.g.:
|
|
22
|
-
//
|
|
23
|
-
// var server = "ws://" + window.location.hostname + ":8188";
|
|
24
|
-
//
|
|
25
|
-
// Of course this assumes that support for WebSockets has been built in
|
|
26
|
-
// when compiling the server. WebSockets support has not been tested
|
|
27
|
-
// as much as the REST API, so handle with care!
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// If you have multiple options available, and want to let the library
|
|
31
|
-
// autodetect the best way to contact your server (or pool of servers),
|
|
32
|
-
// you can also pass an array of servers, e.g., to provide alternative
|
|
33
|
-
// means of access (e.g., try WebSockets first and, if that fails, fall
|
|
34
|
-
// back to plain HTTP) or just have failover servers:
|
|
35
|
-
//
|
|
36
|
-
// var server = [
|
|
37
|
-
// "ws://" + window.location.hostname + ":8188",
|
|
38
|
-
// "/janus"
|
|
39
|
-
// ];
|
|
40
|
-
//
|
|
41
|
-
// This will tell the library to try connecting to each of the servers
|
|
42
|
-
// in the presented order. The first working server will be used for
|
|
43
|
-
// the whole session.
|
|
44
|
-
//
|
|
45
|
-
var server = null;
|
|
46
|
-
if(window.location.protocol === 'http:')
|
|
47
|
-
server = "ws://" + window.location.hostname + "/rtcgw-ws";
|
|
48
|
-
else
|
|
49
|
-
server = "wss://" + window.location.hostname + "/rtcgw-ws";
|
|
50
|
-
|
|
51
|
-
server = "wss://test11.ys7.com/rtcgw-ws";
|
|
52
|
-
var janus = null;
|
|
53
|
-
var sts = null;
|
|
54
|
-
var opaqueId = "sts-"+Janus.randomString(12);
|
|
55
|
-
|
|
56
|
-
// var spinner = null;
|
|
57
|
-
|
|
58
|
-
$(document).ready(function() {
|
|
59
|
-
// Initialize the library (all console debuggers enabled)
|
|
60
|
-
Janus.init({debug: "all", callback: function() {
|
|
61
|
-
// Use a button to start the demo
|
|
62
|
-
window.startWebRTC = function() {
|
|
63
|
-
// Make sure the browser supports WebRTC
|
|
64
|
-
if(!Janus.isWebrtcSupported()) {
|
|
65
|
-
EZUIWebRTC.log("浏览器不支持WebRTC","error");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// if($('#sts_url').val().length == 0){
|
|
70
|
-
// bootbox.alert("Please input sts url... ");
|
|
71
|
-
// return;
|
|
72
|
-
// }
|
|
73
|
-
if(!(window.EZUIWebRTC.opt.stsUrl && window.EZUIWebRTC.opt.stsUrl.length >0)){
|
|
74
|
-
EZUIWebRTC.log("sts地址不能为空","error");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Create session
|
|
79
|
-
janus = new Janus(
|
|
80
|
-
{
|
|
81
|
-
server: server,
|
|
82
|
-
// No "iceServers" is provided, meaning janus.js will use a default STUN server
|
|
83
|
-
// Here are some examples of how an iceServers field may look like to support TURN
|
|
84
|
-
// iceServers: [{urls: "turn:yourturnserver.com:3478", username: "janususer", credential: "januspwd"}],
|
|
85
|
-
// iceServers: [{urls: "turn:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
|
|
86
|
-
// iceServers: [{urls: "turns:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
|
|
87
|
-
// Should the Janus API require authentication, you can specify either the API secret or user token here too
|
|
88
|
-
// token: "mytoken",
|
|
89
|
-
// or
|
|
90
|
-
// apisecret: "serversecret",
|
|
91
|
-
success: function() {
|
|
92
|
-
// Attach to sts plugin
|
|
93
|
-
janus.attach(
|
|
94
|
-
{
|
|
95
|
-
plugin: "rtcgw.plugin.sts",
|
|
96
|
-
opaqueId: opaqueId,
|
|
97
|
-
success: function(pluginHandle) {
|
|
98
|
-
$('#details').remove();
|
|
99
|
-
sts = pluginHandle;
|
|
100
|
-
EZUIWebRTC.log("Plugin attached! (" + sts.getPlugin() + ", id=" + sts.getId() + ")");
|
|
101
|
-
// EZUIWebRTC.log(
|
|
102
|
-
// Negotiate WebRTC
|
|
103
|
-
//test10.ys.com
|
|
104
|
-
//var url = "sts://10.86.29.210:8664/rtc?room=1000"
|
|
105
|
-
// var url = $('#sts_url').val();
|
|
106
|
-
var url = window.EZUIWebRTC.opt.stsUrl;
|
|
107
|
-
var body = { "request": "start", "url": url};
|
|
108
|
-
//sts.send({"message": body});
|
|
109
|
-
EZUIWebRTC.log("Trying a createOffer too (audio/video sendrecv)");
|
|
110
|
-
sts.createOffer(
|
|
111
|
-
{
|
|
112
|
-
// No media provided: by default, it's sendrecv for audio and video
|
|
113
|
-
media: { audio: true, video: true, data: false }, // Audio only
|
|
114
|
-
// If you want to test simulcasting (Chrome and Firefox only), then
|
|
115
|
-
// pass a ?simulcast=true when opening this demo page: it will turn
|
|
116
|
-
// the following 'simulcast' property to pass to janus.js to true
|
|
117
|
-
simulcast: false,
|
|
118
|
-
simulcast2: false,
|
|
119
|
-
success: function(jsep) {
|
|
120
|
-
EZUIWebRTC.log("Got SDP!");
|
|
121
|
-
EZUIWebRTC.log(jsep);
|
|
122
|
-
sts.send({"message": body, "jsep": jsep});
|
|
123
|
-
},
|
|
124
|
-
error: function(error) {
|
|
125
|
-
Janus.error("WebRTC error:", error);
|
|
126
|
-
EZUIWebRTC.log("WebRTC error... " + JSON.stringify(error),"error");
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
error: function(error) {
|
|
131
|
-
EZUIWebRTC.log(" -- Error attaching plugin...", "error");
|
|
132
|
-
},
|
|
133
|
-
consentDialog: function(on) {
|
|
134
|
-
EZUIWebRTC.log("Consent dialog should be " + (on ? "on" : "off") + " now");
|
|
135
|
-
//Janus.debug("Consent dialog should be " + (on ? "on" : "off") + " now");
|
|
136
|
-
// if(on) {
|
|
137
|
-
// // Darken screen and show hint
|
|
138
|
-
// $.blockUI({
|
|
139
|
-
// message: '<div><img src="up_arrow.png"/></div>',
|
|
140
|
-
// css: {
|
|
141
|
-
// border: 'none',
|
|
142
|
-
// padding: '15px',
|
|
143
|
-
// backgroundColor: 'transparent',
|
|
144
|
-
// color: '#aaa',
|
|
145
|
-
// top: '10px',
|
|
146
|
-
// left: (navigator.mozGetUserMedia ? '-100px' : '300px')
|
|
147
|
-
// } });
|
|
148
|
-
// } else {
|
|
149
|
-
// // Restore screen
|
|
150
|
-
// $.unblockUI();
|
|
151
|
-
// }
|
|
152
|
-
},
|
|
153
|
-
iceState: function(state) {
|
|
154
|
-
Janus.log("ICE state changed to " + state);
|
|
155
|
-
EZUIWebRTC.log("ICE state changed to " + state);
|
|
156
|
-
},
|
|
157
|
-
mediaState: function(medium, on) {
|
|
158
|
-
Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
|
|
159
|
-
EZUIWebRTC.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
|
|
160
|
-
},
|
|
161
|
-
webrtcState: function(on) {
|
|
162
|
-
Janus.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
|
|
163
|
-
EZUIWebRTC.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
|
|
164
|
-
// $("#audioleft").parent().unblock();
|
|
165
|
-
},
|
|
166
|
-
slowLink: function(uplink, lost) {
|
|
167
|
-
Janus.warn("Janus reports problems " + (uplink ? "sending" : "receiving") +
|
|
168
|
-
" packets on this PeerConnection (" + lost + " lost packets)");
|
|
169
|
-
EZUIWebRTC.log("Janus reports problems " + (uplink ? "sending" : "receiving") +
|
|
170
|
-
" packets on this PeerConnection (" + lost + " lost packets)","warn");
|
|
171
|
-
},
|
|
172
|
-
onmessage: function(msg, jsep) {
|
|
173
|
-
Janus.debug(" ::: Got a message :::");
|
|
174
|
-
EZUIWebRTC.log(" ::: Got a message :::","debug");
|
|
175
|
-
Janus.debug(msg);
|
|
176
|
-
EZUIWebRTC.log(msg,"debug");
|
|
177
|
-
if(jsep !== undefined && jsep !== null) {
|
|
178
|
-
Janus.debug("Handling SDP as well...");
|
|
179
|
-
Janus.debug(jsep);
|
|
180
|
-
EZUIWebRTC.log("Handling SDP as well...","debug");
|
|
181
|
-
EZUIWebRTC.log(jsep,"debug");
|
|
182
|
-
sts.handleRemoteJsep({jsep: jsep});
|
|
183
|
-
}
|
|
184
|
-
var result = msg["result"];
|
|
185
|
-
if(result !== null && result !== undefined) {
|
|
186
|
-
if(result === "done") {
|
|
187
|
-
// The plugin closed
|
|
188
|
-
//bootbox.alert("The STS Test is over");
|
|
189
|
-
EZUIWebRTC.log("The STS Test is over","warn");
|
|
190
|
-
// if(spinner !== null && spinner !== undefined)
|
|
191
|
-
// spinner.stop();
|
|
192
|
-
// spinner = null;
|
|
193
|
-
$('#myaudio').remove();
|
|
194
|
-
//$('#waitingvideo').remove();
|
|
195
|
-
$('#peeraudio').remove();
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
// Any loss?
|
|
199
|
-
var status = result["status"];
|
|
200
|
-
if(status === "slow_link") {
|
|
201
|
-
//~ var bitrate = result["bitrate"];
|
|
202
|
-
//~ toastr.warning("The bitrate has been cut to " + (bitrate/1000) + "kbps", "Packet loss?", {timeOut: 2000});
|
|
203
|
-
toastr.warning("Janus apparently missed many packets we sent, maybe we should reduce the bitrate", "Packet loss?", {timeOut: 2000});
|
|
204
|
-
EZUIWebRTC.log("Janus apparently missed many packets we sent, maybe we should reduce the bitrate","warn");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
var events = msg["event"];
|
|
208
|
-
if(events !== null && events !== undefined){
|
|
209
|
-
if(events === "room_created"){
|
|
210
|
-
var room = msg["room"];
|
|
211
|
-
Janus.log("sts room created! " + room);
|
|
212
|
-
EZUIWebRTC.log("房间创建成功!" + room,"success");
|
|
213
|
-
EZUIWebRTC.opt.room = room;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
onlocalstream: function(stream) {
|
|
218
|
-
Janus.debug(" ::: Got a local stream :::");
|
|
219
|
-
EZUIWebRTC.log(" ::: Got a local stream :::","debug");
|
|
220
|
-
Janus.debug(stream);
|
|
221
|
-
EZUIWebRTC.log(stream,"debug")
|
|
222
|
-
if($('#myvideo').length === 0) {
|
|
223
|
-
$('#videos').removeClass('hide').show();
|
|
224
|
-
$('#videoleft').append('<video class="rounded centered" id="myvideo" width=320 height=240 autoplay playsinline muted="muted"/>');
|
|
225
|
-
}
|
|
226
|
-
Janus.attachMediaStream($('#myvideo').get(0), stream);
|
|
227
|
-
$("#myvideo").get(0).muted = "muted";
|
|
228
|
-
if(sts.webrtcStuff.pc.iceConnectionState !== "completed" &&
|
|
229
|
-
sts.webrtcStuff.pc.iceConnectionState !== "connected") {
|
|
230
|
-
// $("#videoleft").parent().block({
|
|
231
|
-
// message: '<b>Publishing...</b>',
|
|
232
|
-
// css: {
|
|
233
|
-
// border: 'none',
|
|
234
|
-
// backgroundColor: 'transparent',
|
|
235
|
-
// color: 'white'
|
|
236
|
-
// }
|
|
237
|
-
// });
|
|
238
|
-
// No remote video yet
|
|
239
|
-
$('#videoright').append('<video class="rounded centered" id="waitingvideo" width=320 height=240 />');
|
|
240
|
-
// if(spinner == null) {
|
|
241
|
-
// var target = document.getElementById('videoright');
|
|
242
|
-
// spinner = new Spinner({top:100}).spin(target);
|
|
243
|
-
// } else {
|
|
244
|
-
// spinner.spin();
|
|
245
|
-
// }
|
|
246
|
-
}
|
|
247
|
-
var videoTracks = stream.getVideoTracks();
|
|
248
|
-
if(videoTracks === null || videoTracks === undefined || videoTracks.length === 0) {
|
|
249
|
-
// No webcam
|
|
250
|
-
$('#myvideo').hide();
|
|
251
|
-
if($('#videoleft .no-video-container').length === 0) {
|
|
252
|
-
$('#videoleft').append(
|
|
253
|
-
'<div class="no-video-container">' +
|
|
254
|
-
'No webcam available' +
|
|
255
|
-
'</div>');
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
$('#videoleft .no-video-container').remove();
|
|
259
|
-
$('#myvideo').removeClass('hide').show();
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
onremotestream: function(stream) {
|
|
263
|
-
Janus.debug(" ::: Got a remote stream :::");
|
|
264
|
-
Janus.debug(stream);
|
|
265
|
-
EZUIWebRTC.log(" ::: Got a remote stream :::","debug");
|
|
266
|
-
EZUIWebRTC.log(stream,"debug");
|
|
267
|
-
if($('#peervideo').length === 0) {
|
|
268
|
-
$('#videos').removeClass('hide').show();
|
|
269
|
-
$('#videoright').append('<video class="rounded centered hide" id="peervideo" width=320 height=240 autoplay playsinline/>');
|
|
270
|
-
// Show the video, hide the spinner and show the resolution when we get a playing event
|
|
271
|
-
$("#peervideo").bind("playing", function () {
|
|
272
|
-
$('#waitingvideo').remove();
|
|
273
|
-
if(this.videoWidth)
|
|
274
|
-
$('#peervideo').removeClass('hide').show();
|
|
275
|
-
// if(spinner !== null && spinner !== undefined)
|
|
276
|
-
// spinner.stop();
|
|
277
|
-
// spinner = null;
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
Janus.attachMediaStream($('#peervideo').get(0), stream);
|
|
281
|
-
var videoTracks = stream.getVideoTracks();
|
|
282
|
-
if(videoTracks === null || videoTracks === undefined || videoTracks.length === 0) {
|
|
283
|
-
// No remote video
|
|
284
|
-
$('#peervideo').hide();
|
|
285
|
-
if($('#videoright .no-video-container').length === 0) {
|
|
286
|
-
$('#videoright').append(
|
|
287
|
-
'<div class="no-video-container">' +
|
|
288
|
-
'<i class="fa fa-video-camera fa-5 no-video-icon"></i>' +
|
|
289
|
-
'<span class="no-video-text">No remote video available</span>' +
|
|
290
|
-
'</div>');
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
$('#videoright .no-video-container').remove();
|
|
294
|
-
$('#peervideo').removeClass('hide').show();
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
ondataopen: function(data) {
|
|
298
|
-
Janus.log("The DataChannel is available!");
|
|
299
|
-
EZUIWebRTC.log("The DataChannel is available!","success");
|
|
300
|
-
},
|
|
301
|
-
ondata: function(data) {
|
|
302
|
-
Janus.debug("We got data from the DataChannel! " + data);
|
|
303
|
-
EZUIWebRTC.log("We got data from the DataChannel!" + data,"debug");
|
|
304
|
-
},
|
|
305
|
-
oncleanup: function() {
|
|
306
|
-
Janus.log(" ::: Got a cleanup notification :::");
|
|
307
|
-
EZUIWebRTC.log(" ::: Got a cleanup notification :::");
|
|
308
|
-
// if(spinner !== null && spinner !== undefined)
|
|
309
|
-
// spinner.stop();
|
|
310
|
-
// spinner = null;
|
|
311
|
-
$('#myvideo').remove();
|
|
312
|
-
$('#waitingvideo').remove();
|
|
313
|
-
// $("#videoleft").parent().unblock();
|
|
314
|
-
$('#peervideo').remove();
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
},
|
|
318
|
-
error: function(error) {
|
|
319
|
-
Janus.error(error);
|
|
320
|
-
EZUIWebRTC.log(error,"error")
|
|
321
|
-
// bootbox.alert(error, function() {
|
|
322
|
-
// window.location.reload();
|
|
323
|
-
// });
|
|
324
|
-
},
|
|
325
|
-
destroyed: function() {
|
|
326
|
-
// window.location.reload();
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
}});
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
// 停止
|
|
334
|
-
window.stopWebRTC = function (){
|
|
335
|
-
janus.destroy();
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
1
|
+
// We make use of this 'server' variable to provide the address of the
|
|
2
|
+
// REST Janus API. By default, in this example we assume that Janus is
|
|
3
|
+
// co-located with the web server hosting the HTML pages but listening
|
|
4
|
+
// on a different port (8088, the default for HTTP in Janus), which is
|
|
5
|
+
// why we make use of the 'window.location.hostname' base address. Since
|
|
6
|
+
// Janus can also do HTTPS, and considering we don't really want to make
|
|
7
|
+
// use of HTTP for Janus if your demos are served on HTTPS, we also rely
|
|
8
|
+
// on the 'window.location.protocol' prefix to build the variable, in
|
|
9
|
+
// particular to also change the port used to contact Janus (8088 for
|
|
10
|
+
// HTTP and 8089 for HTTPS, if enabled).
|
|
11
|
+
// In case you place Janus behind an Apache frontend (as we did on the
|
|
12
|
+
// online demos at http://janus.conf.meetecho.com) you can just use a
|
|
13
|
+
// relative path for the variable, e.g.:
|
|
14
|
+
//
|
|
15
|
+
// var server = "/janus";
|
|
16
|
+
//
|
|
17
|
+
// which will take care of this on its own.
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// If you want to use the WebSockets frontend to Janus, instead, you'll
|
|
21
|
+
// have to pass a different kind of address, e.g.:
|
|
22
|
+
//
|
|
23
|
+
// var server = "ws://" + window.location.hostname + ":8188";
|
|
24
|
+
//
|
|
25
|
+
// Of course this assumes that support for WebSockets has been built in
|
|
26
|
+
// when compiling the server. WebSockets support has not been tested
|
|
27
|
+
// as much as the REST API, so handle with care!
|
|
28
|
+
//
|
|
29
|
+
//
|
|
30
|
+
// If you have multiple options available, and want to let the library
|
|
31
|
+
// autodetect the best way to contact your server (or pool of servers),
|
|
32
|
+
// you can also pass an array of servers, e.g., to provide alternative
|
|
33
|
+
// means of access (e.g., try WebSockets first and, if that fails, fall
|
|
34
|
+
// back to plain HTTP) or just have failover servers:
|
|
35
|
+
//
|
|
36
|
+
// var server = [
|
|
37
|
+
// "ws://" + window.location.hostname + ":8188",
|
|
38
|
+
// "/janus"
|
|
39
|
+
// ];
|
|
40
|
+
//
|
|
41
|
+
// This will tell the library to try connecting to each of the servers
|
|
42
|
+
// in the presented order. The first working server will be used for
|
|
43
|
+
// the whole session.
|
|
44
|
+
//
|
|
45
|
+
var server = null;
|
|
46
|
+
if(window.location.protocol === 'http:')
|
|
47
|
+
server = "ws://" + window.location.hostname + "/rtcgw-ws";
|
|
48
|
+
else
|
|
49
|
+
server = "wss://" + window.location.hostname + "/rtcgw-ws";
|
|
50
|
+
|
|
51
|
+
server = "wss://test11.ys7.com/rtcgw-ws";
|
|
52
|
+
var janus = null;
|
|
53
|
+
var sts = null;
|
|
54
|
+
var opaqueId = "sts-"+Janus.randomString(12);
|
|
55
|
+
|
|
56
|
+
// var spinner = null;
|
|
57
|
+
|
|
58
|
+
$(document).ready(function() {
|
|
59
|
+
// Initialize the library (all console debuggers enabled)
|
|
60
|
+
Janus.init({debug: "all", callback: function() {
|
|
61
|
+
// Use a button to start the demo
|
|
62
|
+
window.startWebRTC = function() {
|
|
63
|
+
// Make sure the browser supports WebRTC
|
|
64
|
+
if(!Janus.isWebrtcSupported()) {
|
|
65
|
+
EZUIWebRTC.log("浏览器不支持WebRTC","error");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// if($('#sts_url').val().length == 0){
|
|
70
|
+
// bootbox.alert("Please input sts url... ");
|
|
71
|
+
// return;
|
|
72
|
+
// }
|
|
73
|
+
if(!(window.EZUIWebRTC.opt.stsUrl && window.EZUIWebRTC.opt.stsUrl.length >0)){
|
|
74
|
+
EZUIWebRTC.log("sts地址不能为空","error");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Create session
|
|
79
|
+
janus = new Janus(
|
|
80
|
+
{
|
|
81
|
+
server: server,
|
|
82
|
+
// No "iceServers" is provided, meaning janus.js will use a default STUN server
|
|
83
|
+
// Here are some examples of how an iceServers field may look like to support TURN
|
|
84
|
+
// iceServers: [{urls: "turn:yourturnserver.com:3478", username: "janususer", credential: "januspwd"}],
|
|
85
|
+
// iceServers: [{urls: "turn:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
|
|
86
|
+
// iceServers: [{urls: "turns:yourturnserver.com:443?transport=tcp", username: "janususer", credential: "januspwd"}],
|
|
87
|
+
// Should the Janus API require authentication, you can specify either the API secret or user token here too
|
|
88
|
+
// token: "mytoken",
|
|
89
|
+
// or
|
|
90
|
+
// apisecret: "serversecret",
|
|
91
|
+
success: function() {
|
|
92
|
+
// Attach to sts plugin
|
|
93
|
+
janus.attach(
|
|
94
|
+
{
|
|
95
|
+
plugin: "rtcgw.plugin.sts",
|
|
96
|
+
opaqueId: opaqueId,
|
|
97
|
+
success: function(pluginHandle) {
|
|
98
|
+
$('#details').remove();
|
|
99
|
+
sts = pluginHandle;
|
|
100
|
+
EZUIWebRTC.log("Plugin attached! (" + sts.getPlugin() + ", id=" + sts.getId() + ")");
|
|
101
|
+
// EZUIWebRTC.log(
|
|
102
|
+
// Negotiate WebRTC
|
|
103
|
+
//test10.ys.com
|
|
104
|
+
//var url = "sts://10.86.29.210:8664/rtc?room=1000"
|
|
105
|
+
// var url = $('#sts_url').val();
|
|
106
|
+
var url = window.EZUIWebRTC.opt.stsUrl;
|
|
107
|
+
var body = { "request": "start", "url": url};
|
|
108
|
+
//sts.send({"message": body});
|
|
109
|
+
EZUIWebRTC.log("Trying a createOffer too (audio/video sendrecv)");
|
|
110
|
+
sts.createOffer(
|
|
111
|
+
{
|
|
112
|
+
// No media provided: by default, it's sendrecv for audio and video
|
|
113
|
+
media: { audio: true, video: true, data: false }, // Audio only
|
|
114
|
+
// If you want to test simulcasting (Chrome and Firefox only), then
|
|
115
|
+
// pass a ?simulcast=true when opening this demo page: it will turn
|
|
116
|
+
// the following 'simulcast' property to pass to janus.js to true
|
|
117
|
+
simulcast: false,
|
|
118
|
+
simulcast2: false,
|
|
119
|
+
success: function(jsep) {
|
|
120
|
+
EZUIWebRTC.log("Got SDP!");
|
|
121
|
+
EZUIWebRTC.log(jsep);
|
|
122
|
+
sts.send({"message": body, "jsep": jsep});
|
|
123
|
+
},
|
|
124
|
+
error: function(error) {
|
|
125
|
+
Janus.error("WebRTC error:", error);
|
|
126
|
+
EZUIWebRTC.log("WebRTC error... " + JSON.stringify(error),"error");
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
error: function(error) {
|
|
131
|
+
EZUIWebRTC.log(" -- Error attaching plugin...", "error");
|
|
132
|
+
},
|
|
133
|
+
consentDialog: function(on) {
|
|
134
|
+
EZUIWebRTC.log("Consent dialog should be " + (on ? "on" : "off") + " now");
|
|
135
|
+
//Janus.debug("Consent dialog should be " + (on ? "on" : "off") + " now");
|
|
136
|
+
// if(on) {
|
|
137
|
+
// // Darken screen and show hint
|
|
138
|
+
// $.blockUI({
|
|
139
|
+
// message: '<div><img src="up_arrow.png"/></div>',
|
|
140
|
+
// css: {
|
|
141
|
+
// border: 'none',
|
|
142
|
+
// padding: '15px',
|
|
143
|
+
// backgroundColor: 'transparent',
|
|
144
|
+
// color: '#aaa',
|
|
145
|
+
// top: '10px',
|
|
146
|
+
// left: (navigator.mozGetUserMedia ? '-100px' : '300px')
|
|
147
|
+
// } });
|
|
148
|
+
// } else {
|
|
149
|
+
// // Restore screen
|
|
150
|
+
// $.unblockUI();
|
|
151
|
+
// }
|
|
152
|
+
},
|
|
153
|
+
iceState: function(state) {
|
|
154
|
+
Janus.log("ICE state changed to " + state);
|
|
155
|
+
EZUIWebRTC.log("ICE state changed to " + state);
|
|
156
|
+
},
|
|
157
|
+
mediaState: function(medium, on) {
|
|
158
|
+
Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
|
|
159
|
+
EZUIWebRTC.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
|
|
160
|
+
},
|
|
161
|
+
webrtcState: function(on) {
|
|
162
|
+
Janus.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
|
|
163
|
+
EZUIWebRTC.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
|
|
164
|
+
// $("#audioleft").parent().unblock();
|
|
165
|
+
},
|
|
166
|
+
slowLink: function(uplink, lost) {
|
|
167
|
+
Janus.warn("Janus reports problems " + (uplink ? "sending" : "receiving") +
|
|
168
|
+
" packets on this PeerConnection (" + lost + " lost packets)");
|
|
169
|
+
EZUIWebRTC.log("Janus reports problems " + (uplink ? "sending" : "receiving") +
|
|
170
|
+
" packets on this PeerConnection (" + lost + " lost packets)","warn");
|
|
171
|
+
},
|
|
172
|
+
onmessage: function(msg, jsep) {
|
|
173
|
+
Janus.debug(" ::: Got a message :::");
|
|
174
|
+
EZUIWebRTC.log(" ::: Got a message :::","debug");
|
|
175
|
+
Janus.debug(msg);
|
|
176
|
+
EZUIWebRTC.log(msg,"debug");
|
|
177
|
+
if(jsep !== undefined && jsep !== null) {
|
|
178
|
+
Janus.debug("Handling SDP as well...");
|
|
179
|
+
Janus.debug(jsep);
|
|
180
|
+
EZUIWebRTC.log("Handling SDP as well...","debug");
|
|
181
|
+
EZUIWebRTC.log(jsep,"debug");
|
|
182
|
+
sts.handleRemoteJsep({jsep: jsep});
|
|
183
|
+
}
|
|
184
|
+
var result = msg["result"];
|
|
185
|
+
if(result !== null && result !== undefined) {
|
|
186
|
+
if(result === "done") {
|
|
187
|
+
// The plugin closed
|
|
188
|
+
//bootbox.alert("The STS Test is over");
|
|
189
|
+
EZUIWebRTC.log("The STS Test is over","warn");
|
|
190
|
+
// if(spinner !== null && spinner !== undefined)
|
|
191
|
+
// spinner.stop();
|
|
192
|
+
// spinner = null;
|
|
193
|
+
$('#myaudio').remove();
|
|
194
|
+
//$('#waitingvideo').remove();
|
|
195
|
+
$('#peeraudio').remove();
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
// Any loss?
|
|
199
|
+
var status = result["status"];
|
|
200
|
+
if(status === "slow_link") {
|
|
201
|
+
//~ var bitrate = result["bitrate"];
|
|
202
|
+
//~ toastr.warning("The bitrate has been cut to " + (bitrate/1000) + "kbps", "Packet loss?", {timeOut: 2000});
|
|
203
|
+
toastr.warning("Janus apparently missed many packets we sent, maybe we should reduce the bitrate", "Packet loss?", {timeOut: 2000});
|
|
204
|
+
EZUIWebRTC.log("Janus apparently missed many packets we sent, maybe we should reduce the bitrate","warn");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
var events = msg["event"];
|
|
208
|
+
if(events !== null && events !== undefined){
|
|
209
|
+
if(events === "room_created"){
|
|
210
|
+
var room = msg["room"];
|
|
211
|
+
Janus.log("sts room created! " + room);
|
|
212
|
+
EZUIWebRTC.log("房间创建成功!" + room,"success");
|
|
213
|
+
EZUIWebRTC.opt.room = room;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
onlocalstream: function(stream) {
|
|
218
|
+
Janus.debug(" ::: Got a local stream :::");
|
|
219
|
+
EZUIWebRTC.log(" ::: Got a local stream :::","debug");
|
|
220
|
+
Janus.debug(stream);
|
|
221
|
+
EZUIWebRTC.log(stream,"debug")
|
|
222
|
+
if($('#myvideo').length === 0) {
|
|
223
|
+
$('#videos').removeClass('hide').show();
|
|
224
|
+
$('#videoleft').append('<video class="rounded centered" id="myvideo" width=320 height=240 autoplay playsinline muted="muted"/>');
|
|
225
|
+
}
|
|
226
|
+
Janus.attachMediaStream($('#myvideo').get(0), stream);
|
|
227
|
+
$("#myvideo").get(0).muted = "muted";
|
|
228
|
+
if(sts.webrtcStuff.pc.iceConnectionState !== "completed" &&
|
|
229
|
+
sts.webrtcStuff.pc.iceConnectionState !== "connected") {
|
|
230
|
+
// $("#videoleft").parent().block({
|
|
231
|
+
// message: '<b>Publishing...</b>',
|
|
232
|
+
// css: {
|
|
233
|
+
// border: 'none',
|
|
234
|
+
// backgroundColor: 'transparent',
|
|
235
|
+
// color: 'white'
|
|
236
|
+
// }
|
|
237
|
+
// });
|
|
238
|
+
// No remote video yet
|
|
239
|
+
$('#videoright').append('<video class="rounded centered" id="waitingvideo" width=320 height=240 />');
|
|
240
|
+
// if(spinner == null) {
|
|
241
|
+
// var target = document.getElementById('videoright');
|
|
242
|
+
// spinner = new Spinner({top:100}).spin(target);
|
|
243
|
+
// } else {
|
|
244
|
+
// spinner.spin();
|
|
245
|
+
// }
|
|
246
|
+
}
|
|
247
|
+
var videoTracks = stream.getVideoTracks();
|
|
248
|
+
if(videoTracks === null || videoTracks === undefined || videoTracks.length === 0) {
|
|
249
|
+
// No webcam
|
|
250
|
+
$('#myvideo').hide();
|
|
251
|
+
if($('#videoleft .no-video-container').length === 0) {
|
|
252
|
+
$('#videoleft').append(
|
|
253
|
+
'<div class="no-video-container">' +
|
|
254
|
+
'No webcam available' +
|
|
255
|
+
'</div>');
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
$('#videoleft .no-video-container').remove();
|
|
259
|
+
$('#myvideo').removeClass('hide').show();
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
onremotestream: function(stream) {
|
|
263
|
+
Janus.debug(" ::: Got a remote stream :::");
|
|
264
|
+
Janus.debug(stream);
|
|
265
|
+
EZUIWebRTC.log(" ::: Got a remote stream :::","debug");
|
|
266
|
+
EZUIWebRTC.log(stream,"debug");
|
|
267
|
+
if($('#peervideo').length === 0) {
|
|
268
|
+
$('#videos').removeClass('hide').show();
|
|
269
|
+
$('#videoright').append('<video class="rounded centered hide" id="peervideo" width=320 height=240 autoplay playsinline/>');
|
|
270
|
+
// Show the video, hide the spinner and show the resolution when we get a playing event
|
|
271
|
+
$("#peervideo").bind("playing", function () {
|
|
272
|
+
$('#waitingvideo').remove();
|
|
273
|
+
if(this.videoWidth)
|
|
274
|
+
$('#peervideo').removeClass('hide').show();
|
|
275
|
+
// if(spinner !== null && spinner !== undefined)
|
|
276
|
+
// spinner.stop();
|
|
277
|
+
// spinner = null;
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
Janus.attachMediaStream($('#peervideo').get(0), stream);
|
|
281
|
+
var videoTracks = stream.getVideoTracks();
|
|
282
|
+
if(videoTracks === null || videoTracks === undefined || videoTracks.length === 0) {
|
|
283
|
+
// No remote video
|
|
284
|
+
$('#peervideo').hide();
|
|
285
|
+
if($('#videoright .no-video-container').length === 0) {
|
|
286
|
+
$('#videoright').append(
|
|
287
|
+
'<div class="no-video-container">' +
|
|
288
|
+
'<i class="fa fa-video-camera fa-5 no-video-icon"></i>' +
|
|
289
|
+
'<span class="no-video-text">No remote video available</span>' +
|
|
290
|
+
'</div>');
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
$('#videoright .no-video-container').remove();
|
|
294
|
+
$('#peervideo').removeClass('hide').show();
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
ondataopen: function(data) {
|
|
298
|
+
Janus.log("The DataChannel is available!");
|
|
299
|
+
EZUIWebRTC.log("The DataChannel is available!","success");
|
|
300
|
+
},
|
|
301
|
+
ondata: function(data) {
|
|
302
|
+
Janus.debug("We got data from the DataChannel! " + data);
|
|
303
|
+
EZUIWebRTC.log("We got data from the DataChannel!" + data,"debug");
|
|
304
|
+
},
|
|
305
|
+
oncleanup: function() {
|
|
306
|
+
Janus.log(" ::: Got a cleanup notification :::");
|
|
307
|
+
EZUIWebRTC.log(" ::: Got a cleanup notification :::");
|
|
308
|
+
// if(spinner !== null && spinner !== undefined)
|
|
309
|
+
// spinner.stop();
|
|
310
|
+
// spinner = null;
|
|
311
|
+
$('#myvideo').remove();
|
|
312
|
+
$('#waitingvideo').remove();
|
|
313
|
+
// $("#videoleft").parent().unblock();
|
|
314
|
+
$('#peervideo').remove();
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
},
|
|
318
|
+
error: function(error) {
|
|
319
|
+
Janus.error(error);
|
|
320
|
+
EZUIWebRTC.log(error,"error")
|
|
321
|
+
// bootbox.alert(error, function() {
|
|
322
|
+
// window.location.reload();
|
|
323
|
+
// });
|
|
324
|
+
},
|
|
325
|
+
destroyed: function() {
|
|
326
|
+
// window.location.reload();
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
}});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
// 停止
|
|
334
|
+
window.stopWebRTC = function (){
|
|
335
|
+
janus.destroy();
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|