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;