From 2c059d3a8041fb776774104c62c416eae9dabd9c Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 17 May 2014 17:53:27 +0800 Subject: [PATCH] fix bug #72, also need stream_id for send_and_free_message. 0.9.101 --- trunk/etc/init.d/srs | 4 ++-- trunk/src/app/srs_app_edge.cpp | 2 +- trunk/src/app/srs_app_forward.cpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 2 +- trunk/src/core/srs_core.hpp | 2 +- trunk/src/libs/srs_librtmp.cpp | 2 +- trunk/src/rtmp/srs_protocol_rtmp.cpp | 8 ++++---- trunk/src/rtmp/srs_protocol_rtmp.hpp | 4 ++-- trunk/src/rtmp/srs_protocol_rtmp_stack.cpp | 5 ++++- trunk/src/rtmp/srs_protocol_rtmp_stack.hpp | 3 ++- 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/trunk/etc/init.d/srs b/trunk/etc/init.d/srs index 5c72f9bdc..f49039649 100755 --- a/trunk/etc/init.d/srs +++ b/trunk/etc/init.d/srs @@ -76,9 +76,9 @@ start() { # TODO: FIXME: set limit by, for instance, "ulimit -HSn 10000" if [[ -z $log_file ]]; then - (cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) + (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >/dev/null 2>&1) else - (cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) + (ulimit -c unlimited && cd ${ROOT}; ${APP} -c ${CONFIG} >> $log_file 2>&1) fi # check again after start server diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 3f9e2f482..a746dd9bc 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -491,7 +491,7 @@ int SrsEdgeForwarder::cycle() srs_assert(msg); msgs[i] = NULL; - if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { + if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) { srs_error("edge publish forwarder send message to server failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_forward.cpp b/trunk/src/app/srs_app_forward.cpp index feb0c2512..18dc27b9b 100644 --- a/trunk/src/app/srs_app_forward.cpp +++ b/trunk/src/app/srs_app_forward.cpp @@ -370,7 +370,7 @@ int SrsForwarder::forward() srs_assert(msg); msgs[i] = NULL; - if ((ret = client->send_and_free_message(msg)) != ERROR_SUCCESS) { + if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) { srs_error("forwarder send message to server failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index a534f0ee1..ec5f0e865 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -538,7 +538,7 @@ int SrsRtmpConn::playing(SrsSource* source) duration += msg->header.timestamp - starttime; starttime = msg->header.timestamp; - if ((ret = rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) { + if ((ret = rtmp->send_and_free_message(msg, res->stream_id)) != ERROR_SUCCESS) { srs_error("send message to client failed. ret=%d", ret); return ret; } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 99e8b10c7..b7b6d1e9f 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "100" +#define VERSION_REVISION "101" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "srs" diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 6ed66665e..ea099d3c9 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -365,7 +365,7 @@ int srs_write_packet(srs_rtmp_t rtmp, int type, u_int32_t timestamp, char* data, if (msg) { // send out encoded msg. - if ((ret = context->rtmp->send_and_free_message(msg)) != ERROR_SUCCESS) { + if ((ret = context->rtmp->send_and_free_message(msg, context->stream_id)) != ERROR_SUCCESS) { return ret; } } else { diff --git a/trunk/src/rtmp/srs_protocol_rtmp.cpp b/trunk/src/rtmp/srs_protocol_rtmp.cpp index 5c0ecb3d1..30ab1eb86 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp.cpp @@ -385,9 +385,9 @@ int SrsRtmpClient::decode_message(SrsMessage* msg, SrsPacket** ppacket) return protocol->decode_message(msg, ppacket); } -int SrsRtmpClient::send_and_free_message(SrsMessage* msg) +int SrsRtmpClient::send_and_free_message(SrsMessage* msg, int stream_id) { - return protocol->send_and_free_message(msg); + return protocol->send_and_free_message(msg, stream_id); } int SrsRtmpClient::send_and_free_packet(SrsPacket* packet, int stream_id) @@ -730,9 +730,9 @@ int SrsRtmpServer::decode_message(SrsMessage* msg, SrsPacket** ppacket) return protocol->decode_message(msg, ppacket); } -int SrsRtmpServer::send_and_free_message(SrsMessage* msg) +int SrsRtmpServer::send_and_free_message(SrsMessage* msg, int stream_id) { - return protocol->send_and_free_message(msg); + return protocol->send_and_free_message(msg, stream_id); } int SrsRtmpServer::send_and_free_packet(SrsPacket* packet, int stream_id) diff --git a/trunk/src/rtmp/srs_protocol_rtmp.hpp b/trunk/src/rtmp/srs_protocol_rtmp.hpp index 4bd55b5f0..37c5d7984 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp.hpp +++ b/trunk/src/rtmp/srs_protocol_rtmp.hpp @@ -164,7 +164,7 @@ public: virtual int64_t get_send_bytes(); virtual int recv_message(SrsMessage** pmsg); virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket); - virtual int send_and_free_message(SrsMessage* msg); + virtual int send_and_free_message(SrsMessage* msg, int stream_id); virtual int send_and_free_packet(SrsPacket* packet, int stream_id); public: // try complex, then simple handshake. @@ -209,7 +209,7 @@ public: virtual int64_t get_send_bytes(); virtual int recv_message(SrsMessage** pmsg); virtual int decode_message(SrsMessage* msg, SrsPacket** ppacket); - virtual int send_and_free_message(SrsMessage* msg); + virtual int send_and_free_message(SrsMessage* msg, int stream_id); virtual int send_and_free_packet(SrsPacket* packet, int stream_id); public: virtual int handshake(); diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp index bdca122ab..37c0aaac2 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp @@ -725,8 +725,11 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream, return ret; } -int SrsProtocol::send_and_free_message(SrsMessage* msg) +int SrsProtocol::send_and_free_message(SrsMessage* msg, int stream_id) { + if (msg) { + msg->header.stream_id = stream_id; + } return do_send_and_free_message(msg, NULL); } diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp index 4fccd3196..d63ba0d59 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp @@ -161,8 +161,9 @@ public: * user must never free or use the msg after this method, * for it will always free the msg. * @param msg, the msg to send out, never be NULL. + * @param stream_id, the stream id of packet to send over, 0 for control message. */ - virtual int send_and_free_message(SrsMessage* msg); + virtual int send_and_free_message(SrsMessage* msg, int stream_id); /** * send the RTMP packet and always free it. * user must never free or use the packet after this method,