@flashphoner/websdk 2.0.232 → 2.0.234
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/docTemplate/README.md +1 -1
- package/examples/demo/streaming/console/console.html +75 -1
- package/examples/demo/streaming/console/console.js +88 -8
- package/flashphoner-no-flash.js +14 -14
- package/flashphoner-no-flash.min.js +2 -2
- package/flashphoner-no-webrtc.js +13 -13
- package/flashphoner-no-webrtc.min.js +2 -2
- package/flashphoner-no-wsplayer.js +13 -13
- package/flashphoner-no-wsplayer.min.js +2 -2
- package/flashphoner-rest-api.js +3 -2
- package/flashphoner-temasys-flash-websocket-without-adapterjs.js +15 -15
- package/flashphoner-temasys-flash-websocket.js +15 -15
- package/flashphoner-temasys-flash-websocket.min.js +2 -2
- package/flashphoner-webrtc-only.js +12 -12
- package/flashphoner-webrtc-only.min.js +1 -1
- package/flashphoner.js +13 -13
- package/flashphoner.min.js +2 -2
- package/package.json +1 -1
- package/src/rest-module.js +3 -2
package/docTemplate/README.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<script type="text/javascript" src="../../dependencies/bootstrap/js/bootstrap.min.js"></script>
|
|
15
15
|
<script type="text/javascript" src="../../dependencies/js/utils.js"></script>
|
|
16
16
|
<script type="text/javascript" src="../../../../flashphoner-rest-api.js"></script>
|
|
17
|
+
<script type="text/javascript" src="../../../../flashphoner.js"></script>
|
|
17
18
|
<script type="text/javascript" charset="utf8" src="jquery.dataTables.js"></script>
|
|
18
19
|
<script type="text/javascript" src="console.js"></script>
|
|
19
20
|
</head>
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
<th>MEM</th>
|
|
39
40
|
<th>TH</th>
|
|
40
41
|
<th>CONN</th>
|
|
42
|
+
<th>WS</th>
|
|
41
43
|
<th>IN</th>
|
|
42
44
|
<th>OUT</th>
|
|
43
45
|
</tr>
|
|
@@ -49,10 +51,13 @@
|
|
|
49
51
|
<hr>
|
|
50
52
|
<div id="nodeControls" class="row vdivide hidden">
|
|
51
53
|
<div class="col-sm-2">
|
|
54
|
+
<button id="wsSessionsBatchModalBtn" data-toggle='modal' data-target='#wsSessionsBatchModal' type="button" class="btn btn-default btn-success btn-block">Create sessions</button>
|
|
55
|
+
<hr>
|
|
52
56
|
<button id="pullStreamModalBtn" data-toggle='modal' data-target='#pullModal' type="button" class="btn btn-default btn-success btn-block">Pull stream</button>
|
|
53
57
|
<button id="pullRtspStreamModalBtn" data-toggle='modal' data-target='#pullRtspModal' type="button" class="btn btn-default btn-success btn-block">Pull RTSP stream</button>
|
|
54
58
|
<hr>
|
|
55
59
|
<button id="pullStreamBatchModalBtn" data-toggle='modal' data-target='#pullStreamBatchModal' type="button" class="btn btn-default btn-success btn-block">Pull streams</button>
|
|
60
|
+
<button id="pushStreamBatchModalBtn" data-toggle='modal' data-target='#pushStreamBatchModal' type="button" class="btn btn-default btn-success btn-block">Push streams</button>
|
|
56
61
|
<button id="registerBatchModalBtn" data-toggle='modal' data-target='#registerBatchModal' type="button" class="btn btn-default btn-success btn-block">Register</button>
|
|
57
62
|
<button id="unregisterBatchModalBtn" data-toggle='modal' data-target='#unregisterBatchModal' type="button" class="btn btn-default btn-success btn-block">Unregister</button>
|
|
58
63
|
<button id="callBatchModalBtn" data-toggle='modal' data-target='#callBatchModal' type="button" class="btn btn-default btn-success btn-block">Call</button>
|
|
@@ -200,7 +205,7 @@
|
|
|
200
205
|
</select>
|
|
201
206
|
</div>
|
|
202
207
|
<div class="form-group">
|
|
203
|
-
<label for="
|
|
208
|
+
<label for="pullStreamBatchProto"><span class="glyphicon glyphicon-play-circle"></span> Proto pull</label>
|
|
204
209
|
<select class="custom-select" id="pullStreamBatchProto">
|
|
205
210
|
<option value="ws" selected>WebRTC</option>
|
|
206
211
|
<option value="rtmp">RTMP</option>
|
|
@@ -227,6 +232,75 @@
|
|
|
227
232
|
</div>
|
|
228
233
|
</div>
|
|
229
234
|
</div>
|
|
235
|
+
<div id="pushStreamBatchModal" class="modal fade" role="dialog">
|
|
236
|
+
<div class="modal-dialog">
|
|
237
|
+
<div class="modal-content">
|
|
238
|
+
<div class="modal-header">
|
|
239
|
+
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
240
|
+
<h4>Push Streams</h4>
|
|
241
|
+
</div>
|
|
242
|
+
<div class="modal-body">
|
|
243
|
+
<form action="" id="pushStreamBatchForm">
|
|
244
|
+
<div class="form-group">
|
|
245
|
+
<label for="pushStreamBatchNodes"><span class="glyphicon glyphicon-globe"></span> Choose node</label>
|
|
246
|
+
<select class="custom-select" id="pushStreamBatchNodes">
|
|
247
|
+
</select>
|
|
248
|
+
</div>
|
|
249
|
+
<div class="form-group">
|
|
250
|
+
<label for="pushStreamBatchProto"><span class="glyphicon glyphicon-play-circle"></span> Proto push</label>
|
|
251
|
+
<select class="custom-select" id="pushStreamBatchProto">
|
|
252
|
+
<option value="ws" selected>WebRTC</option>
|
|
253
|
+
<option value="rtmp">RTMP</option>
|
|
254
|
+
</select>
|
|
255
|
+
</div>
|
|
256
|
+
<div class="form-group">
|
|
257
|
+
<label for="pushBatchLocalName"><span class="glyphicon glyphicon-play-circle"></span> Local stream name</label>
|
|
258
|
+
<input type="text" class="form-control" id="pushBatchLocalName" placeholder="my_local_stream">
|
|
259
|
+
</div>
|
|
260
|
+
<div class="form-group">
|
|
261
|
+
<label for="pushBatchRemoteName"><span class="glyphicon glyphicon-play-circle"></span> Remote stream name</label>
|
|
262
|
+
<input type="text" class="form-control" id="pushBatchRemoteName" placeholder="my_remote_stream">
|
|
263
|
+
</div>
|
|
264
|
+
<div class="form-group">
|
|
265
|
+
<label for="pushBatchQty"><span class="glyphicon glyphicon-plus"></span> Qty</label>
|
|
266
|
+
<input type="text" class="form-control" id="pushBatchQty" placeholder="1">
|
|
267
|
+
</div>
|
|
268
|
+
<button id="pushBatchStream" type="button" class="btn btn-default btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Push</button>
|
|
269
|
+
</form>
|
|
270
|
+
</div>
|
|
271
|
+
<div class="modal-footer">
|
|
272
|
+
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
</div>
|
|
276
|
+
</div>
|
|
277
|
+
<div id="wsSessionsBatchModal" class="modal fade" role="dialog">
|
|
278
|
+
<div class="modal-dialog">
|
|
279
|
+
<div class="modal-content">
|
|
280
|
+
<div class="modal-header">
|
|
281
|
+
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
282
|
+
<h4>Create sessions to the node</h4>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="modal-body">
|
|
285
|
+
<form action="" id="wsSessionsBatchForm">
|
|
286
|
+
<div class="form-group">
|
|
287
|
+
<label for="wsSessionsBatchNodes"><span class="glyphicon glyphicon-globe"></span> Choose node</label>
|
|
288
|
+
<select class="custom-select" id="wsSessionsBatchNodes">
|
|
289
|
+
</select>
|
|
290
|
+
</div>
|
|
291
|
+
<div class="form-group">
|
|
292
|
+
<label for="wsSessionsBatchQty"><span class="glyphicon glyphicon-plus"></span> Qty</label>
|
|
293
|
+
<input type="text" class="form-control" id="wsSessionsBatchQty" placeholder="1">
|
|
294
|
+
</div>
|
|
295
|
+
<button id="wsSessionsBatchConnect" type="button" class="btn btn-default btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Connect</button>
|
|
296
|
+
</form>
|
|
297
|
+
</div>
|
|
298
|
+
<div class="modal-footer">
|
|
299
|
+
<button type="button" class="btn btn-default pull-left" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span> Cancel</button>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</div>
|
|
230
304
|
<div id="registerBatchModal" class="modal fade" role="dialog">
|
|
231
305
|
<div class="modal-dialog">
|
|
232
306
|
<div class="modal-content">
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const REFRESH_NODE_STATE_INTERVAL = 5000;
|
|
3
|
+
const REFRESH_NODE_STATE_FAILED_INTERVAL = 10000;
|
|
4
|
+
const REFRESH_NODE_DETAILS = 2000;
|
|
5
|
+
const STRESS_TEST_INTERVAL = 1000;
|
|
6
|
+
const STRESS_TEST_FAILED_INTERVAL = STRESS_TEST_INTERVAL * 2;
|
|
7
|
+
const NODE_STATE = {
|
|
8
8
|
NEW: "new",
|
|
9
9
|
ALIVE: "alive",
|
|
10
10
|
ACTIVE: "active",
|
|
11
11
|
DEACTIVATE: "deactivate",
|
|
12
12
|
FAILED: "failed"
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
const NODE_DETAILS_TYPE = {
|
|
15
15
|
ALL: "all",
|
|
16
16
|
PULLED: "pulled",
|
|
17
17
|
RTSP: "rtsp",
|
|
@@ -19,7 +19,7 @@ var NODE_DETAILS_TYPE = {
|
|
|
19
19
|
TESTS: "tests"
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
const STRESS_TESTS = {
|
|
23
23
|
REGISTER: { running: false},
|
|
24
24
|
CALL: { running: false},
|
|
25
25
|
PLAY_STREAM: { running: false},
|
|
@@ -28,7 +28,11 @@ var STRESS_TESTS = {
|
|
|
28
28
|
|
|
29
29
|
var nodes = {};
|
|
30
30
|
|
|
31
|
+
const SESSION_STATUS = Flashphoner.constants.SESSION_STATUS;
|
|
32
|
+
|
|
31
33
|
$(function() {
|
|
34
|
+
Flashphoner.init();
|
|
35
|
+
|
|
32
36
|
$("#addNodeFormSubmit").on("click", function(e){
|
|
33
37
|
var ip = $("#nodeIp").val();
|
|
34
38
|
if (ip && ip.length > 0) {
|
|
@@ -67,9 +71,21 @@ $(function() {
|
|
|
67
71
|
$('#pullStreamBatchModal').on('show.bs.modal', function(e) {
|
|
68
72
|
populateNodes($("#pullStreamBatchNodes"));
|
|
69
73
|
});
|
|
74
|
+
$('#pushStreamBatchModal').on('show.bs.modal', function(e) {
|
|
75
|
+
populateNodes($("#pushStreamBatchNodes"));
|
|
76
|
+
});
|
|
70
77
|
$("#pullBatchStream").on("click", function(e){
|
|
71
78
|
pullStreamBatch();
|
|
72
79
|
});
|
|
80
|
+
$("#pushBatchStream").on("click", function(e){
|
|
81
|
+
pushStreamBatch();
|
|
82
|
+
});
|
|
83
|
+
$('#wsSessionsBatchModal').on('show.bs.modal', function(e) {
|
|
84
|
+
populateNodes($("#wsSessionsBatchNodes"));
|
|
85
|
+
});
|
|
86
|
+
$("#wsSessionsBatchConnect").on("click", function(e){
|
|
87
|
+
wsSessionsBatch();
|
|
88
|
+
});
|
|
73
89
|
$('#registerBatchModal').on('show.bs.modal', function(e) {
|
|
74
90
|
populateNodes($("#registerBatchNodes"));
|
|
75
91
|
});
|
|
@@ -157,6 +173,7 @@ function createNode(id, ip) {
|
|
|
157
173
|
api.ip = nodeIp;
|
|
158
174
|
api.port = port;
|
|
159
175
|
api.tests = [];
|
|
176
|
+
api.wsSessions = {};
|
|
160
177
|
let state = NODE_STATE.NEW;
|
|
161
178
|
let pollState = function(){
|
|
162
179
|
api.stat.poll().then(function(stat){
|
|
@@ -274,6 +291,17 @@ function createNode(id, ip) {
|
|
|
274
291
|
const json = await result.json();
|
|
275
292
|
return json;
|
|
276
293
|
}
|
|
294
|
+
api.createWsSession = function(wsUrl) {
|
|
295
|
+
Flashphoner.createSession({urlServer: wsUrl}).on(SESSION_STATUS.ESTABLISHED, function (session) {
|
|
296
|
+
api.wsSessions[session.id()] = session;
|
|
297
|
+
}).on(SESSION_STATUS.DISCONNECTED, function (session) {
|
|
298
|
+
console.log("Session with " + wsUrl + " (id: " + session.id() + ") disconnected");
|
|
299
|
+
delete api.wsSessions[session.id()];
|
|
300
|
+
}).on(SESSION_STATUS.FAILED, function (session) {
|
|
301
|
+
console.log("Session with " + wsUrl + " (id: " + session.id() + ") failed");
|
|
302
|
+
delete api.wsSessions[session.id()];
|
|
303
|
+
});
|
|
304
|
+
}
|
|
277
305
|
return api;
|
|
278
306
|
}
|
|
279
307
|
|
|
@@ -323,6 +351,7 @@ function updateNodeState(id, state) {
|
|
|
323
351
|
"<td id='"+id+"-state-mem'>"+(mem)+"</td>" +
|
|
324
352
|
"<td id='"+id+"-state-threads'>"+state.core.core_threads+"</td>" +
|
|
325
353
|
"<td id='"+id+"-state-conn'>"+state.connection.connections+"</td>" +
|
|
354
|
+
"<td id='"+id+"-state-ws'>"+state.connection.connections_websocket+"</td>" +
|
|
326
355
|
"<td id='"+id+"-state-in'>"+(streamsIn)+"</td>" +
|
|
327
356
|
"<td id='"+id+"-state-out'>"+(streamsOut)+"</td>" +
|
|
328
357
|
"</tr>";
|
|
@@ -333,6 +362,7 @@ function updateNodeState(id, state) {
|
|
|
333
362
|
$("#"+id+"-state-mem").text(mem);
|
|
334
363
|
$("#"+id+"-state-threads").text(state.core.core_threads);
|
|
335
364
|
$("#"+id+"-state-conn").text(state.connection.connections);
|
|
365
|
+
$("#"+id+"-state-ws").text(state.connection.connections_websocket);
|
|
336
366
|
$("#"+id+"-state-in").text(streamsIn);
|
|
337
367
|
$("#"+id+"-state-out").text(streamsOut);
|
|
338
368
|
}
|
|
@@ -456,6 +486,25 @@ function pullRTSPStream() {
|
|
|
456
486
|
$("#pullRtspModal").modal('hide');
|
|
457
487
|
}
|
|
458
488
|
|
|
489
|
+
function wsSessionsBatch() {
|
|
490
|
+
if (!$("#wsSessionsBatchNodes").val()) {
|
|
491
|
+
$('#warningModal').modal();
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
var node = getActiveNode();
|
|
495
|
+
var remote = getWebsocketUrl($("#wsSessionsBatchNodes").val()) + "/";
|
|
496
|
+
var qty = parseInt($("#wsSessionsBatchQty").val());
|
|
497
|
+
var interval = setInterval(function(){
|
|
498
|
+
if (qty > 0) {
|
|
499
|
+
node.createWsSession(remote);
|
|
500
|
+
qty--;
|
|
501
|
+
} else {
|
|
502
|
+
clearInterval(interval);
|
|
503
|
+
}
|
|
504
|
+
}, 200);
|
|
505
|
+
$("#wsSessionsBatchModal").modal('hide');
|
|
506
|
+
}
|
|
507
|
+
|
|
459
508
|
//pullBatchStream
|
|
460
509
|
|
|
461
510
|
function pullStreamBatch() {
|
|
@@ -485,6 +534,37 @@ function pullStreamBatch() {
|
|
|
485
534
|
$("#pullStreamBatchModal").modal('hide');
|
|
486
535
|
}
|
|
487
536
|
|
|
537
|
+
function pushStreamBatch() {
|
|
538
|
+
if (!$("#pushStreamBatchNodes").val()) {
|
|
539
|
+
$('#warningModal').modal();
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
var node = getActiveNode();
|
|
543
|
+
var proto = $("#pushStreamBatchProto").val();
|
|
544
|
+
var localName = $("#pushBatchLocalName").val();
|
|
545
|
+
var remoteName = $("#pushBatchRemoteName").val();
|
|
546
|
+
var remote;
|
|
547
|
+
if (proto == "ws") {
|
|
548
|
+
remote = getWebsocketUrl($("#pushStreamBatchNodes").val()) + "/";
|
|
549
|
+
} else {
|
|
550
|
+
remote = "rtmp://" + $("#pushStreamBatchNodes").val() + ":1935/live/";
|
|
551
|
+
}
|
|
552
|
+
var qty = parseInt($("#pushBatchQty").val());
|
|
553
|
+
var interval = setInterval(function(){
|
|
554
|
+
if (qty > 0) {
|
|
555
|
+
if (proto == "ws") {
|
|
556
|
+
node.pull.push(remote, localName, remoteName + qty).catch(function (e) {console.log(e)});
|
|
557
|
+
} else {
|
|
558
|
+
node.push.push(localName, remote + remoteName + qty, true);
|
|
559
|
+
}
|
|
560
|
+
qty--;
|
|
561
|
+
} else {
|
|
562
|
+
clearInterval(interval);
|
|
563
|
+
}
|
|
564
|
+
}, 200);
|
|
565
|
+
$("#pushStreamBatchModal").modal('hide');
|
|
566
|
+
}
|
|
567
|
+
|
|
488
568
|
function registerBatch() {
|
|
489
569
|
if (!$("#registerBatchNodes").val()) {
|
|
490
570
|
$('#warningModal').modal();
|