mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +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>
|
#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
|
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#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_protocol_io.hpp>
|
||||||
#include <srs_librtmp.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,
|
* simple socket stream,
|
||||||
* use tcp socket, sync block mode, for client like srs-librtmp.
|
* 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 <srs_librtmp.h>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
|
||||||
#ifndef _WIN32
|
#ifdef _WIN32
|
||||||
#define SOCKET_ETIME ETIME
|
// include windows first.
|
||||||
#define SOCKET_ECONNRESET ECONNRESET
|
#include <windows.h>
|
||||||
|
// the type used by this header for windows.
|
||||||
#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
|
|
||||||
typedef unsigned long long u_int64_t;
|
typedef unsigned long long u_int64_t;
|
||||||
typedef long long int64_t;
|
typedef long long int64_t;
|
||||||
typedef unsigned int u_int32_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 */
|
void *iov_base; /* Starting address */
|
||||||
size_t iov_len; /* Number of bytes to transfer */
|
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
|
#endif
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* srs-librtmp is a librtmp like library,
|
* srs-librtmp is a librtmp like library,
|
||||||
* used to play/publish rtmp stream from/to rtmp server.
|
* 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);
|
extern int srs_hijack_io_write(srs_hijack_io_t ctx, void* buf, size_t size, ssize_t* nwrite);
|
||||||
#endif
|
#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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue