• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
26BEGIN {
27    push(@INC, $ENV{'srcdir'}) if(defined $ENV{'srcdir'});
28    push(@INC, ".");
29}
30
31use strict;
32use warnings;
33
34use serverhelp qw(
35    server_pidfilename
36    server_logfilename
37    );
38
39use sshhelp qw(
40    exe_ext
41    );
42
43my $verbose = 0;     # set to 1 for debugging
44my $port = 8990;     # just a default
45my $ipvnum = 4;      # default IP version of rtsp server
46my $idnum = 1;       # default rtsp server instance number
47my $proto = 'rtsp';  # protocol the rtsp server speaks
48my $pidfile;         # rtsp server pid file
49my $portfile;
50my $logfile;         # rtsp server log file
51my $srcdir;
52
53my $flags  = "";
54my $path   = '.';
55my $logdir = $path .'/log';
56
57while(@ARGV) {
58    if($ARGV[0] eq '--pidfile') {
59        if($ARGV[1]) {
60            $pidfile = $ARGV[1];
61            shift @ARGV;
62        }
63    }
64    elsif($ARGV[0] eq '--portfile') {
65        if($ARGV[1]) {
66            $portfile = $ARGV[1];
67            shift @ARGV;
68        }
69    }
70    elsif($ARGV[0] eq '--logfile') {
71        if($ARGV[1]) {
72            $logfile = $ARGV[1];
73            shift @ARGV;
74        }
75    }
76    elsif($ARGV[0] eq '--srcdir') {
77        if($ARGV[1]) {
78            $srcdir = $ARGV[1];
79            shift @ARGV;
80        }
81    }
82    elsif($ARGV[0] eq '--ipv4') {
83        $ipvnum = 4;
84    }
85    elsif($ARGV[0] eq '--ipv6') {
86        $ipvnum = 6;
87    }
88    elsif($ARGV[0] eq '--port') {
89        if($ARGV[1] =~ /^(\d+)$/) {
90            $port = $1;
91            shift @ARGV;
92        }
93    }
94    elsif($ARGV[0] eq '--id') {
95        if($ARGV[1] =~ /^(\d+)$/) {
96            $idnum = $1 if($1 > 0);
97            shift @ARGV;
98        }
99    }
100    elsif($ARGV[0] eq '--verbose') {
101        $verbose = 1;
102    }
103    else {
104        print STDERR "\nWarning: rtspserver.pl unknown parameter: $ARGV[0]\n";
105    }
106    shift @ARGV;
107}
108
109if(!$srcdir) {
110    $srcdir = $ENV{'srcdir'} || '.';
111}
112if(!$pidfile) {
113    $pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
114}
115if(!$logfile) {
116    $logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
117}
118
119$flags .= "--pidfile \"$pidfile\" ".
120    "--portfile \"$portfile\" ".
121    "--logfile \"$logfile\" ";
122$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
123
124$| = 1;
125exec("exec server/rtspd".exe_ext('SRV')." $flags");
126