[Live-devel] Ability to specify port number

Roman Gaufman hackeron at gmail.com
Sun Dec 9 06:09:51 PST 2012


Here is a simple patch to allow specifying a port number, e.g.

./proxyServer/live555ProxyServer -p 10001 ...

I often need to run multiple proxy servers on different ports, this allows
to pass a port number as an argument to live555ProxyServer and I think
would make a great addition if it were included in the upstream version:

--- a/proxyServer/live555ProxyServer.cpp
+++ b/proxyServer/live555ProxyServer.cpp
@@ -27,6 +27,7 @@ UsageEnvironment* env;
 int verbosityLevel = 0;
 Boolean streamRTPOverTCP = False;
 portNumBits tunnelOverHTTPPortNum = 0;
+portNumBits rtspServerPortNum = 554;
 char* username = NULL;
 char* password = NULL;

@@ -34,6 +35,7 @@ void usage() {
   *env << "Usage: " << progName
        << " [-v|-V]"
        << " [-t|-T <http-port>]"
+       << " [-p <rtsp-port>]"
        << " [-u <username> <password>]"
        << " <rtsp-url-1> ... <rtsp-url-n>\n";
   exit(1);
@@ -89,6 +91,21 @@ int main(int argc, char** argv) {
       usage();
       break;
     }
+
+    case 'p': {
+        // set port
+        if (argc > 3 && argv[2][0] != '-') {
+            // The next argument is the RTSP server port number:

+            if (sscanf(argv[2], "%hu", &rtspServerPortNum) == 1
+                && rtspServerPortNum > 0) {
+                ++argv; --argc;
+                break;
+            }
+        }
+        // If we get here, the option was specified incorrectly:
+        usage();
+        break;
+    }

     case 'u': { // specify a username and password (to be used if the
'back end' (i.e., proxied) stream requires authentication)
       if (argc < 4) usage(); // there's no argv[3] (for the "password")
@@ -131,12 +148,11 @@ int main(int argc, char** argv) {
   // access to the server.
 #endif

-  // Create the RTSP server.  Try first with the default port number (554),
+  // Create the RTSP server.  Try first with the default port number (554)
or the one set by the caller,
   // and then with the alternative port number (8554):
   RTSPServer* rtspServer;
-  portNumBits rtspServerPortNum = 554;
   rtspServer = RTSPServer::createNew(*env, rtspServerPortNum, authDB);
-  if (rtspServer == NULL) {
+  if (rtspServer == NULL && rtspServerPortNum != 554) {
     rtspServerPortNum = 8554;
     rtspServer = RTSPServer::createNew(*env, rtspServerPortNum, authDB);
   }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20121209/205d45c9/attachment.html>


More information about the live-devel mailing list