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 |
*/ |
8e2038
|
18 |
|
229976
|
19 |
package de.uhilger.calypso; |
8e2038
|
20 |
|
U |
21 |
import java.util.logging.Logger; |
|
22 |
import java.util.logging.Level; |
|
23 |
import java.util.List; |
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.Iterator; |
|
26 |
|
|
27 |
public class MeldeThread extends Thread { |
|
28 |
|
|
29 |
private static final Logger logger = Logger.getLogger(MeldeThread.class.getName()); |
|
30 |
|
|
31 |
private Process omxplayer; |
|
32 |
private int exitValue; |
|
33 |
private List<ProzessLauscher> lauscher = new ArrayList<>(); |
|
34 |
private String meldeUrlStr; |
|
35 |
|
|
36 |
public void setProcess(Process p) { |
|
37 |
this.omxplayer = p; |
|
38 |
} |
|
39 |
|
|
40 |
public int getExitValue() { |
|
41 |
return exitValue; |
|
42 |
} |
|
43 |
|
|
44 |
public void setMeldeUrl(String meldeUrlStr) { |
|
45 |
this.meldeUrlStr = meldeUrlStr; |
|
46 |
} |
|
47 |
|
|
48 |
public void run() { |
|
49 |
try { |
|
50 |
exitValue = omxplayer.waitFor(); |
|
51 |
prozessBeendetMelden(); |
|
52 |
} catch(Exception ex) { |
|
53 |
logger.log(Level.FINE, ex.getMessage(), ex); |
|
54 |
} finally { |
|
55 |
aufraeumen(); |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
private void aufraeumen() { |
|
60 |
lauscher.clear(); |
|
61 |
lauscher = null; |
|
62 |
} |
|
63 |
|
|
64 |
public void lauscherHinzufuegen(ProzessLauscher l) { |
|
65 |
lauscher.add(l); |
|
66 |
} |
|
67 |
|
|
68 |
public void lauscherEntfernen(ProzessLauscher l) { |
|
69 |
lauscher.remove(l); |
|
70 |
} |
|
71 |
|
|
72 |
private void prozessBeendetMelden() { |
|
73 |
Iterator<ProzessLauscher> i = lauscher.iterator(); |
|
74 |
while(i.hasNext()) { |
|
75 |
ProzessLauscher l = i.next(); |
|
76 |
l.prozessBeendet(meldeUrlStr); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
} |