winlin

refine consts

@@ -50,6 +50,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -50,6 +50,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 // for example, libaacplus, aac, fdkaac 50 // for example, libaacplus, aac, fdkaac
51 #define SRS_ENCODER_ACODEC "aac" 51 #define SRS_ENCODER_ACODEC "aac"
52 52
  53 +// when error, encoder sleep for a while and retry.
  54 +#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL)
  55 +
53 // for encoder to detect the dead loop 56 // for encoder to detect the dead loop
54 static std::vector<std::string> _transcoded_url; 57 static std::vector<std::string> _transcoded_url;
55 58
@@ -40,6 +40,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -40,6 +40,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 #include <srs_protocol_utility.hpp> 40 #include <srs_protocol_utility.hpp>
41 #include <srs_protocol_rtmp.hpp> 41 #include <srs_protocol_rtmp.hpp>
42 42
  43 +// when error, forwarder sleep for a while and retry.
  44 +#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL)
  45 +
43 SrsForwarder::SrsForwarder(SrsSource* _source) 46 SrsForwarder::SrsForwarder(SrsSource* _source)
44 { 47 {
45 source = _source; 48 source = _source;
@@ -25,4 +25,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -25,4 +25,29 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 25
26 #ifdef SRS_INGEST 26 #ifdef SRS_INGEST
27 27
  28 +#include <srs_kernel_error.hpp>
  29 +
  30 +// when error, ingester sleep for a while and retry.
  31 +#define SRS_INGESTER_SLEEP_US (int64_t)(3*1000*1000LL)
  32 +
  33 +SrsIngester::SrsIngester()
  34 +{
  35 + pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US);
  36 +}
  37 +
  38 +SrsIngester::~SrsIngester()
  39 +{
  40 + srs_freep(pthread);
  41 +}
  42 +
  43 +int SrsIngester::cycle()
  44 +{
  45 + int ret = ERROR_SUCCESS;
  46 + return ret;
  47 +}
  48 +
  49 +void SrsIngester::on_thread_stop()
  50 +{
  51 +}
  52 +
28 #endif 53 #endif
@@ -31,5 +31,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,5 +31,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 31
32 #ifdef SRS_INGEST 32 #ifdef SRS_INGEST
33 33
  34 +#include <srs_app_thread.hpp>
  35 +
  36 +class SrsIngester : public ISrsThreadHandler
  37 +{
  38 +private:
  39 + SrsThread* pthread;
  40 +public:
  41 + SrsIngester();
  42 + virtual ~SrsIngester();
  43 +// interface ISrsThreadHandler.
  44 +public:
  45 + virtual int cycle();
  46 + virtual void on_thread_stop();
  47 +};
  48 +
34 #endif 49 #endif
35 #endif 50 #endif
@@ -43,6 +43,23 @@ using namespace std; @@ -43,6 +43,23 @@ using namespace std;
43 #include <srs_app_socket.hpp> 43 #include <srs_app_socket.hpp>
44 #include <srs_app_http_hooks.hpp> 44 #include <srs_app_http_hooks.hpp>
45 45
  46 +// when stream is busy, for example, streaming is already
  47 +// publishing, when a new client to request to publish,
  48 +// sleep a while and close the connection.
  49 +#define SRS_STREAM_BUSY_SLEEP_US (int64_t)(3*1000*1000LL)
  50 +
  51 +// the timeout to wait encoder to republish
  52 +// if timeout, close the connection.
  53 +#define SRS_REPUBLISH_SEND_TIMEOUT_US (int64_t)(3*60*1000*1000LL)
  54 +// if timeout, close the connection.
  55 +#define SRS_REPUBLISH_RECV_TIMEOUT_US (int64_t)(3*60*1000*1000LL)
  56 +
  57 +// the timeout to wait client data, when client paused
  58 +// if timeout, close the connection.
  59 +#define SRS_PAUSED_SEND_TIMEOUT_US (int64_t)(30*60*1000*1000LL)
  60 +// if timeout, close the connection.
  61 +#define SRS_PAUSED_RECV_TIMEOUT_US (int64_t)(30*60*1000*1000LL)
  62 +
46 SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) 63 SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd)
47 : SrsConnection(srs_server, client_stfd) 64 : SrsConnection(srs_server, client_stfd)
48 { 65 {
@@ -41,6 +41,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -41,6 +41,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 #include <srs_app_http_api.hpp> 41 #include <srs_app_http_api.hpp>
42 #include <srs_app_http_conn.hpp> 42 #include <srs_app_http_conn.hpp>
43 #include <srs_app_http.hpp> 43 #include <srs_app_http.hpp>
  44 +#ifdef SRS_INGEST
  45 +#include <srs_app_ingest.hpp>
  46 +#endif
44 47
45 #define SERVER_LISTEN_BACKLOG 512 48 #define SERVER_LISTEN_BACKLOG 512
46 #define SRS_TIME_RESOLUTION_MS 500 49 #define SRS_TIME_RESOLUTION_MS 500
@@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -33,6 +33,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 33
34 using namespace std; 34 using namespace std;
35 35
  36 +// when got a messae header, there must be some data,
  37 +// increase recv timeout to got an entire message.
  38 +#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL)
  39 +
36 /**************************************************************************** 40 /****************************************************************************
37 ***************************************************************************** 41 *****************************************************************************
38 ****************************************************************************/ 42 ****************************************************************************/
@@ -35,19 +35,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -35,19 +35,20 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 35
36 #include <srs_kernel_log.hpp> 36 #include <srs_kernel_log.hpp>
37 #include <srs_kernel_error.hpp> 37 #include <srs_kernel_error.hpp>
  38 +
  39 +class ISrsProtocolReaderWriter;
  40 +class SrsBuffer;
  41 +class SrsPacket;
  42 +class SrsStream;
  43 +class SrsCommonMessage;
  44 +class SrsChunkStream;
  45 +class SrsAmf0Object;
  46 +class SrsAmf0Any;
  47 +class ISrsMessage;
38 48
39 // the following is the timeout for rtmp protocol, 49 // the following is the timeout for rtmp protocol,
40 // to avoid death connection. 50 // to avoid death connection.
41 51
42 -// when got a messae header, there must be some data,  
43 -// increase recv timeout to got an entire message.  
44 -#define SRS_MIN_RECV_TIMEOUT_US (int64_t)(60*1000*1000LL)  
45 -  
46 -// the timeout to wait for client control message,  
47 -// if timeout, we generally ignore and send the data to client,  
48 -// generally, it's the pulse time for data seding.  
49 -#define SRS_PULSE_TIMEOUT_US (int64_t)(200*1000LL)  
50 -  
51 // the timeout to wait client data, 52 // the timeout to wait client data,
52 // if timeout, close the connection. 53 // if timeout, close the connection.
53 #define SRS_SEND_TIMEOUT_US (int64_t)(30*1000*1000LL) 54 #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. @@ -56,38 +57,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56 // if timeout, close the connection. 57 // if timeout, close the connection.
57 #define SRS_RECV_TIMEOUT_US (int64_t)(30*1000*1000LL) 58 #define SRS_RECV_TIMEOUT_US (int64_t)(30*1000*1000LL)
58 59
59 -// the timeout to wait client data, when client paused  
60 -// if timeout, close the connection.  
61 -#define SRS_PAUSED_SEND_TIMEOUT_US (int64_t)(30*60*1000*1000LL)  
62 -// if timeout, close the connection.  
63 -#define SRS_PAUSED_RECV_TIMEOUT_US (int64_t)(30*60*1000*1000LL)  
64 -  
65 -// the timeout to wait encoder to republish  
66 -// if timeout, close the connection.  
67 -#define SRS_REPUBLISH_SEND_TIMEOUT_US (int64_t)(3*60*1000*1000LL)  
68 -// if timeout, close the connection.  
69 -#define SRS_REPUBLISH_RECV_TIMEOUT_US (int64_t)(3*60*1000*1000LL)  
70 -  
71 -// when stream is busy, for example, streaming is already  
72 -// publishing, when a new client to request to publish,  
73 -// sleep a while and close the connection.  
74 -#define SRS_STREAM_BUSY_SLEEP_US (int64_t)(3*1000*1000LL)  
75 -  
76 -// when error, forwarder sleep for a while and retry.  
77 -#define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL)  
78 -  
79 -// when error, encoder sleep for a while and retry.  
80 -#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL)  
81 -  
82 -class ISrsProtocolReaderWriter;  
83 -class SrsBuffer;  
84 -class SrsPacket;  
85 -class SrsStream;  
86 -class SrsCommonMessage;  
87 -class SrsChunkStream;  
88 -class SrsAmf0Object;  
89 -class SrsAmf0Any;  
90 -class ISrsMessage; 60 +// the timeout to wait for client control message,
  61 +// if timeout, we generally ignore and send the data to client,
  62 +// generally, it's the pulse time for data seding.
  63 +#define SRS_PULSE_TIMEOUT_US (int64_t)(200*1000LL)
91 64
92 // convert class name to string. 65 // convert class name to string.
93 #define CLASS_NAME_STRING(className) #className 66 #define CLASS_NAME_STRING(className) #className