| 1 |
#!/usr/bin/env perl |
| 2 |
#*************************************************************************** |
| 3 |
# _ _ ____ _ |
| 4 |
# Project ___| | | | _ \| | |
| 5 |
# / __| | | | |_) | | |
| 6 |
# | (__| |_| | _ <| |___ |
| 7 |
# \___|\___/|_| \_\_____| |
| 8 |
# |
| 9 |
# Copyright (C) 1998 - 2017, Daniel Stenberg, <[email protected]>, 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 |
|
| 24 |
BEGIN { |
| 25 |
push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'}); |
| 26 |
push(@INC, "."); |
| 27 |
} |
| 28 |
|
| 29 |
use strict; |
| 30 |
use warnings; |
| 31 |
|
| 32 |
use serverhelp qw( |
| 33 |
server_pidfilename |
| 34 |
server_logfilename |
| 35 |
); |
| 36 |
|
| 37 |
my $verbose = 0; # set to 1 for debugging |
| 38 |
my $port = 8990; # just a default |
| 39 |
my $ipvnum = 4; # default IP version of rtsp server |
| 40 |
my $idnum = 1; # default rtsp server instance number |
| 41 |
my $proto = 'rtsp'; # protocol the rtsp server speaks |
| 42 |
my $pidfile; # rtsp server pid file |
| 43 |
my $logfile; # rtsp server log file |
| 44 |
my $srcdir; |
| 45 |
|
| 46 |
my $flags = ""; |
| 47 |
my $path = '.'; |
| 48 |
my $logdir = $path .'/log'; |
| 49 |
|
| 50 |
while(@ARGV) { |
| 51 |
if($ARGV[0] eq '--pidfile') { |
| 52 |
if($ARGV[1]) { |
| 53 |
$pidfile = $ARGV[1]; |
| 54 |
shift @ARGV; |
| 55 |
} |
| 56 |
} |
| 57 |
elsif($ARGV[0] eq '--logfile') { |
| 58 |
if($ARGV[1]) { |
| 59 |
$logfile = $ARGV[1]; |
| 60 |
shift @ARGV; |
| 61 |
} |
| 62 |
} |
| 63 |
elsif($ARGV[0] eq '--srcdir') { |
| 64 |
if($ARGV[1]) { |
| 65 |
$srcdir = $ARGV[1]; |
| 66 |
shift @ARGV; |
| 67 |
} |
| 68 |
} |
| 69 |
elsif($ARGV[0] eq '--ipv4') { |
| 70 |
$ipvnum = 4; |
| 71 |
} |
| 72 |
elsif($ARGV[0] eq '--ipv6') { |
| 73 |
$ipvnum = 6; |
| 74 |
} |
| 75 |
elsif($ARGV[0] eq '--port') { |
| 76 |
if($ARGV[1] =~ /^(\d+)$/) { |
| 77 |
$port = $1; |
| 78 |
shift @ARGV; |
| 79 |
} |
| 80 |
} |
| 81 |
elsif($ARGV[0] eq '--id') { |
| 82 |
if($ARGV[1] =~ /^(\d+)$/) { |
| 83 |
$idnum = $1 if($1 > 0); |
| 84 |
shift @ARGV; |
| 85 |
} |
| 86 |
} |
| 87 |
elsif($ARGV[0] eq '--verbose') { |
| 88 |
$verbose = 1; |
| 89 |
} |
| 90 |
else { |
| 91 |
print STDERR "\nWarning: rtspserver.pl unknown parameter: $ARGV[0]\n"; |
| 92 |
} |
| 93 |
shift @ARGV; |
| 94 |
} |
| 95 |
|
| 96 |
if(!$srcdir) { |
| 97 |
$srcdir = $ENV{'srcdir'} || '.'; |
| 98 |
} |
| 99 |
if(!$pidfile) { |
| 100 |
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum); |
| 101 |
} |
| 102 |
if(!$logfile) { |
| 103 |
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum); |
| 104 |
} |
| 105 |
|
| 106 |
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" "; |
| 107 |
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\""; |
| 108 |
|
| 109 |
exec("server/rtspd $flags"); |