1#!/usr/bin/env perl 2#*************************************************************************** 3# _ _ ____ _ 4# Project ___| | | | _ \| | 5# / __| | | | |_) | | 6# | (__| |_| | _ <| |___ 7# \___|\___/|_| \_\_____| 8# 9# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. 10# 11# This software is licensed as described in the file COPYING, which 12# you should have received as part of this distribution. The terms 13# are also available at https://curl.haxx.se/docs/copyright.html. 14# 15# You may opt to use, copy, modify, merge, publish, distribute and/or sell 16# copies of the Software, and permit persons to whom the Software is 17# furnished to do so, under the terms of the COPYING file. 18# 19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 20# KIND, either express or implied. 21# 22#*************************************************************************** 23 24BEGIN { 25 push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'}); 26 push(@INC, "."); 27} 28 29use strict; 30use warnings; 31 32use serverhelp qw( 33 server_pidfilename 34 server_logfilename 35 ); 36 37use sshhelp qw( 38 exe_ext 39 ); 40 41my $verbose = 0; # set to 1 for debugging 42my $port = 8990; # just a default 43my $ipvnum = 4; # default IP version of rtsp server 44my $idnum = 1; # default rtsp server instance number 45my $proto = 'rtsp'; # protocol the rtsp server speaks 46my $pidfile; # rtsp server pid file 47my $portfile; 48my $logfile; # rtsp server log file 49my $srcdir; 50 51my $flags = ""; 52my $path = '.'; 53my $logdir = $path .'/log'; 54 55while(@ARGV) { 56 if($ARGV[0] eq '--pidfile') { 57 if($ARGV[1]) { 58 $pidfile = $ARGV[1]; 59 shift @ARGV; 60 } 61 } 62 elsif($ARGV[0] eq '--portfile') { 63 if($ARGV[1]) { 64 $portfile = $ARGV[1]; 65 shift @ARGV; 66 } 67 } 68 elsif($ARGV[0] eq '--logfile') { 69 if($ARGV[1]) { 70 $logfile = $ARGV[1]; 71 shift @ARGV; 72 } 73 } 74 elsif($ARGV[0] eq '--srcdir') { 75 if($ARGV[1]) { 76 $srcdir = $ARGV[1]; 77 shift @ARGV; 78 } 79 } 80 elsif($ARGV[0] eq '--ipv4') { 81 $ipvnum = 4; 82 } 83 elsif($ARGV[0] eq '--ipv6') { 84 $ipvnum = 6; 85 } 86 elsif($ARGV[0] eq '--port') { 87 if($ARGV[1] =~ /^(\d+)$/) { 88 $port = $1; 89 shift @ARGV; 90 } 91 } 92 elsif($ARGV[0] eq '--id') { 93 if($ARGV[1] =~ /^(\d+)$/) { 94 $idnum = $1 if($1 > 0); 95 shift @ARGV; 96 } 97 } 98 elsif($ARGV[0] eq '--verbose') { 99 $verbose = 1; 100 } 101 else { 102 print STDERR "\nWarning: rtspserver.pl unknown parameter: $ARGV[0]\n"; 103 } 104 shift @ARGV; 105} 106 107if(!$srcdir) { 108 $srcdir = $ENV{'srcdir'} || '.'; 109} 110if(!$pidfile) { 111 $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum); 112} 113if(!$logfile) { 114 $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum); 115} 116 117$flags .= "--pidfile \"$pidfile\" ". 118 "--portfile \"$portfile\" ". 119 "--logfile \"$logfile\" "; 120$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\""; 121 122exec("server/rtspd".exe_ext('SRV')." $flags"); 123