winlin

close #454, support obs restart publish. 2.0.184

@@ -342,6 +342,7 @@ Remark: @@ -342,6 +342,7 @@ Remark:
342 342
343 ## History 343 ## History
344 344
  345 +* v2.0, 2015-08-18, close [#454](https://github.com/simple-rtmp-server/srs/issues/454), support obs restart publish. 2.0.184
345 * v2.0, 2015-08-14, use reduce_sequence_header for stream control. 346 * v2.0, 2015-08-14, use reduce_sequence_header for stream control.
346 * v2.0, 2015-08-14, use send_min_interval for stream control. 2.0.183 347 * v2.0, 2015-08-14, use send_min_interval for stream control. 2.0.183
347 * v2.0, 2015-08-12, enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182 348 * v2.0, 2015-08-12, enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182
@@ -508,10 +508,15 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then @@ -508,10 +508,15 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
508 else 508 else
509 echo -e "${YELLOW}warning: without HLS support${BLACK}" 509 echo -e "${YELLOW}warning: without HLS support${BLACK}"
510 fi 510 fi
  511 + if [ $SRS_STREAM_CASTER = YES ]; then
  512 + echo -e "${YELLOW}Experiment: StreamCaster is enabled${BLACK}"
  513 + else
  514 + echo -e "${GREEN}note: without StreamCaster support${BLACK}"
  515 + fi
511 if [ $SRS_HDS = YES ]; then 516 if [ $SRS_HDS = YES ]; then
512 - echo -e "${GREEN}HDS is enabled${BLACK}" 517 + echo -e "${YELLOW}Experiment: HDS is enabled${BLACK}"
513 else 518 else
514 - echo -e "${YELLOW}warning: without HDS support${BLACK}" 519 + echo -e "${GREEN}warning: without HDS support${BLACK}"
515 fi 520 fi
516 if [ $SRS_NGINX = YES ]; then 521 if [ $SRS_NGINX = YES ]; then
517 echo -e "${GREEN}Nginx http server is enabled${BLACK}" 522 echo -e "${GREEN}Nginx http server is enabled${BLACK}"
@@ -96,7 +96,7 @@ int SrsRecvThread::cycle() @@ -96,7 +96,7 @@ int SrsRecvThread::cycle()
96 } 96 }
97 97
98 if (ret != ERROR_SUCCESS) { 98 if (ret != ERROR_SUCCESS) {
99 - if (!srs_is_client_gracefully_close(ret)) { 99 + if (!srs_is_client_gracefully_close(ret) && !srs_is_system_control_error(ret)) {
100 srs_error("thread process message failed. ret=%d", ret); 100 srs_error("thread process message failed. ret=%d", ret);
101 } 101 }
102 102
@@ -337,6 +337,16 @@ int SrsRtmpConn::service_cycle() @@ -337,6 +337,16 @@ int SrsRtmpConn::service_cycle()
337 } 337 }
338 } 338 }
339 339
  340 + // set chunk size to larger.
  341 + // set the chunk size before any larger response greater than 128,
  342 + // to make OBS happy, @see https://github.com/simple-rtmp-server/srs/issues/454
  343 + int chunk_size = _srs_config->get_chunk_size(req->vhost);
  344 + if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {
  345 + srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);
  346 + return ret;
  347 + }
  348 + srs_info("set chunk_size=%d success", chunk_size);
  349 +
