]> granicus.if.org Git - rtmpdump/commitdiff
Fix: handle auth parameters in connect request
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 2 Jan 2010 23:10:00 +0000 (23:10 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Sat, 2 Jan 2010 23:10:00 +0000 (23:10 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@170 400ebc74-4327-4243-bc38-086b20814532

rtmp.c
rtmp.h
rtmpsuck.c

diff --git a/rtmp.c b/rtmp.c
index f13bb9f2ed515f2642c1fe11add128a163eb4a90..be6bcd3c90c35b97f6d13d93eeef90f1cd228b1e 100644 (file)
--- a/rtmp.c
+++ b/rtmp.c
@@ -944,11 +944,9 @@ SendConnectPacket(RTMP * r)
   // add auth string
   if (r->Link.auth.av_len)
     {
-      if (enc+2 >= pend)
+      enc = AMF_EncodeBoolean(enc, pend, r->Link.authflag);
+      if (!enc)
         return false;
-      *enc++ = 0x01;
-      *enc++ = 0x01;
-
       enc = AMF_EncodeString(enc, pend, &r->Link.auth);
       if (!enc)
         return false;
diff --git a/rtmp.h b/rtmp.h
index 6cf4bd0df1b1aeda955a90b159b12cf6871c3fd7..590a59eac528be32d6c1cb0997903a9a0dcd54dd 100644 (file)
--- a/rtmp.h
+++ b/rtmp.h
@@ -125,6 +125,7 @@ typedef struct RTMP_LNK
   AVal flashVer;
   AVal subscribepath;
   AVal token;
+  bool authflag;
 
   double seekTime;
   uint32_t length;
index 7aad6f0a13a66a030f9c9c226e2100fd1ab7aab4..403ac595af9c4251efdf3c6dc7c4b8994133fb61 100644 (file)
@@ -189,8 +189,12 @@ ServeInvoke(STREAMING_SERVER *server, RTMPPacket *pack, const char *body)
             {
               pval = cobj.o_props[i].p_vu.p_aval;
               if (pval.av_val)
-                pval.av_val = strdup(pval.av_val);
-              LogPrintf("%.*s: %.*s\n", pname.av_len, pname.av_val, pval.av_len, pval.av_val);
+              {
+                pval.av_val = malloc(pval.av_len+1);
+                memcpy(pval.av_val, cobj.o_props[i].p_vu.p_aval.av_val, pval.av_len);
+                pval.av_val[pval.av_len] = '\0';
+              }
+              LogPrintf("%.*s: %s\n", pname.av_len, pname.av_val, pval.av_val);
             }
           if (AVMATCH(&pname, &av_app))
             {
@@ -275,6 +279,19 @@ ServeInvoke(STREAMING_SERVER *server, RTMPPacket *pack, const char *body)
           if (pval.av_val)
             free(pval.av_val);
         }
+      if (obj.o_num > 3)
+        {
+          server->rc.Link.authflag = AMFProp_GetBoolean(&obj.o_props[3]);
+          if (obj.o_num > 4)
+          {
+            AVal tmp;
+            AMFProp_GetString(&obj.o_props[4], &tmp);
+            server->rc.Link.auth.av_len = tmp.av_len;
+            server->rc.Link.auth.av_val = malloc(tmp.av_len+1);
+            memcpy(server->rc.Link.auth.av_val, tmp.av_val, tmp.av_len);
+            server->rc.Link.auth.av_val[tmp.av_len] = '\0';
+          }
+        }
 
       if (!RTMP_Connect(&server->rc))
         {