rtspserver.pl 3.2 KB

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