Skip to content

Commit

Permalink
0.2.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
openipcamera committed Mar 28, 2018
1 parent c5df20d commit 9c321ca
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 0 deletions.
87 changes: 87 additions & 0 deletions bootstrap/www/cfg_rtsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/sh

echo "Content-type: text/html"
echo ""

CMDLINE="`grep -m 1 "_server" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server`"
CMDLINE2="snx_isp_ctl --mfset-mode 0"

cat << EOF
<html>
<head>
<title>Fang Hacks</title>
<style type="text/css">
body { background-color: #B0E0E6; font-family: verdana, sans-serif; }
.err { color: red; }
hr { height: 1px; border: 0; border-top: 1px solid #aaa; }
button, input[type=submit] { background-color: #ddeaff; }
.tbl { border-collapse: collapse; border-spacing: 0;}
.tbl th { text-align: left; vertical-align: top; font-weight: bold; padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
.tbl td { padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
</style>
<head>
<body>
<h1>Configure RTSP</h1>
<hr/>
<button title='Status page' type='button' onClick="window.location.href='status'">Status</button>
<button title='Reboot the device' type='button' onClick="window.location.href='action?cmd=reboot'">Reboot</button>
<button title='Info' type='button' onClick="window.location.href='scripts'">Scripts</button>
<button title='View /tmp/hacks.log' type='button' onClick="window.location.href='action?cmd=showlog'">View log</button>
<button title='Network' type='button' onClick="window.location.href='network'">Network</button>
<hr/>
<div style='clear: both;'>
<form action="cfg_rtsp_save" id="textformid" method="get">
Command line: <input type="text" name="name" size="100" value="$CMDLINE"></input><br>
<input type="submit" />
</form>
<pre>Command line options:
Availability of some options depends on the program/version that is installed
-A username:password: username and password for authentication
-Q length: Number of frame queue (default 10)
ZXF options :
-D frame delay: Number of frames to delay (default 0)
-R record thresh: Motion detection threshold to record (default -1, <0 for off)
-L record length: Number of frames to record per file (must be >= 10*fps)
-B record buffer: Number of frames to record prior to motion (must be <= 60)
RTSP options :
-u url : unicast url (default unicast)
-m url : multicast url (default multicast)
-M addr : multicast group (default is a random address)
-P port : RTSP port (default 554)
-T port : RTSP over HTTP port (default 0)
V4L2 options :
-F fps : V4L2 capture framerate (default 30)
-i isp_fps : ISP capture framerate (default 30)
-W width : V4L2 capture width (default 1280)
-H height : V4L2 capture height (default 720)
V4L2 H264 options :
-b bitrate : V4L2 capture bitrate kbps(default 1024 kbps)
-g gop : V4L2 capture gop (default 30 )
device : V4L2 capture device (default /dev/video1)
V4L2 MJPEG options :
-j mjpeg_qp : MJPEG streaming and qp (default is 60)
-c capture path enable (default is disable)
-s encoder scale (1/2/4) (default is 1)
-a : enable A-law pcm streaming</pre>
EOF
#note: to display command line options, following works in shell but does not work in script, needs to be improved
#eval "$(grep -m 1 "_server" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server | awk '{ print $1 }') -h"
cat << EOF
<form action="cfg_rtsp_save-mirror" id="textformid" method="get">
Command line: <input type="text" name="name" size="100" value="$CMDLINE2"></input><br>
<input type="submit" />
</form>
<pre>
snx_isp_ctl --mfset-mode 0 - normal
snx_isp_ctl --mfset-mode 1 - flip
snx_isp_ctl --mfset-mode 2 - mirror
snx_isp_ctl --mfset-mode 3 - flip+mirror
</pre>
</div>
</body>
</html>
EOF

50 changes: 50 additions & 0 deletions bootstrap/www/cfg_rtsp_save
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

echo "Content-type: text/html"
echo ""

cat << EOF
<html>
<head>
<title>Fang Hacks</title>
<style type="text/css">
body { background-color: #B0E0E6; font-family: verdana, sans-serif; }
.err { color: red; }
hr { height: 1px; border: 0; border-top: 1px solid #aaa; }
button, input[type=submit] { background-color: #ddeaff; }
.tbl { border-collapse: collapse; border-spacing: 0;}
.tbl th { text-align: left; vertical-align: top; font-weight: bold; padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
.tbl td { padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
</style>
<head>
<body>
<h1>Save RTSP Config</h1>
<hr/>
<button title='Status page' type='button' onClick="window.location.href='status'">Status</button>
<button title='Reboot the device' type='button' onClick="window.location.href='action?cmd=reboot'">Reboot</button>
<button title='Info' type='button' onClick="window.location.href='scripts'">Scripts</button>
<button title='View /tmp/hacks.log' type='button' onClick="window.location.href='action?cmd=showlog'">View log</button>
<button title='Network' type='button' onClick="window.location.href='network'">Network</button>
<button title='Configure RTSP' type='button' onClick="window.location.href='cfg_rtsp'">Config RTSP</button>
<hr/>
<div style='clear: both;'>
EOF
CMDLINE=$(echo $QUERY_STRING | sed 's/^.....//' | sed -e "s/\+/ /g" | sed -e "s/\%3E/>/g" | sed -e "s/\%26/\&/g" | sed -e "s/\%24/\$/g")
#don't save the file if it doesn't include _server in the command
if [ -z "${CMDLINE##*_server*}" ]; then
sed -i '/_server/c\'"$CMDLINE" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server 2>&1
echo "File saved, 20-rtsp-server script must be restarted for changes to take effect"
else
echo "error"
fi
cat << EOF
</div>
<div style='clear: both;'>
</div>
</body>
</html>
EOF


50 changes: 50 additions & 0 deletions bootstrap/www/cfg_rtsp_save-mirror
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

echo "Content-type: text/html"
echo ""

cat << EOF
<html>
<head>
<title>Fang Hacks</title>
<style type="text/css">
body { background-color: #B0E0E6; font-family: verdana, sans-serif; }
.err { color: red; }
hr { height: 1px; border: 0; border-top: 1px solid #aaa; }
button, input[type=submit] { background-color: #ddeaff; }
.tbl { border-collapse: collapse; border-spacing: 0;}
.tbl th { text-align: left; vertical-align: top; font-weight: bold; padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
.tbl td { padding: 10px 5px; border-style: solid; border-width: 1px; overflow: hidden; word-break: normal; }
</style>
<head>
<body>
<h1>Save RTSP Config-Mirror</h1>
<hr/>
<button title='Status page' type='button' onClick="window.location.href='status'">Status</button>
<button title='Reboot the device' type='button' onClick="window.location.href='action?cmd=reboot'">Reboot</button>
<button title='Info' type='button' onClick="window.location.href='scripts'">Scripts</button>
<button title='View /tmp/hacks.log' type='button' onClick="window.location.href='action?cmd=showlog'">View log</button>
<button title='Network' type='button' onClick="window.location.href='network'">Network</button>
<button title='Configure RTSP' type='button' onClick="window.location.href='cfg_rtsp'">Config RTSP</button>
<hr/>
<div style='clear: both;'>
EOF
CMDLINE=$(echo $QUERY_STRING | sed 's/^.....//' | sed -e "s/\+/ /g" | sed -e "s/\%3E/>/g" | sed -e "s/\%26/\&/g" | sed -e "s/\%24/\$/g")
if [ -z "${CMDLINE##*_ctl*}" ]; then
sed -i '/_ctl/c\'"$CMDLINE" /media/mmcblk0p2/data/etc/scripts/20-rtsp-server 2>&1
echo "File saved, 20-rtsp-server script must be restarted for changes to take effect"
else
echo "error"
fi

cat << EOF
</div>
<div style='clear: both;'>
</div>
</body>
</html>
EOF


9 changes: 9 additions & 0 deletions data/etc/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# /media/mmcblk0p2/data/etc/crontab: system-wide crontab

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/media/mmcblk0p2/data/usr/bin:/media/mmcblk0p2/data/usr/sbin

# m h dom mon dow user command
* * * * * root pgrep snx_rtsp_server || /media/mmcblk0p2/data/etc/scripts/20-rtsp-server start


37 changes: 37 additions & 0 deletions data/etc/scripts/03-crond
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
PIDFILE="/var/run/crond.pid"

status()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill -0 "$pid" 2>/dev/null && echo "PID: $pid" || return 1
fi
}

start()
{
echo "Starting crond..."
mkdir -p /var/spool/cron/crontabs
cp /media/mmcblk0p2/data/etc/crontab /var/spool/cron/crontabs/root
crond
}

stop()
{
pid="$(cat "$PIDFILE" 2>/dev/null)"
if [ "$pid" ]; then
kill $pid || rm "$PIDFILE"
fi
}

if [ $# -eq 0 ]; then
start
else
case $1 in start|stop|status)
$1
;;
esac
fi


0 comments on commit 9c321ca

Please sign in to comment.