From bc756d6ad985fdade11736004c3b512d41584b1f Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 13 Apr 2014 21:55:01 +0800 Subject: [PATCH] fix simple handshake bug #46, copy c1 to s2. change to 0.9.63 --- trunk/src/core/srs_core.hpp | 2 +- trunk/src/rtmp/srs_protocol_handshake.cpp | 2 +- trunk/src/rtmp/srs_protocol_rtmp.cpp | 8 +++++++- trunk/src/rtmp/srs_protocol_rtmp.hpp | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 704804b13..f4cf3e0d6 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "62" +#define VERSION_REVISION "63" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "srs" diff --git a/trunk/src/rtmp/srs_protocol_handshake.cpp b/trunk/src/rtmp/srs_protocol_handshake.cpp index ae979da6d..981304683 100644 --- a/trunk/src/rtmp/srs_protocol_handshake.cpp +++ b/trunk/src/rtmp/srs_protocol_handshake.cpp @@ -1001,7 +1001,7 @@ int SrsSimpleHandshake::handshake_with_client(SrsHandshakeBytes* hs_bytes, ISrsP } srs_verbose("check c0 success, required plain text."); - if ((ret = hs_bytes->create_s0s1s2()) != ERROR_SUCCESS) { + if ((ret = hs_bytes->create_s0s1s2(hs_bytes->c0c1 + 1)) != ERROR_SUCCESS) { return ret; } diff --git a/trunk/src/rtmp/srs_protocol_rtmp.cpp b/trunk/src/rtmp/srs_protocol_rtmp.cpp index f27ff6fc3..1b743c820 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp.cpp @@ -275,7 +275,7 @@ int SrsHandshakeBytes::create_c0c1() return ret; } -int SrsHandshakeBytes::create_s0s1s2() +int SrsHandshakeBytes::create_s0s1s2(const char* c1) { int ret = ERROR_SUCCESS; @@ -294,6 +294,12 @@ int SrsHandshakeBytes::create_s0s1s2() *(int32_t*)(s0s1s2 + 1 + 4) = *(int32_t*)(c0c1 + 1); } + // if c1 specified, copy c1 to s2. + // @see: https://github.com/winlinvip/simple-rtmp-server/issues/46 + if (c1) { + memcpy(s0s1s2 + 1537, c1, 1536); + } + return ret; } diff --git a/trunk/src/rtmp/srs_protocol_rtmp.hpp b/trunk/src/rtmp/srs_protocol_rtmp.hpp index 09b3f6af8..70b5425a2 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp.hpp +++ b/trunk/src/rtmp/srs_protocol_rtmp.hpp @@ -137,7 +137,7 @@ public: virtual int read_s0s1s2(ISrsProtocolReaderWriter* io); virtual int read_c2(ISrsProtocolReaderWriter* io); virtual int create_c0c1(); - virtual int create_s0s1s2(); + virtual int create_s0s1s2(const char* c1 = NULL); virtual int create_c2(); };