rtspserver.pl 3.2 KB

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