winlin

for bug #257, support NULL msg in msgs to send.

@@ -2201,11 +2201,11 @@ bool SrsConfig::get_realtime_enabled(string vhost) @@ -2201,11 +2201,11 @@ bool SrsConfig::get_realtime_enabled(string vhost)
2201 } 2201 }
2202 2202
2203 conf = conf->get("min_latency"); 2203 conf = conf->get("min_latency");
2204 - if (!conf || conf->arg0() != "off") { 2204 + if (!conf || conf->arg0().empty()) {
2205 return SRS_PERF_MIN_LATENCY_ENABLED; 2205 return SRS_PERF_MIN_LATENCY_ENABLED;
2206 } 2206 }
2207 2207
2208 - return false; 2208 + return conf->arg0() == "on";
2209 } 2209 }
2210 2210
2211 int SrsConfig::get_global_chunk_size() 2211 int SrsConfig::get_global_chunk_size()
@@ -688,15 +688,13 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) @@ -688,15 +688,13 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd)
688 } 688 }
689 689
690 // sendout messages, all messages are freed by send_and_free_messages(). 690 // sendout messages, all messages are freed by send_and_free_messages().
691 - if (count > 0) {  
692 // no need to assert msg, for the rtmp will assert it. 691 // no need to assert msg, for the rtmp will assert it.
693 - if ((ret = rtmp->send_and_free_messages(msgs.msgs, count, res->stream_id)) != ERROR_SUCCESS) { 692 + if (count > 0 && (ret = rtmp->send_and_free_messages(msgs.msgs, count, res->stream_id)) != ERROR_SUCCESS) {
694 if (!srs_is_client_gracefully_close(ret)) { 693 if (!srs_is_client_gracefully_close(ret)) {
695 srs_error("send messages to client failed. ret=%d", ret); 694 srs_error("send messages to client failed. ret=%d", ret);
696 } 695 }
697 return ret; 696 return ret;
698 } 697 }
699 - }  
700 698
701 // if duration specified, and exceed it, stop play live. 699 // if duration specified, and exceed it, stop play live.
702 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/45 700 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/45
@@ -237,7 +237,6 @@ public: @@ -237,7 +237,6 @@ public:
237 * get packets in consumer queue. 237 * get packets in consumer queue.
238 * @param msgs the msgs array to dump packets to send. 238 * @param msgs the msgs array to dump packets to send.
239 * @param count the count in array, output param. 239 * @param count the count in array, output param.
240 - * @max_count the max count to dequeue, must be positive.  
241 */ 240 */
242 virtual int dump_packets(SrsMessageArray* msgs, int& count); 241 virtual int dump_packets(SrsMessageArray* msgs, int& count);
243 #ifdef SRS_PERF_QUEUE_COND_WAIT 242 #ifdef SRS_PERF_QUEUE_COND_WAIT
@@ -769,6 +769,10 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs) @@ -769,6 +769,10 @@ int SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msgs)
769 for (int i = 0; i < nb_msgs; i++) { 769 for (int i = 0; i < nb_msgs; i++) {
770 SrsSharedPtrMessage* msg = msgs[i]; 770 SrsSharedPtrMessage* msg = msgs[i];
771 771
  772 + if (!msg) {
  773 + continue;
  774 + }
  775 +
772 // ignore empty message. 776 // ignore empty message.
773 if (!msg->payload || msg->size <= 0) { 777 if (!msg->payload || msg->size <= 0) {
774 srs_info("ignore empty message."); 778 srs_info("ignore empty message.");
@@ -1155,6 +1159,10 @@ int SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, @@ -1155,6 +1159,10 @@ int SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs,
1155 for (int i = 0; i < nb_msgs; i++) { 1159 for (int i = 0; i < nb_msgs; i++) {
1156 SrsSharedPtrMessage* msg = msgs[i]; 1160 SrsSharedPtrMessage* msg = msgs[i];
1157 1161
  1162 + if (!msg) {
  1163 + continue;
  1164 + }
  1165 +
1158 // check perfer cid and stream, 1166 // check perfer cid and stream,
1159 // when one msg stream id is ok, ignore left. 1167 // when one msg stream id is ok, ignore left.
1160 if (msg->check(stream_id)) { 1168 if (msg->check(stream_id)) {