-
Notifications
You must be signed in to change notification settings - Fork 240
/
DecoderFactory.java
655 lines (604 loc) · 29.1 KB
/
DecoderFactory.java
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
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.module.decode;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.alias.action.AliasActionManager;
import io.github.dsheirer.audio.AbstractAudioModule;
import io.github.dsheirer.audio.AudioModule;
import io.github.dsheirer.channel.state.State;
import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.controller.channel.Channel.ChannelType;
import io.github.dsheirer.controller.channel.map.ChannelMap;
import io.github.dsheirer.controller.channel.map.ChannelMapModel;
import io.github.dsheirer.filter.AllPassFilter;
import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.filter.IFilter;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.MessageDirection;
import io.github.dsheirer.module.Module;
import io.github.dsheirer.module.decode.am.AMDecoder;
import io.github.dsheirer.module.decode.am.AMDecoderState;
import io.github.dsheirer.module.decode.am.DecodeConfigAM;
import io.github.dsheirer.module.decode.config.AuxDecodeConfiguration;
import io.github.dsheirer.module.decode.config.DecodeConfiguration;
import io.github.dsheirer.module.decode.dmr.DMRDecoder;
import io.github.dsheirer.module.decode.dmr.DMRDecoderState;
import io.github.dsheirer.module.decode.dmr.DMRTrafficChannelManager;
import io.github.dsheirer.module.decode.dmr.DecodeConfigDMR;
import io.github.dsheirer.module.decode.dmr.audio.DMRAudioModule;
import io.github.dsheirer.module.decode.fleetsync2.Fleetsync2Decoder;
import io.github.dsheirer.module.decode.fleetsync2.Fleetsync2DecoderState;
import io.github.dsheirer.module.decode.fleetsync2.FleetsyncMessageFilter;
import io.github.dsheirer.module.decode.lj1200.LJ1200Decoder;
import io.github.dsheirer.module.decode.lj1200.LJ1200DecoderState;
import io.github.dsheirer.module.decode.lj1200.LJ1200MessageFilter;
import io.github.dsheirer.module.decode.ltrnet.DecodeConfigLTRNet;
import io.github.dsheirer.module.decode.ltrnet.LTRNetDecoder;
import io.github.dsheirer.module.decode.ltrnet.LTRNetDecoderState;
import io.github.dsheirer.module.decode.ltrnet.LTRNetMessageFilter;
import io.github.dsheirer.module.decode.ltrstandard.DecodeConfigLTRStandard;
import io.github.dsheirer.module.decode.ltrstandard.LTRStandardDecoder;
import io.github.dsheirer.module.decode.ltrstandard.LTRStandardDecoderState;
import io.github.dsheirer.module.decode.ltrstandard.LTRStandardMessageFilter;
import io.github.dsheirer.module.decode.mdc1200.MDCDecoder;
import io.github.dsheirer.module.decode.mdc1200.MDCDecoderState;
import io.github.dsheirer.module.decode.mdc1200.MDCMessageFilter;
import io.github.dsheirer.module.decode.mpt1327.DecodeConfigMPT1327;
import io.github.dsheirer.module.decode.mpt1327.MPT1327Decoder;
import io.github.dsheirer.module.decode.mpt1327.MPT1327DecoderState;
import io.github.dsheirer.module.decode.mpt1327.MPT1327MessageFilter;
import io.github.dsheirer.module.decode.mpt1327.MPT1327TrafficChannelManager;
import io.github.dsheirer.module.decode.mpt1327.Sync;
import io.github.dsheirer.module.decode.nbfm.DecodeConfigNBFM;
import io.github.dsheirer.module.decode.nbfm.NBFMDecoder;
import io.github.dsheirer.module.decode.nbfm.NBFMDecoderState;
import io.github.dsheirer.module.decode.p25.P25TrafficChannelManager;
import io.github.dsheirer.module.decode.p25.audio.P25P1AudioModule;
import io.github.dsheirer.module.decode.p25.audio.P25P2AudioModule;
import io.github.dsheirer.module.decode.p25.phase1.DecodeConfigP25Phase1;
import io.github.dsheirer.module.decode.p25.phase1.P25P1DecoderC4FM;
import io.github.dsheirer.module.decode.p25.phase1.P25P1DecoderLSM;
import io.github.dsheirer.module.decode.p25.phase1.P25P1DecoderState;
import io.github.dsheirer.module.decode.p25.phase1.message.filter.P25MessageFilterSet;
import io.github.dsheirer.module.decode.p25.phase2.DecodeConfigP25Phase2;
import io.github.dsheirer.module.decode.p25.phase2.P25P2DecoderHDQPSK;
import io.github.dsheirer.module.decode.p25.phase2.P25P2DecoderState;
import io.github.dsheirer.module.decode.passport.DecodeConfigPassport;
import io.github.dsheirer.module.decode.passport.PassportDecoder;
import io.github.dsheirer.module.decode.passport.PassportDecoderState;
import io.github.dsheirer.module.decode.passport.PassportMessageFilter;
import io.github.dsheirer.module.decode.tait.Tait1200Decoder;
import io.github.dsheirer.module.decode.tait.Tait1200DecoderState;
import io.github.dsheirer.module.decode.traffic.TrafficChannelManager;
import io.github.dsheirer.module.demodulate.fm.FMDemodulatorModule;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.source.SourceType;
import io.github.dsheirer.source.config.SourceConfigTunerMultipleFrequency;
import io.github.dsheirer.source.tuner.channel.rotation.ChannelRotationMonitor;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Factory for creating decoder modules to use in a processing chain for any supported protocols.
*/
public class DecoderFactory
{
private final static Logger mLog = LoggerFactory.getLogger(DecoderFactory.class);
private static final double FM_CHANNEL_BANDWIDTH = 12500.0;
private static final boolean AUDIO_FILTER_ENABLE = true;
/**
* Returns a list of one primary decoder and any auxiliary decoders, as
* specified in the configurations.
*
* @return list of configured decoders
*/
public static List<Module> getModules(ChannelMapModel channelMapModel, Channel channel, AliasModel aliasModel,
UserPreferences userPreferences, TrafficChannelManager trafficChannelManager)
{
List<Module> modules = getPrimaryModules(channelMapModel, channel, aliasModel, userPreferences, trafficChannelManager);
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration()));
return modules;
}
/**
* Constructs a primary decoder as specified in the decode configuration
*
* @param channelMapModel for channel map lookups
* @param channel configuration
* @param aliasModel for alias lookups
* @param userPreferences instance
* @param trafficChannelManager optional traffic channel manager to use
* @return list of modules to use for a processing chain
*/
public static List<Module> getPrimaryModules(ChannelMapModel channelMapModel, Channel channel, AliasModel aliasModel,
UserPreferences userPreferences, TrafficChannelManager trafficChannelManager)
{
List<Module> modules = new ArrayList<Module>();
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
modules.add(new AliasActionManager(aliasList));
ChannelType channelType = channel.getChannelType();
/* Baseband low-pass filter pass and stop frequencies */
DecodeConfiguration decodeConfig = channel.getDecodeConfiguration();
switch(decodeConfig.getDecoderType())
{
case AM:
processAM(channel, modules, aliasList, decodeConfig);
break;
case DMR:
processDMR(channel, userPreferences, modules, aliasList, (DecodeConfigDMR)decodeConfig,
trafficChannelManager);
break;
case NBFM:
processNBFM(channel, modules, aliasList, decodeConfig);
break;
case LTR:
processLTRStandard(channel, modules, aliasList, (DecodeConfigLTRStandard) decodeConfig);
break;
case LTR_NET:
processLTRNet(channel, modules, aliasList, (DecodeConfigLTRNet) decodeConfig);
break;
case MPT1327:
processMPT1327(channelMapModel, channel, modules, aliasList, channelType, (DecodeConfigMPT1327) decodeConfig);
break;
case PASSPORT:
processPassport(channel, modules, aliasList, decodeConfig);
break;
case P25_PHASE1:
processP25Phase1(channel, userPreferences, modules, aliasList, channelType, (DecodeConfigP25Phase1) decodeConfig);
break;
case P25_PHASE2:
processP25Phase2(channel, userPreferences, modules, aliasList);
break;
default:
throw new IllegalArgumentException("Unknown decoder type [" + decodeConfig.getDecoderType().toString() + "]");
}
return modules;
}
/**
* Creates decoder modules for APCO-25 Phase 2 decoder
* @param channel configuration
* @param userPreferences reference
* @param modules collection to add to
* @param aliasList for the channel
*/
private static void processP25Phase2(Channel channel, UserPreferences userPreferences, List<Module> modules, AliasList aliasList) {
modules.add(new P25P2DecoderHDQPSK((DecodeConfigP25Phase2)channel.getDecodeConfiguration()));
modules.add(new P25P2DecoderState(channel, 0));
modules.add(new P25P2DecoderState(channel, 1));
modules.add(new P25P2AudioModule(userPreferences, 0, aliasList));
modules.add(new P25P2AudioModule(userPreferences, 1, aliasList));
}
/**
* Creates decoder modules for APCO-25 Phase 1 decoder
* @param channel configuration
* @param userPreferences reference
* @param modules collection to add to
* @param aliasList for the channel
*/
private static void processP25Phase1(Channel channel, UserPreferences userPreferences, List<Module> modules, AliasList aliasList, ChannelType channelType, DecodeConfigP25Phase1 decodeConfig) {
DecodeConfigP25Phase1 p25Config = decodeConfig;
switch(p25Config.getModulation())
{
case C4FM:
modules.add(new P25P1DecoderC4FM());
break;
case CQPSK:
modules.add(new P25P1DecoderLSM());
break;
default:
throw new IllegalArgumentException("Unrecognized P25 Phase 1 Modulation [" +
p25Config.getModulation() + "]");
}
if(channelType == ChannelType.STANDARD)
{
P25TrafficChannelManager trafficChannelManager = new P25TrafficChannelManager(channel);
modules.add(trafficChannelManager);
modules.add(new P25P1DecoderState(channel, trafficChannelManager));
}
else
{
modules.add(new P25P1DecoderState(channel));
}
modules.add(new P25P1AudioModule(userPreferences, aliasList));
//Add a channel rotation monitor when we have multiple control channel frequencies specified
if(channel.getSourceConfiguration() instanceof SourceConfigTunerMultipleFrequency &&
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).hasMultipleFrequencies())
{
List<State> activeStates = new ArrayList<>();
activeStates.add(State.CONTROL);
modules.add(new ChannelRotationMonitor(activeStates,
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).getFrequencyRotationDelay()));
}
}
/**
* Creates decoder modules for Passport decoder
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param decodeConfig for the channel
*/
private static void processPassport(Channel channel, List<Module> modules, AliasList aliasList, DecodeConfiguration decodeConfig) {
modules.add(new PassportDecoder(decodeConfig));
modules.add(new PassportDecoderState());
modules.add(new AudioModule(aliasList, AUDIO_FILTER_ENABLE));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH));
}
}
/**
* Creates decoder modules for MPT-1327 decoder
* @param channelMapModel to use in calculating traffic channel frequencies
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param channelType for control or traffic
* @param decodeConfig configuration
*/
private static void processMPT1327(ChannelMapModel channelMapModel, Channel channel, List<Module> modules, AliasList aliasList, ChannelType channelType, DecodeConfigMPT1327 decodeConfig) {
DecodeConfigMPT1327 mptConfig = decodeConfig;
ChannelMap channelMap = channelMapModel.getChannelMap(mptConfig.getChannelMapName());
Sync sync = mptConfig.getSync();
modules.add(new MPT1327Decoder(sync));
final int callTimeoutMilliseconds = mptConfig.getCallTimeoutSeconds() * 1000;
// Set max segment audio sample length slightly above call timeout to
// not create a new segment if the processing chain finishes a bit after
// actual call timeout.
long maxAudioSegmentLengthMillis = (callTimeoutMilliseconds + 5000);
modules.add(new AudioModule(aliasList, AbstractAudioModule.DEFAULT_TIMESLOT, maxAudioSegmentLengthMillis, AUDIO_FILTER_ENABLE));
SourceType sourceType = channel.getSourceConfiguration().getSourceType();
if(sourceType == SourceType.TUNER || sourceType == SourceType.TUNER_MULTIPLE_FREQUENCIES)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH));
}
if(channelType == ChannelType.STANDARD)
{
MPT1327TrafficChannelManager trafficChannelManager = new MPT1327TrafficChannelManager(channel, channelMap);
modules.add(trafficChannelManager);
modules.add(new MPT1327DecoderState(trafficChannelManager, channelType, callTimeoutMilliseconds));
}
else
{
modules.add(new MPT1327DecoderState(channelType, callTimeoutMilliseconds));
}
//Add a channel rotation monitor when we have multiple control channel frequencies specified
if(channel.getSourceConfiguration() instanceof SourceConfigTunerMultipleFrequency &&
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).hasMultipleFrequencies())
{
List<State> activeStates = new ArrayList<>();
activeStates.add(State.CONTROL);
modules.add(new ChannelRotationMonitor(activeStates,
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).getFrequencyRotationDelay()));
}
}
/**
* Creates decoder modules for LTR-Net decoder
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param decodeConfig for the channel
*/
private static void processLTRNet(Channel channel, List<Module> modules, AliasList aliasList, DecodeConfigLTRNet decodeConfig) {
modules.add(new LTRNetDecoder(decodeConfig));
modules.add(new LTRNetDecoderState());
modules.add(new AudioModule(aliasList, AUDIO_FILTER_ENABLE));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH));
}
}
/**
* Creates decoder modules for LTR decoder
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param decodeConfig for the channel
*/
private static void processLTRStandard(Channel channel, List<Module> modules, AliasList aliasList, DecodeConfigLTRStandard decodeConfig) {
MessageDirection direction = decodeConfig.getMessageDirection();
modules.add(new LTRStandardDecoder(direction));
modules.add(new LTRStandardDecoderState());
modules.add(new AudioModule(aliasList, AUDIO_FILTER_ENABLE));
if(channel.getSourceConfiguration().getSourceType() == SourceType.TUNER)
{
modules.add(new FMDemodulatorModule(FM_CHANNEL_BANDWIDTH));
}
}
/**
* Creates decoder modules for Narrow Band FM decoder
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param decodeConfig for the channel
*/
private static void processNBFM(Channel channel, List<Module> modules, AliasList aliasList, DecodeConfiguration decodeConfig)
{
if(!(decodeConfig instanceof DecodeConfigNBFM))
{
throw new IllegalArgumentException("Can't create NBFM decoder - unrecognized decode config type: " +
(decodeConfig != null ? decodeConfig.getClass() : "null/empty"));
}
DecodeConfigNBFM decodeConfigNBFM = (DecodeConfigNBFM)decodeConfig;
modules.add(new NBFMDecoder(decodeConfigNBFM));
modules.add(new NBFMDecoderState(channel.getName(), decodeConfigNBFM));
modules.add(new AudioModule(aliasList, 0, 60000, decodeConfigNBFM.isAudioFilter()));
}
/**
* Creates decoder modules for AM decoder
* @param channel configuration
* @param modules collection to add to
* @param aliasList for the channel
* @param decodeConfig for the channel
*/
private static void processAM(Channel channel, List<Module> modules, AliasList aliasList, DecodeConfiguration decodeConfig) {
if(!(decodeConfig instanceof DecodeConfigAM))
{
throw new IllegalArgumentException("Can't create AM decoder - unrecognized decode config type: " +
(decodeConfig != null ? decodeConfig.getClass() : "null/empty"));
}
DecodeConfigAM decodeConfigAM = (DecodeConfigAM) decodeConfig;
modules.add(new AMDecoder(decodeConfigAM));
modules.add(new AMDecoderState(channel.getName(), decodeConfigAM));
modules.add(new AudioModule(aliasList, 0, 60000, AUDIO_FILTER_ENABLE));
}
/**
* Creates modules for DMR decoder setup.
*
* Note: on some DMR systems (e.g. Capacity+) we convert standard channels to traffic channels (when rest channel
* changes) and so we reuse the traffic channel manager from the converted channel.
*
* @param channel for the DMR decoder
* @param userPreferences for access to JMBE audio library
* @param modules list to add to
* @param aliasList for the audio module
* @param decodeConfig for the DMR configuration
* @param trafficChannelManager optional traffic channel manager to re-use
*/
private static void processDMR(Channel channel, UserPreferences userPreferences, List<Module> modules,
AliasList aliasList, DecodeConfigDMR decodeConfig,
TrafficChannelManager trafficChannelManager)
{
modules.add(new DMRDecoder(decodeConfig));
DMRTrafficChannelManager dmrTrafficChannelManager = null;
if(channel.isStandardChannel())
{
if(trafficChannelManager instanceof DMRTrafficChannelManager)
{
dmrTrafficChannelManager = (DMRTrafficChannelManager)trafficChannelManager;
}
else
{
dmrTrafficChannelManager = new DMRTrafficChannelManager(channel);
}
modules.add(dmrTrafficChannelManager);
}
modules.add(new DMRDecoderState(channel, 1, dmrTrafficChannelManager));
modules.add(new DMRDecoderState(channel, 2, dmrTrafficChannelManager));
modules.add(new DMRAudioModule(userPreferences, aliasList, 1));
modules.add(new DMRAudioModule(userPreferences, aliasList, 2));
//Add a channel rotation monitor when we have multiple control channel frequencies specified
if(channel.getSourceConfiguration() instanceof SourceConfigTunerMultipleFrequency &&
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).hasMultipleFrequencies())
{
List<State> activeStates = new ArrayList<>();
activeStates.add(State.CONTROL);
modules.add(new ChannelRotationMonitor(activeStates,
((SourceConfigTunerMultipleFrequency)channel.getSourceConfiguration()).getFrequencyRotationDelay()));
}
}
/**
* Constructs a list of auxiliary decoders, as specified in the channel configuration
*
* @param config - auxiliary configuration
* @return - list of auxiliary decoders
*/
public static List<Module> getAuxiliaryDecoders(AuxDecodeConfiguration config)
{
List<Module> modules = new ArrayList<>();
if(config != null)
{
for(DecoderType auxDecoder : config.getAuxDecoders())
{
switch(auxDecoder)
{
case FLEETSYNC2:
modules.add(new Fleetsync2Decoder());
modules.add(new Fleetsync2DecoderState());
break;
case MDC1200:
modules.add(new MDCDecoder());
modules.add(new MDCDecoderState());
break;
case LJ_1200:
modules.add(new LJ1200Decoder());
modules.add(new LJ1200DecoderState());
break;
case TAIT_1200:
modules.add(new Tait1200Decoder());
modules.add(new Tait1200DecoderState());
break;
default:
throw new IllegalArgumentException("Unrecognized auxiliary decoder type [" + auxDecoder + "]");
}
}
}
return modules;
}
/**
* Assembles a filter set containing filters for the primary channel
* decoder and each of the auxiliary decoders
*/
public static FilterSet<IMessage> getMessageFilters(List<Module> modules)
{
FilterSet<IMessage> filterSet = new FilterSet<>();
for(Module module : modules)
{
if(module instanceof Decoder)
{
filterSet.addFilters(getMessageFilter(((Decoder)module).getDecoderType()));
}
}
/* If we don't have any filters, add an ALL-PASS filter */
if(filterSet.getFilters().isEmpty())
{
filterSet.addFilter(new AllPassFilter<>());
}
return filterSet;
}
/**
* Returns a set of IMessageFilter objects (FilterSets or Filters) that
* can process all of the messages produced by the specified decoder type.
*/
public static List<IFilter<IMessage>> getMessageFilter(DecoderType decoder)
{
ArrayList<IFilter<IMessage>> filters = new ArrayList<>();
switch(decoder)
{
case FLEETSYNC2:
filters.add(new FleetsyncMessageFilter());
break;
case LJ_1200:
filters.add(new LJ1200MessageFilter());
break;
case LTR_NET:
filters.add(new LTRNetMessageFilter());
break;
case LTR:
filters.add(new LTRStandardMessageFilter());
break;
case MDC1200:
filters.add(new MDCMessageFilter());
break;
case MPT1327:
filters.add(new MPT1327MessageFilter());
break;
case P25_PHASE1:
filters.add(new P25MessageFilterSet());
break;
case PASSPORT:
filters.add(new PassportMessageFilter());
break;
case DMR:
//filters.add(new DMR) //todo: not finished
break;
default:
break;
}
return filters;
}
public static DecodeConfiguration getDefaultDecodeConfiguration()
{
return getDecodeConfiguration(DecoderType.NBFM);
}
public static DecodeConfiguration getDecodeConfiguration(DecoderType decoder)
{
switch(decoder)
{
case AM:
return new DecodeConfigAM();
case DMR:
return new DecodeConfigDMR();
case LTR:
return new DecodeConfigLTRStandard();
case LTR_NET:
return new DecodeConfigLTRNet();
case MPT1327:
return new DecodeConfigMPT1327();
case NBFM:
return new DecodeConfigNBFM();
case PASSPORT:
return new DecodeConfigPassport();
case P25_PHASE1:
return new DecodeConfigP25Phase1();
case P25_PHASE2:
return new DecodeConfigP25Phase2();
default:
throw new IllegalArgumentException("DecodeConfigFactory - unknown decoder type [" + decoder + "]");
}
}
/**
* Creates a copy of the configuration
*/
public static DecodeConfiguration copy(DecodeConfiguration config)
{
if(config != null)
{
switch(config.getDecoderType())
{
case AM:
DecodeConfigAM copyAM = new DecodeConfigAM();
DecodeConfigAM origAM = (DecodeConfigAM)config;
copyAM.setBandwidth(origAM.getBandwidth());
copyAM.setTalkgroup(origAM.getTalkgroup());
copyAM.setSquelchThreshold(origAM.getSquelchThreshold());
copyAM.setSquelchAutoTrack(origAM.isSquelchAutoTrack());
return copyAM;
case DMR:
return new DecodeConfigDMR();
case LTR_NET:
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet)config;
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
copyLTRNet.setMessageDirection(originalLTRNet.getMessageDirection());
return copyLTRNet;
case LTR:
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard)config;
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
copyLTRStandard.setMessageDirection(originalLTRStandard.getMessageDirection());
return copyLTRStandard;
case MPT1327:
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
copyMPT.setCallTimeoutSeconds(originalMPT.getCallTimeoutSeconds());
copyMPT.setChannelMapName(originalMPT.getChannelMapName());
copyMPT.setSync(originalMPT.getSync());
copyMPT.setTrafficChannelPoolSize(originalMPT.getTrafficChannelPoolSize());
return copyMPT;
case NBFM:
DecodeConfigNBFM origNBFM = (DecodeConfigNBFM)config;
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
copyNBFM.setBandwidth(origNBFM.getBandwidth());
copyNBFM.setSquelchThreshold(origNBFM.getSquelchThreshold());
copyNBFM.setSquelchAutoTrack(origNBFM.isSquelchAutoTrack());
copyNBFM.setTalkgroup(origNBFM.getTalkgroup());
return copyNBFM;
case P25_PHASE1:
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1)config;
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
copyP25.setIgnoreDataCalls(originalP25.getIgnoreDataCalls());
copyP25.setModulation(originalP25.getModulation());
copyP25.setTrafficChannelPoolSize(originalP25.getTrafficChannelPoolSize());
return copyP25;
case P25_PHASE2:
DecodeConfigP25Phase2 originalP25P2 = (DecodeConfigP25Phase2)config;
DecodeConfigP25Phase2 copyP25P2 = new DecodeConfigP25Phase2();
if(originalP25P2.getScrambleParameters() != null)
{
copyP25P2.setScrambleParameters(originalP25P2.getScrambleParameters().copy());
}
return copyP25P2;
case PASSPORT:
return new DecodeConfigPassport();
default:
throw new IllegalArgumentException("Unrecognized decoder configuration type:" + config.getDecoderType());
}
}
return null;
}
}