New RTMP connector daemon mode
This commit is contained in:
parent
fb4ddbba8c
commit
ee3973a8c6
4 changed files with 95 additions and 23 deletions
58
Connector_RTMP/Conn_RTMP
Executable file
58
Connector_RTMP/Conn_RTMP
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# chkconfig: 345 92 8
|
||||
# description: DDVTech RTMP Connector
|
||||
#
|
||||
# processname: Connector_RTMP
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
prog="Connector_RTMP"
|
||||
fullprog="/usr/bin/Connector_RTMP"
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
gprintf "Starting %s: " $prog
|
||||
daemon --user=root $fullprog
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
stop() {
|
||||
gprintf "Stopping %s: " $prog
|
||||
killproc $fullprog
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
condrestart)
|
||||
if [ -f /var/lock/subsys/$prog ]; then
|
||||
stop
|
||||
start
|
||||
fi
|
||||
;;
|
||||
status)
|
||||
status $fullprog
|
||||
RETVAL=$?
|
||||
;;
|
||||
*)
|
||||
gprintf "Usage: %s {start|stop|restart|status}" $0
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
|
@ -16,8 +16,8 @@ $(OUT): $(OBJ) chunkstream.cpp parsechunks.cpp handshake.cpp crypto.cpp amf.cpp
|
|||
$(CC) $(LIBS) -o $(OUT) $(OBJ)
|
||||
clean:
|
||||
rm -rf $(OBJ) $(OUT) Makefile.bak *~
|
||||
run-test: $(OUT)
|
||||
rm -rf ./meh
|
||||
mkfifo ./meh
|
||||
cat ./meh &
|
||||
nc -l -p 1935 -e './Connector_RTMP 2>./meh'
|
||||
install: $(OUT)
|
||||
-service Conn_RTMP stop
|
||||
cp -f ./$(OUT) /usr/bin/
|
||||
cp -f ./Conn_RTMP /etc/init.d/
|
||||
service Conn_RTMP start
|
||||
|
|
|
@ -22,18 +22,39 @@ int CONN_fd = 0;
|
|||
#include "parsechunks.cpp" //chunkstream parsing
|
||||
#include "handshake.cpp" //handshaking
|
||||
|
||||
int main(){
|
||||
|
||||
int server_socket = DDV_Listen(1935);
|
||||
|
||||
int server_socket = 0;
|
||||
|
||||
void termination_handler (int signum){
|
||||
if (server_socket == 0) return;
|
||||
close(server_socket);
|
||||
server_socket = 0;
|
||||
}
|
||||
|
||||
int main(){
|
||||
//setup signal handler
|
||||
struct sigaction new_action;
|
||||
new_action.sa_handler = termination_handler;
|
||||
sigemptyset (&new_action.sa_mask);
|
||||
new_action.sa_flags = 0;
|
||||
sigaction (SIGINT, &new_action, NULL);
|
||||
sigaction (SIGHUP, &new_action, NULL);
|
||||
sigaction (SIGTERM, &new_action, NULL);
|
||||
|
||||
server_socket = DDV_Listen(1935);
|
||||
if (server_socket > 0){daemon(1, 0);}else{return 1;}
|
||||
int status;
|
||||
while (server_socket > 0){
|
||||
waitpid((pid_t)-1, &status, WNOHANG);
|
||||
CONN_fd = DDV_Accept(server_socket);
|
||||
pid_t myid = fork();
|
||||
if (myid == 0){
|
||||
break;
|
||||
}else{
|
||||
printf("Spawned new process %i for handling socket %i\n", (int)myid, CONN_fd);
|
||||
if (CONN_fd > 0){
|
||||
pid_t myid = fork();
|
||||
if (myid == 0){
|
||||
break;
|
||||
}else{
|
||||
printf("Spawned new process %i for handling socket %i\n", (int)myid, CONN_fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (server_socket <= 0){
|
||||
|
|
15
Makefile
15
Makefile
|
@ -1,4 +1,4 @@
|
|||
default: client-local-install
|
||||
default: client-install
|
||||
|
||||
client:
|
||||
cd Connector_HTTP; $(MAKE)
|
||||
|
@ -14,18 +14,11 @@ client-clean:
|
|||
cd Buffer; $(MAKE) clean
|
||||
clean: client-clean
|
||||
client-install: client-clean client
|
||||
service xinetd stop
|
||||
cp -f ./Connector_HTTP/Connector_HTTP /usr/bin/
|
||||
cp -f ./Connector_RTMP/Connector_RTMP /usr/bin/
|
||||
cd Connector_RTMP; $(MAKE) install
|
||||
cp -f ./Connector_RAW/Connector_RAW /usr/bin/
|
||||
#cp -f ./Connector_RTSP/Connector_RTSP /usr/bin/
|
||||
cp -f ./Buffer/Buffer /usr/bin/
|
||||
cp -f ./PLS /etc/xinetd.d/
|
||||
service xinetd restart
|
||||
client-local-install: client
|
||||
mkdir -p ./bin
|
||||
cp -f ./Connector_HTTP/Connector_HTTP ./bin/
|
||||
cp -f ./Connector_RTMP/Connector_RTMP ./bin/
|
||||
cp -f ./Connector_RAW/Connector_RAW ./bin/
|
||||
#cp -f ./Connector_RTSP/Connector_RTSP ./bin/
|
||||
cp -f ./Buffer/Buffer ./bin/
|
||||
|
||||
service xinetd start
|
||||
|
|
Loading…
Add table
Reference in a new issue