winlin

fix bug #53, never use msg when sent it

@@ -520,17 +520,20 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -520,17 +520,20 @@ int SrsRtmpConn::playing(SrsSource* source)
520 // so set the msgs[i] to NULL. 520 // so set the msgs[i] to NULL.
521 msgs[i] = NULL; 521 msgs[i] = NULL;
522 522
523 - if ((ret = rtmp->send_message(msg)) != ERROR_SUCCESS) {  
524 - srs_error("send message to client failed. ret=%d", ret);  
525 - return ret;  
526 - } 523 + srs_assert(msg);
527 524
528 // foreach msg, collect the duration. 525 // foreach msg, collect the duration.
  526 + // @remark: never use msg when sent it, for the protocol sdk will free it.
529 if (starttime < 0 || starttime > msg->header.timestamp) { 527 if (starttime < 0 || starttime > msg->header.timestamp) {
530 starttime = msg->header.timestamp; 528 starttime = msg->header.timestamp;
531 } 529 }
532 duration += msg->header.timestamp - starttime; 530 duration += msg->header.timestamp - starttime;
533 starttime = msg->header.timestamp; 531 starttime = msg->header.timestamp;
  532 +
  533 + if ((ret = rtmp->send_message(msg)) != ERROR_SUCCESS) {
  534 + srs_error("send message to client failed. ret=%d", ret);
  535 + return ret;
  536 + }
534 } 537 }
535 538
536 // if duration specified, and exceed it, stop play live. 539 // if duration specified, and exceed it, stop play live.