summaryrefslogtreecommitdiff
path: root/rundemo.sh
blob: 0de2a051de662a44c0b53738b117b8ec02140359 (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
#!/bin/bash

BUTTONVALUE=$1
echo "Button pressed: ${BUTTONVALUE}"

GST_LAUNCH_BIN="/usr/bin/gst-launch-0.10"

VIDEO_SCRIPT_NAME="/usr/lib/automotive-message-broker/scripts/start_video.sh"
RIGHT_CAMERA_DEV="/dev/video0"
LEFT_CAMERA_DEV="/dev/video1"

VIDEO_DISPLAY=":0"
CAMERA_DISPLAY=":0"

case ${BUTTONVALUE} in
	"Right")
		echo "Starting right-camera view"
		RIGHT_CAMERA_PID=$[ $(pgrep -f $RIGHT_CAMERA_DEV) ]
		if [ $RIGHT_CAMERA_PID = "0" ]; then
			DISPLAY=$CAMERA_DISPLAY $GST_LAUNCH_BIN v4l2src device=$RIGHT_CAMERA_DEV ! 'video/x-raw-yuv,width=1920,height=1080,framerate=5/1' ! xvimagesink
		fi
		;;
	"Left")
		echo "Starting left-camera view"
		LEFT_CAMERA_PID=$[ $(pgrep -f $LEFT_CAMERA_DEV) ]
		if [ $LEFT_CAMERA_PID = "0" ]; then
			DISPLAY=$CAMERA_DISPLAY $GST_LAUNCH_BIN v4l2src device=$LEFT_CAMERA_DEV ! 'video/x-raw-yuv,width=1920,height=1080,framerate=5/1' ! xvimagesink
		fi
		;;
	"Off")
#		killall $GST_LAUNCH_BIN
		RIGHT_CAMERA_PID=$[ $(pgrep -f $RIGHT_CAMERA_DEV) ]
		LEFT_CAMERA_PID=$[ $(pgrep -f $LEFT_CAMERA_DEV) ]
		if [ $RIGHT_CAMERA_PID != "0" ]; then
			echo "Stopping right-view camera"
			kill $RIGHT_CAMERA_PID
		elif [ $LEFT_CAMERA_PID != "0" ]; then
			echo "Stopping left-view camera"
			kill $LEFT_CAMERA_PID
		else
			echo "No camera to stop"
		fi
		;;

	"Button1")
		#Run script 1 here
		echo "Button 1 script - initiating NFC BT handover"
		/usr/lib/neard/test/bt-handover
		;;
	"Button2")
		#Run script 2 here
		echo "Button 2 script!"
		;;
	"Button3")
		#Run script 3 here
		echo "Button 3 script!"
		;;
	"Button4")
		#Run script 4 here
		VIDEO_SCRIPT_PID=$[ $(pgrep -f $VIDEO_SCRIPT_NAME) ]
		if [ $VIDEO_SCRIPT_PID = "0" ]; then
			echo "Starting Kids entertainment!"
			DISPLAY=$VIDEO_DISPLAY $VIDEO_SCRIPT_NAME
		else
			echo "Stopping Kids entertainment!"
			while [ $VIDEO_SCRIPT_PID != "0" ]; do
				pkill -P $VIDEO_SCRIPT_PID gst-launch
				VIDEO_SCRIPT_PID=$[ $(pgrep -f $VIDEO_SCRIPT_NAME) ]
			done
		fi
		;;
	*)
		echo "Button not implemented"
		;;
esac