-
Notifications
You must be signed in to change notification settings - Fork 1
/
bve-macro-lvcr-2-ways.js
2495 lines (2105 loc) · 105 KB
/
bve-macro-lvcr-2-ways.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
Please contact @author German Cheung <[email protected]> for any questions. Thanks.
*/
import xapi from 'xapi';
const MACRO_VERSION = '1.0.230701';
const LVCR_ROLE_1 = 'lvcr-1';
const LVCR_ROLE_2 = 'lvcr-2';
const LVCR_ROLE_3 = 'lvcr-3';
const LVCR_ROLE_4 = 'lvcr-4';
const LVCR_POSITION_LEFT = [2,1];
const LVCR_POSITION_RIGHT = [1,2];
const LVCR_ROLE_SELF = LVCR_ROLE_1; // *** #1. need to change according to the LVCR role
const LVCR_1_POSITION = LVCR_POSITION_LEFT; // *** #2. need to change according to the position of Room 1 relative to the Room 2
const TEST_BTN_COMBINE_ROOM = false;
/**********************************************************************************/
/* Constants, not suppose to change
*/
const LVCR_DESIGN_32 = 'lvcr32';
const LVCR_DESIGN_33 = 'lvcr33';
const LVCR_DESIGN_34 = 'lvcr34';
const LVCR_DESIGN_SELF = LVCR_DESIGN_32;
const MIC_CEILING = 'mic_ceiling';
const PRESET_1 = '1';
const PRESET_4 = '4';
const PRESET_5 = '5';
const B_MIC_EXCLUSIVE = true; // if true, either ceiling or wireless mic
const B_UI_CEILING_SPEAKER = false;
const B_UI_NOISE_REMOVAL = true;
const B_COMMON_STANDBY = true;
const B_CAMERA_VIEW_AUTO = true;
const DEVICE_SETTING_C = {
'lvcr-1': {
'gpio_pin' : [{'dummy': ''}, {'id': 1, 'Mode': 'InputNoAction', 'State': ''}, {'id': 2, 'Mode': 'InputNoAction', 'State': ''}, {'id': 3, 'Mode': 'InputNoAction', 'State': ''}, {'id': 4, 'Mode': '', 'State': ''}],
'auto_answer' : {'Mode': 'Off'},
'camera_speaker_track' : {'Mode': 'Auto', 'Closeup': 'Auto', 'TrackingMode': 'Auto'},
'presenter_camara_input': '3',
'presenter_camara_id' : '2',
// lvcr-1: Video
'video_main_source' : '1',
'video_main_source_2' : '2',
'video_monitors' : 'Dual', // Auto/Single/Dual/DualPresentationOnly/TriplePresentationOnly/Triple
'video_presentation_source' : '5',
'video_selfview_default' : {'Mode': 'Off'},
// lvcr-1: video_input_connector
'video_input_connector': [{'id': 'dummy'}, // Visibility=IfSignal/Never
{'id': 1, 'Name':'Quad Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '1', 'Mode': 'On'}},
{'id': 2, 'Name':'Camera From Room 2', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'other', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 3, 'Name':'Presenter Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '2', 'Mode': 'On'}},
{'id': 4, 'Name':'', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'PC', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'OnConnect', 'Quality': 'Sharpness', 'RGBQuantizationRange': '', 'Visibility': 'IfSignal', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 5, 'Name':'', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'PC', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'OnConnect', 'Quality': 'Sharpness', 'RGBQuantizationRange': '', 'Visibility': 'IfSignal', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 6, 'Name':'', 'CEC_Mode': '', 'HDCP_Mode': '', 'InputSourceType': '', 'PreferredResolution': '', 'PresentationSelection': '', 'Quality': '', 'RGBQuantizationRange': '', 'Visibility': '', 'CameraControl': {'CameraId': '', 'Mode': ''}}],
// lvcr-1: video_monitor_preset
'video_monitor_preset': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'Second'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Video on Left Display. Presentation on Right Display.
'2': {'output_connecters': [{'id': 1, 'MonitorRole': 'Second'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation on Left Display. Video on Right Display.
'3': {'output_connecters': [{'id': 1, 'MonitorRole': 'PresentationOnly'}, {'id': 2, 'MonitorRole': 'PresentationOnly'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation Only on all Display.
'4': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]} // Video + Presentation on the same Display.
},
'video_output_connector_x': {'CEC': 'On', 'Resolution': '', 'HDCPPolicy': 'Off'},
// lvcr-1: Audio
'audio_ultrasound_max_volume': 60,
'audio_default_volume': 50,
'audio_mic_level_db_max': 70,
'audio_mic_wireless': [],
'audio_mic_wireless_lvcr40': [3,4],
'audio_mic_wireless_lvcr40_combine': [3,4,7,8],
'audio_mic_x': {'Channel': 'Mono', 'PhantomPower': 'On', 'EchoControl': {'Dereverberation': 'Off', 'Mode': 'On', 'NoiseReduction': 'On'}},
'audio_input_hdmi': [{'dummy': ''},
{'id': 1, 'Mode': 'Off'}, {'id': 2, 'Mode': 'Off'}, {'id': 3, 'Mode': 'On'}, {'id': 4, 'Mode': 'On'}, {'id': 5, 'Mode': 'On'}],
'audio_output_line_x': {'Level': '-4', 'Channel': 'Mono'},
// lvcr-1: Non-Room mode related control
'control': {
'ui_camera_view': 'always', // always | auto | 1 | 2 | disable
'ui_wireless_mic': 2,
'use_ceiling_mic': 'always', // never | always | when_combine | when_standalone
'use_ceiling_speaker': 'always', // never | always | when_combine | when_standalone
'use_onboard_speaker': 'never', // never | always | when_combine | when_standalone
'monitor_preset_id': PRESET_1,
'has_sensor': false,
'ir_sensor_type': 'ir_sensor_extron', // ir_sensor_omron | ir_sensor_extron
'camera_1_mic_offset': 0,
'state_camera_position': '',
'state_combined_room': '',
'state_gpio_combine': '',
'state_mute': '',
'state_mic_ceiling': 'on',
'state_mic_wireless': 'off',
'state_xml': '',
'timeout_dnd': 20160,
},
// lvcr-1: Combined behaviour
'combined_mode': {
'video_main_source': LVCR_1_POSITION,
'disable_ultrasound' : true,
'disalbe_wifi_sharing': false,
'force_noise_removal' : true,
'force_speaker_track' : true,
'audio_input_mic': [],
'audio_output_line': [],
'audio_input_mic_x': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 5, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 6, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2}],
'audio_input_mic_1_3': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 5, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 6, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2}],
'audio_output_line_x': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'},
{'id': 3, 'Mode': 'Off'},
{'id': 4, 'Mode': 'Off'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'}],
'video_matrix_assign': [],
},
// lvcr-1: Standalone behaviour
'standalone_mode': {
'audio_input_mic': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_1},
{'id': 5, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 6, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 7, 'Mode': 'Off'},
{'id': 8, 'Mode': 'Off'}],
'audio_output_line': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'Off'},
{'id': 3, 'Mode': 'Off'},
{'id': 4, 'Mode': 'Off'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'}],
'video_matrix_assign': [],
}
},
'lvcr-2': {
'gpio_pin' : [{'dummy': ''}, {'id': 1, 'Mode': 'InputNoAction', 'State': ''}, {'id': 2, 'Mode': 'InputNoAction', 'State': ''}, {'id': 3, 'Mode': 'InputNoAction', 'State': ''}, {'id': 4, 'Mode': 'InputNoAction', 'State': ''}],
'auto_answer' : {'Mode': 'Off'},
'camera_speaker_track' : {'Mode': 'Auto', 'Closeup': 'Auto', 'TrackingMode': 'Auto'},
'presenter_camara_input': '6',
'presenter_camara_id' : '2',
// lvcr-2: Video
'video_main_source' : '1',
'video_monitors' : 'Dual', // Auto/Single/Dual/DualPresentationOnly/TriplePresentationOnly/Triple
'video_presentation_source' : '5',
'video_selfview_default' : {'Mode': 'Off'},
// lvcr-2: video_input_connector
'video_input_connector': [{'id': 'dummy'},
{'id': 1, 'Name':'Quad Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '1', 'Mode': 'On'}},
{'id': 2, 'Name':'LVCR-1 Output 3', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 3, 'Name':'LVCR-1 Output 2', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 4, 'Name':'LVCR-1 Output 1', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 5, 'Name':'', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'PC', 'PreferredResolution': '', 'PresentationSelection': 'OnConnect', 'Quality': 'Sharpness', 'RGBQuantizationRange': '', 'Visibility': 'IfSignal', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 6, 'Name':'Presenter Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '', 'PresentationSelection': '', 'Quality': '', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '2', 'Mode': 'On'}}],
// lvcr-2: video_monitor_preset // Output 3 MonitorRole should always First
'video_monitor_preset': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'Second'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Video on Left Display. Presentation on Right Display.
'2': {'output_connecters': [{'id': 1, 'MonitorRole': 'Second'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation on Left Display. Video on Right Display.
'3': {'output_connecters': [{'id': 1, 'MonitorRole': 'PresentationOnly'}, {'id': 2, 'MonitorRole': 'PresentationOnly'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation Only on all Display.
'4': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]} // Video + Presentation on the same Display.
},
'video_monitor_preset_monitors_single': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'Auto'}, {'id': 2, 'MonitorRole': 'Auto'}, {'id': 3, 'MonitorRole': 'First'}]}
},
'video_output_connector_x': {'CEC': 'On', 'Resolution': '', 'HDCPPolicy': 'Off'},
'video_output_connector_monitors_single': [{'id': 'dummy'},
{'id': 1, 'MonitorRole': 'First', 'OverscanLevel': '', 'Resolution': 'Auto'}, // MonitorRole=Auto/First/Second/Third/PresentationOnly/Recorder
{'id': 2, 'MonitorRole': 'Auto', 'OverscanLevel': '', 'Resolution': 'Auto'},
{'id': 3, 'MonitorRole': 'Recorder', 'OverscanLevel': '', 'Resolution': 'Auto'}],
// lvcr-2: Audio
'audio_ultrasound_max_volume': 60,
'audio_default_volume': 50,
'audio_mic_level_db_max': 70,
'audio_mic_wireless': [],
'audio_mic_wireless_lvcr40': [3,4],
'audio_input_hdmi': [{'dummy': ''},
{'id': 1, 'Mode': 'Off'}, {'id': 2, 'Mode': 'Off'}, {'id': 3, 'Mode': 'Off'}, {'id': 4, 'Mode': 'Off'}, {'id': 5, 'Mode': 'On'}],
// lvcr-2: Non-Room mode related control
'control': {
'ui_wireless_mic': 2,
'use_ceiling_mic': 'always', // never | always | when_combine | when_standalone
'use_ceiling_speaker': 'always', // never | always | when_combine | when_standalone
'use_onboard_speaker': 'never', // never | always | when_combine | when_standalone
'use_video_input_4_only_when_combine': false,
'monitor_preset_id': PRESET_1,
'has_sensor': false,
'state_camera_position': '',
'state_combined_room': '',
'state_mute': '',
'state_gpio_combine': '',
'state_mic_ceiling': 'on',
'state_mic_wireless': 'off',
'state_xml': '',
'timeout_dnd': 20160,
},
// lvcr-2: Combined behaviour
'combined_mode': {
'disable_ultrasound' : true,
'disalbe_wifi_sharing': true,
'force_noise_removal' : true,
'force_speaker_track' : true,
'audio_input_mic': [],
'audio_output_line': [],
'video_matrix_assign': [],
'audio_input_mic_x': [
{'id': 1, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 2, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2}],
'audio_output_line_x': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'}],
'audio_input_mic_combined_2_4': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2}],
'audio_output_line_combined_2_4': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'On'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'}],
'video_matrix_assign_x': [
{'Output': 1, 'SourceID': 4},
{'Output': 2, 'SourceID': 3},
{'Output': 3, 'SourceID': 2}],
'video_matrix_assign_combined_2_4': [],
'video_matrix_assign_use_video_input_4_only': [
{'Output': 1, 'SourceID': 4},
{'Output': 2, 'SourceID': 4},
{'Output': 3, 'SourceID': 4}],
},
// lvcr-2: Standalone behaviour
'standalone_mode': {
'audio_input_mic': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_2}],
'audio_output_line': [
{'id': 1, 'Mode': 'On'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'Off'},
{'id': 2, 'Mode': 'Off'}],
'video_matrix_assign': [],
}
},
'lvcr-3': {
'gpio_pin' : [{'dummy': ''}, {'id': 1, 'Mode': 'InputNoAction', 'State': ''}, {'id': 2, 'Mode': 'InputNoAction', 'State': ''}, {'id': 3, 'Mode': 'InputNoAction', 'State': ''}, {'id': 4, 'Mode': 'InputNoAction', 'State': ''}],
'auto_answer' : {'Mode': 'Off'},
'camera_speaker_track' : {'Mode': 'Auto', 'Closeup': 'Auto', 'TrackingMode': 'Auto'},
'presenter_camara_input': '0',
'presenter_camara_id' : '2',
// lvcr-3: Video
'video_main_source' : '1',
'video_monitors' : 'Dual', // Auto/Single/Dual/DualPresentationOnly/TriplePresentationOnly/Triple
'video_presentation_source' : '5',
'video_selfview_default' : {'Mode': 'Off'},
// lvcr-3: video_input_connector
'video_input_connector': [{'id': 'dummy'},
{'id': 1, 'Name':'Quad Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '1', 'Mode': 'On'}},
{'id': 2, 'Name':'LVCR-1 Output 3', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 3, 'Name':'LVCR-1 Output 2', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 4, 'Name':'LVCR-1 Output 1', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 5, 'Name':'', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'PC', 'PreferredResolution': '', 'PresentationSelection': 'OnConnect', 'Quality': 'Sharpness', 'RGBQuantizationRange': '', 'Visibility': 'IfSignal', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 6, 'Name':'Presenter Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '', 'PresentationSelection': '', 'Quality': '', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}}],
// lvcr-3: video_monitor_preset // Output 3 MonitorRole should always First
'video_monitor_preset': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'Second'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Video on Left Display. Presentation on Right Display.
'2': {'output_connecters': [{'id': 1, 'MonitorRole': 'Second'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation on Left Display. Video on Right Display.
'3': {'output_connecters': [{'id': 1, 'MonitorRole': 'PresentationOnly'}, {'id': 2, 'MonitorRole': 'PresentationOnly'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation Only on all Display.
'4': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]} // Video + Presentation on the same Display.
},
'video_monitor_preset_monitors_single': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'Auto'}, {'id': 2, 'MonitorRole': 'Auto'}, {'id': 3, 'MonitorRole': 'First'}]}
},
'video_output_connector_x': {'CEC': 'On', 'Resolution': 'Auto', 'HDCPPolicy': 'Off'},
'video_output_connector_monitors_single': [{'id': 'dummy'},
{'id': 1, 'MonitorRole': 'First', 'OverscanLevel': '', 'Resolution': 'Auto'}, // MonitorRole=Auto/First/Second/Third/PresentationOnly/Recorder
{'id': 2, 'MonitorRole': 'Auto', 'OverscanLevel': '', 'Resolution': 'Auto'},
{'id': 3, 'MonitorRole': 'Recorder', 'OverscanLevel': '', 'Resolution': 'Auto'}],
// lvcr-3: Audio
'audio_ultrasound_max_volume': 60,
'audio_default_volume': 50,
'audio_mic_level_db_max': 70,
'audio_mic_wireless': [],
'audio_mic_wireless_lvcr40': [3,4],
'audio_input_hdmi': [{'dummy': ''},
{'id': 1, 'Mode': 'Off'}, {'id': 2, 'Mode': 'Off'}, {'id': 3, 'Mode': 'Off'}, {'id': 4, 'Mode': 'Off'}, {'id': 5, 'Mode': 'On'}],
// lvcr-3: Non-Room mode related control
'control': {
'ui_wireless_mic': 0,
'use_ceiling_mic': 'always', // never | always | when_combine | when_standalone
'use_ceiling_speaker': 'never', // never | always | when_combine | when_standalone
'use_onboard_speaker': 'always', // never | always | when_combine | when_standalone
'use_video_input_4_only_when_combine': false,
'monitor_preset_id': PRESET_1,
'has_sensor': false,
'state_camera_position': '',
'state_combined_room': '',
'state_mute': '',
'state_gpio_combine': '',
'state_mic_ceiling': 'on',
'state_mic_wireless': 'off',
'state_xml': '',
'timeout_dnd': 20160,
},
// lvcr-3: Combined behaviour
'combined_mode': {
'disable_ultrasound' : true,
'disalbe_wifi_sharing': true,
'force_noise_removal' : true,
'force_speaker_track' : true,
'audio_input_mic': [
{'id': 1, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_3},
{'id': 2, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_3}],
'audio_output_line': [
{'id': 1, 'Mode': 'Off'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'On'}],
'video_matrix_assign': [],
},
// lvcr-3: Standalone behaviour
'standalone_mode': {
'audio_input_mic': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_3},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_3}],
'audio_output_line': [
{'id': 1, 'Mode': 'On'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'On'}],
'video_matrix_assign': [],
}
},
'lvcr-4': {
'gpio_pin' : [{'dummy': ''}, {'id': 1, 'Mode': 'InputNoAction', 'State': ''}, {'id': 2, 'Mode': 'InputNoAction', 'State': ''}, {'id': 3, 'Mode': 'InputNoAction', 'State': ''}, {'id': 4, 'Mode': 'InputNoAction', 'State': ''}],
'auto_answer' : {'Mode': 'Off'},
'camera_speaker_track' : {'Mode': 'Auto', 'Closeup': 'Auto', 'TrackingMode': 'Auto'},
'presenter_camara_input': '0',
'presenter_camara_id' : '2',
// lvcr-4: Video
'video_main_source' : '1',
'video_monitors' : 'Dual', // Auto/Single/Dual/DualPresentationOnly/TriplePresentationOnly/Triple
'video_presentation_source' : '5',
'video_selfview_default' : {'Mode': 'Off'},
// lvcr-4: video_input_connector
'video_input_connector': [{'id': 'dummy'},
{'id': 1, 'Name':'Quad Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '1920_1080_60', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '1', 'Mode': 'On'}},
{'id': 2, 'Name':'LVCR-1 Output 3', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 3, 'Name':'LVCR-1 Output 2', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 4, 'Name':'LVCR-1 Output 1', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'Other', 'PreferredResolution': '', 'PresentationSelection': 'Manual', 'Quality': 'Motion', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 5, 'Name':'', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'PC', 'PreferredResolution': '', 'PresentationSelection': 'OnConnect', 'Quality': 'Sharpness', 'RGBQuantizationRange': '', 'Visibility': 'IfSignal', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}},
{'id': 6, 'Name':'Presenter Camera', 'CEC_Mode': 'On', 'HDCP_Mode': 'Off', 'InputSourceType': 'camera', 'PreferredResolution': '', 'PresentationSelection': '', 'Quality': '', 'RGBQuantizationRange': '', 'Visibility': 'Never', 'CameraControl': {'CameraId': '', 'Mode': 'Off'}}],
// lvcr-4: video_monitor_preset // Output 3 MonitorRole should always First
'video_monitor_preset': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'Second'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Video on Left Display. Presentation on Right Display.
'2': {'output_connecters': [{'id': 1, 'MonitorRole': 'Second'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation on Left Display. Video on Right Display.
'3': {'output_connecters': [{'id': 1, 'MonitorRole': 'PresentationOnly'}, {'id': 2, 'MonitorRole': 'PresentationOnly'}, {'id': 3, 'MonitorRole': 'Recorder'}]}, // Presentation Only on all Display.
'4': {'output_connecters': [{'id': 1, 'MonitorRole': 'First'}, {'id': 2, 'MonitorRole': 'First'}, {'id': 3, 'MonitorRole': 'Recorder'}]} // Video + Presentation on the same Display.
},
'video_monitor_preset_monitors_single': {
'1': {'output_connecters': [{'id': 1, 'MonitorRole': 'Auto'}, {'id': 2, 'MonitorRole': 'Auto'}, {'id': 3, 'MonitorRole': 'First'}]}
},
'video_output_connector_x': {'CEC': 'On', 'Resolution': 'Auto', 'HDCPPolicy': 'Off'},
'video_output_connector_monitors_single': [{'id': 'dummy'},
{'id': 1, 'MonitorRole': 'First', 'OverscanLevel': '', 'Resolution': 'Auto'}, // MonitorRole=Auto/First/Second/Third/PresentationOnly/Recorder
{'id': 2, 'MonitorRole': 'Auto', 'OverscanLevel': '', 'Resolution': 'Auto'},
{'id': 3, 'MonitorRole': 'Recorder', 'OverscanLevel': '', 'Resolution': 'Auto'}],
// lvcr-4: Audio
'audio_ultrasound_max_volume': 60,
'audio_default_volume': 50,
'audio_mic_level_db_max': 70,
'audio_mic_wireless': [],
'audio_mic_wireless_lvcr40': [3,4],
'audio_input_hdmi': [{'dummy': ''},
{'id': 1, 'Mode': 'Off'}, {'id': 2, 'Mode': 'Off'}, {'id': 3, 'Mode': 'Off'}, {'id': 4, 'Mode': 'Off'}, {'id': 5, 'Mode': 'On'}],
// lvcr-4: Non-Room mode related control
'control': {
'ui_wireless_mic': 0,
'use_ceiling_mic': 'always', // never | always | when_combine | when_standalone
'use_ceiling_speaker': 'never', // never | always | when_combine | when_standalone
'use_onboard_speaker': 'always', // never | always | when_combine | when_standalone
'use_video_input_4_only_when_combine': false,
'monitor_preset_id': PRESET_1,
'has_sensor': false,
'state_camera_position': '',
'state_combined_room': '',
'state_mute': '',
'state_gpio_combine': '',
'state_mic_ceiling': 'on',
'state_mic_wireless': 'off',
'state_xml': '',
'timeout_dnd': 20160,
},
// lvcr-4: Combined behaviour
'combined_mode': {
'disable_ultrasound' : true,
'disalbe_wifi_sharing': true,
'force_noise_removal' : true,
'force_speaker_track' : true,
'audio_input_mic': [
{'id': 1, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_4},
{'id': 2, 'Mode': 'Off', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_4}],
'audio_output_line': [
{'id': 1, 'Mode': 'Off'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'On'}],
'video_matrix_assign': [],
},
// lvcr-4: Standalone behaviour
'standalone_mode': {
'audio_input_mic': [
{'id': 1, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_4},
{'id': 2, 'Mode': 'On', 'Type': MIC_CEILING, 'LocateAt': LVCR_ROLE_4}],
'audio_output_line': [
{'id': 1, 'Mode': 'On'}],
'audio_output_hdmi': [
{'id': 1, 'Mode': 'On'},
{'id': 2, 'Mode': 'On'}],
'video_matrix_assign': [],
}
}
}
/* Constants, not suppose to change
*/
const PANEL_ID = 'panel-bve_lvcr_control';
const PANEL_BTN_NAME = 'Room Control';
const PANEL_BTN_ICON = 'Input';
const REMOVE_PANEL = ['panel-bve_proximity_control'];
const TIMER_RETRY_RESET = 30*60*1000;
const TIMER_MIC_ALERT = 8; // sec
const MSG_MIC_WIRELESS = {Text: 'Wireless Mic is in use', Duration: TIMER_MIC_ALERT};
const MSG_MIC_CEILING = {Text: 'Ceiling Mic is in use', Duration: TIMER_MIC_ALERT};
const MSG_SIGNIN_BANNER = 'This is LVCR device. Do not make any unauthorized changes!';
const IR_SENSOR_TYPE_EXTRON = 'ir_sensor_extron';
const IR_SENSOR_TYPE_OMRON = 'ir_sensor_omron';
const GPIO_IR_SENSOR_EXTRON = {'id': 1, 'State': {'combine': 'High', 'standalone': 'Low'}};
const GPIO_IR_SENSOR_OMRON = {'id': 1, 'State': {'combine': 'Low', 'standalone': 'High'}};
const GPIO_IR_SENSOR = (DEVICE_SETTING_C[LVCR_ROLE_1].control.ir_sensor_type == IR_SENSOR_TYPE_OMRON)? GPIO_IR_SENSOR_OMRON : GPIO_IR_SENSOR_EXTRON;
const GPIO_IR_SENSOR_TYPE = (DEVICE_SETTING_C[LVCR_ROLE_1].control.ir_sensor_type == IR_SENSOR_TYPE_OMRON)? IR_SENSOR_TYPE_OMRON : IR_SENSOR_TYPE_EXTRON;
const GPIO_STANDBY = {'id': 4, 'State': {'deactivate': 'High', 'activate': 'Low'}};
const GPIO_VALUE_PIN_1 = 0x1000;
const GPIO_VALUE_PIN_2 = 0x0100;
const GPIO_VALUE_PIN_3 = 0x0010;
const GPIO_VALUE_PIN_4 = 0x0001;
const AUDIO_OUTPUT_HDMI_2 = ['Codec Pro', 'Room 70D G2'];
const CAMERA_PRESET_MAX = 8;
const MONITOR_DUAL = 'Dual';
const MONITOR_SINGLE = 'Single';
const USE_NEVER = 'never';
const USE_ALWAYS = 'always';
const USE_WHEN_COMBINE = 'when_combine';
const USE_WHEN_STANDALONE = 'when_standalone';
const STATE_COMBINED_ROOM_1 = 'state_combined_room_1';
const STATE_COMBINED_ROOM_1_2 = 'state_combined_room_1_2';
const STATE_COMBINED_ROOM_1_2_3 = 'state_combined_room_1_2_3';
const STATE_COMBINED_ROOM_1_2_4 = 'state_combined_room_1_2_4';
const STATE_COMBINED_ROOM_1_2_3_4 = 'state_combined_room_1_2_3_4';
const STATE_COMBINED_ROOM_1_3 = 'state_combined_room_1_3';
const STATE_COMBINED_ROOM_2_4 = 'state_combined_room_2_4';
const MAP_STATE_COMBINE_NAME = {
'state_combined_room_1_2' : '1 + 2',
'state_combined_room_1_2_3' : '1 + 2 + 3',
'state_combined_room_1_2_4' : '1 + 2 + 4',
'state_combined_room_1_2_3_4': '1 + 2 + 3 + 4',
'state_combined_room_1_3' : '1 + 3',
'state_combined_room_2_4' : '2 + 4'
}
const SHOW_PAGE_AUDIO = true;
const SHOW_PAGE_CAMERA = true;
const SHOW_PAGE_DISPLAY = true;
const SHOW_PAGE_ADVANCED = false;
const widgetIds = {
'page_room_control' : 'page-room_control',
'monitor_preset': 'group-monitor_preset',
'monitor_role_1': 'group-monitor_role_1',
'monitor_role_2': 'group-monitor_role_2',
'monitor_role_3': 'group-monitor_role_3',
'monitor_role_save': 'button-monitor_role_save',
'page_monitor_role_preset': 'page-monitor_role_preset',
'page_monitor_role_advanced': 'page-monitor_role_advanced',
'vc_reset_1': 'text-vc_reset_1',
'status_combine' : 'text-status_combine',
'combine_room' : 'button-combine_room',
'mic_1_mode': 'toggle-mic_1_mode', 'mic_2_mode': 'toggle-mic_2_mode',
'mic_3_mode': 'toggle-mic_3_mode', 'mic_4_mode': 'toggle-mic_4_mode',
'mic_5_mode': 'toggle-mic_5_mode', 'mic_6_mode': 'toggle-mic_6_mode',
'mic_7_mode': 'toggle-mic_7_mode', 'mic_8_mode': 'toggle-mic_8_mode',
'mic_1_level': 'spinner-mic_1_level', 'mic_2_level': 'spinner-mic_2_level',
'mic_3_level': 'spinner-mic_3_level', 'mic_4_level': 'spinner-mic_4_level',
'mic_5_level': 'spinner-mic_5_level', 'mic_6_level': 'spinner-mic_6_level',
'mic_7_level': 'spinner-mic_7_level', 'mic_8_level': 'spinner-mic_8_level',
'noise_removal': 'toggle-noise_removal',
'speaker_ceiling_mode': 'toggle-speaker_ceiling_mode',
'speaker_ceiling_level': 'spinner-speaker_ceiling_level',
'camera_preset': 'group-camera_preset',
'camera_selfview': 'toggle-camera_selfview',
'camera_track': 'group-camera_track',
'camera_view': 'button-camera_view',
'last_camera_preset': 'text-last_camera_preset',
}
const cameras = {
'presenter_track' : {
'name' : 'PresenterTrack',
'enable' : 'True',
'connector' : DEVICE_SETTING_C[LVCR_ROLE_SELF].presenter_camara_input,
},
'speaker_track' : {'name': 'Front', 'mode': 'Auto', 'closeup': 'Auto', 'connector': 1},
}
let device_setting = JSON.parse(JSON.stringify(DEVICE_SETTING_C));
let timer_reset_default = 0;
/* Common
*/
async function common_initConfig() {
const setting = device_setting[LVCR_ROLE_SELF];
handleLog('common_initConfig', `lvcr_design=${LVCR_DESIGN_SELF}, lvcr_role=${LVCR_ROLE_SELF}, sensor=${GPIO_IR_SENSOR_TYPE}`);
const audio = await xapi.config.get('Audio').catch(e => {return ''});
const video = await xapi.config.get('Video').catch(e => {return ''});
const camera = await xapi.config.get('Cameras').catch(e => {return ''});
const conference = await xapi.config.get('Conference').catch(e => {return ''});
const system_unit = await xapi.status.get('SystemUnit').catch(e => {return ''});
handleDebug('common_initConfig', `audio`, audio);
handleDebug('common_initConfig', `video`, video);
handleDebug('common_initConfig', `camera`, camera);
handleDebug('common_initConfig', `conference`, conference);
handleDebug('common_initConfig', `system_unit`, system_unit);
if(!audio || !video || !camera || !conference || !system_unit) {
handleError('common_initConfig', `lvcr_design=${LVCR_DESIGN_SELF}, lvcr_role=${LVCR_ROLE_SELF}`);
return;
}
const setting_x = device_setting[LVCR_ROLE_1];
// GPIO
for(const val of setting.gpio_pin) {
if(!!val.id) {
if(setting.gpio_pin[val.id].Mode) await setGpioMode(val.id, setting.gpio_pin[val.id].Mode);
if(setting.gpio_pin[val.id].Mode == 'OutputManualState')
await setGpioState(val.id, setting.gpio_pin[val.id].State);
}
}
if(!!system_unit.ProductPlatform && AUDIO_OUTPUT_HDMI_2.indexOf(system_unit.ProductPlatform) === -1) {
setting.combined_mode.audio_output_hdmi[1].Mode = '';
setting.standalone_mode.audio_output_hdmi[1].Mode = '';
}
// Audio Wireless Mic
if(setting.control.ui_wireless_mic) {
setting.audio_mic_wireless = setting.audio_mic_wireless_lvcr40;
}
// Audio Input
if(!!audio.Input && audio.Input.ARC)
for(const val of audio.Input.ARC) {
if(!!val.id && val.Mode) await xconfig(`Audio Input ARC ${val.id} Mode`, 'Off');
}
if(!!audio.Input && audio.Input.HDMI)
for(const val of audio.Input.HDMI) {
let setting_id = setting.audio_input_hdmi[val.id];
if(!!val.id && val.Mode) await xconfig(`Audio Input HDMI ${val.id} Mode`, setting_id.Mode);
}
for(const val of audio.Input.Microphone)
if(!!val.id) {
if(!!val.Channel && !!setting_x.audio_mic_x.Channel) await xconfig(`Audio Input Microphone ${val.id} Channel`, setting_x.audio_mic_x.Channel);
if(!!val.PhantomPower && !!setting_x.audio_mic_x.PhantomPower) await xconfig(`Audio Input Microphone ${val.id} PhantomPower`, setting_x.audio_mic_x.PhantomPower);
if(!!val.EchoControl) {
if(!!val.EchoControl.Dereverberation && !!setting_x.audio_mic_x.EchoControl.Dereverberation) await xconfig(`Audio Input Microphone ${val.id} EchoControl Dereverberation`, setting_x.audio_mic_x.EchoControl.Dereverberation);
if(!!val.EchoControl.Mode && !!setting_x.audio_mic_x.EchoControl.Mode) await xconfig(`Audio Input Microphone ${val.id} EchoControl Mode`, setting_x.audio_mic_x.EchoControl.Mode);
if(!!val.EchoControl.NoiseReduction && !!setting_x.audio_mic_x.EchoControl.NoiseReduction) await xconfig(`Audio Input Microphone ${val.id} EchoControl NoiseReduction`, setting_x.audio_mic_x.EchoControl.NoiseReduction);
}
}
const setting_mic = (LVCR_ROLE_SELF == LVCR_ROLE_1) ? setting.combined_mode.audio_input_mic : setting.standalone_mode.audio_input_mic;
const mic_1_level = audio.Input.Microphone[0].Level;
for(const val of setting_mic)
if(!!val.id && val.id != 1 && val.Type == MIC_CEILING) await xconfig(`Audio Input Microphone ${val.id} Level`, mic_1_level);
// Audio Output
if(!!audio.Output && audio.Output.ARC)
for(const val of audio.Output.ARC)
if(!!val.id && val.id == '1') await xconfig(`Audio Output ARC ${val.id} Mode`, 'On');
for(const val of audio.Output.Line)
if(!!val.id) {
if(!!val.Channel && !!setting_x.audio_output_line_x.Channel) await xconfig(`Audio Output Line ${val.id} Channel`, setting_x.audio_output_line_x.Channel);
if(!!val.Level && !!setting_x.audio_output_line_x.Level) await xconfig(`Audio Output Line ${val.id} Level`, setting_x.audio_output_line_x.Level);
}
// Audio Misc
await xconfig('Audio DefaultVolume', setting.audio_default_volume);
await xcommand('Audio Volume Set', {Level: setting.audio_default_volume});
// Video Input
// await xcommand('Video Input SetMainVideoSource', {ConnectorID: setting.video_main_source});
if(!!video.Input && video.Input.Connector)
for(const val of video.Input.Connector) {
let setting_id = setting.video_input_connector[val.id];
if(!!val.id) {
await xconfig(`Video Input Connector ${val.id} Name`, setting_id.Name);
if(!!val.InputSourceType && !!setting_id.InputSourceType) await xconfig(`Video Input Connector ${val.id} InputSourceType`, setting_id.InputSourceType);
if(!!val.PreferredResolution && !!setting_id.PreferredResolution) await xconfig(`Video Input Connector ${val.id} PreferredResolution`, setting_id.PreferredResolution);
if(!!val.PresentationSelection && !!setting_id.PresentationSelection) await xconfig(`Video Input Connector ${val.id} PresentationSelection`, setting_id.PresentationSelection);
if(!!val.Quality && !!setting_id.Quality) await xconfig(`Video Input Connector ${val.id} Quality`, setting_id.Quality);
if(!!val.RGBQuantizationRange && !!setting_id.RGBQuantizationRange) await xconfig(`Video Input Connector ${val.id} RGBQuantizationRange`, setting_id.RGBQuantizationRange);
if(!!val.Visibility && !!setting_id.Visibility) await xconfig(`Video Input Connector ${val.id} Visibility`, setting_id.Visibility);
if(!!val.CEC && val.CEC.Mode && !!setting_id.CEC_Mode) await xconfig(`Video Input Connector ${val.id} CEC Mode`, setting_id.CEC_Mode);
if(!!val.HDCP && val.HDCP.Mode && !!setting_id.HDCP_Mode) await xconfig(`Video Input Connector ${val.id} HDCP Mode`, setting_id.HDCP_Mode);
if(!!val.CameraControl) {
if(val.id != 5 || setting.control.has_sensor) {
if(!!val.CameraControl.CameraId && !!setting_id.CameraControl.CameraId) await xconfig(`Video Input Connector ${val.id} CameraControl CameraId`, setting_id.CameraControl.CameraId);
if(!!val.CameraControl.Mode && !!setting_id.CameraControl.Mode) await xconfig(`Video Input Connector ${val.id} CameraControl Mode`, setting_id.CameraControl.Mode);
}
}
}
}
// Video Output
if(LVCR_ROLE_SELF == LVCR_ROLE_2 && MONITOR_SINGLE == setting.video_monitors)
setting.video_monitor_preset = setting.video_monitor_preset_monitors_single;
if(!!video.Output && video.Output.Connector) {
const video_monitor_preset = setting.video_monitor_preset[setting.control.monitor_preset_id].output_connecters;
handleLog('common_initConfig', `monitor_preset_id=${setting.control.monitor_preset_id}`, video_monitor_preset);
for(const val of video.Output.Connector) {
if(val.CEC && !!setting.video_output_connector_x.CEC) await xconfig(`Video Output Connector ${val.id} CEC Mode`, setting.video_output_connector_x.CEC);
if(val.Resolution && !!setting.video_output_connector_x.Resolution) await xconfig(`Video Output Connector ${val.id} Resolution`, setting.video_output_connector_x.Resolution);
if(val.HDCPPolicy && !!setting.video_output_connector_x.HDCPPolicy) await xconfig(`Video Output Connector ${val.id} HDCPPolicy`, setting.video_output_connector_x.HDCPPolicy);
if(val.MonitorRole) await xconfig(`Video Output Connector ${val.id} MonitorRole`, video_monitor_preset[val.id-1].MonitorRole);
}
}
// Video Misc
await xconfig('Video DefaultMainSource', setting.video_main_source);
await xconfig('Video Monitors', setting.video_monitors);
await xconfig('Video Presentation DefaultSource', setting.video_presentation_source);
await xconfig('Video Selfview Default Mode', setting.video_selfview_default.Mode);
// Camera
if(!!camera.SpeakerTrack) {
if(camera.SpeakerTrack.Mode && !!setting.camera_speaker_track.Mode) await xconfig(`Cameras SpeakerTrack Mode`, setting.camera_speaker_track.Mode);
if(camera.SpeakerTrack.Closeup && !!setting.camera_speaker_track.Closeup) await xconfig(`Cameras SpeakerTrack Closeup`, setting.camera_speaker_track.Closeup);
if(camera.SpeakerTrack.TrackingMode && !!setting.camera_speaker_track.TrackingMode) await xconfig(`Cameras SpeakerTrack TrackingMode`, setting.camera_speaker_track.TrackingMode);
}
// Misc
if(!!conference.AutoAnswer && !!conference.AutoAnswer.Mode) await xconfig(`Conference AutoAnswer Mode`, setting.auto_answer.Mode);
}
async function common_setMode(common_setting) {
const setting = device_setting[LVCR_ROLE_SELF];
const state_mic_wireless = setting.control.state_mic_wireless;
handleLog('common_setMode', `state_mic_wireless=${state_mic_wireless}`);
// Audio Input Microphone
if(state_mic_wireless == C.ON) {
for(const val of common_setting.audio_input_mic)
if(!!val.id) await xconfig(`Audio Input Microphone ${val.id} Mode`, 'Off');
}
else {
for(const id of setting.audio_mic_wireless)
if(!!id) await xconfig(`Audio Input Microphone ${id} Mode`, 'Off');
for(const val of common_setting.audio_input_mic)
if(!!val.id) await xconfig(`Audio Input Microphone ${val.id} Mode`, val.Mode);
}
// Audio Output HDMI
for(const val of common_setting.audio_output_hdmi)
if(!!val.id && !!val.Mode) await xconfig(`Audio Output HDMI ${val.id} Mode`, val.Mode);
// Audio Output Line
for(const val of common_setting.audio_output_line)
if(!!val.id && !!val.Mode) await xconfig(`Audio Output Line ${val.id} Mode`, val.Mode);
// Video Matrix
if(common_setting.video_matrix_assign.length) {
for(const val of common_setting.video_matrix_assign)
if(!!val.Output && !!val.SourceID) await xcommand('Video Matrix Assign', {Output: val.Output, SourceID: val.SourceID});
}
else
await xcommand('Video Matrix Reset');
}
async function common_enableUI() {
handleLog('common_enableUI');
await xcommand('UserInterface Message Prompt Clear');
}
async function common_disableUI(event) {
handleLog('common_disableUI', `event`, event);
await xcommand('UserInterface Extensions Panel Close');
if(event.FeedbackId == 'ui_disabled') {
await xcommand('UserInterface Message Prompt Display', {
Title: 'Room Combined',
Text: 'Please use the panel in the main room.',
FeedbackId: 'ui_disabled'
});
}
}
async function common_setCombinedMode() {
const setting = device_setting[LVCR_ROLE_SELF];
const state_combined_room = setting.control.state_combined_room;
handleLog('common_setCombinedMode', `lvcr_role=${LVCR_ROLE_SELF}, state_combined_room=${state_combined_room}`);
const audio_mic = await xapi.config.get(`Audio Microphones`).catch(e => {return ''});
const camera = await xapi.config.get('Cameras').catch(e => {return ''});
handleDebug('common_setCombinedMode', `audio_mic`, audio_mic);
handleDebug('common_setCombinedMode', `camera`, camera);
if(!audio_mic || !camera) {
handleError('common_setCombinedMode');
return;
}
await xcommand('Call Disconnect');
await xcommand('Presentation Stop');
await common_setMode(setting.combined_mode);
if(setting.combined_mode.disable_ultrasound) await xconfig('Audio Ultrasound MaxVolume', '0');
if(setting.combined_mode.disalbe_wifi_sharing) {
await xconfig('Video Input AirPlay Mode', 'Off');
await xconfig('Video Input Miracast Mode', 'Off');
// await xcommand('AirPlay ResetPairedDevices');
// await xcommand('Proximity Services Deactivate');
}
await xconfig('Standby Control', 'Off');
// await xconfig('UserInterface OSD Mode', 'Unobstructed');
await xconfig('UserInterface Assistant Mode', 'Off');
if(!!audio_mic.NoiseRemoval && setting.combined_mode.force_noise_removal) await xcommand('Audio Microphones NoiseRemoval Activate');
if(!!camera.SpeakerTrack && setting.combined_mode.force_speaker_track) await xcommand('Cameras SpeakerTrack Activate');
await xcommand('Conference DoNotDisturb Activate', {Timeout: setting.control.timeout_dnd});
await xcommand('Audio Microphones Unmute');
await common_disableUI({FeedbackId: 'ui_disabled'});
await common_cbStandby();
const xml = await rebuildUI();
if(xml != setting.control.state_xml) await restoreExtension(xml);
setting.control.state_xml = xml;
await updateUI();
}
async function common_setStandaloneMode() {
handleLog('common_setStandaloneMode');
const setting = device_setting[LVCR_ROLE_SELF];
await common_setMode(setting.standalone_mode);
await xconfig('Audio Ultrasound MaxVolume', setting.audio_ultrasound_max_volume);
await xconfig('Standby Control', 'On');
await xconfig('UserInterface OSD Mode', 'Auto');
await xconfig('UserInterface Assistant Mode', 'On');
await xconfig('Video Input AirPlay Mode', 'On');
await xconfig('Video Input Miracast Mode', 'On');
await xcommand('Conference DoNotDisturb Deactivate');
// await xcommand('Proximity Services Activate');
await common_enableUI();
const xml = await rebuildUI();
if(xml != setting.control.state_xml) await restoreExtension(xml);
setting.control.state_xml = xml;
await updateUI();
}
async function common_cbCallDisconnected(event) {
handleLog('common_cbCallDisconnected', event);
await xcommand('Audio Microphones NoiseRemoval Activate');
await setMicMode(1, C.ON);
await VideoOutputReset('common_cbCallDisconnected', PRESET_1, true);
}
async function common_cbSensorState(event='') {
const gpio_pins = await xapi.status.get('GPIO Pin').catch(e => {return ''});
handleDebug('common_cbSensorState', `event`, event, `gpio_pins`, gpio_pins);
if(!gpio_pins) {
handleError('common_cbSensorState');
return;
}
const setting = device_setting[LVCR_ROLE_SELF];
const sensor_combined = GPIO_IR_SENSOR.State.combine;
if(TEST_BTN_COMBINE_ROOM && setting.control.state_xml) unsetWidgetValue(widgetIds.combine_room);
let state_gpio_combine = 0;
for(const val of gpio_pins) {
if(val.id == '1' && val.State == sensor_combined) state_gpio_combine += GPIO_VALUE_PIN_1;
else if((LVCR_DESIGN_SELF == LVCR_DESIGN_33 || LVCR_DESIGN_SELF == LVCR_DESIGN_34) && val.id == '2' && val.State == sensor_combined) state_gpio_combine += GPIO_VALUE_PIN_2;
else if(LVCR_DESIGN_SELF == LVCR_DESIGN_34 && val.id == '3' && val.State == sensor_combined) state_gpio_combine += GPIO_VALUE_PIN_3;
}
setting.control.state_gpio_combine = state_gpio_combine;
let state_combined_room = '';
if(LVCR_ROLE_SELF == LVCR_ROLE_1) {
if(state_gpio_combine & GPIO_VALUE_PIN_1 && state_gpio_combine & GPIO_VALUE_PIN_2 && state_gpio_combine & GPIO_VALUE_PIN_3) state_combined_room = STATE_COMBINED_ROOM_1_2_3_4;
else if(state_gpio_combine & GPIO_VALUE_PIN_1 && state_gpio_combine & GPIO_VALUE_PIN_2) state_combined_room = STATE_COMBINED_ROOM_1_2_3;
else if(state_gpio_combine & GPIO_VALUE_PIN_1 && state_gpio_combine & GPIO_VALUE_PIN_3) state_combined_room = STATE_COMBINED_ROOM_1_2_4;
else if(state_gpio_combine & GPIO_VALUE_PIN_1) state_combined_room = STATE_COMBINED_ROOM_1_2;
else if(state_gpio_combine & GPIO_VALUE_PIN_2) state_combined_room = STATE_COMBINED_ROOM_1_3;
setting.control.state_combined_room = state_combined_room;
handleLog('common_cbSensorState', `lvcr_role=${LVCR_ROLE_SELF}, state_gpio_combine=0x${state_gpio_combine.toString(16).padStart(4, "0")}, state_combined_room=${state_combined_room}`);
if(state_combined_room) await lvcr1_setCombinedMode();
else await lvcr1_setStandaloneMode();
}
else if(LVCR_ROLE_SELF == LVCR_ROLE_2) {
if((state_gpio_combine & GPIO_VALUE_PIN_1) && (state_gpio_combine & GPIO_VALUE_PIN_2)) state_combined_room = STATE_COMBINED_ROOM_1_2_4;
else if(state_gpio_combine & GPIO_VALUE_PIN_1) state_combined_room = STATE_COMBINED_ROOM_1_2;
else if(state_gpio_combine & GPIO_VALUE_PIN_2) state_combined_room = STATE_COMBINED_ROOM_2_4;
setting.control.state_combined_room = state_combined_room;
handleLog('common_cbSensorState', `lvcr_role=${LVCR_ROLE_SELF}, state_gpio_combine=0x${state_gpio_combine.toString(16).padStart(4, "0")}, state_combined_room=${state_combined_room}`);
if(state_combined_room) await lvcr2_setCombinedMode();
else await common_setStandaloneMode();
}
else if(LVCR_ROLE_SELF == LVCR_ROLE_3) {
if(state_gpio_combine & GPIO_VALUE_PIN_1) state_combined_room = STATE_COMBINED_ROOM_1_3;
setting.control.state_combined_room = state_combined_room;
handleLog('common_cbSensorState', `lvcr_role=${LVCR_ROLE_SELF}, state_gpio_combine=0x${state_gpio_combine.toString(16).padStart(4, "0")}, state_combined_room=${state_combined_room}`);
if(state_combined_room) await common_setCombinedMode();
else await common_setStandaloneMode();
}
else if(LVCR_ROLE_SELF == LVCR_ROLE_4) {
if(state_gpio_combine & GPIO_VALUE_PIN_1) state_combined_room = STATE_COMBINED_ROOM_2_4;
setting.control.state_combined_room = state_combined_room;
handleLog('common_cbSensorState', `lvcr_role=${LVCR_ROLE_SELF}, state_gpio_combine=0x${state_gpio_combine.toString(16).padStart(4, "0")}, state_combined_room=${state_combined_room}`);
if(state_combined_room) await common_setCombinedMode();
else await common_setStandaloneMode();
}
}
async function common_cbStandby(event='') {
const setting = device_setting[LVCR_ROLE_SELF];
const state_combined_room = setting.control.state_combined_room;
handleLog('common_cbStandby', `state_combined_room=${state_combined_room}`, event);
if(B_COMMON_STANDBY && LVCR_ROLE_SELF != LVCR_ROLE_1 && state_combined_room && state_combined_room.includes('_1_')) {
const state_gpio = await xapi.status.get(`GPIO Pin ${GPIO_STANDBY.id} State`).catch(e => {return ''});
const state_standby = await xapi.status.get(`Standby State`).catch(e => {return ''});
handleLog('common_cbStandby', `state_gpio=${state_gpio}, state_standby=${state_standby}`);
if(state_gpio && state_gpio == GPIO_STANDBY.State.activate && state_standby && state_standby != C.STANDBY_STANDBY)
await xcommand('Standby Activate');
if(state_gpio && state_gpio == GPIO_STANDBY.State.deactivate && state_standby && state_standby != C.STANDBY_OFF)
await xcommand('Standby Deactivate');
}
}
function is_commonS() {
if(!LVCR_ROLE_SELF || LVCR_ROLE_SELF == LVCR_ROLE_1) return false;
else return true;
}
let mic_meters = {};
let camera_score = {'camera_1': 0, 'camera_2': 0, 'camera_tie': 0};
let camera_active_view = 0;
const AUDIO_VU_METER = {ConnectorType: 'Microphone', IntervalMs: 500, Source: 'AfterAEC', BufferSize: 3};
const THRESHOLD_CAMERA_SWITCH = 3;