Browse Source

add webcam mode and change rtsp server configs, add avconv for youtube rtmp testing

Alfonso Gamboa 3 năm trước cách đây
mục cha
commit
c98ecf288a

+ 15 - 5
README.md

@@ -35,8 +35,9 @@ Using this project can potentially expose your device to the open internet depen
 * CIFS Supported
 * Play .WAV files using "aplay <file> <vol>" command
 * iptables included
+* Use your camera as a backup Web Camera!
 
-* Inspired by HclX and WyzeHacks!  Bless you for all your work!  You are the master!
+* Inspired by HclX, bakueikozo, and mnakada!
 
 ## Coming Soon
 * onvif - maybe
@@ -189,32 +190,41 @@ The RTSP server supports the two video streams provided by the camera, 1080p/360
 ```
 RTSP_LOGIN="admin"
 RTSP_PASSWORD=""
+RTSP_PORT="8554"
 
 RTSP_HI_RES_ENABLED="true"
 RTSP_HI_RES_ENABLE_AUDIO="true"
-RTSP_HI_RES_PORT="8554"
 RTSP_HI_RES_MAX_BITRATE="2048"
 RTSP_HI_RES_TARGET_BITRATE="1024"
 RTSP_HI_RES_ENC_PARAMETER="2"
 
 RTSP_LOW_RES_ENABLED="false"
 RTSP_LOW_RES_ENABLE_AUDIO="false"
-RTSP_LOW_RES_PORT="8555"
 RTSP_LOW_RES_MAX_BITRATE=""
 RTSP_LOW_RES_TARGET_BITRATE=""
 RTSP_LOW_RES_ENC_PARAMETER=""
 
 ```
-the stream will be located at ```rtsp://login:password@IP_ADDRESS:8554/unicast```
+the singular stream will be located at ```rtsp://login:password@IP_ADDRESS:8554/unicast```
+multiple streams are located at ```rtsp://login:password@IP_ADDRESS:8554/video1_unicast``` and ```rtsp://login:password@IP_ADDRESS:8554/video2_unicast```
 
-Notes:  If you don't set the password, then the password will be the unique MAC address of the camera, in all uppercase, including the colons... for example:. AA:BB:CC:00:11:22.  It's typically printed on the camera.  Higher video bitrates may overload your Wi-Fi connection, so a wired connection is recommended.
+Note:  If you don't set the password, the password will be set to the unique MAC address of the camera, in all uppercase, including the colons... for example:. AA:BB:CC:00:11:22.  It's typically printed on the camera.  Higher video bitrates may overload your Wi-Fi connection, so a wired connection is recommended.
 
 Huge credit to @mnakada for his libcallback library: [https://github.com/mnakada/atomcam_tools](https://github.com/mnakada/atomcam_tools)
 
 ---
 
+Use as a Web Camera for your PC is supported.  I have tested with Windows 10 and Linux, and it appears as a Generic HD Camera.  Audio is supported.  This mode disables all other functionality, and only works as a Web Camera for your PC. Experimental.
+
+```
+ENABLE_WEB_CAM="true"
+```
+
+---
+
 ## Latest Updates
 
+* 05-18-22:  Added PC Web Camera functionality, changed RTSP server, when you use enable more than one stream, they share the port and use different paths.
 * 05-15-22:  fixed rtsp audio for low-res rtsp stream, patched libcallback sources for audio channel 1.
 * 05-15-22:  patched libcallback to support both video streams from the camera.  Added support for them in run_mmc.sh.
 * 05-14-22:  Added ability to specify RTSP bitrate parameters.  Note that changing bitrate in the mobile app will briefly reset the bitrate for the RTSP stream.

BIN
SD_ROOT/wz_mini/bin/avconv


+ 8 - 0
SD_ROOT/wz_mini/etc/init.d/v3_init.sh

@@ -121,6 +121,14 @@ if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "DEBUG_ENABLED\=") == "DEBUG_ENABLED\
         sed -i '/app_init.sh/,+3d' /opt/wz_mini/tmp/.storage/rcS
         sed -i '/^# Run init/i/bin/sh /etc/profile' /opt/wz_mini/tmp/.storage/rcS
 	touch /tmp/dbgflag
+else
+
+if [[ $(cat /opt/wz_mini/run_mmc.sh | grep "ENABLE_WEB_CAM\=") == "ENABLE_WEB_CAM\=\"true\"" ]]; then
+        sed -i '/app_init.sh/,+3d' /opt/wz_mini/tmp/.storage/rcS
+        sed -i '/^# Run init/i/opt/wz_mini/etc/init.d/wz_cam.sh' /opt/wz_mini/tmp/.storage/rcS
+	touch /tmp/dbgflag
+fi
+
 fi
 
 if ! [[ -e /tmp/dbgflag ]]; then

+ 24 - 0
SD_ROOT/wz_mini/etc/init.d/wz_cam.sh

@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -x
+
+exec 1> /opt/wz_mini/log/wz_cam.log 2>&1
+
+
+mount --bind /opt/wz_mini/usr/bin /system/bin
+insmod /system/driver/avpu.ko
+insmod /system/driver/tx-isp-t31.ko isp_clk=220000000
+insmod /system/driver/sensor_gc2053_t31.ko
+insmod /system/driver/audio.ko
+insmod /opt/wz_mini/lib/modules/libcomposite.ko
+insmod /opt/wz_mini/lib/modules/videobuf2-vmalloc.ko
+insmod /opt/wz_mini/lib/modules/usbcamera.ko
+	
+cd /system/bin/
+/system/bin/ucamera &
+
+#Set dwc2 ID_PIN driver memory
+devmem 0x13500000 32 0x001100cc
+devmem 0x10000040 32 0x0b000096
+#wipe the bits to set the ID_PIN
+devmem 0x10000040 32 0x0b000FFF

