1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Support build srs-librtmp by VS2015. 2.0.267

This commit is contained in:
winlin 2019-12-23 17:01:02 +08:00
parent fde11756c3
commit 316628632b
12 changed files with 79 additions and 43 deletions

View file

@ -163,17 +163,27 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
{
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
int sec = (int)(timeout_us / 1000000LL);
int microsec = (int)(timeout_us % 1000000LL);
sec = srs_max(0, sec);
microsec = srs_max(0, microsec);
struct timeval tv = { sec , microsec };
if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
#ifdef _WIN32
DWORD tv = (DWORD)(timeout_us/1000);
// To convert tv to const char* to make VS2015 happy.
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof(tv)) == -1) {
return SOCKET_ERRNO();
}
#else
int sec = (int)(timeout_us / 1000000LL);
int microsec = (int)(timeout_us % 1000000LL);
sec = srs_max(0, sec);
microsec = srs_max(0, microsec);
struct timeval tv = { sec , microsec };
if (setsockopt(skt->fd, SOL_SOCKET, SO_RCVTIMEO, tvv, sizeof(tv)) == -1) {
return SOCKET_ERRNO();
}
#endif
skt->recv_timeout = timeout_us;
return ERROR_SUCCESS;
@ -191,7 +201,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
{
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
#ifdef _WIN32
DWORD tv = (DWORD)(timeout_us/1000);
// To convert tv to const char* to make VS2015 happy.
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, (const char*)&tv, sizeof(tv)) == -1) {
return SOCKET_ERRNO();
}
#else
int sec = (int)(timeout_us / 1000000LL);
int microsec = (int)(timeout_us % 1000000LL);
@ -199,9 +217,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
microsec = srs_max(0, microsec);
struct timeval tv = { sec , microsec };
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) {
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, tvv, sizeof(tv)) == -1) {
return SOCKET_ERRNO();
}
#endif
skt->send_timeout = timeout_us;

View file

@ -43,18 +43,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*************************************************************/
// for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
#ifdef _WIN32
// To disable some security warnings.
#define _CRT_SECURE_NO_WARNINGS
// include windows first.
#include <windows.h>
// the type used by this header for windows.
#if defined(_MSC_VER)
#include <stdint.h>
#else
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
#endif
typedef unsigned long long u_int64_t;
typedef long long int64_t;
typedef unsigned int u_int32_t;
typedef u_int32_t uint32_t;
typedef int int32_t;
typedef unsigned char u_int8_t;
typedef char int8_t;
typedef unsigned short u_int16_t;
typedef short int16_t;
typedef int64_t ssize_t;
struct iovec {
void *iov_base; /* Starting address */
@ -1051,7 +1057,6 @@ typedef void* srs_hijack_io_t;
// for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
#ifdef _WIN32
// for time.
#define _CRT_SECURE_NO_WARNINGS
#include <time.h>
int gettimeofday(struct timeval* tv, struct timezone* tz);
#define PRId64 "lld"
@ -1094,8 +1099,10 @@ typedef void* srs_hijack_io_t;
int socket_setup();
int socket_cleanup();
// others.
#define snprintf _snprintf
// snprintf is defined in VS2015, so we only define this macro before that.
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif
#ifdef __cplusplus