winlin

merge from srs2

@@ -1289,6 +1289,7 @@ Winlin @@ -1289,6 +1289,7 @@ Winlin
1289 [bug #518]: https://github.com/ossrs/srs/issues/518 1289 [bug #518]: https://github.com/ossrs/srs/issues/518
1290 [bug #541]: https://github.com/ossrs/srs/issues/541 1290 [bug #541]: https://github.com/ossrs/srs/issues/541
1291 [bug #546]: https://github.com/ossrs/srs/issues/546 1291 [bug #546]: https://github.com/ossrs/srs/issues/546
  1292 +[bug #418]: https://github.com/ossrs/srs/issues/418
1292 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx 1293 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
1293 1294
1294 [exo #828]: https://github.com/google/ExoPlayer/pull/828 1295 [exo #828]: https://github.com/google/ExoPlayer/pull/828
@@ -1164,6 +1164,11 @@ int SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsP @@ -1164,6 +1164,11 @@ int SrsSimpleHandshake::handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsP
1164 if ((ret = hs_bytes->create_c2()) != ERROR_SUCCESS) { 1164 if ((ret = hs_bytes->create_c2()) != ERROR_SUCCESS) {
1165 return ret; 1165 return ret;
1166 } 1166 }
  1167 +
  1168 + // for simple handshake, copy s1 to c2.
  1169 + // @see https://github.com/ossrs/srs/issues/418
  1170 + memcpy(hs_bytes->c2, hs_bytes->s0s1s2 + 1, 1536);
  1171 +
1167 if ((ret = io->write(hs_bytes->c2, 1536, &nsize)) != ERROR_SUCCESS) { 1172 if ((ret = io->write(hs_bytes->c2, 1536, &nsize)) != ERROR_SUCCESS) {
1168 srs_warn("simple handshake write c2 failed. ret=%d", ret); 1173 srs_warn("simple handshake write c2 failed. ret=%d", ret);
1169 return ret; 1174 return ret;
@@ -3300,11 +3300,26 @@ int SrsConnectAppResPacket::decode(SrsBuffer* stream) @@ -3300,11 +3300,26 @@ int SrsConnectAppResPacket::decode(SrsBuffer* stream)
3300 ret = ERROR_SUCCESS; 3300 ret = ERROR_SUCCESS;
3301 } 3301 }
3302 3302
3303 - if ((ret = props->read(stream)) != ERROR_SUCCESS) { 3303 + // for RED5(1.0.6), the props is NULL, we must ignore it.
  3304 + // @see https://github.com/ossrs/srs/issues/418
  3305 + if (!stream->empty()) {
  3306 + SrsAmf0Any* p = NULL;
  3307 + if ((ret = srs_amf0_read_any(stream, &p)) != ERROR_SUCCESS) {
3304 srs_error("amf0 decode connect props failed. ret=%d", ret); 3308 srs_error("amf0 decode connect props failed. ret=%d", ret);
3305 return ret; 3309 return ret;
3306 } 3310 }
3307 3311
  3312 + // ignore when props is not amf0 object.
  3313 + if (!p->is_object()) {
  3314 + srs_warn("ignore connect response props marker=%#x.", (u_int8_t)p->marker);
  3315 + srs_freep(p);
  3316 + } else {
  3317 + srs_freep(props);
  3318 + props = p->to_object();
  3319 + srs_info("accept amf0 object connect response props");
  3320 + }
  3321 + }
  3322 +
3308 if ((ret = info->read(stream)) != ERROR_SUCCESS) { 3323 if ((ret = info->read(stream)) != ERROR_SUCCESS) {
3309 srs_error("amf0 decode connect info failed. ret=%d", ret); 3324 srs_error("amf0 decode connect info failed. ret=%d", ret);
3310 return ret; 3325 return ret;