blob: 02d2f9f908cdc1952803fd975511e9080c29f1b1 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#!/usr/bin/env perl
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) 1998 - 2017, 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
37my $verbose = 0; # set to 1 for debugging
38my $port = 8990; # just a default
39my $ipvnum = 4; # default IP version of rtsp server
40my $idnum = 1; # default rtsp server instance number
41my $proto = 'rtsp'; # protocol the rtsp server speaks
42my $pidfile; # rtsp server pid file
43my $logfile; # rtsp server log file
44my $srcdir;
45
46my $flags = "";
47my $path = '.';
48my $logdir = $path .'/log';
49
50while(@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
96if(!$srcdir) {
97 $srcdir = $ENV{'srcdir'} || '.';
98}
99if(!$pidfile) {
100 $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
101}
102if(!$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
109exec("server/rtspd $flags");