summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems/vdrmanager/data/Vdr.java
blob: 8dd150f5473034dfaf12d249370496a2b79229a8 (plain)
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
package de.bjusystems.vdrmanager.data;

import java.util.HashMap;
import java.util.Map;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

@DatabaseTable
public class Vdr {

	/**
	 * 
	 */
	@DatabaseField(columnName = "_id", generatedId = true)
	private Integer id;

	@DatabaseField(columnName = "name")
	private String name = "-";

	/**
	 * Use secure channel
	 */
	@DatabaseField(defaultValue = "false")
	private boolean secure;

	/** SVDRP host name or ip */
	@DatabaseField
	private String host;

	/** SVDRP port */
	@DatabaseField
	private int port;

	/** Password */
	@DatabaseField
	private String password;

	/** should channels be filtered? */
	@DatabaseField
	private boolean filterChannels;

	/** last channel to retrieve */
	@DatabaseField
	private String channelFilter;

	/** Enable remote wakeup */
	@DatabaseField
	private boolean wakeupEnabled;

	/** URL of the wakeup script */
	@DatabaseField
	private String wakeupUrl;

	/** User for wakeup */
	@DatabaseField
	private String wakeupUser;

	/** Password for wakeup */
	@DatabaseField
	private String wakeupPassword;

	/**
	 * vdr mac for wol
	 * 
	 * @since 0.2
	 */
	@DatabaseField
	private String mac;

	/**
	 * which wakeup method to use
	 * 
	 * @since 0.2
	 * 
	 */
	@DatabaseField
	private String wakeupMethod;

	/** Check for running VDR is enabled */
	@DatabaseField
	private boolean aliveCheckEnabled;

	/** Intervall for alive test */
	@DatabaseField
	private int aliveCheckInterval;

	/** Buffer before event */
	@DatabaseField
	private int timerPreMargin;

	/** Buffer after event */
	@DatabaseField
	private int timerPostMargin;

	/** Default priority */
	@DatabaseField
	private int timerDefaultPriority;

	/** Default lifetime */
	@DatabaseField
	private int timerDefaultLifetime;

	/** user defined epg search times */
	@DatabaseField
	private String epgSearchTimes;

	/**
	 * Which port to use for streaming
	 * 
	 * @since 0.2
	 */
	@DatabaseField
	private int streamPort = 3000;

	/**
	 * Which format to use for streaming
	 * 
	 * @since 0.2
	 */
	@DatabaseField
	private String streamFormat = "TS";

	/**
	 * Do not send broadcasts, send directly to the host (router problem)
	 * 
	 * @since 0.2
	 */
	@DatabaseField
	private String wolCustomBroadcast = "";

	/**
	 * Use remux ?
	 */
	@DatabaseField
	private boolean enableRemux;

	/**
	 * Remux command
	 */
	@DatabaseField
	private String remuxCommand;

	/**
	 * Remux command Parameter
	 */
	@DatabaseField
	private String remuxParameter;

	@DatabaseField
	private String encoding = "utf-8";

	/**
	 * Connection timeout
	 */
	@DatabaseField
	private int connectionTimeout;

	/**
	 * Read Timeout
	 */
	@DatabaseField
	private int readTimeout;

	/**
	 * Timeout for a whole command run
	 */
	@DatabaseField
	private int timeout;

	@DatabaseField
	private String streamingUsername;

	@DatabaseField
	private String streamingPassword;
	
	@DatabaseField
	private int livePort;
	
	@DatabaseField
	private String recStreamMethod;
	
	@DatabaseField
	private boolean enableRecStreaming = false;

	
	public String getRecStreamMethod() {
		return recStreamMethod;
	}

	public void setRecStreamMethod(String recStreamMethod) {
		this.recStreamMethod = recStreamMethod;
	}

	public int getLivePort() {
		return livePort;
	}

	public void setLivePort(int livePort) {
		this.livePort = livePort;
	}

	public boolean isEnableRecStreaming() {
		return enableRecStreaming;
	}

	public void setEnableRecStreaming(boolean enableRecStreaming) {
		this.enableRecStreaming = enableRecStreaming;
	}


	public String getStreamingPassword() {
		return streamingPassword;
	}

	public void setStreamingPassword(String streamingPassword) {
		this.streamingPassword = streamingPassword;
	}

	public String getStreamingUsername() {
		return streamingUsername;
	}

