From 8d378cda2e5d95bcfde87f14f4ba869cd7be5fca Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 22 Dec 2015 16:48:06 +0800 Subject: [PATCH 1/2] for #418, when simple handshake, copy s1 to c2. --- trunk/src/protocol/srs_rtmp_handshake.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trunk/src/protocol/srs_rtmp_handshake.cpp b/trunk/src/protocol/srs_rtmp_handshake.cpp index c59efbc10..e712ec0bb 100644 --- a/trunk/src/protocol/srs_rtmp_handshake.cpp +++ b/trunk/src/protocol/srs_rtmp_handshake.cpp @@ -1164,6 +1164,11 @@ int SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsP if ((ret = hs_bytes->create_c2()) != ERROR_SUCCESS) { return ret; } + + // for simple handshake, copy s1 to c2. + // @see https://github.com/ossrs/srs/issues/418 + memcpy(hs_bytes->c2, hs_bytes->s0s1s2 + 1, 1536); + if ((ret = io->write(hs_bytes->c2, 1536, &nsize)) != ERROR_SUCCESS) { srs_warn("simple handshake write c2 failed. ret=%d", ret); return ret; From 8b24319ffb0279820976b1cfed2d00557be4705b Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 22 Dec 2015 17:00:22 +0800 Subject: [PATCH 2/2] fix #418, ignore null connect props to make RED5 happy. 2.0.204 --- README.md | 2 ++ trunk/src/core/srs_core.hpp | 2 +- trunk/src/protocol/srs_rtmp_stack.cpp | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2ead68451..075ebe014 100755 --- a/README.md +++ b/README.md @@ -337,6 +337,7 @@ Remark: ## History +* v2.0, 2015-12-22, for [#418][bug #418] ignore null connect props to make RED5 happy. 2.0.204 * v2.0, 2015-12-22, for [#546][bug #546] thread terminate normally dispose bug. 2.0.203 * v2.0, 2015-12-22, for [#541][bug #541] failed when chunk size too small. 2.0.202 * v2.0, 2015-12-15, default hls_on_error to continue. 2.0.201 @@ -1211,6 +1212,7 @@ Winlin [bug #518]: https://github.com/ossrs/srs/issues/518 [bug #541]: https://github.com/ossrs/srs/issues/541 [bug #546]: https://github.com/ossrs/srs/issues/546 +[bug #418]: https://github.com/ossrs/srs/issues/418 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index c747e5839..4033b2f51 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 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 203 +#define VERSION_REVISION 204 // server info. #define RTMP_SIG_SRS_KEY "SRS" diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 049f2eba6..0a0f7a5c1 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -3289,9 +3289,24 @@ int SrsConnectAppResPacket::decode(SrsStream* stream) ret = ERROR_SUCCESS; } - if ((ret = props->read(stream)) != ERROR_SUCCESS) { - srs_error("amf0 decode connect props failed. ret=%d", ret); - return ret; + // for RED5(1.0.6), the props is NULL, we must ignore it. + // @see https://github.com/ossrs/srs/issues/418 + if (!stream->empty()) { + SrsAmf0Any* p = NULL; + if ((ret = srs_amf0_read_any(stream, &p)) != ERROR_SUCCESS) { + srs_error("amf0 decode connect props failed. ret=%d", ret); + return ret; + } + + // ignore when props is not amf0 object. + if (!p->is_object()) { + srs_warn("ignore connect response props marker=%#x.", (u_int8_t)p->marker); + srs_freep(p); + } else { + srs_freep(props); + props = p->to_object(); + srs_info("accept amf0 object connect response props"); + } } if ((ret = info->read(stream)) != ERROR_SUCCESS) {