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 |
|
229976
|
19 |
package de.uhilger.calypso; |
8e2038
|
20 |
|
229976
|
21 |
import de.uhilger.calypso.handler.OMXPlayer; |
U |
22 |
import de.uhilger.calypso.handler.Player; |
|
23 |
import de.uhilger.calypso.handler.VLCPlayer; |
8e2038
|
24 |
import java.io.IOException; |
U |
25 |
import java.util.HashMap; |
|
26 |
import java.util.logging.Level; |
|
27 |
import java.util.logging.Logger; |
|
28 |
|
|
29 |
/** |
cc2a32
|
30 |
* Hauptklasse des av-director |
U |
31 |
* |
|
32 |
* Aufruf mit |
c2c1fd
|
33 |
* java -jar av-director.jar port=9000 ctx="/calypso" |
cc2a32
|
34 |
* java -jar av-director.jar nfs-prefix="/media/mc" port=9000 |
U |
35 |
* java -Djava.util.logging.config.file=logging.properties -jar .. |
|
36 |
* |
|
37 |
* Der Parameter nfs-prefix bewirkt, dass beim Abspielen relative Pfade |
|
38 |
* mit diesem Praefix verbunden werden und setzt voraus, dass auf der |
|
39 |
* Maschine ein NFS-Mount ueber /etc/fstab eingerichtet ist. |
|
40 |
* |
8e2038
|
41 |
* @author ulrich |
60719c
|
42 |
* @version 0.1, 20.03.2021 |
8e2038
|
43 |
*/ |
U |
44 |
public class App { |
|
45 |
|
|
46 |
private static final Logger logger = Logger.getLogger(App.class.getName()); |
|
47 |
|
ac1194
|
48 |
public static final String IP_PORT = "port"; |
U |
49 |
public static final String IP_WWW_DATA = "www-data"; |
|
50 |
public static final String IP_NFS_PREFIX = "nfs-prefix"; |
cfe367
|
51 |
public static final String IP_PLAYER = "player"; |
U |
52 |
public static final String VLC_PLAYER = "vlc"; |
|
53 |
public static final String OMX_PLAYER = "omx"; |
6ff352
|
54 |
public static final String OMX_WD = "omx.wd"; |
c2c1fd
|
55 |
public static final String CTX = "ctx"; |
cfe367
|
56 |
|
c2c1fd
|
57 |
public static final String DEFAULT_CTX = "/calypso"; |
ac1194
|
58 |
|
0af362
|
59 |
private static HashMap initParams; |
a7f0a1
|
60 |
private static Process playerproc; |
cfe367
|
61 |
private static Player player; |
a7f0a1
|
62 |
|
8e2038
|
63 |
/** |
U |
64 |
* @param args the command line arguments |
|
65 |
*/ |
|
66 |
public static void main(String[] args) { |
|
67 |
initParams = new HashMap(); |
|
68 |
for(String arg: args) { |
|
69 |
String[] argParts = arg.split("="); |
|
70 |
initParams.put(argParts[0], argParts[1]); |
|
71 |
} |
ac1194
|
72 |
|
cfe367
|
73 |
String playerType = getInitParameter(IP_PLAYER); |
U |
74 |
switch(playerType) { |
|
75 |
case VLC_PLAYER: |
|
76 |
player = new VLCPlayer(); |
|
77 |
break; |
|
78 |
case OMX_PLAYER: |
|
79 |
player = new OMXPlayer(); |
|
80 |
break; |
|
81 |
} |
ac1194
|
82 |
Server server = new Server(Integer.parseInt(getInitParameter(IP_PORT))); |
c2c1fd
|
83 |
String ctx = getInitParameter(CTX); |
U |
84 |
if(ctx != null && ctx.length() > 0) { |
|
85 |
server.setContextName(ctx); |
|
86 |
} else { |
|
87 |
server.setContextName(DEFAULT_CTX); |
|
88 |
} |
8e2038
|
89 |
try { |
U |
90 |
server.start(); |
|
91 |
} catch (IOException ex) { |
|
92 |
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public static void stop() { |
|
97 |
System.exit(0); |
|
98 |
} |
|
99 |
|
|
100 |
public static String getInitParameter(String pname) { |
|
101 |
String param = null; |
|
102 |
Object o = initParams.get(pname); |
|
103 |
if(o != null) { |
|
104 |
param = o.toString(); |
|
105 |
} |
|
106 |
return param; |
|
107 |
} |
|
108 |
|
a7f0a1
|
109 |
public static Process getPlayerProcess() { |
U |
110 |
return playerproc; |
|
111 |
} |
8e2038
|
112 |
|
a7f0a1
|
113 |
public static void setPlayerProcess(Process p) { |
U |
114 |
playerproc = p; |
|
115 |
} |
cfe367
|
116 |
|
U |
117 |
public static Player getPlayer() { |
|
118 |
return player; |
|
119 |
} |
|
120 |
|
|
121 |
public static void setPlayer(Player pl) { |
|
122 |
player = pl; |
|
123 |
} |
|
124 |
|
|
125 |
|
|
126 |
|
8e2038
|
127 |
} |