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