mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-24 11:46:30 +00:00
Merge pull request #1925 from ccrisan/streameye-rtsp-configurable-port
Fast network camera RTSP configurable port
This commit is contained in:
commit
9c65cc14fd
@ -411,6 +411,7 @@ def _get_streameye_settings(camera_id):
|
||||
'seProto': 'mjpeg',
|
||||
'seAuthMode': 'disabled',
|
||||
'sePort': 8081,
|
||||
'seRTSPPort': 554
|
||||
}
|
||||
|
||||
if os.path.exists(STREAMEYE_CONF):
|
||||
@ -422,16 +423,21 @@ def _get_streameye_settings(camera_id):
|
||||
if not line:
|
||||
continue
|
||||
|
||||
m = re.findall('PORT="?(\d+)"?', line)
|
||||
m = re.findall('^PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['sePort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('AUTH="?(\w+)"?', line)
|
||||
m = re.findall('^RTSP_PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['seRTSPPort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('^AUTH="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seAuthMode'] = m[0]
|
||||
|
||||
m = re.findall('PROTO="?(\w+)"?', line)
|
||||
m = re.findall('^PROTO="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seProto'] = m[0]
|
||||
|
||||
@ -441,6 +447,7 @@ def _get_streameye_settings(camera_id):
|
||||
def _set_streameye_settings(camera_id, s):
|
||||
s = dict(s)
|
||||
s.setdefault('sePort', 8081)
|
||||
s.setdefault('seRTSPPort', 554)
|
||||
s.setdefault('seAuthMode', 'disabled')
|
||||
|
||||
main_config = config.get_main()
|
||||
@ -453,6 +460,7 @@ def _set_streameye_settings(camera_id, s):
|
||||
lines = [
|
||||
'PROTO="%s"' % s['seProto'],
|
||||
'PORT="%s"' % s['sePort'],
|
||||
'RTSP_PORT="%s"' % s['seRTSPPort'],
|
||||
'AUTH="%s"' % s['seAuthMode'],
|
||||
'CREDENTIALS="%s:%s:%s"' % (username, password, realm)
|
||||
]
|
||||
@ -1193,12 +1201,35 @@ def sePort():
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 1024,
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
}
|
||||
|
||||
|
||||
@additional_config
|
||||
def seRTSPPort():
|
||||
if not _get_streameye_enabled():
|
||||
return None
|
||||
|
||||
return {
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==rtsp'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
@ -1219,6 +1250,7 @@ def seAuthMode():
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
|
@ -11,7 +11,7 @@ STREAMEYE_LOG=/var/log/streameye.log
|
||||
test -r ${RASPIMJPEG_CONF} || exit 1
|
||||
test -r ${STREAMEYE_CONF} || exit 1
|
||||
|
||||
watch() {
|
||||
function watch() {
|
||||
source ${STREAMEYE_CONF}
|
||||
count=0
|
||||
while true; do
|
||||
@ -133,7 +133,7 @@ function configure_v4l2_cam() {
|
||||
v4l2-ctl ${video_arg} --set-ctrl=video_bitrate=${video_bitrate} &>/dev/null
|
||||
}
|
||||
|
||||
invalid_opt () {
|
||||
function invalid_opt() {
|
||||
local e match="$1"
|
||||
shift
|
||||
for e; do [[ "${e}" == "${match}" ]] && return 1; done
|
||||
@ -146,15 +146,17 @@ function start() {
|
||||
if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
|
||||
streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${PROTO}" = "rtsp" ]; then
|
||||
pid=$(ps | grep test-launch | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
if [ -n "${pid}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
RTSP_PORT=${RTSP_PORT:-554}
|
||||
|
||||
iptables -A INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -A INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
|
||||
audio_opts=""
|
||||
if [ -n "${AUDIO_DEV}" ]; then
|
||||
@ -197,14 +199,14 @@ function start() {
|
||||
streameye_opts="${streameye_opts} -d"
|
||||
fi
|
||||
|
||||
test-launch -p 554 -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
test-launch -p ${RTSP_PORT} -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
sleep 10
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:554/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:${RTSP_PORT}/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
iptables -D INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
|
||||
else
|
||||
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
|
@ -411,6 +411,7 @@ def _get_streameye_settings(camera_id):
|
||||
'seProto': 'mjpeg',
|
||||
'seAuthMode': 'disabled',
|
||||
'sePort': 8081,
|
||||
'seRTSPPort': 554
|
||||
}
|
||||
|
||||
if os.path.exists(STREAMEYE_CONF):
|
||||
@ -422,16 +423,21 @@ def _get_streameye_settings(camera_id):
|
||||
if not line:
|
||||
continue
|
||||
|
||||
m = re.findall('PORT="?(\d+)"?', line)
|
||||
m = re.findall('^PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['sePort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('AUTH="?(\w+)"?', line)
|
||||
m = re.findall('^RTSP_PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['seRTSPPort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('^AUTH="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seAuthMode'] = m[0]
|
||||
|
||||
m = re.findall('PROTO="?(\w+)"?', line)
|
||||
m = re.findall('^PROTO="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seProto'] = m[0]
|
||||
|
||||
@ -441,6 +447,7 @@ def _get_streameye_settings(camera_id):
|
||||
def _set_streameye_settings(camera_id, s):
|
||||
s = dict(s)
|
||||
s.setdefault('sePort', 8081)
|
||||
s.setdefault('seRTSPPort', 554)
|
||||
s.setdefault('seAuthMode', 'disabled')
|
||||
|
||||
main_config = config.get_main()
|
||||
@ -453,6 +460,7 @@ def _set_streameye_settings(camera_id, s):
|
||||
lines = [
|
||||
'PROTO="%s"' % s['seProto'],
|
||||
'PORT="%s"' % s['sePort'],
|
||||
'RTSP_PORT="%s"' % s['seRTSPPort'],
|
||||
'AUTH="%s"' % s['seAuthMode'],
|
||||
'CREDENTIALS="%s:%s:%s"' % (username, password, realm)
|
||||
]
|
||||
@ -1193,12 +1201,35 @@ def sePort():
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 1024,
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
}
|
||||
|
||||
|
||||
@additional_config
|
||||
def seRTSPPort():
|
||||
if not _get_streameye_enabled():
|
||||
return None
|
||||
|
||||
return {
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==rtsp'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
@ -1219,6 +1250,7 @@ def seAuthMode():
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
|
@ -11,7 +11,7 @@ STREAMEYE_LOG=/var/log/streameye.log
|
||||
test -r ${RASPIMJPEG_CONF} || exit 1
|
||||
test -r ${STREAMEYE_CONF} || exit 1
|
||||
|
||||
watch() {
|
||||
function watch() {
|
||||
source ${STREAMEYE_CONF}
|
||||
count=0
|
||||
while true; do
|
||||
@ -133,7 +133,7 @@ function configure_v4l2_cam() {
|
||||
v4l2-ctl ${video_arg} --set-ctrl=video_bitrate=${video_bitrate} &>/dev/null
|
||||
}
|
||||
|
||||
invalid_opt () {
|
||||
function invalid_opt() {
|
||||
local e match="$1"
|
||||
shift
|
||||
for e; do [[ "${e}" == "${match}" ]] && return 1; done
|
||||
@ -146,15 +146,17 @@ function start() {
|
||||
if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
|
||||
streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${PROTO}" = "rtsp" ]; then
|
||||
pid=$(ps | grep test-launch | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
if [ -n "${pid}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
RTSP_PORT=${RTSP_PORT:-554}
|
||||
|
||||
iptables -A INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -A INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
|
||||
audio_opts=""
|
||||
if [ -n "${AUDIO_DEV}" ]; then
|
||||
@ -197,14 +199,14 @@ function start() {
|
||||
streameye_opts="${streameye_opts} -d"
|
||||
fi
|
||||
|
||||
test-launch -p 554 -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
test-launch -p ${RTSP_PORT} -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
sleep 10
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:554/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:${RTSP_PORT}/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
iptables -D INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
|
||||
else
|
||||
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
|
@ -411,6 +411,7 @@ def _get_streameye_settings(camera_id):
|
||||
'seProto': 'mjpeg',
|
||||
'seAuthMode': 'disabled',
|
||||
'sePort': 8081,
|
||||
'seRTSPPort': 554
|
||||
}
|
||||
|
||||
if os.path.exists(STREAMEYE_CONF):
|
||||
@ -422,16 +423,21 @@ def _get_streameye_settings(camera_id):
|
||||
if not line:
|
||||
continue
|
||||
|
||||
m = re.findall('PORT="?(\d+)"?', line)
|
||||
m = re.findall('^PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['sePort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('AUTH="?(\w+)"?', line)
|
||||
m = re.findall('^RTSP_PORT="?(\d+)"?', line)
|
||||
if m:
|
||||
s['seRTSPPort'] = int(m[0])
|
||||
continue
|
||||
|
||||
m = re.findall('^AUTH="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seAuthMode'] = m[0]
|
||||
|
||||
m = re.findall('PROTO="?(\w+)"?', line)
|
||||
m = re.findall('^PROTO="?(\w+)"?', line)
|
||||
if m:
|
||||
s['seProto'] = m[0]
|
||||
|
||||
@ -441,6 +447,7 @@ def _get_streameye_settings(camera_id):
|
||||
def _set_streameye_settings(camera_id, s):
|
||||
s = dict(s)
|
||||
s.setdefault('sePort', 8081)
|
||||
s.setdefault('seRTSPPort', 554)
|
||||
s.setdefault('seAuthMode', 'disabled')
|
||||
|
||||
main_config = config.get_main()
|
||||
@ -453,6 +460,7 @@ def _set_streameye_settings(camera_id, s):
|
||||
lines = [
|
||||
'PROTO="%s"' % s['seProto'],
|
||||
'PORT="%s"' % s['sePort'],
|
||||
'RTSP_PORT="%s"' % s['seRTSPPort'],
|
||||
'AUTH="%s"' % s['seAuthMode'],
|
||||
'CREDENTIALS="%s:%s:%s"' % (username, password, realm)
|
||||
]
|
||||
@ -1193,12 +1201,35 @@ def sePort():
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 1024,
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
}
|
||||
|
||||
|
||||
@additional_config
|
||||
def seRTSPPort():
|
||||
if not _get_streameye_enabled():
|
||||
return None
|
||||
|
||||
return {
|
||||
'label': 'Streaming Port',
|
||||
'description': 'sets the TCP port on which the webcam streaming server listens',
|
||||
'type': 'number',
|
||||
'min': 0,
|
||||
'max': 65535,
|
||||
'section': 'streaming',
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==rtsp'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
@ -1219,6 +1250,7 @@ def seAuthMode():
|
||||
'advanced': True,
|
||||
'camera': True,
|
||||
'required': True,
|
||||
'depends': ['seProto==mjpeg'],
|
||||
'get': _get_streameye_settings,
|
||||
'set': _set_streameye_settings,
|
||||
'get_set_dict': True
|
||||
|
@ -11,7 +11,7 @@ STREAMEYE_LOG=/var/log/streameye.log
|
||||
test -r ${RASPIMJPEG_CONF} || exit 1
|
||||
test -r ${STREAMEYE_CONF} || exit 1
|
||||
|
||||
watch() {
|
||||
function watch() {
|
||||
source ${STREAMEYE_CONF}
|
||||
count=0
|
||||
while true; do
|
||||
@ -133,7 +133,7 @@ function configure_v4l2_cam() {
|
||||
v4l2-ctl ${video_arg} --set-ctrl=video_bitrate=${video_bitrate} &>/dev/null
|
||||
}
|
||||
|
||||
invalid_opt () {
|
||||
function invalid_opt() {
|
||||
local e match="$1"
|
||||
shift
|
||||
for e; do [[ "${e}" == "${match}" ]] && return 1; done
|
||||
@ -146,15 +146,17 @@ function start() {
|
||||
if [ -n "${CREDENTIALS}" ] && [ "${AUTH}" = "basic" ]; then
|
||||
streameye_opts="${streameye_opts} -a basic -c ${CREDENTIALS}"
|
||||
fi
|
||||
|
||||
|
||||
if [ "${PROTO}" = "rtsp" ]; then
|
||||
pid=$(ps | grep test-launch | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
if [ -n "${pid}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
RTSP_PORT=${RTSP_PORT:-554}
|
||||
|
||||
iptables -A INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -A INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
iptables -A INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
|
||||
audio_opts=""
|
||||
if [ -n "${AUDIO_DEV}" ]; then
|
||||
@ -197,14 +199,14 @@ function start() {
|
||||
streameye_opts="${streameye_opts} -d"
|
||||
fi
|
||||
|
||||
test-launch -p 554 -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
test-launch -p ${RTSP_PORT} -m h264 "\"( ${video_opts} ${audio_opts} )\"" &>${GSTREAMER_LOG} &
|
||||
sleep 10
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:554/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
gst-launch-1.0 -v rtspsrc location=rtsp://127.0.0.1:${RTSP_PORT}/h264 latency=0 drop-on-latency=1 ! rtph264depay ! h264parse ! omxh264dec ! videorate ! video/x-raw,framerate=5/1 ! jpegenc ! filesink location=/dev/stdout | streameye ${streameye_opts} &>${STREAMEYE_LOG} &
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
iptables -D INPUT -p tcp --dport 554 -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport 554 -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport ${RTSP_PORT} -j DROP
|
||||
iptables -D INPUT -p tcp -s localhost --dport ${RTSP_PORT} -j ACCEPT
|
||||
|
||||
else
|
||||
pid=$(ps | grep raspimjpeg.py | grep -v grep | tr -s ' ' | sed -e 's/^\s//' | cut -d ' ' -f 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user