forked from matthiasbock/gstreamer-phone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lohmann.py
executable file
·72 lines (65 loc) · 1.8 KB
/
lohmann.py
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
#! /usr/bin/python
path = '/usr/src/gstreamer-phone'
import sys
if not path in sys.path:
sys.path.append(path)
from socket import gethostbyname
from subprocess import Popen, PIPE
from shlex import split
from time import sleep
from log import *
import buttons, ring
from buttons import pressed, btnLeft, btnRight
from ring import *
# testing for Raspberry Pi OpenMAX libraries
if 'omxh264dec' in Popen(['gst-inspect-1.0'], stdout=PIPE).communicate()[0]:
log("gstreamer has Raspberry Pi superpowers")
else:
log("Error: gstreamer has no Raspberry Pi superpowers")
while True:
#
# Start button
#
if pressed(btnRight):
log("Initiating session ...")
waehlton()
success = False
try:
ip = gethostbyname("urmel.local")
log("Paintner was found in the local network at "+ip)
success = (ip is not None) and (ip != '')
except:
pass
if not success:
try:
ip = gethostbyname("la-cp386.no-ip.org")
log("Paintner resolved to "+ip)
success = True
except:
log("Network error: Unable to resolve Paintner's IP address. Check your LAN or WLAN connection.")
keinfreizeichenton()
if success:
log("Calling "+ip+" ...")
Popen(split(path+'/streaming/lohmann-to-paintner '+ip))
#
# Stop button
#
# patch: right button press also somehow invokes left button event
if pressed(btnLeft) and not pressed(btnRight):
waehlton()
sleep(1)
if pressed(btnLeft): # still pressed
if pressed(btnRight): # both pressed at once
log("Shutdown")
herunterfahrton()
Popen(['halt'])
# else:
# log("Reboot")
# neustartton()
# Popen(['reboot'])
else:
Popen(split('killall ssh'), stdout=PIPE, stderr=PIPE)
Popen(split('killall gst-launch-0.10'), stdout=PIPE, stderr=PIPE)
Popen(split('killall gst-launch-1.0'), stdout=PIPE, stderr=PIPE)
log("Session terminated.")
sleep(0.1)