-
Notifications
You must be signed in to change notification settings - Fork 2
/
filters.js
78 lines (64 loc) · 1.71 KB
/
filters.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
/**
* Created by solvek on 11.02.16.
*/
function ensureTrackParams(track){
if (!track.params){
track.params = {};
}
}
module.exports = {
// General purpose filters
/**
* @param {string} proxy For example 'http://192.168.0.1:4000/udp/'
*/
udpProxy: function(proxy){
return function(track){
track.file = track.file.replace('udp://@', proxy);
return track;
}
},
// Filter conditions
forStream: function(stream, modifier){
return function(track, source, collected){
if (stream != track.file){
return track;
}
return modifier(track, source, collected);
}
},
forSource: function(source, modifier){
return function(track, sourceActual, collected){
if (source != sourceActual){
return track;
}
return modifier(track, sourceActual, collected);
}
},
forGroup: function(group, modifier){
return function(track, source, collected){
ensureTrackParams(track);
if (group != track.params['group-title']){
return track;
}
return modifier(track, group, collected);
}
},
// track modifiers
remove: function(){
return undefined;
},
setImage: function(image){
return function(track){
ensureTrackParams(track);
track.params.logo = image;
return track;
}
},
setGroup: function(group){
return function(track){
ensureTrackParams(track);
track.params['group-title'] = group;
return track;
}
}
}