正在显示
9 个修改的文件
包含
185 行增加
和
113 行删除
@@ -338,7 +338,7 @@ CORE_OBJS="${MODULE_OBJS[@]}" | @@ -338,7 +338,7 @@ CORE_OBJS="${MODULE_OBJS[@]}" | ||
338 | MODULE_ID="KERNEL" | 338 | MODULE_ID="KERNEL" |
339 | MODULE_DEPENDS=("CORE") | 339 | MODULE_DEPENDS=("CORE") |
340 | ModuleLibIncs=(${SRS_OBJS}) | 340 | ModuleLibIncs=(${SRS_OBJS}) |
341 | -MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer") | 341 | +MODULE_FILES=("srs_kernel_error" "srs_kernel_log" "srs_kernel_stream" "srs_kernel_buffer" "srs_kernel_utility") |
342 | KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh | 342 | KERNEL_INCS="src/kernel"; MODULE_DIR=${KERNEL_INCS} . auto/modules.sh |
343 | KERNEL_OBJS="${MODULE_OBJS[@]}" | 343 | KERNEL_OBJS="${MODULE_OBJS[@]}" |
344 | # | 344 | # |
@@ -34,6 +34,7 @@ using namespace std; | @@ -34,6 +34,7 @@ using namespace std; | ||
34 | #include <srs_protocol_rtmp_stack.hpp> | 34 | #include <srs_protocol_rtmp_stack.hpp> |
35 | #include <srs_app_config.hpp> | 35 | #include <srs_app_config.hpp> |
36 | #include <srs_core_autofree.hpp> | 36 | #include <srs_core_autofree.hpp> |
37 | +#include <srs_kernel_utility.hpp> | ||
37 | 38 | ||
38 | SrsBandwidth::SrsBandwidth() | 39 | SrsBandwidth::SrsBandwidth() |
39 | { | 40 | { |
@@ -37,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -37,6 +37,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
37 | #include <srs_kernel_error.hpp> | 37 | #include <srs_kernel_error.hpp> |
38 | #include <srs_app_client.hpp> | 38 | #include <srs_app_client.hpp> |
39 | #include <srs_app_config.hpp> | 39 | #include <srs_app_config.hpp> |
40 | +#include <srs_kernel_utility.hpp> | ||
40 | 41 | ||
41 | #define SERVER_LISTEN_BACKLOG 512 | 42 | #define SERVER_LISTEN_BACKLOG 512 |
42 | #define SRS_TIME_RESOLUTION_MS 500 | 43 | #define SRS_TIME_RESOLUTION_MS 500 |
@@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
24 | #include <srs_app_socket.hpp> | 24 | #include <srs_app_socket.hpp> |
25 | 25 | ||
26 | #include <srs_kernel_error.hpp> | 26 | #include <srs_kernel_error.hpp> |
27 | +#include <srs_kernel_utility.hpp> | ||
27 | 28 | ||
28 | SrsSocket::SrsSocket(st_netfd_t client_stfd) | 29 | SrsSocket::SrsSocket(st_netfd_t client_stfd) |
29 | { | 30 | { |
@@ -24,30 +24,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -24,30 +24,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
24 | #include <srs_core.hpp> | 24 | #include <srs_core.hpp> |
25 | 25 | ||
26 | #include <string.h> | 26 | #include <string.h> |
27 | -#include <sys/time.h> | ||
28 | #include <netdb.h> | 27 | #include <netdb.h> |
29 | #include <arpa/inet.h> | 28 | #include <arpa/inet.h> |
30 | 29 | ||
31 | -static int64_t _srs_system_time_us_cache = 0; | ||
32 | - | ||
33 | -int64_t srs_get_system_time_ms() | ||
34 | -{ | ||
35 | - return _srs_system_time_us_cache / 1000; | ||
36 | -} | ||
37 | - | ||
38 | -void srs_update_system_time_ms() | ||
39 | -{ | ||
40 | - timeval now; | ||
41 | - | ||
42 | - gettimeofday(&now, NULL); | ||
43 | - | ||
44 | - // @see: https://github.com/winlinvip/simple-rtmp-server/issues/35 | ||
45 | - // we must convert the tv_sec/tv_usec to int64_t. | ||
46 | - _srs_system_time_us_cache = ((int64_t)now.tv_sec) * 1000 * 1000 + (int64_t)now.tv_usec; | ||
47 | - | ||
48 | - _srs_system_time_us_cache = srs_max(0, _srs_system_time_us_cache); | ||
49 | -} | ||
50 | - | ||
51 | std::string srs_replace(std::string str, std::string old_str, std::string new_str) | 30 | std::string srs_replace(std::string str, std::string old_str, std::string new_str) |
52 | { | 31 | { |
53 | std::string ret = str; | 32 | std::string ret = str; |
@@ -86,11 +86,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -86,11 +86,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
86 | #define srs_min(a, b) (((a) < (b))? (a) : (b)) | 86 | #define srs_min(a, b) (((a) < (b))? (a) : (b)) |
87 | #define srs_max(a, b) (((a) < (b))? (b) : (a)) | 87 | #define srs_max(a, b) (((a) < (b))? (b) : (a)) |
88 | 88 | ||
89 | -// get current system time in ms, use cache to avoid performance problem | ||
90 | -extern int64_t srs_get_system_time_ms(); | ||
91 | -// the deamon st-thread will update it. | ||
92 | -extern void srs_update_system_time_ms(); | ||
93 | - | ||
94 | // signal defines. | 89 | // signal defines. |
95 | #define SIGNAL_RELOAD SIGHUP | 90 | #define SIGNAL_RELOAD SIGHUP |
96 | 91 |
trunk/src/kernel/srs_kernel_utility.cpp
0 → 100644
1 | +/* | ||
2 | +The MIT License (MIT) | ||
3 | + | ||
4 | +Copyright (c) 2013-2014 winlin | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
7 | +this software and associated documentation files (the "Software"), to deal in | ||
8 | +the Software without restriction, including without limitation the rights to | ||
9 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
10 | +the Software, and to permit persons to whom the Software is furnished to do so, | ||
11 | +subject to the following conditions: | ||
12 | + | ||
13 | +The above copyright notice and this permission notice shall be included in all | ||
14 | +copies or substantial portions of the Software. | ||
15 | + | ||
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
18 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
19 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
20 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
21 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
22 | +*/ | ||
23 | + | ||
24 | +#include <srs_kernel_utility.hpp> | ||
25 | + | ||
26 | +#include <sys/time.h> | ||
27 | + | ||
28 | +#include <srs_kernel_log.hpp> | ||
29 | + | ||
30 | +static int64_t _srs_system_time_us_cache = 0; | ||
31 | + | ||
32 | +int64_t srs_get_system_time_ms() | ||
33 | +{ | ||
34 | + return _srs_system_time_us_cache / 1000; | ||
35 | +} | ||
36 | + | ||
37 | +void srs_update_system_time_ms() | ||
38 | +{ | ||
39 | + timeval now; | ||
40 | + | ||
41 | + if (gettimeofday(&now, NULL) < 0) { | ||
42 | + srs_warn("gettimeofday failed, ignore"); | ||
43 | + return; | ||
44 | + } | ||
45 | + | ||
46 | + // @see: https://github.com/winlinvip/simple-rtmp-server/issues/35 | ||
47 | + // we must convert the tv_sec/tv_usec to int64_t. | ||
48 | + int64_t now_us = ((int64_t)now.tv_sec) * 1000 * 1000 + (int64_t)now.tv_usec; | ||
49 | + if (now_us < _srs_system_time_us_cache) { | ||
50 | + srs_warn("system time negative, " | ||
51 | + "history=%"PRId64"us, now=%"PRId64"", _srs_system_time_us_cache, now_us); | ||
52 | + } | ||
53 | + | ||
54 | + _srs_system_time_us_cache = now_us; | ||
55 | +} |
trunk/src/kernel/srs_kernel_utility.hpp
0 → 100644
1 | +/* | ||
2 | +The MIT License (MIT) | ||
3 | + | ||
4 | +Copyright (c) 2013-2014 winlin | ||
5 | + | ||
6 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
7 | +this software and associated documentation files (the "Software"), to deal in | ||
8 | +the Software without restriction, including without limitation the rights to | ||
9 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
10 | +the Software, and to permit persons to whom the Software is furnished to do so, | ||
11 | +subject to the following conditions: | ||
12 | + | ||
13 | +The above copyright notice and this permission notice shall be included in all | ||
14 | +copies or substantial portions of the Software. | ||
15 | + | ||
16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
18 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
19 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
20 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
21 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
22 | +*/ | ||
23 | + | ||
24 | +#ifndef SRS_KERNEL_UTILITY_HPP | ||
25 | +#define SRS_KERNEL_UTILITY_HPP | ||
26 | + | ||
27 | +/* | ||
28 | +#include <srs_kernel_utility.hpp> | ||
29 | +*/ | ||
30 | + | ||
31 | +#include <srs_core.hpp> | ||
32 | + | ||
33 | +// get current system time in ms, use cache to avoid performance problem | ||
34 | +extern int64_t srs_get_system_time_ms(); | ||
35 | +// the deamon st-thread will update it. | ||
36 | +extern void srs_update_system_time_ms(); | ||
37 | + | ||
38 | +#endif |
1 | file | 1 | file |
2 | - main readonly separator, | ||
3 | - ..\main\srs_main_server.cpp, | ||
4 | - ..\main\srs_main_bandcheck.cpp, | ||
5 | - auto readonly separator, | ||
6 | - ..\..\objs\srs_auto_headers.hpp, | ||
7 | - libs readonly separator, | ||
8 | - ..\libs\srs_librtmp.hpp, | ||
9 | - ..\libs\srs_librtmp.cpp, | ||
10 | - ..\libs\srs_lib_simple_socket.hpp, | ||
11 | - ..\libs\srs_lib_simple_socket.cpp, | ||
12 | - core readonly separator, | ||
13 | - ..\core\srs_core.hpp, | ||
14 | - ..\core\srs_core.cpp, | ||
15 | - ..\core\srs_core_autofree.hpp, | ||
16 | - ..\core\srs_core_autofree.cpp, | ||
17 | - kernel readonly separator, | ||
18 | - ..\kernel\srs_kernel_buffer.hpp, | ||
19 | - ..\kernel\srs_kernel_buffer.cpp, | ||
20 | - ..\kernel\srs_kernel_error.hpp, | ||
21 | - ..\kernel\srs_kernel_error.cpp, | ||
22 | - ..\kernel\srs_kernel_log.hpp, | ||
23 | - ..\kernel\srs_kernel_log.cpp, | ||
24 | - ..\kernel\srs_kernel_stream.hpp, | ||
25 | - ..\kernel\srs_kernel_stream.cpp, | ||
26 | - rtmp-protocol readonly separator, | ||
27 | - ..\rtmp\srs_protocol_amf0.hpp, | ||
28 | - ..\rtmp\srs_protocol_amf0.cpp, | ||
29 | - ..\rtmp\srs_protocol_handshake.hpp, | ||
30 | - ..\rtmp\srs_protocol_handshake.cpp, | ||
31 | - ..\rtmp\srs_protocol_io.hpp, | ||
32 | - ..\rtmp\srs_protocol_io.cpp, | ||
33 | - ..\rtmp\srs_protocol_rtmp.hpp, | ||
34 | - ..\rtmp\srs_protocol_rtmp.cpp, | ||
35 | - ..\rtmp\srs_protocol_rtmp_stack.hpp, | ||
36 | - ..\rtmp\srs_protocol_rtmp_stack.cpp, | ||
37 | - ..\rtmp\srs_protocol_utility.hpp, | ||
38 | - ..\rtmp\srs_protocol_utility.cpp, | ||
39 | - app readonly separator, | ||
40 | - ..\app\srs_app_bandwidth.hpp, | ||
41 | - ..\app\srs_app_bandwidth.cpp, | ||
42 | - ..\app\srs_app_client.hpp, | ||
43 | - ..\app\srs_app_client.cpp, | ||
44 | - ..\app\srs_app_codec.hpp, | ||
45 | - ..\app\srs_app_codec.cpp, | ||
46 | - ..\app\srs_app_conn.hpp, | ||
47 | - ..\app\srs_app_conn.cpp, | ||
48 | - ..\app\srs_app_config.hpp, | ||
49 | - ..\app\srs_app_config.cpp, | ||
50 | - ..\app\srs_app_encoder.hpp, | ||
51 | - ..\app\srs_app_encoder.cpp, | ||
52 | - ..\app\srs_app_forward.hpp, | ||
53 | - ..\app\srs_app_forward.cpp, | ||
54 | - ..\app\srs_app_hls.hpp, | ||
55 | - ..\app\srs_app_hls.cpp, | ||
56 | - ..\app\srs_app_http.hpp, | ||
57 | - ..\app\srs_app_http.cpp, | ||
58 | - ..\app\srs_app_log.hpp, | ||
59 | - ..\app\srs_app_log.cpp, | ||
60 | - ..\app\srs_app_refer.hpp, | ||
61 | - ..\app\srs_app_refer.cpp, | ||
62 | - ..\app\srs_app_reload.hpp, | ||
63 | - ..\app\srs_app_reload.cpp, | ||
64 | - ..\app\srs_app_pithy_print.hpp, | ||
65 | - ..\app\srs_app_pithy_print.cpp, | ||
66 | - ..\app\srs_app_thread.hpp, | ||
67 | - ..\app\srs_app_thread.cpp, | ||
68 | - ..\app\srs_app_server.hpp, | ||
69 | - ..\app\srs_app_server.cpp, | ||
70 | - ..\app\srs_app_st.hpp, | ||
71 | - ..\app\srs_app_st.cpp, | ||
72 | - ..\app\srs_app_socket.hpp, | ||
73 | - ..\app\srs_app_socket.cpp, | ||
74 | - ..\app\srs_app_source.hpp, | ||
75 | - ..\app\srs_app_source.cpp, | ||
76 | - utest readonly separator, | ||
77 | - ..\utest\srs_utest.hpp, | ||
78 | - ..\utest\srs_utest.cpp, | ||
79 | - ..\utest\srs_utest_amf0.hpp, | ||
80 | - ..\utest\srs_utest_amf0.cpp, | ||
81 | - ..\utest\srs_utest_handshake.hpp, | ||
82 | - ..\utest\srs_utest_handshake.cpp, | ||
83 | - research readonly separator, | ||
84 | - ..\..\research\librtmp\srs_play.c, | ||
85 | - ..\..\research\librtmp\srs_publish.c, | ||
86 | - ..\..\research\hls\ts_info.cc; | 2 | + main readonly separator, |
3 | + ..\main\srs_main_server.cpp, | ||
4 | + ..\main\srs_main_bandcheck.cpp, | ||
5 | + auto readonly separator, | ||
6 | + ..\..\objs\srs_auto_headers.hpp, | ||
7 | + libs readonly separator, | ||
8 | + ..\libs\srs_librtmp.hpp, | ||
9 | + ..\libs\srs_librtmp.cpp, | ||
10 | + ..\libs\srs_lib_simple_socket.hpp, | ||
11 | + ..\libs\srs_lib_simple_socket.cpp, | ||
12 | + core readonly separator, | ||
13 | + ..\core\srs_core.hpp, | ||
14 | + ..\core\srs_core.cpp, | ||
15 | + ..\core\srs_core_autofree.hpp, | ||
16 | + ..\core\srs_core_autofree.cpp, | ||
17 | + kernel readonly separator, | ||
18 | + ..\kernel\srs_kernel_buffer.hpp, | ||
19 | + ..\kernel\srs_kernel_buffer.cpp, | ||
20 | + ..\kernel\srs_kernel_error.hpp, | ||
21 | + ..\kernel\srs_kernel_error.cpp, | ||
22 | + ..\kernel\srs_kernel_log.hpp, | ||
23 | + ..\kernel\srs_kernel_log.cpp, | ||
24 | + ..\kernel\srs_kernel_stream.hpp, | ||
25 | + ..\kernel\srs_kernel_stream.cpp, | ||
26 | + ..\kernel\srs_kernel_utility.hpp, | ||
27 | + ..\kernel\srs_kernel_utility.cpp, | ||
28 | + rtmp-protocol readonly separator, | ||
29 | + ..\rtmp\srs_protocol_amf0.hpp, | ||
30 | + ..\rtmp\srs_protocol_amf0.cpp, | ||
31 | + ..\rtmp\srs_protocol_handshake.hpp, | ||
32 | + ..\rtmp\srs_protocol_handshake.cpp, | ||
33 | + ..\rtmp\srs_protocol_io.hpp, | ||
34 | + ..\rtmp\srs_protocol_io.cpp, | ||
35 | + ..\rtmp\srs_protocol_rtmp.hpp, | ||
36 | + ..\rtmp\srs_protocol_rtmp.cpp, | ||
37 | + ..\rtmp\srs_protocol_rtmp_stack.hpp, | ||
38 | + ..\rtmp\srs_protocol_rtmp_stack.cpp, | ||
39 | + ..\rtmp\srs_protocol_utility.hpp, | ||
40 | + ..\rtmp\srs_protocol_utility.cpp, | ||
41 | + app readonly separator, | ||
42 | + ..\app\srs_app_bandwidth.hpp, | ||
43 | + ..\app\srs_app_bandwidth.cpp, | ||
44 | + ..\app\srs_app_client.hpp, | ||
45 | + ..\app\srs_app_client.cpp, | ||
46 | + ..\app\srs_app_codec.hpp, | ||
47 | + ..\app\srs_app_codec.cpp, | ||
48 | + ..\app\srs_app_conn.hpp, | ||
49 | + ..\app\srs_app_conn.cpp, | ||
50 | + ..\app\srs_app_config.hpp, | ||
51 | + ..\app\srs_app_config.cpp, | ||
52 | + ..\app\srs_app_encoder.hpp, | ||
53 | + ..\app\srs_app_encoder.cpp, | ||
54 | + ..\app\srs_app_forward.hpp, | ||
55 | + ..\app\srs_app_forward.cpp, | ||
56 | + ..\app\srs_app_hls.hpp, | ||
57 | + ..\app\srs_app_hls.cpp, | ||
58 | + ..\app\srs_app_http.hpp, | ||
59 | + ..\app\srs_app_http.cpp, | ||
60 | + ..\app\srs_app_log.hpp, | ||
61 | + ..\app\srs_app_log.cpp, | ||
62 | + ..\app\srs_app_refer.hpp, | ||
63 | + ..\app\srs_app_refer.cpp, | ||
64 | + ..\app\srs_app_reload.hpp, | ||
65 | + ..\app\srs_app_reload.cpp, | ||
66 | + ..\app\srs_app_pithy_print.hpp, | ||
67 | + ..\app\srs_app_pithy_print.cpp, | ||
68 | + ..\app\srs_app_thread.hpp, | ||
69 | + ..\app\srs_app_thread.cpp, | ||
70 | + ..\app\srs_app_server.hpp, | ||
71 | + ..\app\srs_app_server.cpp, | ||
72 | + ..\app\srs_app_st.hpp, | ||
73 | + ..\app\srs_app_st.cpp, | ||
74 | + ..\app\srs_app_socket.hpp, | ||
75 | + ..\app\srs_app_socket.cpp, | ||
76 | + ..\app\srs_app_source.hpp, | ||
77 | + ..\app\srs_app_source.cpp, | ||
78 | + utest readonly separator, | ||
79 | + ..\utest\srs_utest.hpp, | ||
80 | + ..\utest\srs_utest.cpp, | ||
81 | + ..\utest\srs_utest_amf0.hpp, | ||
82 | + ..\utest\srs_utest_amf0.cpp, | ||
83 | + ..\utest\srs_utest_handshake.hpp, | ||
84 | + ..\utest\srs_utest_handshake.cpp, | ||
85 | + research readonly separator, | ||
86 | + ..\..\research\librtmp\srs_play.c, | ||
87 | + ..\..\research\librtmp\srs_publish.c, | ||
88 | + ..\..\research\hls\ts_info.cc; | ||
87 | 89 | ||
88 | mainconfig | 90 | mainconfig |
89 | - "" = "MAIN"; | 91 | + "" = "MAIN"; |
90 | 92 |
-
请 注册 或 登录 后发表评论