正在显示
1 个修改的文件
包含
120 行增加
和
120 行删除
trunk/src/core/srs_core.hpp
100755 → 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_CORE_HPP | ||
| 25 | -#define SRS_CORE_HPP | ||
| 26 | - | ||
| 27 | -/* | ||
| 28 | -#include <srs_core.hpp> | ||
| 29 | -*/ | ||
| 30 | - | ||
| 31 | -/** | ||
| 32 | -* the core provides the common defined macros, utilities, | ||
| 33 | -* user must include the srs_core.hpp before any header, or maybe | ||
| 34 | -* build failed. | ||
| 35 | -*/ | ||
| 36 | - | ||
| 37 | -// for int64_t print using PRId64 format. | ||
| 38 | -#ifndef __STDC_FORMAT_MACROS | ||
| 39 | - #define __STDC_FORMAT_MACROS | ||
| 40 | -#endif | ||
| 41 | -#include <inttypes.h> | ||
| 42 | - | ||
| 43 | -#include <assert.h> | ||
| 44 | -#define srs_assert(expression) assert(expression) | ||
| 45 | - | ||
| 46 | -#include <stddef.h> | ||
| 47 | -#include <sys/types.h> | ||
| 48 | - | ||
| 49 | -#include <st.h> | ||
| 50 | - | ||
| 51 | -// generated by configure. | ||
| 52 | -#include <srs_auto_headers.hpp> | ||
| 53 | - | ||
| 54 | -// free the p and set to NULL. | ||
| 55 | -// p must be a T*. | ||
| 56 | -#define srs_freep(p) \ | ||
| 57 | - if (p) { \ | ||
| 58 | - delete p; \ | ||
| 59 | - p = NULL; \ | ||
| 60 | - } \ | ||
| 61 | - (void)0 | ||
| 62 | -// free the p which represents a array | ||
| 63 | -#define srs_freepa(p) \ | ||
| 64 | - if (p) { \ | ||
| 65 | - delete[] p; \ | ||
| 66 | - p = NULL; \ | ||
| 67 | - } \ | ||
| 68 | - (void)0 | ||
| 69 | - | ||
| 70 | -// current release version | ||
| 71 | -#define RTMP_SIG_SRS_VERSION "0.9.1" | ||
| 72 | -// server info. | ||
| 73 | -#define RTMP_SIG_SRS_KEY "srs" | ||
| 74 | -#define RTMP_SIG_SRS_ROLE "origin server" | ||
| 75 | -#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(simple rtmp server)" | ||
| 76 | -#define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT | ||
| 77 | -#define RTMP_SIG_SRS_URL_SHORT "github.com/winlinvip/simple-rtmp-server" | ||
| 78 | -#define RTMP_SIG_SRS_WEB "http://blog.csdn.net/win_lin" | ||
| 79 | -#define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com" | ||
| 80 | -#define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)" | ||
| 81 | -#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2014 winlin" | ||
| 82 | -#define RTMP_SIG_SRS_PRIMARY_AUTHROS "winlin,wenjiegit" | ||
| 83 | - | ||
| 84 | -// compare | ||
| 85 | -#define srs_min(a, b) (((a) < (b))? (a) : (b)) | ||
| 86 | -#define srs_max(a, b) (((a) < (b))? (b) : (a)) | ||
| 87 | - | ||
| 88 | -// get current system time in ms, use cache to avoid performance problem | ||
| 89 | -extern int64_t srs_get_system_time_ms(); | ||
| 90 | -// the deamon st-thread will update it. | ||
| 91 | -extern void srs_update_system_time_ms(); | ||
| 92 | - | ||
| 93 | -// signal defines. | ||
| 94 | -#define SIGNAL_RELOAD SIGHUP | ||
| 95 | - | ||
| 96 | -#include <string> | ||
| 97 | -// replace utility | ||
| 98 | -extern std::string srs_replace(std::string str, std::string old_str, std::string new_str); | ||
| 99 | -// dns resolve utility, return the resolved ip address. | ||
| 100 | -extern std::string srs_dns_resolve(std::string host); | ||
| 101 | -// resolve the vhost in query string | ||
| 102 | -// @param app, may contains the vhost in query string format: | ||
| 103 | -// app?vhost=request_vhost | ||
| 104 | -// app...vhost...request_vhost | ||
| 105 | -extern void srs_vhost_resolve(std::string& vhost, std::string& app); | ||
| 106 | - | ||
| 107 | -// close the netfd, and close the underlayer fd. | ||
| 108 | -extern void srs_close_stfd(st_netfd_t& stfd); | ||
| 109 | - | ||
| 110 | -/** | ||
| 111 | -* disable copy constructor of class | ||
| 112 | -*/ | ||
| 113 | -#define disable_default_copy(className)\ | ||
| 114 | - private:\ | ||
| 115 | - /** \ | ||
| 116 | - * disable the copy constructor and operator=, donot allow directly copy. \ | ||
| 117 | - */ \ | ||
| 118 | - className(const className&); \ | ||
| 119 | - className& operator= (const className&) | ||
| 120 | - | 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_CORE_HPP | ||
| 25 | +#define SRS_CORE_HPP | ||
| 26 | + | ||
| 27 | +/* | ||
| 28 | +#include <srs_core.hpp> | ||
| 29 | +*/ | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | +* the core provides the common defined macros, utilities, | ||
| 33 | +* user must include the srs_core.hpp before any header, or maybe | ||
| 34 | +* build failed. | ||
| 35 | +*/ | ||
| 36 | + | ||
| 37 | +// for int64_t print using PRId64 format. | ||
| 38 | +#ifndef __STDC_FORMAT_MACROS | ||
| 39 | + #define __STDC_FORMAT_MACROS | ||
| 40 | +#endif | ||
| 41 | +#include <inttypes.h> | ||
| 42 | + | ||
| 43 | +#include <assert.h> | ||
| 44 | +#define srs_assert(expression) assert(expression) | ||
| 45 | + | ||
| 46 | +#include <stddef.h> | ||
| 47 | +#include <sys/types.h> | ||
| 48 | + | ||
| 49 | +#include <st.h> | ||
| 50 | + | ||
| 51 | +// generated by configure. | ||
| 52 | +#include <srs_auto_headers.hpp> | ||
| 53 | + | ||
| 54 | +// free the p and set to NULL. | ||
| 55 | +// p must be a T*. | ||
| 56 | +#define srs_freep(p) \ | ||
| 57 | + if (p) { \ | ||
| 58 | + delete p; \ | ||
| 59 | + p = NULL; \ | ||
| 60 | + } \ | ||
| 61 | + (void)0 | ||
| 62 | +// free the p which represents a array | ||
| 63 | +#define srs_freepa(p) \ | ||
| 64 | + if (p) { \ | ||
| 65 | + delete[] p; \ | ||
| 66 | + p = NULL; \ | ||
| 67 | + } \ | ||
| 68 | + (void)0 | ||
| 69 | + | ||
| 70 | +// current release version | ||
| 71 | +#define RTMP_SIG_SRS_VERSION "0.9.2" | ||
| 72 | +// server info. | ||
| 73 | +#define RTMP_SIG_SRS_KEY "srs" | ||
| 74 | +#define RTMP_SIG_SRS_ROLE "origin server" | ||
| 75 | +#define RTMP_SIG_SRS_NAME RTMP_SIG_SRS_KEY"(simple rtmp server)" | ||
| 76 | +#define RTMP_SIG_SRS_URL "https://"RTMP_SIG_SRS_URL_SHORT | ||
| 77 | +#define RTMP_SIG_SRS_URL_SHORT "github.com/winlinvip/simple-rtmp-server" | ||
| 78 | +#define RTMP_SIG_SRS_WEB "http://blog.csdn.net/win_lin" | ||
| 79 | +#define RTMP_SIG_SRS_EMAIL "winlin@vip.126.com" | ||
| 80 | +#define RTMP_SIG_SRS_LICENSE "The MIT License (MIT)" | ||
| 81 | +#define RTMP_SIG_SRS_COPYRIGHT "Copyright (c) 2013-2014 winlin" | ||
| 82 | +#define RTMP_SIG_SRS_PRIMARY_AUTHROS "winlin,wenjiegit" | ||
| 83 | + | ||
| 84 | +// compare | ||
| 85 | +#define srs_min(a, b) (((a) < (b))? (a) : (b)) | ||
| 86 | +#define srs_max(a, b) (((a) < (b))? (b) : (a)) | ||
| 87 | + | ||
| 88 | +// get current system time in ms, use cache to avoid performance problem | ||
| 89 | +extern int64_t srs_get_system_time_ms(); | ||
| 90 | +// the deamon st-thread will update it. | ||
| 91 | +extern void srs_update_system_time_ms(); | ||
| 92 | + | ||
| 93 | +// signal defines. | ||
| 94 | +#define SIGNAL_RELOAD SIGHUP | ||
| 95 | + | ||
| 96 | +#include <string> | ||
| 97 | +// replace utility | ||
| 98 | +extern std::string srs_replace(std::string str, std::string old_str, std::string new_str); | ||
| 99 | +// dns resolve utility, return the resolved ip address. | ||
| 100 | +extern std::string srs_dns_resolve(std::string host); | ||
| 101 | +// resolve the vhost in query string | ||
| 102 | +// @param app, may contains the vhost in query string format: | ||
| 103 | +// app?vhost=request_vhost | ||
| 104 | +// app...vhost...request_vhost | ||
| 105 | +extern void srs_vhost_resolve(std::string& vhost, std::string& app); | ||
| 106 | + | ||
| 107 | +// close the netfd, and close the underlayer fd. | ||
| 108 | +extern void srs_close_stfd(st_netfd_t& stfd); | ||
| 109 | + | ||
| 110 | +/** | ||
| 111 | +* disable copy constructor of class | ||
| 112 | +*/ | ||
| 113 | +#define disable_default_copy(className)\ | ||
| 114 | + private:\ | ||
| 115 | + /** \ | ||
| 116 | + * disable the copy constructor and operator=, donot allow directly copy. \ | ||
| 117 | + */ \ | ||
| 118 | + className(const className&); \ | ||
| 119 | + className& operator= (const className&) | ||
| 120 | + | ||
| 121 | #endif | 121 | #endif |
-
请 注册 或 登录 后发表评论