BIN
SD_ROOT/wz_mini/lib/modules/libcomposite.ko


BIN
SD_ROOT/wz_mini/lib/modules/usbcamera.ko


BIN
SD_ROOT/wz_mini/lib/modules/videobuf2-vmalloc.ko


+ 25 - 14
SD_ROOT/wz_mini/run_mmc.sh

@@ -9,6 +9,11 @@ set -x
 
 HOSTNAME="WCV3"
 
+#### W E B CAMERA###
+##THIS MODE DISABLES EVERYTHING AND IT WILL
+## WORK AS A WEB CAMERA FOR YOUR PC ***ONLY***
+ENABLE_WEB_CAM="false"
+
 #####NETWORKING#####
 ENABLE_USB_ETH="false"
 
@@ -32,17 +37,16 @@ REMOTE_SPOTLIGHT_HOST="0.0.0.0"
 #####VIDEO STREAM#####
 RTSP_LOGIN="admin"
 RTSP_PASSWORD=""
+RTSP_PORT="8554"
 
 RTSP_HI_RES_ENABLED="false"
 RTSP_HI_RES_ENABLE_AUDIO="false"
-RTSP_HI_RES_PORT="8554"
 RTSP_HI_RES_MAX_BITRATE=""
 RTSP_HI_RES_TARGET_BITRATE=""
 RTSP_HI_RES_ENC_PARAMETER=""
 
 RTSP_LOW_RES_ENABLED="false"
 RTSP_LOW_RES_ENABLE_AUDIO="false"
-RTSP_LOW_RES_PORT="8555"
 RTSP_LOW_RES_MAX_BITRATE=""
 RTSP_LOW_RES_TARGET_BITRATE=""
 RTSP_LOW_RES_ENC_PARAMETER=""
@@ -183,7 +187,6 @@ swap_enable() {
 first_run_check
 wait_sdroot
 wait_wlan
-hostname_set
 
 
 if [[ "$ENABLE_SWAP" == "true" ]]; then
@@ -361,19 +364,20 @@ if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
 	swap_enable
 	fi
 
-	/opt/wz_mini/bin/cmd video on
-	/opt/wz_mini/bin/cmd audio on
-
-
 	if [[ "$RTSP_PASSWORD" = "" ]]; then
 	RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
 	fi
 
+	/opt/wz_mini/bin/cmd video on
+
         if [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]; then
-                LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -C 1 -a S16_LE  /dev/video1,hw:Loopback,0 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_HI_RES_PORT &
+		/opt/wz_mini/bin/cmd audio on
+		AUDIO_CH="-C 1"
+		AUDIO_FMT="-a S16_LE"
+		DEVICE1="/dev/video1,hw:Loopback,0"
         else
-                echo "rtsp audio disabled"
-                LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -s /dev/video1 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_HI_RES_PORT &
+                DEVICE1="/dev/video1"
+		echo "rtsp audio disabled"
         fi
 
 	if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
@@ -393,6 +397,7 @@ if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
 
 fi
 
+
 if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
 
 	if [[ "$ENABLE_SWAP" == "true" ]]; then
@@ -402,18 +407,19 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
 	fi
 
 	/opt/wz_mini/bin/cmd video on1
-	/opt/wz_mini/bin/cmd audio on1
-
 
 	if [[ "$RTSP_PASSWORD" = "" ]]; then
 	RTSP_PASSWORD=$(cat /opt/wz_mini/tmp/wlan0_mac)
 	fi
 
         if [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
-                LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -C 1 -a S16_LE  /dev/video2,hw:Loopback,1 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
+		/opt/wz_mini/bin/cmd audio on1
+		AUDIO_CH="-C 1"
+		AUDIO_FMT="-a S16_LE"
+		DEVICE2="/dev/video2,hw:Loopback,1"
         else
+                DEVICE2="/dev/video2"
                 echo "rtsp audio disabled"
-                LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -s /dev/video2 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
         fi
 
 	if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
@@ -433,6 +439,11 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
 
 fi
 
+if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
+	LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_PORT $DEVICE1 $DEVICE2
+fi
+
+hostname_set
 touch /opt/wz_mini/tmp/.run_mmc_firstrun
 sync;echo 3 > /proc/sys/vm/drop_caches
 sleep 3

BIN
SD_ROOT/wz_mini/usr/bin/ucamera


+ 16 - 0
SD_ROOT/wz_mini/usr/bin/uvc.config

@@ -0,0 +1,16 @@
+sensor_name     :gc2053
+i2c_addr        :0x37
+fps_num         :30
+width           :1920
+height          :1080
+wdr_en          :0
+bitrate         :8000
+rcmode          :cbr
+audio_en        :1
+gop             :30
+adb_en          :1
+speak_en        :0
+nframes         :3
+{640,  360}
+{1280, 720}
+{1920, 1080}

+ 0 - 0
libcallback_wz_mod/libcallback.so