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