-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.js
141 lines (130 loc) · 4.82 KB
/
action.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
exports = module.exports = function (action) {
var self = this;
var cmd;
var options = action.options;
if(options.port === undefined) {
options.port = null;
}
switch (action.action) {
// beep
case "beep_startup":
cmd = '/api/beep/startup?port=' + encodeURIComponent(options.port);
break;
// config
case "config_set":
config_data = {};
config_data[options.configname] = options.configvalue;
cmd = '/api/config/set?properties=' + JSON.stringify(config_data);
break;
// notifications
case 'notification_message':
cmd = '/api/notifications/message?text=' + encodeURIComponent(options.message);
break;
// record
case 'record_monitor':
cmd = '/api/record/monitor?port=' + encodeURIComponent(options.port);
break;
case 'record_stop':
cmd = '/api/record/stop?port=' + encodeURIComponent(options.port);
break;
case 'record_start':
cmd = '/api/record/start?port=' + encodeURIComponent(options.port);
break;
case 'record_chunknow':
cmd = '/api/record/chunknow?port=' + encodeURIComponent(options.port);
break;
case 'record_keyframe':
cmd = '/api/record/keyframe?port=' + encodeURIComponent(options.port);
break;
case 'record_grabstill':
cmd = '/api/record/grabstill?port=' + encodeURIComponent(options.port);
break;
// port
case 'port_togglelock':
cmd = '/api/port/toggleportlockstate?port=' + encodeURIComponent(options.port);
break;
case 'port_setlock':
cmd = '/api/port/setlockstate?port=' + encodeURIComponent(options.port) + "&state=" + (encodeURIComponent(options.lockstate ? "1" : "0"));
break;
// port settings
case 'portsettings_togglemodetype':
cmd = '/api/portsettings/togglemodetype?port=' + encodeURIComponent(options.port);
break;
// playout
case 'playout_eject':
cmd = '/api/playout/eject?port=' + encodeURIComponent(options.port);
break;
case 'playout_repeatframes':
cmd = '/api/playout/repeatframes?port=' + encodeURIComponent(options.port) + "&framecount=" + encodeURIComponent(options.framecount);
break;
case 'playout_dropframes':
cmd = '/api/playout/dropframes?port=' + encodeURIComponent(options.port) + "&framecount=" + encodeURIComponent(options.framecount);
break;
case 'playout_removeall':
cmd = '/api/playout/removeall?port=' + encodeURIComponent(options.port);
break;
case 'playout_keyframe':
cmd = '/api/playout/keyframe?port=' + encodeURIComponent(options.port);
break;
case 'playout_play':
cmd = '/api/playout/play?port=' + encodeURIComponent(options.port);
break;
case 'playout_pause':
cmd = '/api/playout/pause?port=' + encodeURIComponent(options.port);
break;
case 'playout_previous':
cmd = '/api/playout/previous?port=' + encodeURIComponent(options.port);
break;
case 'playout_previousstep':
cmd = '/api/playout/previousstep?port=' + encodeURIComponent(options.port);
break;
case 'playout_previousframe':
cmd = '/api/playout/previousframe?port=' + encodeURIComponent(options.port);
break;
case 'playout_next':
cmd = '/api/playout/next?port=' + encodeURIComponent(options.port);
break;
case 'playout_nextstep':
cmd = '/api/playout/nextstep?port=' + encodeURIComponent(options.port);
break;
case 'playout_nextframe':
cmd = '/api/playout/nextframe?port=' + encodeURIComponent(options.port);
break;
case 'playout_add':
cmd = '/api/playout/add?port=' + encodeURIComponent(options.port) + "&clipids=" + encodeURIComponent(options.clipids);
break;
case 'playout_loadnow':
cmd = '/api/playout/loadnow?port=' + encodeURIComponent(options.port) + "&clipids=" + encodeURIComponent(options.clipids);
break;
case 'playout_playnow':
cmd = '/api/playout/playnow?port=' + encodeURIComponent(options.port) + "&clipids=" + encodeURIComponent(options.clipids);
break;
case 'playout_load':
cmd = '/api/playout/load?port=' + encodeURIComponent(options.port) + "&index=" + encodeURIComponent(options.index);
break;
case 'playout_seek':
cmd = '/api/playout/seek?port=' + encodeURIComponent(options.port) + "&frame=" + encodeURIComponent(options.frame);
break;
case 'playout_stop':
cmd = '/api/playout/stop?port=' + encodeURIComponent(options.port);
break;
case 'playout_togglefield':
cmd = '/api/playout/togglefield?port=' + encodeURIComponent(options.port);
break;
case 'playout_pauseafter':
cmd = '/api/playout/pauseafter?port=' + encodeURIComponent(options.port);
break;
case 'playout_loop':
cmd = '/api/playout/loop?port=' + encodeURIComponent(options.port) + "&loopflag=" + (encodeURIComponent(options.loopflag ? "1" : "0"));
break;
}
if (self.client !== undefined) {
let url = 'http://' + self.config.host + cmd;
self.log('debug', 'sending API command: ' + url);
self.client.get(url, function (data, response) {
if (data != "OK") {
self.log('warn', 'ERROR from raven API :' + data);
}
});
}
};