commit | author | age
|
60719c
|
1 |
/* |
U |
2 |
AV-Direktor - Control OMXPlayer on Raspberry Pi via HTTP |
|
3 |
Copyright (C) 2021 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
8e2038
|
19 |
package de.uhilger.avdirektor; |
U |
20 |
|
|
21 |
import java.io.IOException; |
|
22 |
import java.util.HashMap; |
|
23 |
import java.util.logging.Level; |
|
24 |
import java.util.logging.Logger; |
|
25 |
|
|
26 |
/** |
cc2a32
|
27 |
* Hauptklasse des av-director |
U |
28 |
* |
|
29 |
* Aufruf mit |
|
30 |
* java -jar av-director.jar port=9000 |
|
31 |
* java -jar av-director.jar nfs-prefix="/media/mc" port=9000 |
|
32 |
* java -Djava.util.logging.config.file=logging.properties -jar .. |
|
33 |
* |
|
34 |
* Der Parameter nfs-prefix bewirkt, dass beim Abspielen relative Pfade |
|
35 |
* mit diesem Praefix verbunden werden und setzt voraus, dass auf der |
|
36 |
* Maschine ein NFS-Mount ueber /etc/fstab eingerichtet ist. |
|
37 |
* |
8e2038
|
38 |
* @author ulrich |
60719c
|
39 |
* @version 0.1, 20.03.2021 |
8e2038
|
40 |
*/ |
U |
41 |
public class App { |
|
42 |
|
|
43 |
private static final Logger logger = Logger.getLogger(App.class.getName()); |
|
44 |
|
ac1194
|
45 |
public static final String IP_PORT = "port"; |
U |
46 |
public static final String IP_WWW_DATA = "www-data"; |
|
47 |
public static final String IP_NFS_PREFIX = "nfs-prefix"; |
|
48 |
|
0af362
|
49 |
private static HashMap initParams; |
a7f0a1
|
50 |
private static Process playerproc; |
U |
51 |
|
8e2038
|
52 |
/** |
U |
53 |
* @param args the command line arguments |
|
54 |
*/ |
|
55 |
public static void main(String[] args) { |
|
56 |
initParams = new HashMap(); |
|
57 |
for(String arg: args) { |
|
58 |
String[] argParts = arg.split("="); |
|
59 |
initParams.put(argParts[0], argParts[1]); |
|
60 |
} |
ac1194
|
61 |
|
U |
62 |
Server server = new Server(Integer.parseInt(getInitParameter(IP_PORT))); |
8e2038
|
63 |
try { |
U |
64 |
server.start(); |
|
65 |
} catch (IOException ex) { |
|
66 |
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
public static void stop() { |
|
71 |
System.exit(0); |
|
72 |
} |
|
73 |
|
|
74 |
public static String getInitParameter(String pname) { |
|
75 |
String param = null; |
|
76 |
Object o = initParams.get(pname); |
|
77 |
if(o != null) { |
|
78 |
param = o.toString(); |
|
79 |
} |
|
80 |
return param; |
|
81 |
} |
|
82 |
|
a7f0a1
|
83 |
public static Process getPlayerProcess() { |
U |
84 |
return playerproc; |
|
85 |
} |
8e2038
|
86 |
|
a7f0a1
|
87 |
public static void setPlayerProcess(Process p) { |
U |
88 |
playerproc = p; |
|
89 |
} |
8e2038
|
90 |
} |