Revision 9cba6f5f libavformat/rtsp.c
libavformat/rtsp.c | ||
---|---|---|
46 | 46 |
int rtsp_default_protocols = (1 << RTSP_LOWER_TRANSPORT_UDP); |
47 | 47 |
#endif |
48 | 48 |
|
49 |
/* Timout values for socket select, in ms, |
|
50 |
* and read_packet(), in seconds */ |
|
51 |
#define SELECT_TIMEOUT_MS 100 |
|
52 |
#define READ_PACKET_TIMEOUT_S 10 |
|
53 |
#define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS |
|
54 |
|
|
49 | 55 |
#define SPACE_CHARS " \t\r\n" |
50 | 56 |
/* we use memchr() instead of strchr() here because strchr() will return |
51 | 57 |
* the terminating '\0' of SPACE_CHARS instead of NULL if c is '\0'. */ |
... | ... | |
1634 | 1640 |
RTSPState *rt = s->priv_data; |
1635 | 1641 |
RTSPStream *rtsp_st; |
1636 | 1642 |
fd_set rfds; |
1637 |
int fd, fd_max, n, i, ret, tcp_fd; |
|
1643 |
int fd, fd_max, n, i, ret, tcp_fd, timeout_cnt = 0;
|
|
1638 | 1644 |
struct timeval tv; |
1639 | 1645 |
|
1640 | 1646 |
for (;;) { |
... | ... | |
1660 | 1666 |
} |
1661 | 1667 |
} |
1662 | 1668 |
tv.tv_sec = 0; |
1663 |
tv.tv_usec = 100 * 1000;
|
|
1669 |
tv.tv_usec = SELECT_TIMEOUT_MS * 1000;
|
|
1664 | 1670 |
n = select(fd_max + 1, &rfds, NULL, NULL, &tv); |
1665 | 1671 |
if (n > 0) { |
1672 |
timeout_cnt = 0; |
|
1666 | 1673 |
for (i = 0; i < rt->nb_rtsp_streams; i++) { |
1667 | 1674 |
rtsp_st = rt->rtsp_streams[i]; |
1668 | 1675 |
if (rtsp_st->rtp_handle) { |
... | ... | |
1688 | 1695 |
return 0; |
1689 | 1696 |
} |
1690 | 1697 |
#endif |
1691 |
} |
|
1698 |
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) { |
|
1699 |
return AVERROR(ETIME); |
|
1700 |
} else if (n < 0 && errno != EINTR) |
|
1701 |
return AVERROR(errno); |
|
1692 | 1702 |
} |
1693 | 1703 |
} |
1694 | 1704 |
|
Also available in: Unified diff