[Live-devel] RTSP patch

Josh Norell josh at kci.net
Wed Jun 4 09:52:30 PDT 2008


Here's a patch that we wrote in response to solving this problem:

http://lists.live555.com/pipermail/live-devel/2008-March/008275.html


It was done on the 2008.02.08 build, so it may not be valid any more,
but here it is anyway in case someoen finds it useful:




diff -u -r live-clean/liveMedia/RTSPCommon.cpp
live/liveMedia/RTSPCommon.cpp
--- live-clean/liveMedia/RTSPCommon.cpp 2008-04-02 10:48:33.000000000
-0600
+++ live/liveMedia/RTSPCommon.cpp       2008-04-02 14:15:38.000000000
-0600
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <stdio.h>
 
+#include <iostream.h>
 #define DEBUG 1
 
 Boolean parseRTSPRequestString(char const* reqStr,
@@ -91,10 +92,7 @@
       while (k2 <= k) resultURLSuffix[n++] = reqStr[k2++];
       resultURLSuffix[n] = '\0';
 
-      // Also look for the URL 'pre-suffix' before this:
-      unsigned k3 = --k1;
-      while (k3 > i && reqStr[k3] != '/') --k3;
-      // the URL pre-suffix comes from [k3+1,k1]
+                       unsigned k3 = i;
 
       // Copy "resultURLPreSuffix":
       if (k1 - k3 + 1 > resultURLPreSuffixMaxSize) return False; //
there's no room
@@ -102,6 +100,59 @@
       while (k2 <= k1) resultURLPreSuffix[n++] = reqStr[k2++];
       resultURLPreSuffix[n] = '\0';
 
+/*
+** the dangerous bit
+** if it's 'SETUP' pre is full path, file is the track (track1)
+** if it's anything else, file is full path, pre empty
+** we really should do something to see if we already got 'track1' or
so
+** heavily overdocumented for now
+** ref http://www.sourcepole.ch/sources/programming/cpp/cppqref.html
+*/
+// create the string with limits
+char tmpURL[RTSP_PARAM_STRING_MAX] = "";
+char tmpPreURL[RTSP_PARAM_STRING_MAX] = "";
+
+// copy current URLSuffix to our tmp
+strncpy(tmpURL,resultURLSuffix,RTSP_PARAM_STRING_MAX);
+// copy current URLPreSuffix to our tmp
+strncpy(tmpPreURL,resultURLPreSuffix,RTSP_PARAM_STRING_MAX);
+
+// now add the suffix to it (up to the limit) _if_ it's not 'track'
+// we could just 'if (strstr(resultURLSuffix,"track") > 0)' but what if
+//             we have a file with a legit 'track' in the filename?
+if (strncmp(tmpURL,"track",5) != 0) {
+       // trail with "/" if the tmp still has space and doesn't end
with a "/"
+       if (strlen(tmpPreURL) > 0
+                       && strlen(tmpPreURL) < resultURLSuffixMaxSize
+                       && tmpPreURL[strlen(tmpPreURL)-1] != '/')
+               strcat(tmpPreURL,"/");
+
+       // add the suffix
+       strncat(tmpPreURL,resultURLSuffix,RTSP_PARAM_STRING_MAX-strlen(tmpPreURL));
+}
+
+// if our tmp still has the trailing "/" we strip it.
+if (tmpPreURL[strlen(tmpPreURL)-1] == '/') {
+       strncpy(tmpURL,tmpPreURL,strlen(tmpPreURL)-1);
+       strcpy(tmpPreURL,tmpURL);
+}
+// if our tmp has a leading "/" we should strip it.
+// should.
+
+// now, depending on the command, we do various things
+if (strcmp(resultCmdName,"SETUP") == 0) {
+       // if this is the setup command
+       // copy our tmp into the pre
+       strncpy(resultURLPreSuffix,tmpPreURL,resultURLPreSuffixMaxSize);
+       // set the 'main' to "track1"
+       strcpy(resultURLSuffix,"track1");
+} else {
+       // if this is any other command
(OPTIONS,DESCRIBE,PLAY,TEARDOWN,PAUSE)
+       strcpy(resultURLPreSuffix,"");
+       strncpy(resultURLSuffix,tmpPreURL,resultURLSuffixMaxSize);
+}
+/* back to your normal code */
+
       i = k + 7; // to go past " RTSP/"
       parseSucceeded = True;
       break;




More information about the live-devel mailing list