	public void setStreamingUsername(String streamingUsername) {
		this.streamingUsername = streamingUsername;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public boolean isSecure() {
		return secure;
	}

	public void setSecure(boolean secure) {
		this.secure = secure;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isFilterChannels() {
		return filterChannels;
	}

	public void setFilterChannels(boolean filterChannels) {
		this.filterChannels = filterChannels;
	}

	public String getChannelFilter() {
		return channelFilter;
	}

	public void setChannelFilter(String channelFilter) {
		this.channelFilter = channelFilter;
	}

	public boolean isWakeupEnabled() {
		return wakeupEnabled;
	}

	public void setWakeupEnabled(boolean wakeupEnabled) {
		this.wakeupEnabled = wakeupEnabled;
	}

	public String getWakeupUrl() {
		return wakeupUrl;
	}

	public void setWakeupUrl(String wakeupUrl) {
		this.wakeupUrl = wakeupUrl;
	}

	public String getWakeupUser() {
		return wakeupUser;
	}

	public void setWakeupUser(String wakeupUser) {
		this.wakeupUser = wakeupUser;
	}

	public String getWakeupPassword() {
		return wakeupPassword;
	}

	public void setWakeupPassword(String wakeupPassword) {
		this.wakeupPassword = wakeupPassword;
	}

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public String getWakeupMethod() {
		return wakeupMethod;
	}

	public void setWakeupMethod(String wakeupMethod) {
		this.wakeupMethod = wakeupMethod;
	}

	public boolean isAliveCheckEnabled() {
		return aliveCheckEnabled;
	}

	public void setAliveCheckEnabled(boolean aliveCheckEnabled) {
		this.aliveCheckEnabled = aliveCheckEnabled;
	}

	public int getAliveCheckInterval() {
		return aliveCheckInterval;
	}

	public void setAliveCheckInterval(int aliveCheckInterval) {
		this.aliveCheckInterval = aliveCheckInterval;
	}

	public int getTimerPreMargin() {
		return timerPreMargin;
	}

	public void setTimerPreMargin(int timerPreMargin) {
		this.timerPreMargin = timerPreMargin;
	}

	public int getTimerPostMargin() {
		return timerPostMargin;
	}

	public void setTimerPostMargin(int timerPostMargin) {
		this.timerPostMargin = timerPostMargin;
	}

	public int getTimerDefaultPriority() {
		return timerDefaultPriority;
	}

	public void setTimerDefaultPriority(int timerDefaultPriority) {
		this.timerDefaultPriority = timerDefaultPriority;
	}

	public int getTimerDefaultLifetime() {
		return timerDefaultLifetime;
	}

	public void setTimerDefaultLifetime(int timerDefaultLifetime) {
		this.timerDefaultLifetime = timerDefaultLifetime;
	}

	public String getEpgSearchTimes() {
		return epgSearchTimes;
	}

	public void setEpgSearchTimes(String epgSearchTimes) {
		this.epgSearchTimes = epgSearchTimes;
	}

	public int getStreamPort() {
		return streamPort;
	}

	public void setStreamPort(int streamPort) {
		this.streamPort = streamPort;
	}

	public String getStreamFormat() {
		return streamFormat;
	}

	public void setStreamFormat(String streamFormat) {
		this.streamFormat = streamFormat;
	}

	public String getWolCustomBroadcast() {
		return wolCustomBroadcast;
	}

	public void setWolCustomBroadcast(String wolCustomBroadcast) {
		this.wolCustomBroadcast = wolCustomBroadcast;
	}

	public boolean isEnableRemux() {
		return enableRemux;
	}

	public void setEnableRemux(boolean enableRemux) {
		this.enableRemux = enableRemux;
	}

	public String getRemuxCommand() {
		return remuxCommand;
	}

	public void setRemuxCommand(String remuxCommand) {
		this.remuxCommand = remuxCommand;
	}

	public String getRemuxParameter() {
		return remuxParameter;
	}

	public void setRemuxParameter(String remuxParameter) {
		this.remuxParameter = remuxParameter;
	}

	public String getEncoding() {
		return encoding;
	}

	public void setEncoding(String encoding) {
		this.encoding = encoding;
	}

	public int getConnectionTimeout() {
		return connectionTimeout;
	}

	public void setConnectionTimeout(int connectionTimeout) {
		this.connectionTimeout = connectionTimeout;
	}

	public int getReadTimeout() {
		return readTimeout;
	}

	public void setReadTimeout(int readTimeout) {
		this.readTimeout = readTimeout;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}

	private static <T> T get(Map<String, Object> map, String key) {
		return get(map, key, null);
	}

	private static <T> T get(Map<String, Object> map, String key, Object def) {
		return (T) map.get(key);
	}

	private static Integer getInteger(Map<String, Object> map, String key) {
		if (map.containsKey(key) == false) {
			return Integer.valueOf(0);
		}

		Object obj = get(map, key);
		if (obj instanceof Integer) {
			return (Integer) obj;
		}
		return Integer.valueOf(String.valueOf(obj));
	}

	private static Boolean getBoolean(Map<String, Object> map, String key) {
		if (map.containsKey(key) == false) {
			return Boolean.FALSE;
		}
		Object obj = get(map, key);
		if (obj instanceof Boolean) {
			return (Boolean) obj;
		}
		return Boolean.valueOf(String.valueOf(obj));
	}

	public HashMap<String, Object> toMap() {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("vdr_name", name);
		map.put("vdr_host", host);
		map.put("vdr_port", port);
		map.put("vdr_password", password);
		map.put("vdr_secure", secure);

		map.put("limit_channels", filterChannels);
		map.put("last_channel", channelFilter);

		map.put("key_wakeup_enabled", wakeupEnabled);
		map.put("key_wakeup_url", wakeupUrl);
		map.put("key_wakeup_user", wakeupUser);
		map.put("key_wakeup_password", wakeupPassword);
		map.put("key_wakeup_method", wakeupMethod);
		map.put("key_wol_custom_broadcast", wolCustomBroadcast);
		map.put("key_wakeup_wol_mac", mac);

		map.put("key_conntimeout_key", connectionTimeout);
		map.put("key_vdr_readtimeout", readTimeout);
		map.put("key_vdr_timeout", timeout);

		map.put("timer_pre_start_buffer", timerPreMargin);
		map.put("timer_post_end_buffer", timerPreMargin);
		map.put("timer_default_priority", timerDefaultPriority);
		map.put("timer_default_lifetime", timerDefaultLifetime);

		map.put("streamingport", streamPort);
		map.put("key_streaming_password", streamingPassword);
		map.put("key_streaming_username", streamingUsername);
		map.put("key_vdr_encoding", encoding);
		map.put("livetv_streamformat", streamFormat);
		map.put("remux_command", remuxCommand);
		map.put("remux_parameter", remuxParameter);
		map.put("remux_enable", enableRemux);
		map.put("key_rec_stream_enable", enableRecStreaming);
		map.put("key_live_port", livePort);
		map.put("key_recstream_method", recStreamMethod );
		return map;
	}

	public void init(Map<String, Object> map) {
		name = get(map, "vdr_name", name);
		host = get(map, "vdr_host" );
		port = getInteger(map, "vdr_port");
		password = get(map, "vdr_password");
		secure = getBoolean(map, "vdr_secure");

		filterChannels = getBoolean(map, "limit_channels");
		channelFilter = get(map, "last_channel");

		wakeupEnabled = getBoolean(map, "key_wakeup_enabled");
		wakeupUrl = get(map, "key_wakeup_url", "0.0.0.0");
		wakeupUser = get(map, "key_wakeup_user","");
		wakeupPassword = get(map, "key_wakeup_password","");
		wakeupMethod = get(map, "key_wakeup_method","wol");
		wolCustomBroadcast = get(map, "key_wol_custom_broadcast","");
		mac = get(map, "key_wakeup_wol_mac","");

		connectionTimeout = getInteger(map, "key_conntimeout_key");
		readTimeout = getInteger(map, "key_vdr_readtimeout");
		timeout = getInteger(map, "key_vdr_timeout");

		timerPreMargin = getInteger(map, "timer_pre_start_buffer");
		timerPreMargin = getInteger(map, "timer_post_end_buffer");
		timerDefaultPriority = getInteger(map, "timer_default_priority");
		timerDefaultLifetime = getInteger(map, "timer_default_lifetime");

		streamPort = getInteger(map, "streamingport");
		streamingPassword = get(map, "key_streaming_password");
		streamingUsername = get(map, "key_streaming_username");
		encoding = get(map, "key_vdr_encoding");
		streamFormat = get(map, "livetv_streamformat");
		remuxCommand = get(map, "remux_command");
		remuxParameter = get(map, "remux_parameter");
		enableRemux = getBoolean(map, "remux_enable");
		
		enableRecStreaming = getBoolean(map, "key_rec_stream_enable");
		livePort = getInteger(map, "key_live_port");
		recStreamMethod = get(map, "key_recstream_method");

	}

}