mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 20:31:56 +00:00
refine the macros for windows of srs-librtmp
This commit is contained in:
parent
15ae4745f4
commit
9387d09f5f
3 changed files with 78 additions and 60 deletions
|
@ -25,6 +25,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_kernel_error.hpp>
|
||||
|
||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||
#ifndef _WIN32
|
||||
#define SOCKET_ETIME ETIME
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
|
||||
#define SOCKET_ERRNO() errno
|
||||
#define SOCKET_RESET(fd) fd = -1; (void)0
|
||||
#define SOCKET_CLOSE(fd) \
|
||||
if (fd > 0) {\
|
||||
::close(fd); \
|
||||
fd = -1; \
|
||||
} \
|
||||
(void)0
|
||||
#define SOCKET_VALID(x) (x > 0)
|
||||
#define SOCKET_SETUP() (void)0
|
||||
#define SOCKET_CLEANUP() (void)0
|
||||
#else
|
||||
#define SOCKET_ETIME WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_ERRNO() WSAGetLastError()
|
||||
#define SOCKET_RESET(x) x=INVALID_SOCKET
|
||||
#define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;}
|
||||
#define SOCKET_VALID(x) (x!=INVALID_SOCKET)
|
||||
#define SOCKET_BUFF(x) ((char*)x)
|
||||
#define SOCKET_SETUP() socket_setup()
|
||||
#define SOCKET_CLEANUP() socket_cleanup()
|
||||
#endif
|
||||
|
||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -33,6 +33,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_protocol_io.hpp>
|
||||
#include <srs_librtmp.hpp>
|
||||
|
||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||
#ifndef _WIN32
|
||||
#define SOCKET int
|
||||
#endif
|
||||
|
||||
/**
|
||||
* simple socket stream,
|
||||
* use tcp socket, sync block mode, for client like srs-librtmp.
|
||||
|
|
|
@ -28,27 +28,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_librtmp.h>
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||
#ifndef _WIN32
|
||||
#define SOCKET_ETIME ETIME
|
||||
#define SOCKET_ECONNRESET ECONNRESET
|
||||
|
||||
#define SOCKET int
|
||||
#define SOCKET_ERRNO() errno
|
||||
#define SOCKET_RESET(fd) fd = -1; (void)0
|
||||
#define SOCKET_CLOSE(fd) \
|
||||
if (fd > 0) {\
|
||||
::close(fd); \
|
||||
fd = -1; \
|
||||
} \
|
||||
(void)0
|
||||
#define SOCKET_VALID(x) (x > 0)
|
||||
#define SOCKET_SETUP() (void)0
|
||||
#define SOCKET_CLEANUP() (void)0
|
||||
#else
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#ifdef _WIN32
|
||||
// include windows first.
|
||||
#include <windows.h>
|
||||
// the type used by this header for windows.
|
||||
typedef unsigned long long u_int64_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned int u_int32_t;
|
||||
|
@ -62,48 +46,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
void *iov_base; /* Starting address */
|
||||
size_t iov_len; /* Number of bytes to transfer */
|
||||
};
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
int gettimeofday(struct timeval* tv, struct timezone* tz);
|
||||
#define PRId64 "lld"
|
||||
|
||||
#define SOCKET_ETIME WSAETIMEDOUT
|
||||
#define SOCKET_ECONNRESET WSAECONNRESET
|
||||
#define SOCKET_ERRNO() WSAGetLastError()
|
||||
#define SOCKET_RESET(x) x=INVALID_SOCKET
|
||||
#define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;}
|
||||
#define SOCKET_VALID(x) (x!=INVALID_SOCKET)
|
||||
#define SOCKET_BUFF(x) ((char*)x)
|
||||
#define SOCKET_SETUP() socket_setup()
|
||||
#define SOCKET_CLEANUP() socket_cleanup()
|
||||
|
||||
typedef int socklen_t;
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
typedef int mode_t;
|
||||
#define S_IRUSR 0
|
||||
#define S_IWUSR 0
|
||||
#define S_IRGRP 0
|
||||
#define S_IWGRP 0
|
||||
#define S_IROTH 0
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#define open _open
|
||||
#define close _close
|
||||
#define lseek _lseek
|
||||
#define write _write
|
||||
#define read _read
|
||||
|
||||
typedef int pid_t;
|
||||
pid_t getpid(void);
|
||||
#define snprintf _snprintf
|
||||
ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
|
||||
typedef int64_t useconds_t;
|
||||
int usleep(useconds_t usec);
|
||||
int socket_setup();
|
||||
int socket_cleanup();
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/**
|
||||
* srs-librtmp is a librtmp like library,
|
||||
* used to play/publish rtmp stream from/to rtmp server.
|
||||
|
@ -1028,6 +974,45 @@ typedef void* srs_hijack_io_t;
|
|||
extern int srs_hijack_io_write(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nwrite);
|
||||
#endif
|
||||
|
||||
/*************************************************************
|
||||
**************************************************************
|
||||
* Windows SRS-LIBRTMP solution
|
||||
**************************************************************
|
||||
*************************************************************/
|
||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||
#ifdef _WIN32
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <time.h>
|
||||
int gettimeofday(struct timeval* tv, struct timezone* tz);
|
||||
#define PRId64 "lld"
|
||||
|
||||
typedef int socklen_t;
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
||||
typedef int mode_t;
|
||||
#define S_IRUSR 0
|
||||
#define S_IWUSR 0
|
||||
#define S_IRGRP 0
|
||||
#define S_IWGRP 0
|
||||
#define S_IROTH 0
|
||||
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#define open _open
|
||||
#define close _close
|
||||
#define lseek _lseek
|
||||
#define write _write
|
||||
#define read _read
|
||||
|
||||
typedef int pid_t;
|
||||
pid_t getpid(void);
|
||||
#define snprintf _snprintf
|
||||
ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
|
||||
typedef int64_t useconds_t;
|
||||
int usleep(useconds_t usec);
|
||||
int socket_setup();
|
||||
int socket_cleanup();
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue