From eea2310b073c4d574558050012c4f533cbd8f6f3 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 7 Apr 2014 09:07:12 +0800 Subject: [PATCH] refine consts --- trunk/src/app/srs_app_encoder.cpp | 3 ++ trunk/src/app/srs_app_forward.cpp | 3 ++ trunk/src/app/srs_app_ingest.cpp | 25 ++++++++++ trunk/src/app/srs_app_ingest.hpp | 15 ++++++ trunk/src/app/srs_app_rtmp_conn.cpp | 17 +++++++ trunk/src/app/srs_app_server.cpp | 3 ++ trunk/src/rtmp/srs_protocol_rtmp_stack.cpp | 4 ++ trunk/src/rtmp/srs_protocol_rtmp_stack.hpp | 55 ++++++---------------- 8 files changed, 84 insertions(+), 41 deletions(-) diff --git a/trunk/src/app/srs_app_encoder.cpp b/trunk/src/app/srs_app_encoder.cpp index 6b77165b2..3ae57a304 100644 --- a/trunk/src/app/srs_app_encoder.cpp +++ b/trunk/src/app/srs_app_encoder.cpp @@ -50,6 +50,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // for example, libaacplus, aac, fdkaac #define SRS_ENCODER_ACODEC "aac" +// when error, encoder sleep for a while and retry. +#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL) + // for encoder to detect the dead loop static std::vector _transcoded_url; diff --git a/trunk/src/app/srs_app_forward.cpp b/trunk/src/app/srs_app_forward.cpp index a86894204..47b45f5b8 100644 --- a/trunk/src/app/srs_app_forward.cpp +++ b/trunk/src/app/srs_app_forward.cpp @@ -40,6 +40,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +// when error, forwarder sleep for a while and retry. +#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) + SrsForwarder::SrsForwarder(SrsSource* _source) { source = _source; diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index ec6dbcbe0..d58d9fd42 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -25,4 +25,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef SRS_INGEST +#include + +// when error, ingester sleep for a while and retry. +#define SRS_INGESTER_SLEEP_US (int64_t)(3*1000*1000LL) + +SrsIngester::SrsIngester() +{ + pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US); +} + +SrsIngester::~SrsIngester() +{ + srs_freep(pthread); +} + +int SrsIngester::cycle() +{ + int ret = ERROR_SUCCESS; + return ret; +} + +void SrsIngester::on_thread_stop() +{ +} + #endif diff --git a/trunk/src/app/srs_app_ingest.hpp b/trunk/src/app/srs_app_ingest.hpp index 285b05c18..2e0d4cac3 100644 --- a/trunk/src/app/srs_app_ingest.hpp +++ b/trunk/src/app/srs_app_ingest.hpp @@ -31,5 +31,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef SRS_INGEST +#include + +class SrsIngester : public ISrsThreadHandler +{ +private: + SrsThread* pthread; +public: + SrsIngester(); + virtual ~SrsIngester(); +// interface ISrsThreadHandler. +public: + virtual int cycle(); + virtual void on_thread_stop(); +}; + #endif #endif diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 147bf2f00..0df3db74e 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -43,6 +43,23 @@ using namespace std; #include #include +// when stream is busy, for example, streaming is already +// publishing, when a new client to request to publish, +// sleep a while and close the connection. +#define SRS_STREAM_BUSY_SLEEP_US (int64_t)(3*1000*1000LL) + +// the timeout to wait encoder to republish +// if timeout, close the connection. +#define SRS_REPUBLISH_SEND_TIMEOUT_US (int64_t)(3*60*1000*1000LL) +// if timeout, close the connection. +#define SRS_REPUBLISH_RECV_TIMEOUT_US (int64_t)(3*60*1000*1000LL) + +// the timeout to wait client data, when client paused +// if timeout, close the connection. +#define SRS_PAUSED_SEND_TIMEOUT_US (int64_t)(30*60*1000*1000LL) +// if timeout, close the connection. +#define SRS_PAUSED_RECV_TIMEOUT_US (int64_t)(30*60*1000*1000LL) + SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) : SrsConnection(srs_server, client_stfd) { diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 446b7021d..64d3a79cd 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -41,6 +41,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#ifdef SRS_INGEST +#include +#endif #define SERVER_LISTEN_BACKLOG 512 #define SRS_TIME_RESOLUTION_MS 500 diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp index 76473caec..28addb7cc 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using namespace std; +// when got a messae header, there must be some data, +// increase recv timeout to got an entire message. +#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL) + /**************************************************************************** ***************************************************************************** ****************************************************************************/ diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp index ea339afd6..1486e014d 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp @@ -35,19 +35,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include + +class ISrsProtocolReaderWriter; +class SrsBuffer; +class SrsPacket; +class SrsStream; +class SrsCommonMessage; +class SrsChunkStream; +class SrsAmf0Object; +class SrsAmf0Any; +class ISrsMessage; // the following is the timeout for rtmp protocol, // to avoid death connection. -// when got a messae header, there must be some data, -// increase recv timeout to got an entire message. -#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL) - -// the timeout to wait for client control message, -// if timeout, we generally ignore and send the data to client, -// generally, it's the pulse time for data seding. -#define SRS_PULSE_TIMEOUT_US (int64_t)(200*1000LL) - // the timeout to wait client data, // if timeout, close the connection. #define SRS_SEND_TIMEOUT_US (int64_t)(30*1000*1000LL) @@ -56,38 +57,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // if timeout, close the connection. #define SRS_RECV_TIMEOUT_US (int64_t)(30*1000*1000LL) -// the timeout to wait client data, when client paused -// if timeout, close the connection. -#define SRS_PAUSED_SEND_TIMEOUT_US (int64_t)(30*60*1000*1000LL) -// if timeout, close the connection. -#define SRS_PAUSED_RECV_TIMEOUT_US (int64_t)(30*60*1000*1000LL) - -// the timeout to wait encoder to republish -// if timeout, close the connection. -#define SRS_REPUBLISH_SEND_TIMEOUT_US (int64_t)(3*60*1000*1000LL) -// if timeout, close the connection. -#define SRS_REPUBLISH_RECV_TIMEOUT_US (int64_t)(3*60*1000*1000LL) - -// when stream is busy, for example, streaming is already -// publishing, when a new client to request to publish, -// sleep a while and close the connection. -#define SRS_STREAM_BUSY_SLEEP_US (int64_t)(3*1000*1000LL) - -// when error, forwarder sleep for a while and retry. -#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) - -// when error, encoder sleep for a while and retry. -#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL) - -class ISrsProtocolReaderWriter; -class SrsBuffer; -class SrsPacket; -class SrsStream; -class SrsCommonMessage; -class SrsChunkStream; -class SrsAmf0Object; -class SrsAmf0Any; -class ISrsMessage; +// the timeout to wait for client control message, +// if timeout, we generally ignore and send the data to client, +// generally, it's the pulse time for data seding. +#define SRS_PULSE_TIMEOUT_US (int64_t)(200*1000LL) // convert class name to string. #define CLASS_NAME_STRING(className) #className