]> granicus.if.org Git - rtmpdump/commitdiff
Handle extensions followed by URL parameters
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 9 Jan 2010 16:24:29 +0000 (16:24 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 9 Jan 2010 16:24:29 +0000 (16:24 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@230 400ebc74-4327-4243-bc38-086b20814532

parseurl.c

index 816084bea16983a2be0535b3d681f4b15a830b48..37fba1765c7e94faa280375a2e1763e7d0b9df81 100644 (file)
@@ -274,7 +274,7 @@ parsehost:
  * the playpath part of the URL with formating depending on the stream
  * type:
  *
- * mp4 streams: prepend "mp4:"
+ * mp4 streams: prepend "mp4:", remove extension
  * mp3 streams: prepend "mp3:", remove extension
  * flv streams: remove extension
  */
@@ -284,8 +284,10 @@ char *ParsePlaypath(const char *playpath) {
 
        int addMP4 = 0;
        int addMP3 = 0;
-       const char *temp;
+       int subExt = 0;
+       const char *temp, *q, *ext = NULL;
        const char *ppstart = playpath;
+
        int pplen = strlen(playpath);
 
        if ((*ppstart == '?') &&
@@ -299,18 +301,23 @@ char *ParsePlaypath(const char *playpath) {
                }
        }
 
+       q = strchr(ppstart, '?');
        if (pplen >= 4) {
-               const char *ext = &ppstart[pplen-4];
-               if ((strcmp(ext, ".f4v") == 0) ||
-                   (strcmp(ext, ".mp4") == 0)) {
+               if (q)
+                       ext = q-4;
+               else
+                       ext = &ppstart[pplen-4];
+               if ((strncmp(ext, ".f4v", 4) == 0) ||
+                   (strncmp(ext, ".mp4", 4) == 0)) {
                        addMP4 = 1;
+                       subExt = 1;
                // Only remove .flv from rtmp URL, not slist params
                } else if ((ppstart == playpath) &&
-                   (strcmp(ext, ".flv") == 0)) {
-                       pplen -= 4;
-               } else if (strcmp(ext, ".mp3") == 0) {
+                   (strncmp(ext, ".flv", 4) == 0)) {
+                       subExt = 1;
+               } else if (strncmp(ext, ".mp3", 4) == 0) {
                        addMP3 = 1;
-                       pplen -= 4;
+                       subExt = 1;
                }
        }
 
@@ -328,6 +335,11 @@ char *ParsePlaypath(const char *playpath) {
        }
 
        for (p=(char *)ppstart; pplen >0;) {
+               /* skip extension */
+               if (subExt && p == ext) {
+                       p += 4;
+                       pplen -= 4;
+               }
                if (*p == '%') {
                        int c;
                        sscanf(p+1, "%02x", &c);