rtspserver.pl 2.9 KB

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