Merge r62 and r63 into 1.x branch 1.x
authorhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Dec 2009 20:26:39 +0000 (20:26 +0000)
committerhyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Wed, 16 Dec 2009 20:26:39 +0000 (20:26 +0000)
git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/branches/1.x@73 400ebc74-4327-4243-bc38-086b20814532

handshake.cpp
rtmp.cpp

index 8d53eae..82052ff 100644 (file)
@@ -257,12 +257,10 @@ bool CRTMP::HandShake(bool FP9HandShake)
 {
        bool encrypted = Link.protocol == RTMP_PROTOCOL_RTMPE || Link.protocol == RTMP_PROTOCOL_RTMPTE;
 
-       FP9HandShake = true;//false;
-
-       if(encrypted && !FP9HandShake) {
-               Log(LOGERROR, "%s: RTMPE requires FP9 handshake!", __FUNCTION__);
-               return false;
-       }
+       if ( encrypted || Link.SWFHash )
+               FP9HandShake = true;
+       else
+               FP9HandShake = false;
 
        char clientsig[RTMP_SIG_SIZE+1];
        char serversig[RTMP_SIG_SIZE];
@@ -398,11 +396,16 @@ bool CRTMP::HandShake(bool FP9HandShake)
        LogHex(LOGDEBUG, serversig, RTMP_SIG_SIZE);
        #endif
 
+       if (!FP9HandShake) {
+               if(!WriteN(serversig, RTMP_SIG_SIZE))
+                       return false;
+       }
+
        // we have to use this signature now to find the correct algorithms for getting the digest and DH positions
        int digestPosServer = GetDigestOffset2(serversig, RTMP_SIG_SIZE);
        int dhposServer     = GetDHOffset2(serversig, RTMP_SIG_SIZE);
 
-       if(!VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36)) {
+       if(FP9HandShake && !VerifyDigest(digestPosServer, serversig, GenuineFMSKey, 36)) {
                Log(LOGWARNING, "Trying different position for server digest!\n");
                 digestPosServer = GetDigestOffset1(serversig, RTMP_SIG_SIZE);
                dhposServer     = GetDHOffset1(serversig, RTMP_SIG_SIZE);
@@ -493,8 +496,6 @@ bool CRTMP::HandShake(bool FP9HandShake)
                        Log(LOGWARNING, "%s: client signature does not match!", __FUNCTION__);
                }
 
-               if(!WriteN(serversig, RTMP_SIG_SIZE))
-                       return false;
        } else {
                // verify server response
                int digestPosClient = GetDigestOffset1(clientsig+1, RTMP_SIG_SIZE);
index 682c7c7..6f1c223 100644 (file)
--- a/rtmp.cpp
+++ b/rtmp.cpp
@@ -754,7 +754,7 @@ bool CRTMP::SendConnectPacket()
   if(Link.pageUrl)
        enc += EncodeString(enc, "pageUrl", Link.pageUrl);
 
-  //enc += EncodeNumber(enc, "objectEncoding", 3.0); // use AMF3 objects, not supported yet
+  enc += EncodeNumber(enc, "objectEncoding", 0.0); // AMF0, AMF3 not supported yet
   enc += 2; // end of object - 0x00 0x00 0x09
   *enc = 0x09;
   enc++;