340 // response the client connect ok. 350 // response the client connect ok.
341 if ((ret = rtmp->response_connect_app(req, local_ip.c_str())) != ERROR_SUCCESS) { 351 if ((ret = rtmp->response_connect_app(req, local_ip.c_str())) != ERROR_SUCCESS) {
342 srs_error("response connect app failed. ret=%d", ret); 352 srs_error("response connect app failed. ret=%d", ret);
@@ -424,14 +434,6 @@ int SrsRtmpConn::stream_service_cycle() @@ -424,14 +434,6 @@ int SrsRtmpConn::stream_service_cycle()
424 rtmp->set_recv_timeout(SRS_CONSTS_RTMP_RECV_TIMEOUT_US); 434 rtmp->set_recv_timeout(SRS_CONSTS_RTMP_RECV_TIMEOUT_US);
425 rtmp->set_send_timeout(SRS_CONSTS_RTMP_SEND_TIMEOUT_US); 435 rtmp->set_send_timeout(SRS_CONSTS_RTMP_SEND_TIMEOUT_US);
426 436
427 - // set chunk size to larger.  
428 - int chunk_size = _srs_config->get_chunk_size(req->vhost);  
429 - if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) {  
430 - srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret);  
431 - return ret;  
432 - }  
433 - srs_info("set chunk_size=%d success", chunk_size);  
434 -  
435 // find a source to serve. 437 // find a source to serve.
436 SrsSource* source = SrsSource::fetch(req); 438 SrsSource* source = SrsSource::fetch(req);
437 if (!source) { 439 if (!source) {
@@ -637,7 +639,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe @@ -637,7 +639,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
637 639
638 // quit when recv thread error. 640 // quit when recv thread error.
639 if ((ret = trd->error_code()) != ERROR_SUCCESS) { 641 if ((ret = trd->error_code()) != ERROR_SUCCESS) {
640 - if (!srs_is_client_gracefully_close(ret)) { 642 + if (!srs_is_client_gracefully_close(ret) && !srs_is_system_control_error(ret)) {
641 srs_error("recv thread failed. ret=%d", ret); 643 srs_error("recv thread failed. ret=%d", ret);
642 } 644 }
643 return ret; 645 return ret;
@@ -824,7 +826,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) @@ -824,7 +826,7 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd)
824 826
825 // check the thread error code. 827 // check the thread error code.
826 if ((ret = trd->error_code()) != ERROR_SUCCESS) { 828 if ((ret = trd->error_code()) != ERROR_SUCCESS) {
827 - if (!srs_is_client_gracefully_close(ret)) { 829 + if (!srs_is_system_control_error(ret) && !srs_is_client_gracefully_close(ret)) {
828 srs_error("recv thread failed. ret=%d", ret); 830 srs_error("recv thread failed. ret=%d", ret);
829 } 831 }
830 return ret; 832 return ret;
@@ -187,7 +187,7 @@ namespace internal { @@ -187,7 +187,7 @@ namespace internal {
187 srs_info("thread %s on before cycle success"); 187 srs_info("thread %s on before cycle success");
188 188
189 if ((ret = handler->cycle()) != ERROR_SUCCESS) { 189 if ((ret = handler->cycle()) != ERROR_SUCCESS) {
190 - if (!srs_is_client_gracefully_close(ret)) { 190 + if (!srs_is_client_gracefully_close(ret) && !srs_is_system_control_error(ret)) {
191 srs_warn("thread %s cycle failed, ignored and retry, ret=%d", _name, ret); 191 srs_warn("thread %s cycle failed, ignored and retry, ret=%d", _name, ret);
192 } 192 }
193 goto failed; 193 goto failed;
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 183 34 +#define VERSION_REVISION 184
35 35
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"
@@ -2924,7 +2924,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid) @@ -2924,7 +2924,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid)
2924 pkt->data->set(StatusDescription, SrsAmf0Any::str("Stop publishing stream.")); 2924 pkt->data->set(StatusDescription, SrsAmf0Any::str("Stop publishing stream."));
2925 2925
2926 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) { 2926 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) {
  2927 + if (!srs_is_system_control_error(ret) && !srs_is_client_gracefully_close(ret)) {
2927 srs_error("send onFCUnpublish(NetStream.unpublish.Success) message failed. ret=%d", ret); 2928 srs_error("send onFCUnpublish(NetStream.unpublish.Success) message failed. ret=%d", ret);
  2929 + }
2928 return ret; 2930 return ret;
2929 } 2931 }
2930 srs_info("send onFCUnpublish(NetStream.unpublish.Success) message success."); 2932 srs_info("send onFCUnpublish(NetStream.unpublish.Success) message success.");
@@ -2933,7 +2935,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid) @@ -2933,7 +2935,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid)
2933 if (true) { 2935 if (true) {
2934 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(unpublish_tid); 2936 SrsFMLEStartResPacket* pkt = new SrsFMLEStartResPacket(unpublish_tid);
2935 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) { 2937 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) {
  2938 + if (!srs_is_system_control_error(ret) && !srs_is_client_gracefully_close(ret)) {
2936 srs_error("send FCUnpublish response message failed. ret=%d", ret); 2939 srs_error("send FCUnpublish response message failed. ret=%d", ret);
  2940 + }
2937 return ret; 2941 return ret;
2938 } 2942 }
2939 srs_info("send FCUnpublish response message success."); 2943 srs_info("send FCUnpublish response message success.");
@@ -2948,7 +2952,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid) @@ -2948,7 +2952,9 @@ int SrsRtmpServer::fmle_unpublish(int stream_id, double unpublish_tid)
2948 pkt->data->set(StatusClientId, SrsAmf0Any::str(RTMP_SIG_CLIENT_ID)); 2952 pkt->data->set(StatusClientId, SrsAmf0Any::str(RTMP_SIG_CLIENT_ID));
2949 2953
2950 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) { 2954 if ((ret = protocol->send_and_free_packet(pkt, stream_id)) != ERROR_SUCCESS) {
  2955 + if (!srs_is_system_control_error(ret) && !srs_is_client_gracefully_close(ret)) {
2951 srs_error("send onStatus(NetStream.Unpublish.Success) message failed. ret=%d", ret); 2956 srs_error("send onStatus(NetStream.Unpublish.Success) message failed. ret=%d", ret);
  2957 + }
2952 return ret; 2958 return ret;
2953 } 2959 }
2954 srs_info("send onStatus(NetStream.Unpublish.Success) message success."); 2960 srs_info("send onStatus(NetStream.Unpublish.Success) message success.");