Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/guysoft/OctoPi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/filesystem/home/pi/scripts/webcamDaemon')
-rwxr-xr-xsrc/filesystem/home/pi/scripts/webcamDaemon53
1 files changed, 40 insertions, 13 deletions
diff --git a/src/filesystem/home/pi/scripts/webcamDaemon b/src/filesystem/home/pi/scripts/webcamDaemon
index 3f5b37b..2525376 100755
--- a/src/filesystem/home/pi/scripts/webcamDaemon
+++ b/src/filesystem/home/pi/scripts/webcamDaemon
@@ -8,11 +8,14 @@ MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"
+additional_brokenfps_usb_devices=()
if [ -e "/boot/octopi.txt" ]; then
source "/boot/octopi.txt"
fi
+brokenfps_usb_devices=("046d:082b" "${additional_brokenfps_usb_devices[@]}")
+
# runs MJPG Streamer, using the provided input plugin + configuration
function runMjpgStreamer {
input=$1
@@ -24,14 +27,45 @@ function runMjpgStreamer {
# starts up the RasPiCam
function startRaspi {
- logger -s "Starting Raspberry Pi camera"
+ logger "Starting Raspberry Pi camera"
runMjpgStreamer "$MJPGSTREAMER_INPUT_RASPICAM $camera_raspi_options"
}
# starts up the USB webcam
function startUsb {
- logger -s "Starting USB webcam"
- runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $camera_usb_options"
+ options="$camera_usb_options"
+ device="video0"
+
+ extracted_device=`echo $options | sed 's@.*-d /dev/\(video[0-9]+\).*@\1@'`
+ if [ "$extracted_device" != "$options" ]
+ then
+ # the camera options refer to another device, use that for determining product
+ device=$extracted_device
+ fi
+
+ uevent_file="/sys/class/video4linux/$device/device/uevent"
+ if [ -e $uevent_file ]; then
+ # let's see what kind of webcam we have here, fetch vid and pid...
+ product=`cat $uevent_file | grep PRODUCT | cut -d"=" -f2`
+ vid=`echo $product | cut -d"/" -f1`
+ pid=`echo $product | cut -d"/" -f2`
+ vidpid=`printf "%04x:%04x" "0x$vid" "0x$pid"`
+
+ # ... then look if it is in our list of known broken-fps-devices and if so remove
+ # the -f parameter from the options (if it's in there, else that's just a no-op)
+ for identifier in ${brokenfps_usb_devices[@]};
+ do
+ if [ "$vidpid" = "$identifier" ]; then
+ echo
+ echo "Camera model $vidpid is known to not work with -f parameter, stripping it out"
+ echo
+ options=`echo $options | sed -e "s/\(\s\+\|^\)-f\s\+[0-9]\+//g"`
+ fi
+ done
+ fi
+
+ logger "Starting USB webcam"
+ runMjpgStreamer "$MJPGSTREAMER_INPUT_USB $options"
}
# we need this to prevent the later calls to vcgencmd from blocking
@@ -39,14 +73,9 @@ function startUsb {
vcgencmd version
# echo configuration
-echo "Starting up webcamDaemon..."
-echo ""
-echo "--- Configuration: -----------------------------"
-echo "camera: $camera"
-echo "usb options: $camera_usb_options"
-echo "raspi options: $camera_raspi_options"
-echo "-----------------------------------------------"
-echo ""
+echo camera: $camera
+echo usb options: $camera_usb_options
+echo raspi options: $camera_raspi_options
# keep mjpg streamer running if some camera is attached
while true; do
@@ -61,5 +90,3 @@ while true; do
sleep 120
done
-echo "Goodbye..."
-echo "" \ No newline at end of file