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

merge from 2.0

This commit is contained in:
winlin 2016-08-10 22:05:21 +08:00
commit 14760003ba
4 changed files with 87 additions and 15 deletions

View file

@ -27,7 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// for srs-librtmp, @see https://github.com/ossrs/srs/issues/213
#ifndef _WIN32
#define SOCKET_ETIME ETIME
#define SOCKET_ETIME EWOULDBLOCK
#define SOCKET_ECONNRESET ECONNRESET
#define SOCKET_ERRNO() errno
@ -160,10 +160,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return ret;
}
void srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
int srs_hijack_io_set_recv_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
{
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
int sec = timeout_us / (1000 * 1000LL);
int microsec = timeout_us / 1000LL % 1000;
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) {
return SOCKET_ERRNO();
}
skt->recv_timeout = timeout_us;
return ERROR_SUCCESS;
}
int64_t srs_hijack_io_get_recv_timeout(srs_hijack_io_t ctx)
{
@ -175,10 +188,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
return skt->recv_bytes;
}
void srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
int srs_hijack_io_set_send_timeout(srs_hijack_io_t ctx, int64_t timeout_us)
{
SrsBlockSyncSocket* skt = (SrsBlockSyncSocket*)ctx;
int sec = timeout_us / (1000 * 1000LL);
int microsec = timeout_us / 1000LL % 1000;
sec = srs_max(0, sec);
microsec = srs_max(0, microsec);
struct timeval tv = { sec , microsec };
if (setsockopt(skt->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1) {
return SOCKET_ERRNO();
}
skt->send_timeout = timeout_us;
return ERROR_SUCCESS;
}
int64_t srs_hijack_io_get_send_timeout(srs_hijack_io_t ctx)
{