winlin

fix bug #72, also need stream_id for send_and_free_message. 0.9.101

@@ -76,9 +76,9 @@ start() { @@ -76,9 +76,9 @@ start() {
76 76
77 # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" 77 # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000"
78 if [[ -z $log_file ]]; then 78 if [[ -z $log_file ]]; then
79 - (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) 79 + (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1)
80 else 80 else
81 - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) 81 + (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1)
82 fi 82 fi
83 83
84 # check again after start server 84 # check again after start server
@@ -491,7 +491,7 @@ int SrsEdgeForwarder::cycle() @@ -491,7 +491,7 @@ int SrsEdgeForwarder::cycle()
491 srs_assert(msg); 491 srs_assert(msg);
492 msgs[i] = NULL; 492 msgs[i] = NULL;
493 493
494 - if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { 494 + if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) {
495 srs_error("edge publish forwarder send message to server failed. ret=%d", ret); 495 srs_error("edge publish forwarder send message to server failed. ret=%d", ret);
496 return ret; 496 return ret;
497 } 497 }
@@ -370,7 +370,7 @@ int SrsForwarder::forward() @@ -370,7 +370,7 @@ int SrsForwarder::forward()
370 srs_assert(msg); 370 srs_assert(msg);
371 msgs[i] = NULL; 371 msgs[i] = NULL;
372 372
373 - if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { 373 + if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) {
374 srs_error("forwarder send message to server failed. ret=%d", ret); 374 srs_error("forwarder send message to server failed. ret=%d", ret);
375 return ret; 375 return ret;
376 } 376 }
@@ -538,7 +538,7 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -538,7 +538,7 @@ int SrsRtmpConn::playing(SrsSource* source)
538 duration += msg->header.timestamp - starttime; 538 duration += msg->header.timestamp - starttime;
539 starttime = msg->header.timestamp; 539 starttime = msg->header.timestamp;
540 540
541 - if ((ret = rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) { 541 + if ((ret = rtmp->send_and_free_message(msg, res->stream_id)) != ERROR_SUCCESS) {
542 srs_error("send message to client failed. ret=%d", ret); 542 srs_error("send message to client failed. ret=%d", ret);
543 return ret; 543 return ret;
544 } 544 }
@@ -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 "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "100" 34 +#define VERSION_REVISION "101"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "srs" 37 #define RTMP_SIG_SRS_KEY "srs"
@@ -365,7 +365,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, @@ -365,7 +365,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data,
365 365
366 if (msg) { 366 if (msg) {
367 // send out encoded msg. 367 // send out encoded msg.
368 - if ((ret = context->rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) { 368 + if ((ret = context->rtmp->send_and_free_message(msg, context->stream_id)) != ERROR_SUCCESS) {
369 return ret; 369 return ret;
370 } 370 }
371 } else { 371 } else {
@@ -385,9 +385,9 @@ int SrsRtmpClient::decode_message(SrsMessage* msg, SrsPacket** ppacket) @@ -385,9 +385,9 @@ int SrsRtmpClient::decode_message(SrsMessage* msg, SrsPacket** ppacket)
385 return protocol->decode_message(msg, ppacket); 385 return protocol->decode_message(msg, ppacket);
386 } 386 }
387 387
388 -int SrsRtmpClient::send_and_free_message(SrsMessage* msg) 388 +int SrsRtmpClient::send_and_free_message(SrsMessage* msg, int stream_id)
389 { 389 {
390 - return protocol->send_and_free_message(msg); 390 + return protocol->send_and_free_message(msg, stream_id);
391 } 391 }
392 392
393 int SrsRtmpClient::send_and_free_packet(SrsPacket* packet, int stream_id) 393 int SrsRtmpClient::send_and_free_packet(SrsPacket* packet, int stream_id)
@@ -730,9 +730,9 @@ int SrsRtmpServer::decode_message(SrsMessage* msg, SrsPacket** ppacket) @@ -730,9 +730,9 @@ int SrsRtmpServer::decode_message(SrsMessage* msg, SrsPacket** ppacket)
730 return protocol->decode_message(msg, ppacket); 730 return protocol->decode_message(msg, ppacket);
731 } 731 }
732 732
733 -int SrsRtmpServer::send_and_free_message(SrsMessage* msg) 733 +int SrsRtmpServer::send_and_free_message(SrsMessage* msg, int stream_id)
734 { 734 {
735 - return protocol->send_and_free_message(msg); 735 + return protocol->send_and_free_message(msg, stream_id);
736 } 736 }
737 737
738 int SrsRtmpServer::send_and_free_packet(SrsPacket* packet, int stream_id) 738 int SrsRtmpServer::send_and_free_packet(SrsPacket* packet, int stream_id)
@@ -164,7 +164,7 @@ public: @@ -164,7 +164,7 @@ public:
164 virtual int64_t get_send_bytes(); 164 virtual int64_t get_send_bytes();
165 virtual int recv_message(SrsMessage** pmsg); 165 virtual int recv_message(SrsMessage** pmsg);
166 virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket); 166 virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket);
167 - virtual int send_and_free_message(SrsMessage* msg); 167 + virtual int send_and_free_message(SrsMessage* msg, int stream_id);
168 virtual int send_and_free_packet(SrsPacket* packet, int stream_id); 168 virtual int send_and_free_packet(SrsPacket* packet, int stream_id);
169 public: 169 public:
170 // try complex, then simple handshake. 170 // try complex, then simple handshake.
@@ -209,7 +209,7 @@ public: @@ -209,7 +209,7 @@ public:
209 virtual int64_t get_send_bytes(); 209 virtual int64_t get_send_bytes();
210 virtual int recv_message(SrsMessage** pmsg); 210 virtual int recv_message(SrsMessage** pmsg);
211 virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket); 211 virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket);
212 - virtual int send_and_free_message(SrsMessage* msg); 212 + virtual int send_and_free_message(SrsMessage* msg, int stream_id);
213 virtual int send_and_free_packet(SrsPacket* packet, int stream_id); 213 virtual int send_and_free_packet(SrsPacket* packet, int stream_id);
214 public: 214 public:
215 virtual int handshake(); 215 virtual int handshake();
@@ -725,8 +725,11 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, @@ -725,8 +725,11 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream,
725 return ret; 725 return ret;
726 } 726 }
727 727
728 -int SrsProtocol::send_and_free_message(SrsMessage* msg) 728 +int SrsProtocol::send_and_free_message(SrsMessage* msg, int stream_id)
729 { 729 {
  730 + if (msg) {
  731 + msg->header.stream_id = stream_id;
  732 + }
730 return do_send_and_free_message(msg, NULL); 733 return do_send_and_free_message(msg, NULL);
731 } 734 }
732 735
@@ -161,8 +161,9 @@ public: @@ -161,8 +161,9 @@ public:
161 * user must never free or use the msg after this method, 161 * user must never free or use the msg after this method,
162 * for it will always free the msg. 162 * for it will always free the msg.
163 * @param msg, the msg to send out, never be NULL. 163 * @param msg, the msg to send out, never be NULL.
  164 + * @param stream_id, the stream id of packet to send over, 0 for control message.
164 */ 165 */
165 - virtual int send_and_free_message(SrsMessage* msg); 166 + virtual int send_and_free_message(SrsMessage* msg, int stream_id);
166 /** 167 /**
167 * send the RTMP packet and always free it. 168 * send the RTMP packet and always free it.
168 * user must never free or use the packet after this method, 169 * user must never free or use the packet after this method,