]> granicus.if.org Git - rtmpdump/commitdiff
Derive output name from playpath. (Code copied from rtmpsuck)
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 20 Feb 2010 02:37:51 +0000 (02:37 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 20 Feb 2010 02:37:51 +0000 (02:37 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@255 400ebc74-4327-4243-bc38-086b20814532

rtmpsrv.c

index 9eead689ba478918107b246224b514ef41b85752..0ec6b2eba6abc0a6a225f43b2db82119d5b0ecbb 100644 (file)
--- a/rtmpsrv.c
+++ b/rtmpsrv.c
@@ -388,6 +388,7 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
     }
   else if (AVMATCH(&method, &av_play))
     {
+      char *file, *p, *q;
       RTMPPacket pc = {0};
       AMFProp_GetString(AMF_GetProp(&obj, NULL, 3), &r->Link.playpath);
       r->Link.seekTime = AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 4));
@@ -412,9 +413,45 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
               dumpAMF(&r->Link.extras);
               AMF_Reset(&r->Link.extras);
             }
-          printf(" -y \"%.*s\" -o output.flv\n\n",
-            r->Link.playpath.av_len, r->Link.playpath.av_val);
+          if (r->Link.playpath.av_val)
+            {
+              AVal av = r->Link.playpath;
+              /* strip trailing URL parameters */
+              q = memchr(av.av_val, '?', av.av_len);
+              if (q)
+                av.av_len = q - av.av_val;
+              /* strip leading slash components */
+              for (p=av.av_val+av.av_len-1; p>=av.av_val; p--)
+                if (*p == '/')
+                  {
+                    p++;
+                    av.av_len -= p - av.av_val;
+                    av.av_val = p;
+                    break;
+                  }
+              /* skip leading dot */
+              if (av.av_val[0] == '.')
+                {
+                  av.av_val++;
+                  av.av_len--;
+                }
+              file = malloc(av.av_len+1);
+
+              memcpy(file, av.av_val, av.av_len);
+              file[av.av_len] = '\0';
+              for (p=file; *p; p++)
+                if (*p == ':')
+                  *p = '_';
+           }
+         else
+           {
+             file="output.flv";
+           }
+          printf(" -y \"%.*s\" -o %s\n\n",
+            r->Link.playpath.av_len, r->Link.playpath.av_val, file);
           fflush(stdout);
+         if (r->Link.playpath.av_val)
+           free(file);
         }
       pc.m_body = server->connect;
       server->connect = NULL;