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.
Files changed (166) hide show
  1. package/demos/EZUIKitHD/EZUIKitHD.html +171 -0
  2. package/demos/EZUIKitHD/js/jsWebControl-1.0.0.min.js +80 -0
  3. package/demos/base-demo/base.html +116 -116
  4. package/demos/base-demo/ezuikit.js +4405 -258
  5. package/demos/base-demo/ezuikit_static/v65/v1/js/SuperRender_10.js +394 -394
  6. package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/DecodeWorker.js +617 -617
  7. package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/JSPlaySDKInterface.js +2052 -2052
  8. package/demos/base-demo/ezuikit_static/v65/v1/js/playctrl/SuperRender_10.js +395 -395
  9. package/demos/base-demo/ezuikit_static/v65/v1/js/transform/SystemTransform.js +22 -22
  10. package/demos/base-demo/ezuikit_static/v65/v1/js/tts-v4.js +346 -346
  11. package/demos/base-demo/ezuikit_static/v65/v1/rec/jquery.min.js +1 -1
  12. package/demos/base-demo/ezuikit_static/v65/v1/talk/tts-v4.js +346 -346
  13. package/demos/base-demo/ezuikit_static/v65/v2/rec/jquery.min.js +1 -1
  14. package/demos/base-demo/ezuikit_static/v65/v2/talk/tts-v4.js +343 -343
  15. package/demos/base-demo/ezuikit_static/v66/v1/css/theme.css +121 -0
  16. package/demos/base-demo/ezuikit_static/v66/v1/js/AudioRenderer.js +225 -0
  17. package/demos/base-demo/ezuikit_static/v66/v1/js/SuperRender_10.js +395 -0
  18. package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js +22 -0
  19. package/demos/base-demo/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
  20. package/demos/base-demo/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +26 -0
  21. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +225 -0
  22. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +618 -0
  23. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/Decoder.js +1 -0
  24. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +2052 -0
  25. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +396 -0
  26. package/demos/base-demo/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +1 -0
  27. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js +22 -0
  28. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
  29. package/demos/base-demo/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +1 -0
  30. package/demos/base-demo/ezuikit_static/v66/v1/js/tts-v4.js +346 -0
  31. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.js +1522 -0
  32. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.min.css +36 -0
  33. package/demos/base-demo/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +19 -0
  34. package/demos/base-demo/ezuikit_static/v66/v1/rec/jquery.min.js +2 -0
  35. package/demos/base-demo/ezuikit_static/v66/v1/speed/speed.css +144 -0
  36. package/demos/base-demo/ezuikit_static/v66/v1/talk/adapeter.js +5497 -0
  37. package/demos/base-demo/ezuikit_static/v66/v1/talk/janus.js +3507 -0
  38. package/demos/base-demo/ezuikit_static/v66/v1/talk/tts-v4.js +346 -0
  39. package/demos/base-demo/ezuikit_static/v66/v2/css/theme.css +121 -0
  40. package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.js +9198 -0
  41. package/demos/base-demo/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
  42. package/demos/base-demo/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +4662 -0
  43. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.js +1522 -0
  44. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.min.css +36 -0
  45. package/demos/base-demo/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +19 -0
  46. package/demos/base-demo/ezuikit_static/v66/v2/rec/jquery.min.js +2 -0
  47. package/demos/base-demo/ezuikit_static/v66/v2/speed/speed.css +144 -0
  48. package/demos/base-demo/ezuikit_static/v66/v2/talk/adapeter.js +5497 -0
  49. package/demos/base-demo/ezuikit_static/v66/v2/talk/janus.js +3507 -0
  50. package/demos/base-demo/ezuikit_static/v66/v2/talk/tts-v4.js +343 -0
  51. package/demos/base-demo/hls.html +23 -23
  52. package/demos/base-demo/index.html +116 -116
  53. package/demos/base-demo/localDecoder.html +117 -117
  54. package/demos/base-demo/mobileLive.html +116 -116
  55. package/demos/base-demo/mobileRec.html +115 -115
  56. package/demos/base-demo/multi.html +128 -128
  57. package/demos/base-demo/pcLive.html +116 -116
  58. package/demos/base-demo/pcRec.html +115 -115
  59. package/demos/base-demo/template.html +123 -123
  60. package/demos/base-demo/themeData.html +231 -231
  61. package/demos/nginx-demo/conf/fastcgi.conf +26 -26
  62. package/demos/nginx-demo/conf/fastcgi_params +25 -25
  63. package/demos/nginx-demo/conf/koi-utf +109 -109
  64. package/demos/nginx-demo/conf/koi-win +103 -103
  65. package/demos/nginx-demo/conf/mime.types +95 -95
  66. package/demos/nginx-demo/conf/nginx.conf +121 -121
  67. package/demos/nginx-demo/conf/scgi_params +17 -17
  68. package/demos/nginx-demo/conf/uwsgi_params +17 -17
  69. package/demos/nginx-demo/conf/win-utf +126 -126
  70. package/demos/nginx-demo/contrib/README +21 -21
  71. package/demos/nginx-demo/contrib/geo2nginx.pl +58 -58
  72. package/demos/nginx-demo/contrib/unicode2nginx/koi-utf +131 -131
  73. package/demos/nginx-demo/contrib/unicode2nginx/unicode-to-nginx.pl +48 -48
  74. package/demos/nginx-demo/contrib/unicode2nginx/win-utf +130 -130
  75. package/demos/nginx-demo/contrib/vim/ftdetect/nginx.vim +4 -4
  76. package/demos/nginx-demo/contrib/vim/ftplugin/nginx.vim +1 -1
  77. package/demos/nginx-demo/contrib/vim/indent/nginx.vim +11 -11
  78. package/demos/nginx-demo/contrib/vim/syntax/nginx.vim +2268 -2268
  79. package/demos/nginx-demo/docs/CHANGES +8115 -8115
  80. package/demos/nginx-demo/docs/CHANGES.ru +8252 -8252
  81. package/demos/nginx-demo/docs/LICENSE +26 -26
  82. package/demos/nginx-demo/docs/OpenSSL.LICENSE +127 -127
  83. package/demos/nginx-demo/docs/PCRE.LICENCE +93 -93
  84. package/demos/nginx-demo/docs/README +3 -3
  85. package/demos/nginx-demo/docs/zlib.LICENSE +20 -20
  86. package/demos/nginx-demo/html/50x.html +21 -21
  87. package/demos/nginx-demo/html/ezuikit5/ezuikit.js +29 -29
  88. package/demos/nginx-demo/html/ezuikit5/index.html +116 -116
  89. package/demos/nginx-demo/html/ezuikit5/server.js +67 -67
  90. package/demos/nginx-demo/html/index.html +16 -16
  91. package/demos/nginx-demo/html/js/adapeter.js +5496 -5496
  92. package/demos/nginx-demo/html/js/janus.js +3507 -3507
  93. package/demos/nginx-demo/html/js/jquery.min.js +1 -1
  94. package/demos/nginx-demo/html/js/sts.js +340 -340
  95. package/demos/nginx-demo/logs/access.log +109 -109
  96. package/demos/nginx-demo/logs/error.log +15 -15
  97. package/demos/nginx-demo/logs/nginx.pid +1 -1
  98. package/demos/react-demo/README.md +68 -68
  99. package/demos/react-demo/package.json +36 -36
  100. package/demos/react-demo/public/index.html +43 -43
  101. package/demos/react-demo/public/manifest.json +25 -25
  102. package/demos/react-demo/public/robots.txt +3 -3
  103. package/demos/react-demo/src/App.css +38 -38
  104. package/demos/react-demo/src/App.js +114 -114
  105. package/demos/react-demo/src/App.test.js +9 -9
  106. package/demos/react-demo/src/index.css +13 -13
  107. package/demos/react-demo/src/index.js +17 -17
  108. package/demos/react-demo/src/logo.svg +7 -7
  109. package/demos/react-demo/src/serviceWorker.js +141 -141
  110. package/demos/react-demo/src/setupTests.js +5 -5
  111. package/demos/vue-demo/README.md +24 -24
  112. package/demos/vue-demo/babel.config.js +5 -5
  113. package/demos/vue-demo/package.json +43 -43
  114. package/demos/vue-demo/public/index.html +17 -17
  115. package/demos/vue-demo/src/App.vue +27 -27
  116. package/demos/vue-demo/src/components/EZUIKitJs.vue +115 -115
  117. package/demos/vue-demo/src/main.js +8 -8
  118. package/ezuikit.js +4343 -219
  119. package/ezuikit_static/v65/v1/js/SuperRender_10.js +394 -394
  120. package/ezuikit_static/v65/v1/js/playctrl/DecodeWorker.js +617 -617
  121. package/ezuikit_static/v65/v1/js/playctrl/JSPlaySDKInterface.js +2052 -2052
  122. package/ezuikit_static/v65/v1/js/playctrl/SuperRender_10.js +395 -395
  123. package/ezuikit_static/v65/v1/js/transform/SystemTransform.js +22 -22
  124. package/ezuikit_static/v65/v1/js/tts-v4.js +346 -346
  125. package/ezuikit_static/v65/v1/rec/jquery.min.js +1 -1
  126. package/ezuikit_static/v65/v1/talk/tts-v4.js +346 -346
  127. package/ezuikit_static/v65/v2/js/jsPluginV2-2.0.1.min.js +74 -11
  128. package/ezuikit_static/v65/v2/rec/jquery.min.js +1 -1
  129. package/ezuikit_static/v65/v2/talk/tts-v4.js +343 -343
  130. package/ezuikit_static/v66/v1/css/theme.css +121 -0
  131. package/ezuikit_static/v66/v1/js/AudioRenderer.js +225 -0
  132. package/ezuikit_static/v66/v1/js/SuperRender_10.js +395 -0
  133. package/ezuikit_static/v66/v1/js/SystemTransform.js +22 -0
  134. package/ezuikit_static/v66/v1/js/SystemTransform.js.mem +0 -0
  135. package/ezuikit_static/v66/v1/js/jsPluginV1-1.0.0.min.js +26 -0
  136. package/ezuikit_static/v66/v1/js/playctrl/AudioRenderer.js +225 -0
  137. package/ezuikit_static/v66/v1/js/playctrl/DecodeWorker.js +618 -0
  138. package/ezuikit_static/v66/v1/js/playctrl/Decoder.js +1 -0
  139. package/ezuikit_static/v66/v1/js/playctrl/JSPlaySDKInterface.js +2052 -0
  140. package/ezuikit_static/v66/v1/js/playctrl/SuperRender_10.js +396 -0
  141. package/ezuikit_static/v66/v1/js/playctrl/SuperRender_20.js +1 -0
  142. package/ezuikit_static/v66/v1/js/transform/SystemTransform.js +22 -0
  143. package/ezuikit_static/v66/v1/js/transform/SystemTransform.js.mem +0 -0
  144. package/ezuikit_static/v66/v1/js/transform/systemTransform-worker.min.js +1 -0
  145. package/ezuikit_static/v66/v1/js/tts-v4.js +346 -0
  146. package/ezuikit_static/v66/v1/rec/datepicker.js +1522 -0
  147. package/ezuikit_static/v66/v1/rec/datepicker.min.css +36 -0
  148. package/ezuikit_static/v66/v1/rec/datepicker.zh-CN.js +19 -0
  149. package/ezuikit_static/v66/v1/rec/jquery.min.js +2 -0
  150. package/ezuikit_static/v66/v1/speed/speed.css +144 -0
  151. package/ezuikit_static/v66/v1/talk/adapeter.js +5497 -0
  152. package/ezuikit_static/v66/v1/talk/janus.js +3507 -0
  153. package/ezuikit_static/v66/v1/talk/tts-v4.js +346 -0
  154. package/ezuikit_static/v66/v2/css/theme.css +121 -0
  155. package/ezuikit_static/v66/v2/js/Decoder.js +9198 -0
  156. package/ezuikit_static/v66/v2/js/Decoder.wasm +0 -0
  157. package/ezuikit_static/v66/v2/js/jsPluginV2-2.0.1.min.js +4662 -0
  158. package/ezuikit_static/v66/v2/rec/datepicker.js +1522 -0
  159. package/ezuikit_static/v66/v2/rec/datepicker.min.css +36 -0
  160. package/ezuikit_static/v66/v2/rec/datepicker.zh-CN.js +19 -0
  161. package/ezuikit_static/v66/v2/rec/jquery.min.js +2 -0
  162. package/ezuikit_static/v66/v2/speed/speed.css +144 -0
  163. package/ezuikit_static/v66/v2/talk/adapeter.js +5497 -0
  164. package/ezuikit_static/v66/v2/talk/janus.js +3507 -0
  165. package/ezuikit_static/v66/v2/talk/tts-v4.js +343 -0
  166. 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
+