正在显示
11 个修改的文件
包含
174 行增加
和
297 行删除
| @@ -299,10 +299,9 @@ END | @@ -299,10 +299,9 @@ END | ||
| 299 | GDBDebug=" -g -O0" | 299 | GDBDebug=" -g -O0" |
| 300 | # the warning level. | 300 | # the warning level. |
| 301 | WarnLevel=" -Wall" | 301 | WarnLevel=" -Wall" |
| 302 | -# the compile standard. | ||
| 303 | -if [ "$MSYSTEM" != "MINGW32" -a "$MSYSTEM" != "MINGW64" ]; then | ||
| 304 | - CppStd="-ansi" | ||
| 305 | -fi | 302 | +# the compile in c++ standard. |
| 303 | +# @remark, donot specifies it for mingw. | ||
| 304 | +CppStd="-ansi" && echo $MSYSTEM|grep "MINGW">/dev/null && CppStd="" | ||
| 306 | # for library compile | 305 | # for library compile |
| 307 | LibraryCompile=" -fPIC" | 306 | LibraryCompile=" -fPIC" |
| 308 | # performance of gprof | 307 | # performance of gprof |
| @@ -85,7 +85,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -85,7 +85,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 85 | 85 | ||
| 86 | // generated by configure. | 86 | // generated by configure. |
| 87 | #include <srs_auto_headers.hpp> | 87 | #include <srs_auto_headers.hpp> |
| 88 | -#include <srs_platform.hpp> | 88 | + |
| 89 | // free the p and set to NULL. | 89 | // free the p and set to NULL. |
| 90 | // p must be a T*. | 90 | // p must be a T*. |
| 91 | #define srs_freep(p) \ | 91 | #define srs_freep(p) \ |
| @@ -110,5 +110,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -110,5 +110,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 110 | className(const className&); \ | 110 | className(const className&); \ |
| 111 | className& operator= (const className&) | 111 | className& operator= (const className&) |
| 112 | 112 | ||
| 113 | +// for windows to compile srs-librtmp | ||
| 114 | +// @see: https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 115 | +#include <srs_platform.hpp> | ||
| 116 | + | ||
| 113 | #endif | 117 | #endif |
| 114 | 118 |
| 1 | +/* | ||
| 2 | +The MIT License (MIT) | ||
| 3 | + | ||
| 4 | +Copyright (c) 2014 allspace | ||
| 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_platform.hpp> | ||
| 25 | + | ||
| 1 | #include <stdlib.h> | 26 | #include <stdlib.h> |
| 2 | #include <stdio.h> | 27 | #include <stdio.h> |
| 3 | #include <sys/types.h> | 28 | #include <sys/types.h> |
| 4 | -#include "srs_platform.hpp" | ||
| 5 | - | ||
| 6 | 29 | ||
| 7 | #if defined(_WIN32) && !defined(__CYGWIN__) | 30 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 8 | - | ||
| 9 | int socket_setup() | 31 | int socket_setup() |
| 10 | { | 32 | { |
| 11 | WORD wVersionRequested; | 33 | WORD wVersionRequested; |
| @@ -31,8 +53,8 @@ int socket_cleanup() | @@ -31,8 +53,8 @@ int socket_cleanup() | ||
| 31 | return 0; | 53 | return 0; |
| 32 | } | 54 | } |
| 33 | 55 | ||
| 34 | - int gettimeofday(struct timeval* tv, struct timezone* tz) | ||
| 35 | - { | 56 | +int gettimeofday(struct timeval* tv, struct timezone* tz) |
| 57 | +{ | ||
| 36 | time_t clock; | 58 | time_t clock; |
| 37 | struct tm tm; | 59 | struct tm tm; |
| 38 | SYSTEMTIME win_time; | 60 | SYSTEMTIME win_time; |
| @@ -53,21 +75,21 @@ int socket_cleanup() | @@ -53,21 +75,21 @@ int socket_cleanup() | ||
| 53 | tv->tv_usec = win_time.wMilliseconds * 1000; | 75 | tv->tv_usec = win_time.wMilliseconds * 1000; |
| 54 | 76 | ||
| 55 | return 0; | 77 | return 0; |
| 56 | - } | 78 | +} |
| 57 | 79 | ||
| 58 | - pid_t getpid(void) | ||
| 59 | - { | 80 | +pid_t getpid(void) |
| 81 | +{ | ||
| 60 | return (pid_t)GetCurrentProcessId(); | 82 | return (pid_t)GetCurrentProcessId(); |
| 61 | - } | 83 | +} |
| 62 | 84 | ||
| 63 | - int usleep(useconds_t usec) | ||
| 64 | - { | 85 | +int usleep(useconds_t usec) |
| 86 | +{ | ||
| 65 | Sleep((DWORD)(usec / 1000)); | 87 | Sleep((DWORD)(usec / 1000)); |
| 66 | return 0; | 88 | return 0; |
| 67 | - } | 89 | +} |
| 68 | 90 | ||
| 69 | - ssize_t writev(int fd, const struct iovec *iov, int iovcnt) | ||
| 70 | - { | 91 | +ssize_t writev(int fd, const struct iovec *iov, int iovcnt) |
| 92 | +{ | ||
| 71 | ssize_t nwrite = 0; | 93 | ssize_t nwrite = 0; |
| 72 | for (int i = 0; i < iovcnt; i++) { | 94 | for (int i = 0; i < iovcnt; i++) { |
| 73 | const struct iovec* current = iov + i; | 95 | const struct iovec* current = iov + i; |
| @@ -83,13 +105,13 @@ int socket_cleanup() | @@ -83,13 +105,13 @@ int socket_cleanup() | ||
| 83 | } | 105 | } |
| 84 | } | 106 | } |
| 85 | return nwrite; | 107 | return nwrite; |
| 86 | - } | 108 | +} |
| 87 | 109 | ||
| 88 | - //////////////////////// strlcpy.c (modified) ////////////////////////// | 110 | +//////////////////////// strlcpy.c (modified) ////////////////////////// |
| 89 | 111 | ||
| 90 | - /* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ | 112 | +/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ |
| 91 | 113 | ||
| 92 | - /*- | 114 | +/*- |
| 93 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> | 115 | * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> |
| 94 | * | 116 | * |
| 95 | * Permission to use, copy, modify, and distribute this software for any | 117 | * Permission to use, copy, modify, and distribute this software for any |
| @@ -105,23 +127,23 @@ int socket_cleanup() | @@ -105,23 +127,23 @@ int socket_cleanup() | ||
| 105 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 127 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 106 | */ | 128 | */ |
| 107 | 129 | ||
| 108 | - //#include <sys/cdefs.h> // **** | ||
| 109 | - //#include <cstddef> // **** | ||
| 110 | - // __FBSDID("$FreeBSD: stable/9/sys/libkern/strlcpy.c 243811 2012-12-03 18:08:44Z delphij $"); // **** | 130 | +//#include <sys/cdefs.h> // **** |
| 131 | +//#include <cstddef> // **** | ||
| 132 | +// __FBSDID("$FreeBSD: stable/9/sys/libkern/strlcpy.c 243811 2012-12-03 18:08:44Z delphij $"); // **** | ||
| 111 | 133 | ||
| 112 | - // #include <sys/types.h> // **** | ||
| 113 | - // #include <sys/libkern.h> // **** | 134 | +// #include <sys/types.h> // **** |
| 135 | +// #include <sys/libkern.h> // **** | ||
| 114 | 136 | ||
| 115 | - /* | 137 | +/* |
| 116 | * Copy src to string dst of size siz. At most siz-1 characters | 138 | * Copy src to string dst of size siz. At most siz-1 characters |
| 117 | * will be copied. Always NUL terminates (unless siz == 0). | 139 | * will be copied. Always NUL terminates (unless siz == 0). |
| 118 | * Returns strlen(src); if retval >= siz, truncation occurred. | 140 | * Returns strlen(src); if retval >= siz, truncation occurred. |
| 119 | */ | 141 | */ |
| 120 | 142 | ||
| 121 | - //#define __restrict // **** | 143 | +//#define __restrict // **** |
| 122 | 144 | ||
| 123 | - size_t strlcpy(char * __restrict dst, const char * __restrict src, size_t siz) | ||
| 124 | - { | 145 | +size_t strlcpy(char * __restrict dst, const char * __restrict src, size_t siz) |
| 146 | +{ | ||
| 125 | char *d = dst; | 147 | char *d = dst; |
| 126 | const char *s = src; | 148 | const char *s = src; |
| 127 | size_t n = siz; | 149 | size_t n = siz; |
| @@ -143,10 +165,10 @@ int socket_cleanup() | @@ -143,10 +165,10 @@ int socket_cleanup() | ||
| 143 | } | 165 | } |
| 144 | 166 | ||
| 145 | return(s - src - 1); /* count does not include NUL */ | 167 | return(s - src - 1); /* count does not include NUL */ |
| 146 | - } | 168 | +} |
| 147 | 169 | ||
| 148 | - // http://www.cplusplus.com/forum/general/141779///////////////////////// inet_ntop.c (modified) ////////////////////////// | ||
| 149 | - /* | 170 | +// http://www.cplusplus.com/forum/general/141779///////////////////////// inet_ntop.c (modified) ////////////////////////// |
| 171 | +/* | ||
| 150 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") | 172 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
| 151 | * Copyright (c) 1996-1999 by Internet Software Consortium. | 173 | * Copyright (c) 1996-1999 by Internet Software Consortium. |
| 152 | * | 174 | * |
| @@ -163,32 +185,32 @@ int socket_cleanup() | @@ -163,32 +185,32 @@ int socket_cleanup() | ||
| 163 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 185 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 164 | */ | 186 | */ |
| 165 | 187 | ||
| 166 | - // #if defined(LIBC_SCCS) && !defined(lint) // **** | ||
| 167 | - //static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $"; | ||
| 168 | - // #endif /* LIBC_SCCS and not lint */ // **** | ||
| 169 | - // #include <sys/cdefs.h> // **** | ||
| 170 | - // __FBSDID("$FreeBSD: stable/9/sys/libkern/inet_ntop.c 213103 2010-09-24 15:01:45Z attilio $"); // **** | 188 | +// #if defined(LIBC_SCCS) && !defined(lint) // **** |
| 189 | +//static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $"; | ||
| 190 | +// #endif /* LIBC_SCCS and not lint */ // **** | ||
| 191 | +// #include <sys/cdefs.h> // **** | ||
| 192 | +// __FBSDID("$FreeBSD: stable/9/sys/libkern/inet_ntop.c 213103 2010-09-24 15:01:45Z attilio $"); // **** | ||
| 171 | 193 | ||
| 172 | - //#define _WIN32_WINNT _WIN32_WINNT_WIN8 // **** | ||
| 173 | - //#include <Ws2tcpip.h> // **** | ||
| 174 | - //#pragma comment(lib, "Ws2_32.lib") // **** | ||
| 175 | - //#include <cstdio> // **** | 194 | +//#define _WIN32_WINNT _WIN32_WINNT_WIN8 // **** |
| 195 | +//#include <Ws2tcpip.h> // **** | ||
| 196 | +//#pragma comment(lib, "Ws2_32.lib") // **** | ||
| 197 | +//#include <cstdio> // **** | ||
| 176 | 198 | ||
| 177 | - // #include <sys/param.h> // **** | ||
| 178 | - // #include <sys/socket.h> // **** | ||
| 179 | - // #include <sys/systm.h> // **** | 199 | +// #include <sys/param.h> // **** |
| 200 | +// #include <sys/socket.h> // **** | ||
| 201 | +// #include <sys/systm.h> // **** | ||
| 180 | 202 | ||
| 181 | - // #include <netinet/in.h> // **** | 203 | +// #include <netinet/in.h> // **** |
| 182 | 204 | ||
| 183 | - /*% | 205 | +/*% |
| 184 | * WARNING: Don't even consider trying to compile this on a system where | 206 | * WARNING: Don't even consider trying to compile this on a system where |
| 185 | * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. | 207 | * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. |
| 186 | */ | 208 | */ |
| 187 | 209 | ||
| 188 | - static char *inet_ntop4(const u_char *src, char *dst, socklen_t size); | ||
| 189 | - static char *inet_ntop6(const u_char *src, char *dst, socklen_t size); | 210 | +static char *inet_ntop4(const u_char *src, char *dst, socklen_t size); |
| 211 | +static char *inet_ntop6(const u_char *src, char *dst, socklen_t size); | ||
| 190 | 212 | ||
| 191 | - /* char * | 213 | +/* char * |
| 192 | * inet_ntop(af, src, dst, size) | 214 | * inet_ntop(af, src, dst, size) |
| 193 | * convert a network format address to presentation format. | 215 | * convert a network format address to presentation format. |
| 194 | * return: | 216 | * return: |
| @@ -196,24 +218,24 @@ int socket_cleanup() | @@ -196,24 +218,24 @@ int socket_cleanup() | ||
| 196 | * author: | 218 | * author: |
| 197 | * Paul Vixie, 1996. | 219 | * Paul Vixie, 1996. |
| 198 | */ | 220 | */ |
| 199 | - const char* inet_ntop(int af, const void *src, char *dst, socklen_t size) | ||
| 200 | - { | 221 | +const char* inet_ntop(int af, const void *src, char *dst, socklen_t size) |
| 222 | +{ | ||
| 201 | switch (af) { | 223 | switch (af) { |
| 202 | case AF_INET: | 224 | case AF_INET: |
| 203 | return (inet_ntop4( (unsigned char*)src, (char*)dst, size)); // **** | 225 | return (inet_ntop4( (unsigned char*)src, (char*)dst, size)); // **** |
| 204 | - #ifdef AF_INET6 | 226 | +#ifdef AF_INET6 |
| 205 | //#error "IPv6 not supported" | 227 | //#error "IPv6 not supported" |
| 206 | //case AF_INET6: | 228 | //case AF_INET6: |
| 207 | // return (char*)(inet_ntop6( (unsigned char*)src, (char*)dst, size)); // **** | 229 | // return (char*)(inet_ntop6( (unsigned char*)src, (char*)dst, size)); // **** |
| 208 | - #endif | 230 | +#endif |
| 209 | default: | 231 | default: |
| 210 | // return (NULL); // **** | 232 | // return (NULL); // **** |
| 211 | return 0 ; // **** | 233 | return 0 ; // **** |
| 212 | } | 234 | } |
| 213 | /* NOTREACHED */ | 235 | /* NOTREACHED */ |
| 214 | - } | 236 | +} |
| 215 | 237 | ||
| 216 | - /* const char * | 238 | +/* const char * |
| 217 | * inet_ntop4(src, dst, size) | 239 | * inet_ntop4(src, dst, size) |
| 218 | * format an IPv4 address | 240 | * format an IPv4 address |
| 219 | * return: | 241 | * return: |
| @@ -224,8 +246,8 @@ int socket_cleanup() | @@ -224,8 +246,8 @@ int socket_cleanup() | ||
| 224 | * author: | 246 | * author: |
| 225 | * Paul Vixie, 1996. | 247 | * Paul Vixie, 1996. |
| 226 | */ | 248 | */ |
| 227 | - static char * inet_ntop4(const u_char *src, char *dst, socklen_t size) | ||
| 228 | - { | 249 | +static char * inet_ntop4(const u_char *src, char *dst, socklen_t size) |
| 250 | +{ | ||
| 229 | static const char fmt[128] = "%u.%u.%u.%u"; | 251 | static const char fmt[128] = "%u.%u.%u.%u"; |
| 230 | char tmp[sizeof "255.255.255.255"]; | 252 | char tmp[sizeof "255.255.255.255"]; |
| 231 | int l; | 253 | int l; |
| @@ -236,16 +258,16 @@ int socket_cleanup() | @@ -236,16 +258,16 @@ int socket_cleanup() | ||
| 236 | } | 258 | } |
| 237 | strlcpy(dst, tmp, size); | 259 | strlcpy(dst, tmp, size); |
| 238 | return (dst); | 260 | return (dst); |
| 239 | - } | 261 | +} |
| 240 | 262 | ||
| 241 | - /* const char * | 263 | +/* const char * |
| 242 | * inet_ntop6(src, dst, size) | 264 | * inet_ntop6(src, dst, size) |
| 243 | * convert IPv6 binary address into presentation (printable) format | 265 | * convert IPv6 binary address into presentation (printable) format |
| 244 | * author: | 266 | * author: |
| 245 | * Paul Vixie, 1996. | 267 | * Paul Vixie, 1996. |
| 246 | */ | 268 | */ |
| 247 | - static char * inet_ntop6(const u_char *src, char *dst, socklen_t size) | ||
| 248 | - { | 269 | +static char * inet_ntop6(const u_char *src, char *dst, socklen_t size) |
| 270 | +{ | ||
| 249 | /* | 271 | /* |
| 250 | * Note that int32_t and int16_t need only be "at least" large enough | 272 | * Note that int32_t and int16_t need only be "at least" large enough |
| 251 | * to contain a value of the specified size. On some systems, like | 273 | * to contain a value of the specified size. On some systems, like |
| @@ -255,8 +277,8 @@ int socket_cleanup() | @@ -255,8 +277,8 @@ int socket_cleanup() | ||
| 255 | */ | 277 | */ |
| 256 | char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; | 278 | char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp; |
| 257 | struct { int base, len; } best, cur; | 279 | struct { int base, len; } best, cur; |
| 258 | - #define NS_IN6ADDRSZ 16 | ||
| 259 | - #define NS_INT16SZ 2 | 280 | +#define NS_IN6ADDRSZ 16 |
| 281 | +#define NS_INT16SZ 2 | ||
| 260 | u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; | 282 | u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; |
| 261 | int i; | 283 | int i; |
| 262 | 284 | ||
| @@ -333,7 +355,7 @@ int socket_cleanup() | @@ -333,7 +355,7 @@ int socket_cleanup() | ||
| 333 | } | 355 | } |
| 334 | strcpy(dst, tmp); | 356 | strcpy(dst, tmp); |
| 335 | return (dst); | 357 | return (dst); |
| 336 | - } | 358 | +} |
| 337 | 359 | ||
| 338 | #define Set_errno(num) SetLastError((num)) | 360 | #define Set_errno(num) SetLastError((num)) |
| 339 | 361 | ||
| @@ -347,61 +369,5 @@ int socket_cleanup() | @@ -347,61 +369,5 @@ int socket_cleanup() | ||
| 347 | /* from public\sdk\inc\crt\errno.h */ | 369 | /* from public\sdk\inc\crt\errno.h */ |
| 348 | #define ENOSPC 28 | 370 | #define ENOSPC 28 |
| 349 | 371 | ||
| 350 | -/* | ||
| 351 | - * | ||
| 352 | - */ | ||
| 353 | -/* | ||
| 354 | -#ifndef INET_ADDRSTRLEN | ||
| 355 | -#define INET_ADDRSTRLEN 16 | ||
| 356 | -#endif | ||
| 357 | - | ||
| 358 | -static const char * | ||
| 359 | -inet_ntop_v4 (const void *src, char *dst, size_t size) | ||
| 360 | -{ | ||
| 361 | - const char digits[] = "0123456789"; | ||
| 362 | - int i; | ||
| 363 | - struct in_addr *addr = (struct in_addr *)src; | ||
| 364 | - u_long a = ntohl(addr->s_addr); | ||
| 365 | - const char *orig_dst = dst; | ||
| 366 | - | ||
| 367 | - if (size < INET_ADDRSTRLEN) { | ||
| 368 | - Set_errno(ENOSPC); | ||
| 369 | - return NULL; | ||
| 370 | - } | ||
| 371 | - for (i = 0; i < 4; ++i) { | ||
| 372 | - int n = (a >> (24 - i * 8)) & 0xFF; | ||
| 373 | - int non_zerop = 0; | ||
| 374 | - | ||
| 375 | - if (non_zerop || n / 100 > 0) { | ||
| 376 | - *dst++ = digits[n / 100]; | ||
| 377 | - n %= 100; | ||
| 378 | - non_zerop = 1; | ||
| 379 | - } | ||
| 380 | - if (non_zerop || n / 10 > 0) { | ||
| 381 | - *dst++ = digits[n / 10]; | ||
| 382 | - n %= 10; | ||
| 383 | - non_zerop = 1; | ||
| 384 | - } | ||
| 385 | - *dst++ = digits[n]; | ||
| 386 | - if (i != 3) | ||
| 387 | - *dst++ = '.'; | ||
| 388 | - } | ||
| 389 | - *dst++ = '\0'; | ||
| 390 | - return orig_dst; | ||
| 391 | -} | ||
| 392 | - | ||
| 393 | -const char * | ||
| 394 | -inet_ntop(int af, const void *src, char *dst, size_t size) | ||
| 395 | -{ | ||
| 396 | - switch (af) { | ||
| 397 | - case AF_INET : | ||
| 398 | - return inet_ntop_v4 (src, dst, size); | ||
| 399 | - default : | ||
| 400 | - Set_errno(EAFNOSUPPORT); | ||
| 401 | - return NULL; | ||
| 402 | - } | ||
| 403 | -} | ||
| 404 | - | ||
| 405 | -*/ | ||
| 406 | #endif | 372 | #endif |
| 407 | 373 |
| 1 | #ifndef SRS_WIN_PORTING_H | 1 | #ifndef SRS_WIN_PORTING_H |
| 2 | #define SRS_WIN_PORTING_H | 2 | #define SRS_WIN_PORTING_H |
| 3 | 3 | ||
| 4 | -#if !defined(_WIN32) || defined(__CYGWIN__) /*not on windows or it's cygwin. _WIN32 includes both 32-bit and 64-bit*/ | ||
| 5 | - | ||
| 6 | -#define SOCKET_ETIME ETIME | ||
| 7 | -#define SOCKET_ECONNRESET ECONNRESET | 4 | +// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 |
| 5 | +#if defined(_WIN32) | ||
| 6 | + #include <windows.h> | ||
| 7 | +#endif | ||
| 8 | 8 | ||
| 9 | -#define SOCKET int | ||
| 10 | -#define SOCKET_ERRNO() errno | ||
| 11 | -#define SOCKET_RESET(x) x=-1 | ||
| 12 | -#define SOCKET_CLOSE(x) if(x>=0){::close(x);x=-1;} | ||
| 13 | -#define SOCKET_VALID(x) (x>=0) | ||
| 14 | -#define SOCKET_SETUP() {} | ||
| 15 | -#define SOCKET_CLEANUP() {} | 9 | +/** |
| 10 | +* for linux like, | ||
| 11 | +* for example, not on windows or it's cygwin. | ||
| 12 | +* while the _WIN32 includes both 32-bit and 64-bit | ||
| 13 | +*/ | ||
| 14 | +#if !defined(_WIN32) || defined(__CYGWIN__) | ||
| 15 | + #define SOCKET_ETIME ETIME | ||
| 16 | + #define SOCKET_ECONNRESET ECONNRESET | ||
| 16 | 17 | ||
| 18 | + #define SOCKET int | ||
| 19 | + #define SOCKET_ERRNO() errno | ||
| 20 | + #define SOCKET_RESET(fd) fd = -1; (void)0 | ||
| 21 | + #define SOCKET_CLOSE(fd) \ | ||
| 22 | + if (fd > 0) {\ | ||
| 23 | + ::close(fd); \ | ||
| 24 | + fd = -1; \ | ||
| 25 | + } \ | ||
| 26 | + (void)0 | ||
| 27 | + #define SOCKET_VALID(x) (x > 0) | ||
| 28 | + #define SOCKET_SETUP() (void)0 | ||
| 29 | + #define SOCKET_CLEANUP() (void)0 | ||
| 17 | #else /*on windows, but not on cygwin*/ | 30 | #else /*on windows, but not on cygwin*/ |
| 31 | + #include <sys/stat.h> | ||
| 32 | + #include <time.h> | ||
| 33 | + #include <winsock2.h> | ||
| 34 | + #include <stdint.h> | ||
| 18 | 35 | ||
| 19 | -#include <sys/stat.h> | ||
| 20 | -#include <time.h> | ||
| 21 | -#include <winsock2.h> | ||
| 22 | -#include <stdint.h> | 36 | + #ifdef _MSC_VER //for VS2010 |
| 37 | + #include <io.h> | ||
| 38 | + #include <fcntl.h> | ||
| 39 | + #define S_IRUSR _S_IREAD | ||
| 40 | + #define S_IWUSR _S_IWRITE | ||
| 41 | + #define open _open | ||
| 42 | + #define close _close | ||
| 43 | + #define lseek _lseek | ||
| 44 | + #define write _write | ||
| 45 | + #define read _read | ||
| 23 | 46 | ||
| 24 | -#ifdef _MSC_VER //for VS2010 | ||
| 25 | -#include <io.h> | ||
| 26 | -#include <fcntl.h> | ||
| 27 | -#define S_IRUSR _S_IREAD | ||
| 28 | -#define S_IWUSR _S_IWRITE | ||
| 29 | -#define open _open | ||
| 30 | -#define close _close | ||
| 31 | -#define lseek _lseek | ||
| 32 | -#define write _write | ||
| 33 | -#define read _read | ||
| 34 | - | ||
| 35 | -typedef int ssize_t; | ||
| 36 | -typedef int pid_t; | ||
| 37 | -typedef int mode_t; | ||
| 38 | -typedef int64_t useconds_t; | ||
| 39 | -#endif | 47 | + typedef int ssize_t; |
| 48 | + typedef int pid_t; | ||
| 49 | + typedef int mode_t; | ||
| 50 | + typedef int64_t useconds_t; | ||
| 51 | + #endif | ||
| 40 | 52 | ||
| 41 | -#define S_IRGRP 0 | ||
| 42 | -#define S_IWGRP 0 | ||
| 43 | -#define S_IXGRP 0 | ||
| 44 | -#define S_IRWXG 0 | ||
| 45 | -#define S_IROTH 0 | ||
| 46 | -#define S_IWOTH 0 | ||
| 47 | -#define S_IXOTH 0 | ||
| 48 | -#define S_IRWXO 0 | 53 | + #define S_IRGRP 0 |
| 54 | + #define S_IWGRP 0 | ||
| 55 | + #define S_IXGRP 0 | ||
| 56 | + #define S_IRWXG 0 | ||
| 57 | + #define S_IROTH 0 | ||
| 58 | + #define S_IWOTH 0 | ||
| 59 | + #define S_IXOTH 0 | ||
| 60 | + #define S_IRWXO 0 | ||
| 49 | 61 | ||
| 50 | -#define PRId64 "lld" | 62 | + #define PRId64 "lld" |
| 51 | 63 | ||
| 52 | -#define SOCKET_ETIME WSAETIMEDOUT | ||
| 53 | -#define SOCKET_ECONNRESET WSAECONNRESET | ||
| 54 | -#define SOCKET_ERRNO() WSAGetLastError() | ||
| 55 | -#define SOCKET_RESET(x) x=INVALID_SOCKET | ||
| 56 | -#define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;} | ||
| 57 | -#define SOCKET_VALID(x) (x!=INVALID_SOCKET) | ||
| 58 | -#define SOCKET_BUFF(x) ((char*)x) | ||
| 59 | -#define SOCKET_SETUP() socket_setup() | ||
| 60 | -#define SOCKET_CLEANUP() socket_cleanup() | 64 | + #define SOCKET_ETIME WSAETIMEDOUT |
| 65 | + #define SOCKET_ECONNRESET WSAECONNRESET | ||
| 66 | + #define SOCKET_ERRNO() WSAGetLastError() | ||
| 67 | + #define SOCKET_RESET(x) x=INVALID_SOCKET | ||
| 68 | + #define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;} | ||
| 69 | + #define SOCKET_VALID(x) (x!=INVALID_SOCKET) | ||
| 70 | + #define SOCKET_BUFF(x) ((char*)x) | ||
| 71 | + #define SOCKET_SETUP() socket_setup() | ||
| 72 | + #define SOCKET_CLEANUP() socket_cleanup() | ||
| 61 | 73 | ||
| 62 | -typedef uint32_t u_int32_t; | ||
| 63 | -typedef uint8_t u_int8_t; | ||
| 64 | -typedef int socklen_t; | ||
| 65 | -struct iovec { | 74 | + typedef uint32_t u_int32_t; |
| 75 | + typedef uint8_t u_int8_t; | ||
| 76 | + typedef int socklen_t; | ||
| 77 | + struct iovec { | ||
| 66 | void* iov_base; /* Starting address */ | 78 | void* iov_base; /* Starting address */ |
| 67 | size_t iov_len; /* Length in bytes */ | 79 | size_t iov_len; /* Length in bytes */ |
| 68 | -}; | 80 | + }; |
| 69 | 81 | ||
| 70 | -#define snprintf _snprintf | ||
| 71 | -ssize_t writev(int fd, const struct iovec *iov, int iovcnt); | ||
| 72 | -const char* inet_ntop(int af, const void *src, char *dst, socklen_t size); | ||
| 73 | -int gettimeofday(struct timeval* tv, struct timezone* tz); | ||
| 74 | -pid_t getpid(void); | ||
| 75 | -int usleep(useconds_t usec); | ||
| 76 | -int socket_setup(); | ||
| 77 | -int socket_cleanup(); | 82 | + #define snprintf _snprintf |
| 83 | + ssize_t writev(int fd, const struct iovec *iov, int iovcnt); | ||
| 84 | + const char* inet_ntop(int af, const void *src, char *dst, socklen_t size); | ||
| 85 | + int gettimeofday(struct timeval* tv, struct timezone* tz); | ||
| 86 | + pid_t getpid(void); | ||
| 87 | + int usleep(useconds_t usec); | ||
| 88 | + int socket_setup(); | ||
| 89 | + int socket_cleanup(); | ||
| 78 | #endif | 90 | #endif |
| 79 | 91 | ||
| 80 | #endif //SRS_WIN_PORTING_H | 92 | #endif //SRS_WIN_PORTING_H |
| @@ -30,11 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,11 +30,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | 30 | ||
| 31 | #include <srs_core.hpp> | 31 | #include <srs_core.hpp> |
| 32 | 32 | ||
| 33 | -// success, ok | ||
| 34 | -#if !defined(_WIN32) || defined(__CYGWIN__) //avoid redefine error on Windows | 33 | +// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 |
| 34 | +#ifndef _WIN32 | ||
| 35 | #define ERROR_SUCCESS 0 | 35 | #define ERROR_SUCCESS 0 |
| 36 | -#else | ||
| 37 | -#include <windows.h> | ||
| 38 | #endif | 36 | #endif |
| 39 | 37 | ||
| 40 | /////////////////////////////////////////////////////// | 38 | /////////////////////////////////////////////////////// |
| @@ -45,7 +45,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -45,7 +45,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 45 | 45 | ||
| 46 | SimpleSocketStream::SimpleSocketStream() | 46 | SimpleSocketStream::SimpleSocketStream() |
| 47 | { | 47 | { |
| 48 | - //fd = -1; | ||
| 49 | SOCKET_RESET(fd); | 48 | SOCKET_RESET(fd); |
| 50 | send_timeout = recv_timeout = ST_UTIME_NO_TIMEOUT; | 49 | send_timeout = recv_timeout = ST_UTIME_NO_TIMEOUT; |
| 51 | recv_bytes = send_bytes = 0; | 50 | recv_bytes = send_bytes = 0; |
| @@ -54,19 +53,14 @@ SimpleSocketStream::SimpleSocketStream() | @@ -54,19 +53,14 @@ SimpleSocketStream::SimpleSocketStream() | ||
| 54 | 53 | ||
| 55 | SimpleSocketStream::~SimpleSocketStream() | 54 | SimpleSocketStream::~SimpleSocketStream() |
| 56 | { | 55 | { |
| 57 | - //if (fd != -1) { | ||
| 58 | - // ::close(fd); | ||
| 59 | - // fd = -1; | ||
| 60 | - //} | ||
| 61 | SOCKET_CLOSE(fd); | 56 | SOCKET_CLOSE(fd); |
| 62 | SOCKET_CLEANUP(); | 57 | SOCKET_CLEANUP(); |
| 63 | } | 58 | } |
| 64 | 59 | ||
| 65 | int SimpleSocketStream::create_socket() | 60 | int SimpleSocketStream::create_socket() |
| 66 | { | 61 | { |
| 67 | - //if((fd = ::socket(AF_INET, SOCK_STREAM, 0)) < 0){ | ||
| 68 | fd = ::socket(AF_INET, SOCK_STREAM, 0); | 62 | fd = ::socket(AF_INET, SOCK_STREAM, 0); |
| 69 | - if(!SOCKET_VALID(fd)){ | 63 | + if (!SOCKET_VALID(fd)) { |
| 70 | return ERROR_SOCKET_CREATE; | 64 | return ERROR_SOCKET_CREATE; |
| 71 | } | 65 | } |
| 72 | 66 |
| @@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include <srs_librtmp.hpp> | 24 | #include <srs_librtmp.hpp> |
| 25 | -#include <srs_platform.hpp> | 25 | + |
| 26 | #include <stdlib.h> | 26 | #include <stdlib.h> |
| 27 | 27 | ||
| 28 | // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | 28 | // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 |
| @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 34 | #include <sstream> | 34 | #include <sstream> |
| 35 | using namespace std; | 35 | using namespace std; |
| 36 | 36 | ||
| 37 | +#include <srs_platform.hpp> | ||
| 37 | #include <srs_kernel_error.hpp> | 38 | #include <srs_kernel_error.hpp> |
| 38 | #include <srs_protocol_rtmp.hpp> | 39 | #include <srs_protocol_rtmp.hpp> |
| 39 | #include <srs_lib_simple_socket.hpp> | 40 | #include <srs_lib_simple_socket.hpp> |
| @@ -107,56 +108,6 @@ struct Context | @@ -107,56 +108,6 @@ struct Context | ||
| 107 | } | 108 | } |
| 108 | }; | 109 | }; |
| 109 | 110 | ||
| 110 | -// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 111 | -#ifdef _WIN32 | ||
| 112 | - | ||
| 113 | -/* | ||
| 114 | - int open(const char *pathname, int flags) | ||
| 115 | - { | ||
| 116 | - return open(pathname, flags, 0); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - int open(const char *pathname, int flags, mode_t mode) | ||
| 120 | - { | ||
| 121 | - FILE* file = NULL; | ||
| 122 | - | ||
| 123 | - if ((flags & O_RDONLY) == O_RDONLY) { | ||
| 124 | - file = fopen(pathname, "r"); | ||
| 125 | - } else { | ||
| 126 | - file = fopen(pathname, "w+"); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - if (file == NULL) { | ||
| 130 | - return -1; | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - return (int)file; | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - int close(int fd) | ||
| 137 | - { | ||
| 138 | - FILE* file = (FILE*)fd; | ||
| 139 | - return fclose(file); | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - off_t lseek(int fd, off_t offset, int whence) | ||
| 143 | - { | ||
| 144 | - return (off_t)fseek((FILE*)fd, offset, whence); | ||
| 145 | - } | ||
| 146 | - | ||
| 147 | - ssize_t write(int fd, const void *buf, size_t count) | ||
| 148 | - { | ||
| 149 | - return (ssize_t)fwrite(buf, count, 1, (FILE*)fd); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - ssize_t read(int fd, void *buf, size_t count) | ||
| 153 | - { | ||
| 154 | - return (ssize_t)fread(buf, count, 1, (FILE*)fd); | ||
| 155 | - } | ||
| 156 | -*/ | ||
| 157 | - | ||
| 158 | -#endif | ||
| 159 | - | ||
| 160 | int srs_librtmp_context_parse_uri(Context* context) | 111 | int srs_librtmp_context_parse_uri(Context* context) |
| 161 | { | 112 | { |
| 162 | int ret = ERROR_SUCCESS; | 113 | int ret = ERROR_SUCCESS; |
| @@ -31,53 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,53 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | -// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 35 | -#if 0 | ||
| 36 | - #define _CRT_SECURE_NO_WARNINGS | ||
| 37 | - typedef unsigned long long u_int64_t; | ||
| 38 | - typedef long long int64_t; | ||
| 39 | - typedef unsigned int u_int32_t; | ||
| 40 | - typedef int int32_t; | ||
| 41 | - typedef unsigned char u_int8_t; | ||
| 42 | - typedef char int8_t; | ||
| 43 | - typedef unsigned short u_int16_t; | ||
| 44 | - typedef short int16_t; | ||
| 45 | - typedef int64_t ssize_t; | ||
| 46 | - struct iovec { | ||
| 47 | - void *iov_base; /* Starting address */ | ||
| 48 | - size_t iov_len; /* Number of bytes to transfer */ | ||
| 49 | - }; | ||
| 50 | - #include <time.h> | ||
| 51 | - #include <windows.h> | ||
| 52 | - int gettimeofday(struct timeval* tv, struct timezone* tz); | ||
| 53 | - #define PRId64 "lld" | ||
| 54 | - typedef int socklen_t; | ||
| 55 | - const char *inet_ntop(int af, const void *src, char *dst, socklen_t size); | ||
| 56 | - typedef int mode_t; | ||
| 57 | - #define S_IRUSR 0 | ||
| 58 | - #define S_IWUSR 0 | ||
| 59 | - #define S_IRGRP 0 | ||
| 60 | - #define S_IWGRP 0 | ||
| 61 | - #define S_IROTH 0 | ||
| 62 | - int open(const char *pathname, int flags); | ||
| 63 | - int open(const char *pathname, int flags, mode_t mode); | ||
| 64 | - int close(int fd); | ||
| 65 | - off_t lseek(int fd, off_t offset, int whence); | ||
| 66 | - ssize_t write(int fd, const void *buf, size_t count); | ||
| 67 | - ssize_t read(int fd, void *buf, size_t count); | ||
| 68 | - typedef int pid_t; | ||
| 69 | - pid_t getpid(void); | ||
| 70 | - #define snprintf _snprintf | ||
| 71 | - ssize_t writev(int fd, const struct iovec *iov, int iovcnt); | ||
| 72 | - typedef int64_t useconds_t; | ||
| 73 | - int usleep(useconds_t usec); | ||
| 74 | -#endif | ||
| 75 | - | ||
| 76 | -#if defined(_WIN32) && !defined(__CYGWIN__) | ||
| 77 | -#include <stdint.h> | ||
| 78 | -typedef uint32_t u_int32_t; | ||
| 79 | -#endif | ||
| 80 | - | ||
| 81 | /** | 34 | /** |
| 82 | * srs-librtmp is a librtmp like library, | 35 | * srs-librtmp is a librtmp like library, |
| 83 | * used to play/publish rtmp stream from/to rtmp server. | 36 | * used to play/publish rtmp stream from/to rtmp server. |
| @@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
| 19 | #undef SRS_AUTO_HTTP_CALLBACK | 19 | #undef SRS_AUTO_HTTP_CALLBACK |
| 20 | #undef SRS_AUTO_SSL | 20 | #undef SRS_AUTO_SSL |
| 21 | #undef SRS_AUTO_FFMPEG_TOOL | 21 | #undef SRS_AUTO_FFMPEG_TOOL |
| 22 | -#define SRS_AUTO_FFMPEG_STUB | 22 | +#undef SRS_AUTO_FFMPEG_STUB |
| 23 | #undef SRS_AUTO_TRANSCODE | 23 | #undef SRS_AUTO_TRANSCODE |
| 24 | #undef SRS_AUTO_INGEST | 24 | #undef SRS_AUTO_INGEST |
| 25 | #undef SRS_AUTO_STAT | 25 | #undef SRS_AUTO_STAT |
| @@ -77,7 +77,7 @@ | @@ -77,7 +77,7 @@ | ||
| 77 | </Link> | 77 | </Link> |
| 78 | </ItemDefinitionGroup> | 78 | </ItemDefinitionGroup> |
| 79 | <ItemGroup> | 79 | <ItemGroup> |
| 80 | - <ClCompile Include="..\research\librtmp\srs_play.c" /> | 80 | + <ClCompile Include="srs_play.c" /> |
| 81 | </ItemGroup> | 81 | </ItemGroup> |
| 82 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | 82 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
| 83 | <ImportGroup Label="ExtensionTargets"> | 83 | <ImportGroup Label="ExtensionTargets"> |
| @@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
| 15 | </Filter> | 15 | </Filter> |
| 16 | </ItemGroup> | 16 | </ItemGroup> |
| 17 | <ItemGroup> | 17 | <ItemGroup> |
| 18 | - <ClCompile Include="..\research\librtmp\srs_play.c"> | 18 | + <ClCompile Include="srs_play.c"> |
| 19 | <Filter>Source Files</Filter> | 19 | <Filter>Source Files</Filter> |
| 20 | </ClCompile> | 20 | </ClCompile> |
| 21 | </ItemGroup> | 21 | </ItemGroup> |
-
请 注册 或 登录 后发表评论