ucservice 1.1.2 → 1.1.3
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/dist/ucservice.common.js +247 -246
- package/dist/ucservice.common.js.gz +0 -0
- package/dist/ucservice.common.js.map +1 -1
- package/dist/ucservice.umd.js +247 -246
- package/dist/ucservice.umd.js.gz +0 -0
- package/dist/ucservice.umd.js.map +1 -1
- package/dist/ucservice.umd.min.js +1 -1
- package/dist/ucservice.umd.min.js.gz +0 -0
- package/dist/ucservice.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/scooper.video.js +249 -248
package/src/scooper.video.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
define(['jquery', './lib/janus', 'webrtc-adapter'], factory);
|
|
13
13
|
} else if (typeof exports === 'object') {
|
|
14
14
|
// Node, CommonJS之类的
|
|
15
|
-
module.exports = factory(require('jquery'), require('./lib/janus'), require('webrtc-adapter'));
|
|
15
|
+
module.exports = factory(require('jquery'), require('./lib/janus').default, require('webrtc-adapter'));
|
|
16
16
|
} else {
|
|
17
17
|
// 浏览器全局变量(root 即 window)
|
|
18
18
|
root.scooper = root.scooper || {};
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
root.scooper.video = factory(root.jQuery, root.Janus, root.adapter);
|
|
21
21
|
}
|
|
22
22
|
}(this, function ($, Janus, adapter) {
|
|
23
|
+
console.log($, Janus, adapter);
|
|
23
24
|
"use strict";
|
|
24
25
|
|
|
25
26
|
window.console = window.console || (function(){
|
|
26
|
-
|
|
27
|
+
let c = {}; c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir = c.profile
|
|
27
28
|
= c.clear = c.exception = c.trace = c.assert = function(){};
|
|
28
29
|
return c;
|
|
29
30
|
})();
|
|
@@ -37,9 +38,9 @@
|
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
Array.prototype.indexOf = function(item) {
|
|
40
|
-
|
|
41
|
+
let len = this.length >>> 0; //保证结构为非负数
|
|
41
42
|
|
|
42
|
-
for(
|
|
43
|
+
for(let i = 0; i<len ; i++) {
|
|
43
44
|
if(i in this && this[i] === item) {
|
|
44
45
|
return i;
|
|
45
46
|
}
|
|
@@ -52,8 +53,8 @@
|
|
|
52
53
|
* 闭包
|
|
53
54
|
* 为事件添加唯一标识字符串
|
|
54
55
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
let guid = (function() {
|
|
57
|
+
let id = 1;
|
|
57
58
|
return function() {
|
|
58
59
|
return 'SCVIDEO_ID_'+ (++id).toString();
|
|
59
60
|
}
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
* 让新出来的对象是独立的
|
|
74
75
|
*/
|
|
75
76
|
function cloneObj(obj) {
|
|
76
|
-
|
|
77
|
+
let str, newObj = $.isArray(obj)?[]:{};
|
|
77
78
|
if ( typeof obj != 'object' ) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
* 公共方法
|
|
94
95
|
* 提示
|
|
95
96
|
*/
|
|
96
|
-
|
|
97
|
+
let showPrompt = true;
|
|
97
98
|
function promptSuccess(msg, type) {
|
|
98
99
|
console.log(msg);
|
|
99
100
|
//panduanpromptView弹层对象是否引入
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
console.log("Not support enumerateDevices() .");
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
132
|
-
|
|
133
|
+
let startTime = new Date().getTime();
|
|
133
134
|
// 列出相机和麦克风.
|
|
134
135
|
navigator.mediaDevices.enumerateDevices()
|
|
135
136
|
.then(function(devices) {
|
|
@@ -152,7 +153,7 @@
|
|
|
152
153
|
* 判断是否是http
|
|
153
154
|
*/
|
|
154
155
|
function checkIsHttp() {
|
|
155
|
-
|
|
156
|
+
let protocolStr = document.location.protocol;
|
|
156
157
|
if(protocolStr == "http:" && window.location.hostname != "localhost" ) return true;
|
|
157
158
|
return false;
|
|
158
159
|
}
|
|
@@ -164,7 +165,7 @@
|
|
|
164
165
|
* 这也是分开的另一个目的
|
|
165
166
|
*/
|
|
166
167
|
function checkIsHttps() {
|
|
167
|
-
|
|
168
|
+
let protocolStr = document.location.protocol;
|
|
168
169
|
if(protocolStr == "https:") return true;
|
|
169
170
|
return false;
|
|
170
171
|
}
|
|
@@ -183,7 +184,7 @@
|
|
|
183
184
|
/**
|
|
184
185
|
* 轮巡工具类
|
|
185
186
|
*/
|
|
186
|
-
|
|
187
|
+
let PollTimer = /** @class */ (function () {
|
|
187
188
|
function PollTimer(cb, time) {
|
|
188
189
|
cb(true); // 首次执行
|
|
189
190
|
this.timerId = setInterval(cb, time * 1000);
|
|
@@ -203,7 +204,7 @@
|
|
|
203
204
|
}());
|
|
204
205
|
|
|
205
206
|
|
|
206
|
-
|
|
207
|
+
let waitTimerId = 0;
|
|
207
208
|
function wait(time) {
|
|
208
209
|
return new Promise(function(resolve, reject) {
|
|
209
210
|
if (waitTimerId) {
|
|
@@ -232,7 +233,7 @@
|
|
|
232
233
|
if (typeof handler != 'function') {
|
|
233
234
|
return;
|
|
234
235
|
}
|
|
235
|
-
|
|
236
|
+
let t = this._listeners,id;
|
|
236
237
|
if (typeof key == "string" && key) {
|
|
237
238
|
if (/[^\w\-]/.test(key)) {
|
|
238
239
|
throw("nonstandard key:" + key);
|
|
@@ -253,7 +254,7 @@
|
|
|
253
254
|
*/
|
|
254
255
|
removeListener: function(type, handler){
|
|
255
256
|
type.indexOf("on") != 0 && (type = "on" + type);
|
|
256
|
-
|
|
257
|
+
let t = this._listeners;
|
|
257
258
|
if (!t[type]) {
|
|
258
259
|
return;
|
|
259
260
|
}
|
|
@@ -277,10 +278,10 @@
|
|
|
277
278
|
e = new VideoEvent(e);
|
|
278
279
|
}
|
|
279
280
|
options = options || {};
|
|
280
|
-
for (
|
|
281
|
+
for (let i in options) {
|
|
281
282
|
e[i] = options[i];
|
|
282
283
|
}
|
|
283
|
-
|
|
284
|
+
let i, t = this._listeners, p = e.type;
|
|
284
285
|
e.target || (e.target = this);
|
|
285
286
|
e.currentTarget = this;
|
|
286
287
|
p.indexOf("on") != 0 && (p = "on" + p);
|
|
@@ -294,7 +295,7 @@
|
|
|
294
295
|
}
|
|
295
296
|
}
|
|
296
297
|
|
|
297
|
-
|
|
298
|
+
let videoListener = new Listener();
|
|
298
299
|
|
|
299
300
|
/**
|
|
300
301
|
* 使用ocx方式的video工具类
|
|
@@ -332,7 +333,7 @@
|
|
|
332
333
|
this.dispatch('beforeplay',{index:index, video:video, id:id});
|
|
333
334
|
|
|
334
335
|
this._obj.SCWebSetCurrentWindow(index);
|
|
335
|
-
|
|
336
|
+
let playId = this._obj.SCWebRealPlay(video, this._opts.streamType);
|
|
336
337
|
console.log("play = " + playId);
|
|
337
338
|
|
|
338
339
|
opts = opts || {};
|
|
@@ -344,7 +345,7 @@
|
|
|
344
345
|
},this.dispatch('playsuccess', this.videoStatus[index]));
|
|
345
346
|
|
|
346
347
|
if (playId < 0) {
|
|
347
|
-
|
|
348
|
+
let name = opts.name || '视频';
|
|
348
349
|
promptFailed(name + '播放失败!');
|
|
349
350
|
}
|
|
350
351
|
|
|
@@ -357,7 +358,7 @@
|
|
|
357
358
|
* 返回true/false
|
|
358
359
|
*/
|
|
359
360
|
playByOrder: function(video, id, opts){
|
|
360
|
-
|
|
361
|
+
let freeWindow = this._getMinIndexFreeWindow(0);
|
|
361
362
|
|
|
362
363
|
if(freeWindow == -1 ||
|
|
363
364
|
(this._getChoiceWindow() != -1 && !this.getInChoiceVideo())){
|
|
@@ -371,12 +372,12 @@
|
|
|
371
372
|
*/
|
|
372
373
|
playByOrderExpandWindow: function(video,id,opts){
|
|
373
374
|
|
|
374
|
-
|
|
375
|
+
let freeWindow = this._getMinIndexFreeWindow(0);
|
|
375
376
|
|
|
376
|
-
|
|
377
|
+
let maxWindows = this._opts.windowsNum || 16;
|
|
377
378
|
|
|
378
379
|
while (this._opts.windows < maxWindows && freeWindow == -1) {
|
|
379
|
-
|
|
380
|
+
let zoom = Math.sqrt(this._opts.windows*1)+1;
|
|
380
381
|
|
|
381
382
|
if (this._opts.windows == 6) {
|
|
382
383
|
this.setWindowsNum(9);
|
|
@@ -401,7 +402,7 @@
|
|
|
401
402
|
if (array.length > this._opts.windows) {
|
|
402
403
|
throw new Error('windows is not enough');
|
|
403
404
|
}
|
|
404
|
-
|
|
405
|
+
let me = this;
|
|
405
406
|
me.closeAll();
|
|
406
407
|
$.each(array,function(i,obj){
|
|
407
408
|
me.play(i,obj.video,obj.id,obj.opts);
|
|
@@ -411,7 +412,7 @@
|
|
|
411
412
|
* 在鼠标选中的窗口中播放视频
|
|
412
413
|
*/
|
|
413
414
|
playInChoice: function(video,id,opts){
|
|
414
|
-
|
|
415
|
+
let index = this._obj.SCWebGetCurrentWindowIndex();
|
|
415
416
|
this.videoStatus[index] && this.close(index);
|
|
416
417
|
return this.play(index,video,id,opts);
|
|
417
418
|
},
|
|
@@ -419,7 +420,7 @@
|
|
|
419
420
|
* 如果被指定的窗口有视频id,则播放
|
|
420
421
|
*/
|
|
421
422
|
playMulWindows: function(indexs) {
|
|
422
|
-
|
|
423
|
+
let me = this;
|
|
423
424
|
$.each(indexs,function(i,index){
|
|
424
425
|
me.videoStatus[index] && me.play(index,me.videoStatus[index].video,me.videoStatus[index].id);
|
|
425
426
|
});
|
|
@@ -428,7 +429,7 @@
|
|
|
428
429
|
* 检索当前点的视频是否被播放,被播放则返回播放的视频窗口
|
|
429
430
|
*/
|
|
430
431
|
isPlaying: function(id){
|
|
431
|
-
|
|
432
|
+
let index = -1;
|
|
432
433
|
$.each(this.videoStatus,function(key,val){
|
|
433
434
|
if (id == val.id) {
|
|
434
435
|
index = key;
|
|
@@ -466,7 +467,7 @@
|
|
|
466
467
|
* IE下才有该方法
|
|
467
468
|
*/
|
|
468
469
|
getWindowByPlayId: function(playId) {
|
|
469
|
-
|
|
470
|
+
let index = -1;
|
|
470
471
|
$.each(this.videoStatus,function(key,val){
|
|
471
472
|
if (playId == val.playId) {
|
|
472
473
|
index = key;
|
|
@@ -494,7 +495,7 @@
|
|
|
494
495
|
return;
|
|
495
496
|
}
|
|
496
497
|
this._obj.SCWebSetCurrentWindow(index);
|
|
497
|
-
|
|
498
|
+
let close = this._obj.SCWebStopRealPlay(this.videoStatus[index].playId);
|
|
498
499
|
console.log("close = "+close);
|
|
499
500
|
|
|
500
501
|
if (!isSave) {
|
|
@@ -508,19 +509,19 @@
|
|
|
508
509
|
* 关闭指定视频编号正在播放的视频
|
|
509
510
|
*/
|
|
510
511
|
closeByVideo: function(video, isSave){
|
|
511
|
-
|
|
512
|
+
let me = this;
|
|
512
513
|
|
|
513
514
|
if (video == undefined) {
|
|
514
515
|
console.info('video参数错误');
|
|
515
516
|
return;
|
|
516
517
|
}
|
|
517
518
|
|
|
518
|
-
|
|
519
|
+
let videoData = me.videoStatus;
|
|
519
520
|
if (!videoData || videoData.length == 0) {
|
|
520
521
|
return;
|
|
521
522
|
}
|
|
522
523
|
|
|
523
|
-
for (
|
|
524
|
+
for (let i in videoData) {
|
|
524
525
|
if (video == videoData[i].video) {
|
|
525
526
|
me.close(videoData[i].index);
|
|
526
527
|
}
|
|
@@ -531,9 +532,9 @@
|
|
|
531
532
|
*
|
|
532
533
|
*/
|
|
533
534
|
closeHistory: function(playId) {
|
|
534
|
-
|
|
535
|
+
let close = this._obj.SCWebStopRealPlay(playId);
|
|
535
536
|
console.log("close = "+close);
|
|
536
|
-
|
|
537
|
+
let index = this._getChoiceWindow();
|
|
537
538
|
delete this.videoStatus[index];
|
|
538
539
|
},
|
|
539
540
|
|
|
@@ -542,9 +543,9 @@
|
|
|
542
543
|
* TODO 不可关闭
|
|
543
544
|
*/
|
|
544
545
|
closeAll: function(isSave){
|
|
545
|
-
|
|
546
|
+
let me = this;
|
|
546
547
|
isSave || (this._disableClosed = []);
|
|
547
|
-
|
|
548
|
+
let windows = me._obj.SCWebGetRealPlayWindows();
|
|
548
549
|
console.log('要关闭的视频窗:' + windows);
|
|
549
550
|
if (windows) {
|
|
550
551
|
$.each(windows.split(','),function(i,index){
|
|
@@ -559,8 +560,8 @@
|
|
|
559
560
|
* @returns
|
|
560
561
|
*/
|
|
561
562
|
getWindowsPlay : function() {
|
|
562
|
-
|
|
563
|
-
|
|
563
|
+
let me = this;
|
|
564
|
+
let windows = me._obj.SCWebGetRealPlayWindows();
|
|
564
565
|
return windows;
|
|
565
566
|
},
|
|
566
567
|
|
|
@@ -588,9 +589,9 @@
|
|
|
588
589
|
* 设置视频窗口数
|
|
589
590
|
*/
|
|
590
591
|
setWindowsNum: function(num,extra) {
|
|
591
|
-
|
|
592
|
+
let me = this;
|
|
592
593
|
num = num*1;
|
|
593
|
-
|
|
594
|
+
let result;
|
|
594
595
|
if (extra) {
|
|
595
596
|
result = me._obj.SCWebDecoderSetExtraScreenMode(num);
|
|
596
597
|
} else {
|
|
@@ -640,7 +641,7 @@
|
|
|
640
641
|
|
|
641
642
|
time = $.isNumeric(time) ? time : this._opts.pollInterval;
|
|
642
643
|
this._pollArray = array;
|
|
643
|
-
|
|
644
|
+
let me = this,
|
|
644
645
|
windowNum = me._opts.windows,
|
|
645
646
|
maxNum = array.length,
|
|
646
647
|
nowNum = 0 ;
|
|
@@ -657,7 +658,7 @@
|
|
|
657
658
|
}
|
|
658
659
|
|
|
659
660
|
me.delayTimeId = setTimeout(function() {
|
|
660
|
-
for(
|
|
661
|
+
for(let i = 0; i < windowNum; i++) {
|
|
661
662
|
if(nowNum == maxNum){
|
|
662
663
|
nowNum = 0;
|
|
663
664
|
if(maxNum < windowNum) {
|
|
@@ -729,32 +730,32 @@
|
|
|
729
730
|
* cruiserun 启动巡航
|
|
730
731
|
*/
|
|
731
732
|
holder: function(type, opts, isStop) {
|
|
732
|
-
|
|
733
|
+
let index = this._getChoiceWindow();
|
|
733
734
|
if( !this.videoStatus[index] ){
|
|
734
735
|
promptAlarm('未选中播放的视频!');
|
|
735
736
|
return;
|
|
736
737
|
}
|
|
737
738
|
|
|
738
|
-
|
|
739
|
+
let holdType = 'up down left right upleft upright downleft downright zoomin zoomout focusnear focusfar irisopen irisclose pointset pointdel pointgoto '+
|
|
739
740
|
'scansetleft scansetright scansetspeed scanrun cruiseadd cruisedel cruisespeed cruisepausetime cruiserun';
|
|
740
741
|
|
|
741
|
-
|
|
742
|
+
let typeVal = (Number(holdType.split(' ').indexOf(type))+Number(1));
|
|
742
743
|
console.log("holdType:" + typeVal + " type:" + type + (isStop ? ' 停止' : ''));
|
|
743
744
|
|
|
744
745
|
if (!typeVal || typeVal <= 0) {
|
|
745
746
|
console.error('异常PTZ指令:' + typeVal);
|
|
746
747
|
}
|
|
747
748
|
|
|
748
|
-
|
|
749
|
+
let video = this.videoStatus[index].video;
|
|
749
750
|
|
|
750
751
|
if(isStop) {
|
|
751
|
-
//
|
|
752
|
-
|
|
753
|
-
//
|
|
752
|
+
//let playerId = this._obj.SCWebGetCurrentPlayID();
|
|
753
|
+
let result = this._obj.SCWebPTZControl(video,1,typeVal,0,0,0,0);
|
|
754
|
+
//let result = this._obj.SCWebPTZControlEx(playerId, 4, 1, 1);
|
|
754
755
|
console.log(">>>>yuntai control,stop, video=" + video + ", result=" + result);
|
|
755
756
|
return;
|
|
756
757
|
}
|
|
757
|
-
|
|
758
|
+
let _opts = {
|
|
758
759
|
speed: 200,
|
|
759
760
|
group: 0,
|
|
760
761
|
present: 0,
|
|
@@ -773,17 +774,17 @@
|
|
|
773
774
|
* @return playId
|
|
774
775
|
*/
|
|
775
776
|
playHistory: function(video,startTime,endTime,opts) {
|
|
776
|
-
|
|
777
|
-
|
|
777
|
+
let me = this;
|
|
778
|
+
let playId = me._obj.SCWebHistoryPlay(video, startTime, endTime);
|
|
778
779
|
console.log("play = " + playId);
|
|
779
780
|
|
|
780
781
|
if (playId < 0) {
|
|
781
|
-
|
|
782
|
+
let name = opts.name || '视频';
|
|
782
783
|
promptFailed(name + '播放失败!');
|
|
783
784
|
return playId;
|
|
784
785
|
}
|
|
785
786
|
|
|
786
|
-
|
|
787
|
+
let index = me._getChoiceWindow();
|
|
787
788
|
|
|
788
789
|
opts = opts || {};
|
|
789
790
|
playId > 0 && (me.videoStatus[index] = {
|
|
@@ -805,12 +806,12 @@
|
|
|
805
806
|
* @param {string} startTime 回放时间(暂时无用)
|
|
806
807
|
*/
|
|
807
808
|
historyControl: function(playId, playType, playSpeed, startTime) {
|
|
808
|
-
|
|
809
|
+
let contorlType = {
|
|
809
810
|
play: 1,
|
|
810
811
|
pause: 2
|
|
811
812
|
};
|
|
812
813
|
|
|
813
|
-
|
|
814
|
+
let playCommand = contorlType[playType];
|
|
814
815
|
if (!playCommand) {
|
|
815
816
|
console.error('unsupported type: ', playType);
|
|
816
817
|
return;
|
|
@@ -823,12 +824,12 @@
|
|
|
823
824
|
* 历史流控制(原)
|
|
824
825
|
*/
|
|
825
826
|
_historyControl: function(playId,type,speed,startTime) {
|
|
826
|
-
|
|
827
|
+
let contorlType = {
|
|
827
828
|
normal: 1,
|
|
828
829
|
pause: 2,
|
|
829
830
|
'continue': 3,
|
|
830
831
|
};
|
|
831
|
-
|
|
832
|
+
let commad = 1;
|
|
832
833
|
|
|
833
834
|
type == 'speed' ? speed && speed < 1 ? (commad = 7 , speed = 1/speed) : commad = 6
|
|
834
835
|
: commad = contorlType[type];
|
|
@@ -849,7 +850,7 @@
|
|
|
849
850
|
* @return 0:失败|1:成功
|
|
850
851
|
*/
|
|
851
852
|
capturePicture: function(playId) {
|
|
852
|
-
|
|
853
|
+
let videoCapImagePath = this._opts.videoCapImagePath ? this._opts.videoCapImagePath : '';
|
|
853
854
|
return this._obj.SCWebCapturePicture(playId, videoCapImagePath, '');
|
|
854
855
|
},
|
|
855
856
|
|
|
@@ -863,7 +864,7 @@
|
|
|
863
864
|
return;
|
|
864
865
|
}
|
|
865
866
|
this.closeAll();
|
|
866
|
-
|
|
867
|
+
let me = this;
|
|
867
868
|
$.each(this._saveList,function(index,obj){
|
|
868
869
|
me.play(index, obj.video, obj.id, obj.opts);
|
|
869
870
|
});
|
|
@@ -901,7 +902,7 @@
|
|
|
901
902
|
* 获取截屏数据
|
|
902
903
|
*/
|
|
903
904
|
getScreenCaptureData: function(index, callback) {
|
|
904
|
-
|
|
905
|
+
let msg = 'IE下暂不支持获取截屏数据!';
|
|
905
906
|
console.log(msg)
|
|
906
907
|
throw Error(msg);
|
|
907
908
|
},
|
|
@@ -936,7 +937,7 @@
|
|
|
936
937
|
/*
|
|
937
938
|
* 总的初始化
|
|
938
939
|
* 参数示例:
|
|
939
|
-
*
|
|
940
|
+
* let opts = {
|
|
940
941
|
windows: 4, //初始化的窗口数
|
|
941
942
|
conf: { //配置参数
|
|
942
943
|
user: conf['video.username'], //用户名
|
|
@@ -954,7 +955,7 @@
|
|
|
954
955
|
};
|
|
955
956
|
*/
|
|
956
957
|
_init: function($dom,opts){
|
|
957
|
-
|
|
958
|
+
let me = this;
|
|
958
959
|
//配置项
|
|
959
960
|
me._opts = {
|
|
960
961
|
windows: 4,
|
|
@@ -969,14 +970,14 @@
|
|
|
969
970
|
};
|
|
970
971
|
|
|
971
972
|
$.extend(me._opts,opts);
|
|
972
|
-
|
|
973
|
+
let windowsArr = me._opts.windowsArr;
|
|
973
974
|
if (!windowsArr || windowsArr.length == 0) {
|
|
974
975
|
me._windowList = {1:{}, 4:{}, 6:{}, 9:{}, 16:{}}
|
|
975
976
|
me._windowsArr = [1, 4, 6, 9, 16];
|
|
976
977
|
} else {
|
|
977
978
|
me._windowList = {};
|
|
978
|
-
for (
|
|
979
|
-
|
|
979
|
+
for (let index in windowsArr){
|
|
980
|
+
let item = windowsArr[index];
|
|
980
981
|
me._windowList[item] = {};
|
|
981
982
|
}
|
|
982
983
|
me._windowsArr = windowsArr;
|
|
@@ -1018,15 +1019,15 @@
|
|
|
1018
1019
|
me._obj = me._obj[0];
|
|
1019
1020
|
|
|
1020
1021
|
|
|
1021
|
-
|
|
1022
|
+
let conf = me._opts.conf;
|
|
1022
1023
|
//初始化和登录
|
|
1023
|
-
|
|
1024
|
+
let init = me._obj.ScWebDecoderInit(0);
|
|
1024
1025
|
console.log('init:' + init);
|
|
1025
1026
|
//是否开启抓图
|
|
1026
1027
|
|
|
1027
1028
|
conf.ip == '127.0.0.1' && (conf.ip = location.hostname);
|
|
1028
1029
|
|
|
1029
|
-
|
|
1030
|
+
let login;
|
|
1030
1031
|
if(conf.token && conf.token.length > 0 && me._obj.SCWebDecoderLoginInVS_Token) {
|
|
1031
1032
|
login = me._obj.SCWebDecoderLoginInVS_Token(conf.token, conf.ip, conf.port);
|
|
1032
1033
|
} else {
|
|
@@ -1050,8 +1051,8 @@
|
|
|
1050
1051
|
* TODO 添加注释
|
|
1051
1052
|
*/
|
|
1052
1053
|
_getTipObj: function() {
|
|
1053
|
-
|
|
1054
|
-
|
|
1054
|
+
let obj = {};
|
|
1055
|
+
let fncName = 'play playByOrder playAll playInChoice playMulWindows click getWindowsNum setWindowsNum',
|
|
1055
1056
|
fncName2 = 'isPlaying setChoiceWindow close closeAll enableClosede disableClosed addListener removeListener dispatch';
|
|
1056
1057
|
$.each(fncName.split(' '),function(i,name) {
|
|
1057
1058
|
obj[name] = function() {
|
|
@@ -1072,7 +1073,7 @@
|
|
|
1072
1073
|
*/
|
|
1073
1074
|
_getMinIndexFreeWindow: function(searchedZoom) {
|
|
1074
1075
|
searchedZoom = searchedZoom || 0;
|
|
1075
|
-
|
|
1076
|
+
let index = Math.ceil(Math.pow(searchedZoom,2));
|
|
1076
1077
|
for (; index < this._opts.windows ; index++) {
|
|
1077
1078
|
if (!this.videoStatus[index]) {
|
|
1078
1079
|
return index;
|
|
@@ -1085,8 +1086,8 @@
|
|
|
1085
1086
|
* 获取选择的窗口的编号
|
|
1086
1087
|
*/
|
|
1087
1088
|
_getChoiceWindow: function(){
|
|
1088
|
-
//
|
|
1089
|
-
//
|
|
1089
|
+
// let playId = this._obj.SCWebGetCurrentPlayID();
|
|
1090
|
+
// let index;
|
|
1090
1091
|
// if (playId > 0) {
|
|
1091
1092
|
// index = this._obj.SCWebGetRealPlayWindows().split(',')[0];
|
|
1092
1093
|
// this.setChoiceWindow(index ? index : 0);
|
|
@@ -1099,7 +1100,7 @@
|
|
|
1099
1100
|
* 切换分屏
|
|
1100
1101
|
*/
|
|
1101
1102
|
/* _changeWindowsAction: function(num) {
|
|
1102
|
-
|
|
1103
|
+
let me = this,
|
|
1103
1104
|
old = me._opts.windows,
|
|
1104
1105
|
now = num,
|
|
1105
1106
|
oldZoom = Math.sqrt(old),
|
|
@@ -1110,7 +1111,7 @@
|
|
|
1110
1111
|
if (me._opts.openChangeWindowStrategy) {
|
|
1111
1112
|
if (old > now) {
|
|
1112
1113
|
for (; now < old ; now++) {
|
|
1113
|
-
|
|
1114
|
+
let tempZoom = Math.ceil(Math.sqrt(now+1));
|
|
1114
1115
|
|
|
1115
1116
|
me.videoStatus[now] && (me._windowList[tempZoom][now] = {
|
|
1116
1117
|
video: me.videoStatus[now].video,
|
|
@@ -1142,7 +1143,7 @@
|
|
|
1142
1143
|
* 切换分屏
|
|
1143
1144
|
*/
|
|
1144
1145
|
_changeWindowsAction: function(num) {
|
|
1145
|
-
|
|
1146
|
+
let me = this,
|
|
1146
1147
|
old = me._opts.windows,
|
|
1147
1148
|
now = num;
|
|
1148
1149
|
// oldZoom = Math.sqrt(old),
|
|
@@ -1153,8 +1154,8 @@
|
|
|
1153
1154
|
if (me._opts.openChangeWindowStrategy) {
|
|
1154
1155
|
if (old > now) {
|
|
1155
1156
|
for (; now < old ; now++) {
|
|
1156
|
-
//
|
|
1157
|
-
|
|
1157
|
+
//let tempZoom = Math.ceil(Math.sqrt(now+1));
|
|
1158
|
+
let tempZoom = me._getWindowsNum(now + 1);
|
|
1158
1159
|
|
|
1159
1160
|
me.videoStatus[now] && (me._windowList[tempZoom][now] = {
|
|
1160
1161
|
video: me.videoStatus[now].video,
|
|
@@ -1187,9 +1188,9 @@
|
|
|
1187
1188
|
* now为当前窗口的编号
|
|
1188
1189
|
*/
|
|
1189
1190
|
_getWindowsNum: function(now) {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
for (
|
|
1191
|
+
let me = this;
|
|
1192
|
+
let windowsArr = me._windowsArr;
|
|
1193
|
+
for (let index in windowsArr){
|
|
1193
1194
|
if (now <= windowsArr[index]) {
|
|
1194
1195
|
return windowsArr[index];
|
|
1195
1196
|
}
|
|
@@ -1200,9 +1201,9 @@
|
|
|
1200
1201
|
* 获取下一窗口
|
|
1201
1202
|
*/
|
|
1202
1203
|
_getNextWindowsNum: function(old) {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
for (
|
|
1204
|
+
let me = this;
|
|
1205
|
+
let windowsArr = me._windowsArr;
|
|
1206
|
+
for (let index in windowsArr){
|
|
1206
1207
|
if (index == windowsArr.length - 1) {
|
|
1207
1208
|
return windowsArr[index]
|
|
1208
1209
|
}
|
|
@@ -1213,7 +1214,7 @@
|
|
|
1213
1214
|
},
|
|
1214
1215
|
|
|
1215
1216
|
_addStopHandler: function() {
|
|
1216
|
-
|
|
1217
|
+
let me = this;
|
|
1217
1218
|
window.stopVideo = function(playId,videoId) {
|
|
1218
1219
|
if (me.getWindowByPlayId(playId) != -1 &&
|
|
1219
1220
|
me.videoStatus[me.getWindowByPlayId(playId)].isPlayBack) {
|
|
@@ -1229,7 +1230,7 @@
|
|
|
1229
1230
|
},
|
|
1230
1231
|
|
|
1231
1232
|
_addClickHandler: function() {
|
|
1232
|
-
|
|
1233
|
+
let me = this;
|
|
1233
1234
|
window.clickVideo = function(playId) {
|
|
1234
1235
|
me.dispatch('click',me.videoStatus[me.getWindowByPlayId(playId)]);
|
|
1235
1236
|
};
|
|
@@ -1237,7 +1238,7 @@
|
|
|
1237
1238
|
},
|
|
1238
1239
|
|
|
1239
1240
|
_addHisHandler: function() {
|
|
1240
|
-
|
|
1241
|
+
let me = this;
|
|
1241
1242
|
window.playbackVideo = function(playId,videoId,historytime) {
|
|
1242
1243
|
me.dispatch('playback',{playId:playId,videoId:videoId,historyTime:historytime});
|
|
1243
1244
|
};
|
|
@@ -1246,7 +1247,7 @@
|
|
|
1246
1247
|
|
|
1247
1248
|
//监听截图事件
|
|
1248
1249
|
_addCapPicHandler: function() {
|
|
1249
|
-
|
|
1250
|
+
let me = this;
|
|
1250
1251
|
window.getCapPicPath = function(playId, capPicPath, capPicName) {
|
|
1251
1252
|
me.dispatch('getCapPicPath', {playId:playId, capPicPath:capPicPath, capPicName: capPicName});
|
|
1252
1253
|
};
|
|
@@ -1255,7 +1256,7 @@
|
|
|
1255
1256
|
|
|
1256
1257
|
//监听点击视频框的历史回放
|
|
1257
1258
|
_addHistoryPlayHandler: function() {
|
|
1258
|
-
|
|
1259
|
+
let me = this;
|
|
1259
1260
|
window.historyPlay = function(playId, videoId) {
|
|
1260
1261
|
me.dispatch('historyPlay', {playId:playId, videoId:videoId});
|
|
1261
1262
|
};
|
|
@@ -1264,7 +1265,7 @@
|
|
|
1264
1265
|
|
|
1265
1266
|
_regEvent: function(eventName,handlerName) {
|
|
1266
1267
|
window._addScriptFlag = true;
|
|
1267
|
-
|
|
1268
|
+
let script;
|
|
1268
1269
|
try {
|
|
1269
1270
|
script = $('<script>').attr({
|
|
1270
1271
|
'for': this._opts.ocxName,
|
|
@@ -1286,7 +1287,7 @@
|
|
|
1286
1287
|
},
|
|
1287
1288
|
|
|
1288
1289
|
_beforeUnload: function() {
|
|
1289
|
-
|
|
1290
|
+
let me = this;
|
|
1290
1291
|
window.onbeforeunload = function (e) {
|
|
1291
1292
|
me.closeAll();
|
|
1292
1293
|
me._obj.SCWebDecoderDestroy();
|
|
@@ -1299,7 +1300,7 @@
|
|
|
1299
1300
|
* 使用webRtc方式的video工具类
|
|
1300
1301
|
*/
|
|
1301
1302
|
function VideoWebRtc($dom,opts){
|
|
1302
|
-
|
|
1303
|
+
let _self = this;
|
|
1303
1304
|
if (!opts) {
|
|
1304
1305
|
console.error('VideoWebRtc的参数opts不能为空');
|
|
1305
1306
|
return;
|
|
@@ -1307,8 +1308,8 @@
|
|
|
1307
1308
|
hasMediaDevices();
|
|
1308
1309
|
//检测声卡设备为异步方法,耗时在几十毫秒左右,因此需要做延迟
|
|
1309
1310
|
//默认检查次数为40 间隔为20ms
|
|
1310
|
-
|
|
1311
|
-
|
|
1311
|
+
let count = 0;
|
|
1312
|
+
let index = setInterval(function () {
|
|
1312
1313
|
if (count == 40) {
|
|
1313
1314
|
clearInterval(index);
|
|
1314
1315
|
_self._init($dom,opts);
|
|
@@ -1336,7 +1337,7 @@
|
|
|
1336
1337
|
* 返回true/false
|
|
1337
1338
|
*/
|
|
1338
1339
|
play: function(index, video, id, opts){
|
|
1339
|
-
|
|
1340
|
+
let me = this;
|
|
1340
1341
|
// if (me.isPlaying(id) != -1) {
|
|
1341
1342
|
// console.info('该视频正在播放');
|
|
1342
1343
|
// return false;
|
|
@@ -1367,7 +1368,7 @@
|
|
|
1367
1368
|
* 返回true/false
|
|
1368
1369
|
*/
|
|
1369
1370
|
playByOrder: function(video, id, opts){
|
|
1370
|
-
|
|
1371
|
+
let freeWindow = this._getMinIndexFreeWindow();
|
|
1371
1372
|
|
|
1372
1373
|
if(freeWindow == -1 ||
|
|
1373
1374
|
(this._getChoiceWindow() != -1 && !this.getInChoiceVideo() && this._opts.windowsNum > 1)){
|
|
@@ -1381,19 +1382,19 @@
|
|
|
1381
1382
|
* 扩展视频窗口数的播放方式
|
|
1382
1383
|
*/
|
|
1383
1384
|
playByOrderExpandWindow: function(video, id, opts){
|
|
1384
|
-
|
|
1385
|
+
let me = this;
|
|
1385
1386
|
|
|
1386
|
-
|
|
1387
|
+
let freeWindow = this._getMinIndexFreeWindow();
|
|
1387
1388
|
|
|
1388
1389
|
// while (this._opts.windows < 16 && freeWindow == -1) {
|
|
1389
1390
|
// me.setWindowsNum(me._getNextWindowsNum(parseInt(me._opts.windows)));
|
|
1390
1391
|
// freeWindow = this._getMinIndexFreeWindow(0);
|
|
1391
1392
|
// }
|
|
1392
1393
|
|
|
1393
|
-
|
|
1394
|
+
let maxWindows = this._opts.windowsNum || 16;
|
|
1394
1395
|
|
|
1395
1396
|
while (me._opts.windows < maxWindows && freeWindow == -1) {
|
|
1396
|
-
|
|
1397
|
+
let zoom = Math.sqrt(this._opts.windows*1)+1;
|
|
1397
1398
|
|
|
1398
1399
|
if (this._opts.windows == 6) {
|
|
1399
1400
|
this.setWindowsNum(9);
|
|
@@ -1423,7 +1424,7 @@
|
|
|
1423
1424
|
if (array.length > this._opts.windows) {
|
|
1424
1425
|
throw new Error('windows is not enough');
|
|
1425
1426
|
}
|
|
1426
|
-
|
|
1427
|
+
let me = this;
|
|
1427
1428
|
me.closeAll();
|
|
1428
1429
|
$.each(array,function(i,obj){
|
|
1429
1430
|
me.play(i, obj.video, obj.id, obj.opts);
|
|
@@ -1434,8 +1435,8 @@
|
|
|
1434
1435
|
* 在鼠标选中的窗口中播放视频
|
|
1435
1436
|
*/
|
|
1436
1437
|
playInChoice: function(video, id, opts){
|
|
1437
|
-
|
|
1438
|
-
|
|
1438
|
+
let me = this;
|
|
1439
|
+
let selView = $('[video-flag="'+me._opts.windowsBeginIndex+'"]>li.sel');
|
|
1439
1440
|
if(selView.length){
|
|
1440
1441
|
if (me.VIDEO_DATA[selView.index()].playing) {
|
|
1441
1442
|
me.close(selView.index());
|
|
@@ -1453,8 +1454,8 @@
|
|
|
1453
1454
|
* 检索当前点的视频是否被播放,被播放则返回播放的视频窗口
|
|
1454
1455
|
*/
|
|
1455
1456
|
isPlaying: function(id){
|
|
1456
|
-
|
|
1457
|
-
|
|
1457
|
+
let me = this;
|
|
1458
|
+
let index = -1;
|
|
1458
1459
|
$.each(me.VIDEO_DATA,function(key,val){
|
|
1459
1460
|
if (id == val.id && me.VIDEO_DATA[key].playing) {
|
|
1460
1461
|
index = key;
|
|
@@ -1467,7 +1468,7 @@
|
|
|
1467
1468
|
* 判断指定窗口是否正在播放视频
|
|
1468
1469
|
*/
|
|
1469
1470
|
isPlayingByIndex: function(index){
|
|
1470
|
-
|
|
1471
|
+
let me = this;
|
|
1471
1472
|
if (index > me.VIDEO_DATA.length - 1 || index < 0) return false;
|
|
1472
1473
|
|
|
1473
1474
|
return me.VIDEO_DATA[index].playing;
|
|
@@ -1501,19 +1502,19 @@
|
|
|
1501
1502
|
* 关闭指定视频编号正在播放的视频
|
|
1502
1503
|
*/
|
|
1503
1504
|
closeByVideo: function(video, isSave){
|
|
1504
|
-
|
|
1505
|
+
let me = this;
|
|
1505
1506
|
|
|
1506
1507
|
if (video == undefined) {
|
|
1507
1508
|
console.info('video参数错误');
|
|
1508
1509
|
return;
|
|
1509
1510
|
}
|
|
1510
1511
|
|
|
1511
|
-
|
|
1512
|
+
let videoData = me.VIDEO_DATA;
|
|
1512
1513
|
if (!videoData || videoData.length == 0) {
|
|
1513
1514
|
return;
|
|
1514
1515
|
}
|
|
1515
1516
|
|
|
1516
|
-
for (
|
|
1517
|
+
for (let i in videoData) {
|
|
1517
1518
|
if (video == videoData[i].video) {
|
|
1518
1519
|
me.close(videoData[i].index);
|
|
1519
1520
|
|
|
@@ -1528,10 +1529,10 @@
|
|
|
1528
1529
|
* 关闭所有视频
|
|
1529
1530
|
*/
|
|
1530
1531
|
closeAll: function(isSave){
|
|
1531
|
-
|
|
1532
|
+
let me = this;
|
|
1532
1533
|
|
|
1533
|
-
|
|
1534
|
-
for(
|
|
1534
|
+
let openVideos = [];
|
|
1535
|
+
for(let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++){
|
|
1535
1536
|
if(me.VIDEO_DATA[i].playing){
|
|
1536
1537
|
me.close(i, isSave)
|
|
1537
1538
|
}
|
|
@@ -1540,8 +1541,8 @@
|
|
|
1540
1541
|
// if(!openVideos.length) return;
|
|
1541
1542
|
//
|
|
1542
1543
|
// //适当延时进行关闭
|
|
1543
|
-
//
|
|
1544
|
-
//
|
|
1544
|
+
// let count = 0;
|
|
1545
|
+
// let interval = setInterval(function(){
|
|
1545
1546
|
// if(count == openVideos.length){
|
|
1546
1547
|
// clearInterval(interval);
|
|
1547
1548
|
// }else{
|
|
@@ -1569,7 +1570,7 @@
|
|
|
1569
1570
|
* 分屏切换,传入的参数为新的屏数
|
|
1570
1571
|
*/
|
|
1571
1572
|
setWindowsNum: function(num) {
|
|
1572
|
-
|
|
1573
|
+
let me = this;
|
|
1573
1574
|
|
|
1574
1575
|
//切换屏幕后 选中空闲最小的窗口
|
|
1575
1576
|
if (me._opts.windows != num && me._getMinIndexFreeWindow() != -1) {
|
|
@@ -1577,9 +1578,9 @@
|
|
|
1577
1578
|
}
|
|
1578
1579
|
|
|
1579
1580
|
$('[video-flag="'+me._opts.windowsBeginIndex+'"]').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
|
|
1580
|
-
|
|
1581
|
+
let _li = $('[video-flag="'+me._opts.windowsBeginIndex+'"]>li').hide();
|
|
1581
1582
|
me._opts.windows = num;
|
|
1582
|
-
for(
|
|
1583
|
+
for(let i = 0; i < num; i++){
|
|
1583
1584
|
_li.eq(i).show();
|
|
1584
1585
|
}
|
|
1585
1586
|
//分屏切换事件
|
|
@@ -1604,7 +1605,7 @@
|
|
|
1604
1605
|
|
|
1605
1606
|
time = $.isNumeric(time) ? time : this._opts.pollInterval;
|
|
1606
1607
|
this._pollArray = array;
|
|
1607
|
-
|
|
1608
|
+
let me = this,
|
|
1608
1609
|
windowNum = me._opts.windows,
|
|
1609
1610
|
maxNum = array.length,
|
|
1610
1611
|
nowNum = 0 ;
|
|
@@ -1614,7 +1615,7 @@
|
|
|
1614
1615
|
me.closeAll();
|
|
1615
1616
|
|
|
1616
1617
|
wait(500).then(function(){
|
|
1617
|
-
for(
|
|
1618
|
+
for(let i = 0; i < windowNum; i++) {
|
|
1618
1619
|
if(nowNum == maxNum){
|
|
1619
1620
|
nowNum = 0;
|
|
1620
1621
|
if(maxNum < windowNum) {
|
|
@@ -1661,7 +1662,7 @@
|
|
|
1661
1662
|
},
|
|
1662
1663
|
|
|
1663
1664
|
holder: function(type, opts, isStop) {
|
|
1664
|
-
|
|
1665
|
+
let index = this._getChoiceWindow();
|
|
1665
1666
|
if (index < 0) {
|
|
1666
1667
|
promptFailed('请先选中视频');
|
|
1667
1668
|
return false;
|
|
@@ -1676,9 +1677,9 @@
|
|
|
1676
1677
|
* @return playId
|
|
1677
1678
|
*/
|
|
1678
1679
|
playHistory: function(video, startTime, endTime, opts) {
|
|
1679
|
-
|
|
1680
|
+
let me = this;
|
|
1680
1681
|
|
|
1681
|
-
|
|
1682
|
+
let index;
|
|
1682
1683
|
//回放是一分屏的默认使用一个窗口
|
|
1683
1684
|
if (me._opts.windowsNum == 1) {
|
|
1684
1685
|
index = me._opts.windowsBeginIndex;
|
|
@@ -1701,10 +1702,10 @@
|
|
|
1701
1702
|
closeHistory: function(video, index) {
|
|
1702
1703
|
if (!video) return;
|
|
1703
1704
|
|
|
1704
|
-
|
|
1705
|
+
let me = this;
|
|
1705
1706
|
|
|
1706
1707
|
if (!index) {
|
|
1707
|
-
|
|
1708
|
+
let index;
|
|
1708
1709
|
if (me._opts.windowsNum == 1) {
|
|
1709
1710
|
index = me._opts.windowsBeginIndex;
|
|
1710
1711
|
}
|
|
@@ -1721,8 +1722,8 @@
|
|
|
1721
1722
|
* @param {string} startTime 回放时间(暂时无用)
|
|
1722
1723
|
*/
|
|
1723
1724
|
historyControl: function(video, playType, playSpeed, startTime) {
|
|
1724
|
-
|
|
1725
|
-
|
|
1725
|
+
let me = this;
|
|
1726
|
+
let index;
|
|
1726
1727
|
if (me._opts.windowsNum == 1) {
|
|
1727
1728
|
index = me._opts.windowsBeginIndex;
|
|
1728
1729
|
} else {
|
|
@@ -1741,7 +1742,7 @@
|
|
|
1741
1742
|
return;
|
|
1742
1743
|
}
|
|
1743
1744
|
this.closeAll();
|
|
1744
|
-
|
|
1745
|
+
let me = this;
|
|
1745
1746
|
$.each(this._saveList, function(index, obj){
|
|
1746
1747
|
if (obj.video) {
|
|
1747
1748
|
me.play(obj.index, obj.video, obj.id, obj.opts);
|
|
@@ -1753,8 +1754,8 @@
|
|
|
1753
1754
|
* 获取当前选择窗口的视频video
|
|
1754
1755
|
*/
|
|
1755
1756
|
getInChoiceVideo: function() {
|
|
1756
|
-
|
|
1757
|
-
|
|
1757
|
+
let me = this;
|
|
1758
|
+
let selView = $('[video-flag="'+me._opts.windowsBeginIndex+'"]>li.sel');
|
|
1758
1759
|
if(selView.length && me.VIDEO_DATA[selView.index()].video){
|
|
1759
1760
|
return me.VIDEO_DATA[selView.index()];
|
|
1760
1761
|
}
|
|
@@ -1780,27 +1781,27 @@
|
|
|
1780
1781
|
* @param callback 回调函数
|
|
1781
1782
|
*/
|
|
1782
1783
|
getScreenCaptureData: function(index, callback) {
|
|
1783
|
-
|
|
1784
|
+
let me = this;
|
|
1784
1785
|
|
|
1785
1786
|
//如果index为空则使用选中窗口的index
|
|
1786
|
-
|
|
1787
|
+
let dataObj = me.VIDEO_DATA[index != undefined ? index : me._getChoiceWindow()];
|
|
1787
1788
|
|
|
1788
1789
|
if (!dataObj.playing) {
|
|
1789
1790
|
promptAlarm('请选择播放的视频源!');
|
|
1790
1791
|
return;
|
|
1791
1792
|
}
|
|
1792
1793
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1794
|
+
let canvasObj = document.getElementById('myCanvas');
|
|
1795
|
+
let videoObj = dataObj.tagBox.get(0);
|
|
1795
1796
|
|
|
1796
1797
|
canvasObj.width = dataObj.tagBox.parent().width();
|
|
1797
1798
|
canvasObj.height = dataObj.tagBox.parent().height();
|
|
1798
1799
|
|
|
1799
|
-
|
|
1800
|
+
let ctx = canvasObj.getContext("2d");
|
|
1800
1801
|
ctx.drawImage(videoObj, 0, 0, dataObj.tagBox.parent().width(),
|
|
1801
1802
|
dataObj.tagBox.parent().height());
|
|
1802
1803
|
|
|
1803
|
-
|
|
1804
|
+
let dataUrl = canvasObj.toDataURL('image/jpeg');
|
|
1804
1805
|
callback ? callback(dataUrl) : null;
|
|
1805
1806
|
},
|
|
1806
1807
|
|
|
@@ -1808,7 +1809,7 @@
|
|
|
1808
1809
|
* 开始录像
|
|
1809
1810
|
*/
|
|
1810
1811
|
startAvRecord: function(index) {
|
|
1811
|
-
|
|
1812
|
+
let me = this;
|
|
1812
1813
|
return me.VIDEO_DATA[index].recordAv("start_av_record", recordAvBusinessId);
|
|
1813
1814
|
},
|
|
1814
1815
|
|
|
@@ -1816,7 +1817,7 @@
|
|
|
1816
1817
|
* 结束录像
|
|
1817
1818
|
*/
|
|
1818
1819
|
stopAvRecord: function(index) {
|
|
1819
|
-
|
|
1820
|
+
let me = this;
|
|
1820
1821
|
return me.VIDEO_DATA[index].recordAv("stop_av_record", recordAvBusinessId);
|
|
1821
1822
|
},
|
|
1822
1823
|
|
|
@@ -1825,7 +1826,7 @@
|
|
|
1825
1826
|
* @param resolution 新分辨率
|
|
1826
1827
|
*/
|
|
1827
1828
|
changeResolution: function(index, resolution) {
|
|
1828
|
-
|
|
1829
|
+
let me = this;
|
|
1829
1830
|
return me.VIDEO_DATA[index].changeResolution("change_resolution", resolution);
|
|
1830
1831
|
},
|
|
1831
1832
|
|
|
@@ -1835,9 +1836,9 @@
|
|
|
1835
1836
|
* @param centerTel 调度中心号
|
|
1836
1837
|
*/
|
|
1837
1838
|
openPocCall: function(pocNo, centerTel) {
|
|
1838
|
-
|
|
1839
|
+
let me = this;
|
|
1839
1840
|
|
|
1840
|
-
|
|
1841
|
+
let index;
|
|
1841
1842
|
//对讲预呼叫默认使用一个窗口
|
|
1842
1843
|
if (me._opts.windowsNum == 1) {
|
|
1843
1844
|
index = me._opts.windowsBeginIndex;
|
|
@@ -1858,9 +1859,9 @@
|
|
|
1858
1859
|
* @param centerTel 调度中心号
|
|
1859
1860
|
*/
|
|
1860
1861
|
closePocCall: function(pocNo, centerTel) {
|
|
1861
|
-
|
|
1862
|
+
let me = this;
|
|
1862
1863
|
|
|
1863
|
-
|
|
1864
|
+
let index;
|
|
1864
1865
|
//对讲预呼叫默认使用一个窗口
|
|
1865
1866
|
if (me._opts.windowsNum == 1) {
|
|
1866
1867
|
index = me._opts.windowsBeginIndex;
|
|
@@ -1881,7 +1882,7 @@
|
|
|
1881
1882
|
* @param businessId 业务ID
|
|
1882
1883
|
*/
|
|
1883
1884
|
setRecordAvBusinessId: function(businessId) {
|
|
1884
|
-
//
|
|
1885
|
+
//let me = this;
|
|
1885
1886
|
recordAvBusinessId = businessId;
|
|
1886
1887
|
},
|
|
1887
1888
|
|
|
@@ -1889,8 +1890,8 @@
|
|
|
1889
1890
|
* 开启音频
|
|
1890
1891
|
*/
|
|
1891
1892
|
sendAudio: function(index) {
|
|
1892
|
-
|
|
1893
|
-
|
|
1893
|
+
let me = this;
|
|
1894
|
+
index = (index != undefined ? index : me._opts.windowsBeginIndex);
|
|
1894
1895
|
me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = true;
|
|
1895
1896
|
},
|
|
1896
1897
|
|
|
@@ -1898,8 +1899,8 @@
|
|
|
1898
1899
|
* 关闭音频
|
|
1899
1900
|
*/
|
|
1900
1901
|
unSendAudio: function(index) {
|
|
1901
|
-
|
|
1902
|
-
|
|
1902
|
+
let me = this;
|
|
1903
|
+
index = (index != undefined ? index : me._opts.windowsBeginIndex);
|
|
1903
1904
|
me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = false;
|
|
1904
1905
|
},
|
|
1905
1906
|
|
|
@@ -1927,7 +1928,7 @@
|
|
|
1927
1928
|
* 获取编号最小的空闲窗口的编号
|
|
1928
1929
|
*/
|
|
1929
1930
|
_getMinIndexFreeWindow: function(index) {
|
|
1930
|
-
|
|
1931
|
+
let me = this;
|
|
1931
1932
|
index = index || me._opts.windowsBeginIndex;
|
|
1932
1933
|
for (; index < me._opts.windowsBeginIndex + me._opts.windows ; index++) {
|
|
1933
1934
|
if (!me.VIDEO_DATA[index].playing) {
|
|
@@ -1941,8 +1942,8 @@
|
|
|
1941
1942
|
* 获取选中的窗口的index
|
|
1942
1943
|
*/
|
|
1943
1944
|
_getChoiceWindow: function() {
|
|
1944
|
-
|
|
1945
|
-
|
|
1945
|
+
let me = this;
|
|
1946
|
+
let selView = $('[video-flag="' + me._opts.windowsBeginIndex+'"]>li.sel');
|
|
1946
1947
|
if (selView.length) {
|
|
1947
1948
|
return selView.index();
|
|
1948
1949
|
}
|
|
@@ -1953,9 +1954,9 @@
|
|
|
1953
1954
|
* 获取下一窗口
|
|
1954
1955
|
*/
|
|
1955
1956
|
_getNextWindowsNum: function(old) {
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
for (
|
|
1957
|
+
let me = this;
|
|
1958
|
+
let windowsArr = me._windowsArr;
|
|
1959
|
+
for (let index in windowsArr){
|
|
1959
1960
|
if (index == windowsArr.length - 1) {
|
|
1960
1961
|
return windowsArr[index]
|
|
1961
1962
|
}
|
|
@@ -1969,7 +1970,7 @@
|
|
|
1969
1970
|
* 设置鼠标选中窗口
|
|
1970
1971
|
*/
|
|
1971
1972
|
_clickWindow: function() {
|
|
1972
|
-
|
|
1973
|
+
let me = this;
|
|
1973
1974
|
//视频窗口选中
|
|
1974
1975
|
$('[video-flag="'+me._opts.windowsBeginIndex+'"]>li').click(function(){
|
|
1975
1976
|
$('[video-flag="'+me._opts.windowsBeginIndex+'"]>li').removeClass("sel");
|
|
@@ -1985,7 +1986,7 @@
|
|
|
1985
1986
|
/*
|
|
1986
1987
|
* 总的初始化
|
|
1987
1988
|
* 参数示例:
|
|
1988
|
-
*
|
|
1989
|
+
* let opts = {
|
|
1989
1990
|
windows: 4, //初始化的窗口数
|
|
1990
1991
|
conf: { //配置参数
|
|
1991
1992
|
user: 'admin', //用户名
|
|
@@ -1996,7 +1997,7 @@
|
|
|
1996
1997
|
};
|
|
1997
1998
|
*/
|
|
1998
1999
|
_init: function($dom,opts){
|
|
1999
|
-
|
|
2000
|
+
let me = this;
|
|
2000
2001
|
//配置项
|
|
2001
2002
|
me._opts = {
|
|
2002
2003
|
windows: 4,
|
|
@@ -2008,14 +2009,14 @@
|
|
|
2008
2009
|
|
|
2009
2010
|
$.extend(me._opts,opts);
|
|
2010
2011
|
|
|
2011
|
-
|
|
2012
|
+
let windowsArr = me._opts.windowsArr;
|
|
2012
2013
|
if (!windowsArr || windowsArr.length == 0) {
|
|
2013
2014
|
me._windowList = {1:{}, 4:{}, 6:{}, 9:{}, 16:{}}
|
|
2014
2015
|
me._windowsArr = [1, 4, 6, 9, 16];
|
|
2015
2016
|
} else {
|
|
2016
2017
|
me._windowList = {};
|
|
2017
|
-
for (
|
|
2018
|
-
|
|
2018
|
+
for (let index in windowsArr){
|
|
2019
|
+
let item = windowsArr[index];
|
|
2019
2020
|
me._windowList[item] = {};
|
|
2020
2021
|
}
|
|
2021
2022
|
me._windowsArr = windowsArr;
|
|
@@ -2047,12 +2048,12 @@
|
|
|
2047
2048
|
* 初始化按钮点击事件
|
|
2048
2049
|
*/
|
|
2049
2050
|
_initBtnEvent: function() {
|
|
2050
|
-
|
|
2051
|
-
|
|
2051
|
+
let me = this;
|
|
2052
|
+
let videoFlagObj = $('[video-flag="'+me._opts.windowsBeginIndex+'"]');
|
|
2052
2053
|
|
|
2053
2054
|
//锁定视频事件
|
|
2054
2055
|
videoFlagObj.find("button[name='lockVideo']").click(function(){
|
|
2055
|
-
|
|
2056
|
+
let index = Number($(this).parent().parent().attr("index"));
|
|
2056
2057
|
|
|
2057
2058
|
if (!me.VIDEO_DATA[index].playing) {
|
|
2058
2059
|
promptAlarm('请选择播放的视频源!');
|
|
@@ -2070,8 +2071,8 @@
|
|
|
2070
2071
|
|
|
2071
2072
|
//接收音频事件
|
|
2072
2073
|
videoFlagObj.find("button[name='recvAudio']").click(function(){
|
|
2073
|
-
|
|
2074
|
-
|
|
2074
|
+
let _self = this;
|
|
2075
|
+
let index = Number($(this).parent().parent().attr("index"));
|
|
2075
2076
|
|
|
2076
2077
|
if (!me.VIDEO_DATA[index].playing) {
|
|
2077
2078
|
promptAlarm('请选择播放的视频源!');
|
|
@@ -2085,14 +2086,14 @@
|
|
|
2085
2086
|
me.VIDEO_DATA[index].tagBox.muted = false;
|
|
2086
2087
|
} else {
|
|
2087
2088
|
//发送前先关闭其它音频通道(包括接收和发送音频)
|
|
2088
|
-
|
|
2089
|
-
for (
|
|
2090
|
-
|
|
2089
|
+
let lis = $($(_self).parent().parent().parent()).children();
|
|
2090
|
+
for (let i = 0; i < lis.length; i++) {
|
|
2091
|
+
let btnIndex = Number($(lis[i]).attr("index"));
|
|
2091
2092
|
if (index == btnIndex) {
|
|
2092
2093
|
continue;
|
|
2093
2094
|
}
|
|
2094
|
-
|
|
2095
|
-
|
|
2095
|
+
let recvBtn = $($(lis[i]).find("button[name='recvAudio']")[0]);
|
|
2096
|
+
let sendBtn = $($(lis[i]).find("button[name='sendAudio']")[0]);
|
|
2096
2097
|
|
|
2097
2098
|
if (recvBtn.attr("class") == 'recv-audio-btn') {
|
|
2098
2099
|
if (me.VIDEO_DATA[btnIndex].playing) {
|
|
@@ -2116,7 +2117,7 @@
|
|
|
2116
2117
|
|
|
2117
2118
|
//发送音频事件
|
|
2118
2119
|
videoFlagObj.find("button[name='sendAudio']").click(function(){
|
|
2119
|
-
|
|
2120
|
+
let index = Number($(this).parent().parent().attr("index"));
|
|
2120
2121
|
|
|
2121
2122
|
if (!me.VIDEO_DATA[index].playing) {
|
|
2122
2123
|
promptAlarm('请选择播放的视频源!');
|
|
@@ -2136,7 +2137,7 @@
|
|
|
2136
2137
|
|
|
2137
2138
|
//关闭视频事件
|
|
2138
2139
|
videoFlagObj.find("button[name='closeVideo']").click(function(){
|
|
2139
|
-
|
|
2140
|
+
let index = Number($(this).parent().parent().attr("index"));
|
|
2140
2141
|
me.close(index);
|
|
2141
2142
|
});
|
|
2142
2143
|
},
|
|
@@ -2145,7 +2146,7 @@
|
|
|
2145
2146
|
* 双击某个视频全屏
|
|
2146
2147
|
*/
|
|
2147
2148
|
_dbClickFullScreen: function() {
|
|
2148
|
-
|
|
2149
|
+
let me = this;
|
|
2149
2150
|
$('[video-flag="'+me._opts.windowsBeginIndex+'"]').find('.video-box').on("dblclick",function(){
|
|
2150
2151
|
me._fullScreenEvent(this);
|
|
2151
2152
|
});
|
|
@@ -2155,7 +2156,7 @@
|
|
|
2155
2156
|
* 全屏事件
|
|
2156
2157
|
*/
|
|
2157
2158
|
_fullScreenEvent: function(el) {
|
|
2158
|
-
|
|
2159
|
+
let isFullscreen = el.fullScreen || el.mozFullScreen || el.webkitIsFullScreen;
|
|
2159
2160
|
if(!isFullscreen){//进入全屏,多重短路表达式
|
|
2160
2161
|
(el.requestFullscreen && el.requestFullscreen()) ||
|
|
2161
2162
|
(el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
|
|
@@ -2179,27 +2180,27 @@
|
|
|
2179
2180
|
* 在视频界面上显示视频的信息 码率、分辨率、丢包率
|
|
2180
2181
|
*/
|
|
2181
2182
|
_showVideoInfo: function() {
|
|
2182
|
-
|
|
2183
|
+
let me = this;
|
|
2183
2184
|
function clock(){
|
|
2184
|
-
for (
|
|
2185
|
+
for (let i = 0; i < me.VIDEO_DATA.length; i++) {
|
|
2185
2186
|
if (me.VIDEO_DATA[i].playing) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2187
|
+
let number = Number(i) + Number(1);
|
|
2188
|
+
let videoObj = document.getElementById('video-' + number);
|
|
2188
2189
|
|
|
2189
2190
|
if (!videoObj) continue;
|
|
2190
2191
|
|
|
2191
|
-
|
|
2192
|
-
|
|
2192
|
+
let width = videoObj.videoWidth;
|
|
2193
|
+
let height = videoObj.videoHeight;
|
|
2193
2194
|
|
|
2194
2195
|
//码率
|
|
2195
|
-
|
|
2196
|
+
let bitrate = me.VIDEO_DATA[i].sipcall.getBitrate();
|
|
2196
2197
|
if (!width || !height || !bitrate || bitrate.indexOf("kbits") == -1 || bitrate.indexOf("NaN") != -1) {
|
|
2197
2198
|
continue;
|
|
2198
2199
|
}
|
|
2199
2200
|
|
|
2200
|
-
|
|
2201
|
+
let config = me.VIDEO_DATA[i].sipcall.webrtcStuff;
|
|
2201
2202
|
me._setPacketsLostRate(i, config, me);
|
|
2202
|
-
|
|
2203
|
+
let resolution = width + "×" + height;
|
|
2203
2204
|
switch(height + '') {
|
|
2204
2205
|
case '1080':
|
|
2205
2206
|
resolution = "1080P";
|
|
@@ -2217,8 +2218,8 @@
|
|
|
2217
2218
|
break;
|
|
2218
2219
|
}
|
|
2219
2220
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2221
|
+
let videoInfoObj = document.getElementById('info-' + number);
|
|
2222
|
+
let videoName = me.VIDEO_DATA[i].opts && me.VIDEO_DATA[i].opts.name ?
|
|
2222
2223
|
me.VIDEO_DATA[i].opts.name : me.VIDEO_DATA[i].video;
|
|
2223
2224
|
videoInfoObj.innerHTML = videoName + ' ' + resolution +
|
|
2224
2225
|
'<br>丢包率:' + me.VIDEO_DATA[i].packetsLostRate + ' ' + bitrate.replace("kbits/sec", "kbps");
|
|
@@ -2244,7 +2245,7 @@
|
|
|
2244
2245
|
if(!res) {
|
|
2245
2246
|
return;
|
|
2246
2247
|
}
|
|
2247
|
-
|
|
2248
|
+
let inStats = false;
|
|
2248
2249
|
// Check if these are statistics on incoming media
|
|
2249
2250
|
if((res.mediaType === "video" || res.id.toLowerCase().indexOf("video") > -1) &&
|
|
2250
2251
|
res.type === "inbound-rtp" && res.id.indexOf("rtcp") < 0) {
|
|
@@ -2262,13 +2263,13 @@
|
|
|
2262
2263
|
if (!res.packetsLost || isNaN(res.packetsLost) || Number(res.packetsLost) == '0' || res.packetsLost == 'NaN') {
|
|
2263
2264
|
me.VIDEO_DATA[index].packetsLostRate = '0.00%';
|
|
2264
2265
|
} else {
|
|
2265
|
-
|
|
2266
|
-
|
|
2266
|
+
let packetsLost = Number(res.packetsLost) - Number(me.VIDEO_DATA[index].packetsLostSum);
|
|
2267
|
+
let packetsReceived = Number(res.packetsReceived) - Number(me.VIDEO_DATA[index].packetsReceivedSum);
|
|
2267
2268
|
|
|
2268
|
-
|
|
2269
|
+
let packetsLostRate = 0;
|
|
2269
2270
|
//防止分母是0
|
|
2270
2271
|
if (packetsLost > 0) {
|
|
2271
|
-
|
|
2272
|
+
let packetsLostRate = (Number(packetsLost) / (Number(packetsLost) + Number(packetsReceived))) * 100;
|
|
2272
2273
|
}
|
|
2273
2274
|
me.VIDEO_DATA[index].packetsLostRate = packetsLostRate.toFixed(2) + '%';
|
|
2274
2275
|
}
|
|
@@ -2287,11 +2288,11 @@
|
|
|
2287
2288
|
* 视频界面的初始化,在传过来的dom中创建界面
|
|
2288
2289
|
*/
|
|
2289
2290
|
_initVideoView: function($dom) {
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
for (
|
|
2291
|
+
let me = this;
|
|
2292
|
+
let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
|
|
2293
|
+
let videoHtml = '<ul class="' + objClass +'" id="video-main-web-rtc" video-flag="'+me._opts.windowsBeginIndex+'">';
|
|
2294
|
+
let index = me._opts.windowsBeginIndex + 1;
|
|
2295
|
+
for (let i = index; i < index + me._opts.windowsNum; i++) {
|
|
2295
2296
|
videoHtml += '<li class="screen-' + i +'" index="' + (i - 1) +'"><video class="video-box" id="video-' + i +'" autoplay ></video>' +
|
|
2296
2297
|
'<div class="info hide" id="info-' + i +'"></div>' +
|
|
2297
2298
|
'<div class="operate-btn">';
|
|
@@ -2312,11 +2313,11 @@
|
|
|
2312
2313
|
* 音频界面的初始化,在传过来的dom中创建界面
|
|
2313
2314
|
*/
|
|
2314
2315
|
_initAudioView: function($dom) {
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
for (
|
|
2316
|
+
let me = this;
|
|
2317
|
+
let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
|
|
2318
|
+
let videoHtml = '<ul class="' + objClass +'" id="video-main-web-rtc" video-flag="'+me._opts.windowsBeginIndex+'">';
|
|
2319
|
+
let index = me._opts.windowsBeginIndex + 1;
|
|
2320
|
+
for (let i = index; i < index + me._opts.windowsNum; i++) {
|
|
2320
2321
|
videoHtml += '<audio id="audio-' + i +'" autoplay ></video>';
|
|
2321
2322
|
}
|
|
2322
2323
|
$dom.append(videoHtml);
|
|
@@ -2326,7 +2327,7 @@
|
|
|
2326
2327
|
* Janus的初始化
|
|
2327
2328
|
*/
|
|
2328
2329
|
_initJanus: function(){
|
|
2329
|
-
|
|
2330
|
+
let me = this;
|
|
2330
2331
|
|
|
2331
2332
|
// if (window.parent && window.parent.janus) {
|
|
2332
2333
|
// me._initSVideo(window.parent.janus);
|
|
@@ -2344,7 +2345,7 @@
|
|
|
2344
2345
|
return;
|
|
2345
2346
|
}
|
|
2346
2347
|
|
|
2347
|
-
|
|
2348
|
+
let janusUrl = me._opts.conf.janusUrl;
|
|
2348
2349
|
checkIsHttps() && (janusUrl = janusUrl.replace('ws:','wss:'));
|
|
2349
2350
|
me._opts.janus = new Janus({
|
|
2350
2351
|
server: janusUrl.indexOf("127.0.0.1") == -1 ? janusUrl : janusUrl.split("//")[0] + "//" + (location.hostname)+":"+janusUrl.split(":")[2],
|
|
@@ -2374,7 +2375,7 @@
|
|
|
2374
2375
|
* 销毁:Janus销毁、资源释放
|
|
2375
2376
|
*/
|
|
2376
2377
|
destoryJanus: function() {
|
|
2377
|
-
|
|
2378
|
+
let me = this;
|
|
2378
2379
|
me._opts.janus.destroy({
|
|
2379
2380
|
success: function() {
|
|
2380
2381
|
window.windowsSum = 0;
|
|
@@ -2391,12 +2392,12 @@
|
|
|
2391
2392
|
* 初始化插件、登陆,初始化窗口
|
|
2392
2393
|
*/
|
|
2393
2394
|
_initSVideo: function(janus){
|
|
2394
|
-
|
|
2395
|
+
let me = this;
|
|
2395
2396
|
|
|
2396
2397
|
//已经初始化过,则直接拿来用
|
|
2397
2398
|
// if (janus && (registered || (window.parent && window.parent.registered))) {
|
|
2398
2399
|
// //生成主界面
|
|
2399
|
-
// for(
|
|
2400
|
+
// for(let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++){
|
|
2400
2401
|
// me.VIDEO_DATA[i] = new SVideo({
|
|
2401
2402
|
// index:i,
|
|
2402
2403
|
// janus:janus
|
|
@@ -2407,14 +2408,14 @@
|
|
|
2407
2408
|
// }
|
|
2408
2409
|
|
|
2409
2410
|
//初始化一个插件,用来登陆,不能用此插件播放视频。
|
|
2410
|
-
|
|
2411
|
+
let _loginSipCall = null;
|
|
2411
2412
|
janus.attach({
|
|
2412
2413
|
plugin: me._opts.conf.janusPlugin ? me._opts.conf.janusPlugin : "janus.plugin.videoserver",
|
|
2413
2414
|
opaqueId: "siptest-" + Janus.randomString(12),
|
|
2414
2415
|
success: function(pluginHandle) {
|
|
2415
2416
|
console.log("Janus登陆插件初始化成功!");
|
|
2416
2417
|
_loginSipCall = pluginHandle;
|
|
2417
|
-
|
|
2418
|
+
let register = {
|
|
2418
2419
|
"request" : "register",
|
|
2419
2420
|
"username" : me._opts.conf.user,
|
|
2420
2421
|
"secret": me._opts.conf.passwd,
|
|
@@ -2432,8 +2433,8 @@
|
|
|
2432
2433
|
return false;
|
|
2433
2434
|
}
|
|
2434
2435
|
|
|
2435
|
-
|
|
2436
|
-
|
|
2436
|
+
let result = msg["result"];
|
|
2437
|
+
let event = result["event"];
|
|
2437
2438
|
|
|
2438
2439
|
if (result.error_code && result.error_code != 0) {
|
|
2439
2440
|
promptFailed(FAILED_CODE[result.error_code] || '错误码:' + result.error_code);
|
|
@@ -2446,12 +2447,12 @@
|
|
|
2446
2447
|
return;
|
|
2447
2448
|
}
|
|
2448
2449
|
if(event === 'registered') {
|
|
2449
|
-
|
|
2450
|
+
let userToken = result["userToken"];
|
|
2450
2451
|
console.log('janus登陆成功')
|
|
2451
2452
|
registered = true;
|
|
2452
2453
|
|
|
2453
2454
|
//生成主界面
|
|
2454
|
-
for(
|
|
2455
|
+
for(let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++){
|
|
2455
2456
|
me.VIDEO_DATA[i] = new SVideo({
|
|
2456
2457
|
index: i,
|
|
2457
2458
|
janus: janus,
|
|
@@ -2470,7 +2471,7 @@
|
|
|
2470
2471
|
|
|
2471
2472
|
}
|
|
2472
2473
|
|
|
2473
|
-
|
|
2474
|
+
let FAILED_CODE = {
|
|
2474
2475
|
1001 : "账号或密码错误",
|
|
2475
2476
|
1002 : "该帐号已连接",
|
|
2476
2477
|
1004 : "没有鉴权",
|
|
@@ -2495,13 +2496,13 @@
|
|
|
2495
2496
|
4006 : "终端离开云眼音频"
|
|
2496
2497
|
}
|
|
2497
2498
|
|
|
2498
|
-
|
|
2499
|
+
let STATUS_CODE_ARR = ['5002', '4003', '4004', '4005', '4006'];
|
|
2499
2500
|
|
|
2500
2501
|
//window.VIDEO_DATA = [];//记录视频各分屏的状态
|
|
2501
2502
|
window.windowsSum = 0; //当前页面的视频总数,可能有多个VideoWebRtc对象
|
|
2502
|
-
//
|
|
2503
|
-
|
|
2504
|
-
|
|
2503
|
+
//let userToken = null;
|
|
2504
|
+
let registered = false;
|
|
2505
|
+
let recordAvBusinessId = null;
|
|
2505
2506
|
|
|
2506
2507
|
function SVideo (opts) {
|
|
2507
2508
|
this.janus = opts.janus;
|
|
@@ -2525,7 +2526,7 @@
|
|
|
2525
2526
|
* 初始化
|
|
2526
2527
|
*/
|
|
2527
2528
|
init:function(){
|
|
2528
|
-
|
|
2529
|
+
let self = this;
|
|
2529
2530
|
|
|
2530
2531
|
self.janus.attach({
|
|
2531
2532
|
plugin: self.janusPlugin ? self.janusPlugin : "janus.plugin.videoserver",
|
|
@@ -2560,7 +2561,7 @@
|
|
|
2560
2561
|
return false;
|
|
2561
2562
|
}
|
|
2562
2563
|
|
|
2563
|
-
|
|
2564
|
+
let result = msg["result"];
|
|
2564
2565
|
if (!result) return;
|
|
2565
2566
|
if (result.error_code && result.error_code != 0) {
|
|
2566
2567
|
//videoListener.dispatch('afterclose', self);
|
|
@@ -2568,7 +2569,7 @@
|
|
|
2568
2569
|
if (!STATUS_CODE_ARR.includes(result.error_code + '')) {
|
|
2569
2570
|
//videoListener.dispatch('afterclose', self);
|
|
2570
2571
|
//播放失败 关闭视频
|
|
2571
|
-
|
|
2572
|
+
let video = self.video;
|
|
2572
2573
|
self.close('err');
|
|
2573
2574
|
|
|
2574
2575
|
if (self.isLockVideo) {
|
|
@@ -2586,7 +2587,7 @@
|
|
|
2586
2587
|
}
|
|
2587
2588
|
|
|
2588
2589
|
//事件响应
|
|
2589
|
-
|
|
2590
|
+
let event = result["event"];
|
|
2590
2591
|
if (!event) return;
|
|
2591
2592
|
switch(event) {
|
|
2592
2593
|
//即将播放视频
|
|
@@ -2595,7 +2596,7 @@
|
|
|
2595
2596
|
jsep: jsep,
|
|
2596
2597
|
media: { audioSend: checkUserMediaAvailable(), videoSend:false, audioRecv: true , videoRecv: true},
|
|
2597
2598
|
success: function(jsep) {
|
|
2598
|
-
|
|
2599
|
+
let body = {
|
|
2599
2600
|
request:"accept",
|
|
2600
2601
|
videoidentify: result["videoidentify"],
|
|
2601
2602
|
playseq: parseInt(result["playseq"]),
|
|
@@ -2605,7 +2606,7 @@
|
|
|
2605
2606
|
},
|
|
2606
2607
|
error: function(error) {
|
|
2607
2608
|
console.error(error);
|
|
2608
|
-
|
|
2609
|
+
let body = { "request": "decline", "code": 480 };
|
|
2609
2610
|
self.sipcall.send({"message": body});
|
|
2610
2611
|
}
|
|
2611
2612
|
});
|
|
@@ -2644,7 +2645,7 @@
|
|
|
2644
2645
|
jsep: jsep,
|
|
2645
2646
|
media: {audioSend: checkUserMediaAvailable(), videoSend:false, audioRecv: true , videoRecv: false},
|
|
2646
2647
|
success: function(jsep) {
|
|
2647
|
-
|
|
2648
|
+
let body = {
|
|
2648
2649
|
request:"accept",
|
|
2649
2650
|
userToken: self.userToken,
|
|
2650
2651
|
};
|
|
@@ -2652,7 +2653,7 @@
|
|
|
2652
2653
|
},
|
|
2653
2654
|
error: function(error) {
|
|
2654
2655
|
console.error(error);
|
|
2655
|
-
//
|
|
2656
|
+
// let body = { "request": "decline", "code": 480 };
|
|
2656
2657
|
// self.sipcall.send({"message": body});
|
|
2657
2658
|
}
|
|
2658
2659
|
});
|
|
@@ -2682,14 +2683,14 @@
|
|
|
2682
2683
|
self.stream = stream;
|
|
2683
2684
|
|
|
2684
2685
|
// Janus.attachMediaStream(self.tagBox.get(0), stream);
|
|
2685
|
-
//
|
|
2686
|
+
// let s = stream.getAudioTracks()[0];
|
|
2686
2687
|
// stream.removeTrack(s);
|
|
2687
2688
|
// self.sipcall.webrtcStuff.myStream.addTrack(s);
|
|
2688
2689
|
// self.sipcall.webrtcStuff.myStream.removeTrack(s);
|
|
2689
2690
|
// stream.getTracks().forEach(track => track.stop());
|
|
2690
2691
|
|
|
2691
2692
|
// if (self.isVideoTag) {
|
|
2692
|
-
//
|
|
2693
|
+
// let btnObj = self.tagBox.parent().find("button[name='sendAudio']");
|
|
2693
2694
|
// btnObj.unbind('click');
|
|
2694
2695
|
// //stream.getAudioTracks()[0].enabled = false;
|
|
2695
2696
|
//
|
|
@@ -2737,8 +2738,8 @@
|
|
|
2737
2738
|
self.tagBox.parent().find('.recv-audio-btn').attr("class", "unrecv-audio-btn");
|
|
2738
2739
|
self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
|
|
2739
2740
|
|
|
2740
|
-
|
|
2741
|
-
|
|
2741
|
+
let width = this.videoWidth;
|
|
2742
|
+
let height = this.videoHeight;
|
|
2742
2743
|
//保持长宽比例填充video视频框
|
|
2743
2744
|
if (width <= height && width != '0') {
|
|
2744
2745
|
self.tagBox.css('object-fit', 'contain');
|
|
@@ -2757,7 +2758,7 @@
|
|
|
2757
2758
|
promptAlarm('视频ID不能为空');
|
|
2758
2759
|
return;
|
|
2759
2760
|
}
|
|
2760
|
-
|
|
2761
|
+
let body = {
|
|
2761
2762
|
request: "call",
|
|
2762
2763
|
videoidentify: video,
|
|
2763
2764
|
playseq: this.index,
|
|
@@ -2772,7 +2773,7 @@
|
|
|
2772
2773
|
this.packetsReceivedSum = 0;
|
|
2773
2774
|
|
|
2774
2775
|
//loading
|
|
2775
|
-
|
|
2776
|
+
let _li = this.tagBox.parent();
|
|
2776
2777
|
if(!_li.hasClass("loading")){
|
|
2777
2778
|
_li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
|
|
2778
2779
|
}
|
|
@@ -2787,9 +2788,9 @@
|
|
|
2787
2788
|
|
|
2788
2789
|
}
|
|
2789
2790
|
|
|
2790
|
-
//
|
|
2791
|
+
//let reqType = type ? type : "hangup";
|
|
2791
2792
|
if(!this.playing) return;
|
|
2792
|
-
|
|
2793
|
+
let _hangup = {
|
|
2793
2794
|
request: "hangup",
|
|
2794
2795
|
videoidentify: this.video,
|
|
2795
2796
|
playseq: this.index,
|
|
@@ -2850,9 +2851,9 @@
|
|
|
2850
2851
|
return;
|
|
2851
2852
|
}
|
|
2852
2853
|
|
|
2853
|
-
|
|
2854
|
+
let holdType = 'up down left right upleft upright downleft downright zoomin zoomout focusnear focusfar irisopen irisclose pointset pointdel pointgoto '+
|
|
2854
2855
|
'scansetleft scansetright scansetspeed scanrun cruiseadd cruisedel cruisespeed cruisepausetime cruiserun';
|
|
2855
|
-
|
|
2856
|
+
let typeVal = (Number(holdType.split(' ').indexOf(type))+Number(1));
|
|
2856
2857
|
|
|
2857
2858
|
console.log("holdType:" + typeVal + " type:" + type + (isStop ? ' 停止' : ''));
|
|
2858
2859
|
|
|
@@ -2861,7 +2862,7 @@
|
|
|
2861
2862
|
return false;
|
|
2862
2863
|
}
|
|
2863
2864
|
|
|
2864
|
-
|
|
2865
|
+
let body = {
|
|
2865
2866
|
request: "ptz",
|
|
2866
2867
|
videoidentify: this.video,
|
|
2867
2868
|
playseq: this.index,
|
|
@@ -2897,7 +2898,7 @@
|
|
|
2897
2898
|
return;
|
|
2898
2899
|
}
|
|
2899
2900
|
|
|
2900
|
-
|
|
2901
|
+
let body = {
|
|
2901
2902
|
request: "av_playback",
|
|
2902
2903
|
videoidentify: video,
|
|
2903
2904
|
playseq: this.index,
|
|
@@ -2916,7 +2917,7 @@
|
|
|
2916
2917
|
this.isPlayBack = true;
|
|
2917
2918
|
|
|
2918
2919
|
//loading
|
|
2919
|
-
|
|
2920
|
+
let _li = this.tagBox.parent();
|
|
2920
2921
|
if(!_li.hasClass("loading")){
|
|
2921
2922
|
_li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
|
|
2922
2923
|
}
|
|
@@ -2929,9 +2930,9 @@
|
|
|
2929
2930
|
* video设备ID playType类型 playSpeed速率 startTime开始时间
|
|
2930
2931
|
*/
|
|
2931
2932
|
playbackControl: function(video, playType, playSpeed, startTime) {
|
|
2932
|
-
|
|
2933
|
+
let self = this;
|
|
2933
2934
|
|
|
2934
|
-
|
|
2935
|
+
let body = {
|
|
2935
2936
|
request: "av_control",
|
|
2936
2937
|
videoidentify: video,
|
|
2937
2938
|
playseq: self.index,
|
|
@@ -2974,13 +2975,13 @@
|
|
|
2974
2975
|
* requstType: recv_audio、stop_audio、send_audio、unsend_audio
|
|
2975
2976
|
*/
|
|
2976
2977
|
operateAudio: function(requestType) {
|
|
2977
|
-
|
|
2978
|
+
let self = this;
|
|
2978
2979
|
|
|
2979
2980
|
if(!self.video){
|
|
2980
2981
|
promptAlarm('视频ID不能为空');
|
|
2981
2982
|
return;
|
|
2982
2983
|
}
|
|
2983
|
-
|
|
2984
|
+
let body = {
|
|
2984
2985
|
request: requestType,
|
|
2985
2986
|
videoidentify: self.video,
|
|
2986
2987
|
playseq: self.index,
|
|
@@ -2996,13 +2997,13 @@
|
|
|
2996
2997
|
* requstType: start_av_record(开启录像)、stop_av_record(停止录像)
|
|
2997
2998
|
*/
|
|
2998
2999
|
recordAv: function(requestType, businessId) {
|
|
2999
|
-
|
|
3000
|
+
let self = this;
|
|
3000
3001
|
|
|
3001
3002
|
if(!self.video){
|
|
3002
3003
|
promptAlarm('视频ID不能为空');
|
|
3003
3004
|
return;
|
|
3004
3005
|
}
|
|
3005
|
-
|
|
3006
|
+
let body = {
|
|
3006
3007
|
request: requestType,
|
|
3007
3008
|
videoidentify: self.video,
|
|
3008
3009
|
playseq: self.index,
|
|
@@ -3020,14 +3021,14 @@
|
|
|
3020
3021
|
* CIF 480P 720P 1080P
|
|
3021
3022
|
*/
|
|
3022
3023
|
changeResolution: function(requestType, resolution) {
|
|
3023
|
-
|
|
3024
|
+
let self = this;
|
|
3024
3025
|
|
|
3025
3026
|
if(!self.video){
|
|
3026
3027
|
promptAlarm('视频ID不能为空');
|
|
3027
3028
|
return;
|
|
3028
3029
|
}
|
|
3029
3030
|
|
|
3030
|
-
|
|
3031
|
+
let body = {
|
|
3031
3032
|
request: requestType,
|
|
3032
3033
|
videoidentify: self.video,
|
|
3033
3034
|
playseq: self.index,
|
|
@@ -3046,9 +3047,9 @@
|
|
|
3046
3047
|
* centerTel
|
|
3047
3048
|
*/
|
|
3048
3049
|
pocCall: function(requestType, pocNo, centerTel) {
|
|
3049
|
-
|
|
3050
|
+
let self = this;
|
|
3050
3051
|
|
|
3051
|
-
|
|
3052
|
+
let body = {
|
|
3052
3053
|
request: requestType,
|
|
3053
3054
|
pocno: pocNo,
|
|
3054
3055
|
playseq: self.index,
|