2
0

rtspserver.pl 2.9 KB

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