Mercurial > libavformat.hg
comparison rtsp.c @ 6420:e3eb93b5a119 libavformat
rtsp: Check the RTCP file handle for new packets, too
Patch by Josh Allmann, joshua dot allmann at gmail
author | mstorsjo |
---|---|
date | Sun, 29 Aug 2010 10:16:54 +0000 |
parents | 6d6b63b7e5e3 |
children | 2685bf2b0b78 |
comparison
equal
deleted
inserted
replaced
6419:abd88124e6a9 | 6420:e3eb93b5a119 |
---|---|
1651 uint8_t *buf, int buf_size) | 1651 uint8_t *buf, int buf_size) |
1652 { | 1652 { |
1653 RTSPState *rt = s->priv_data; | 1653 RTSPState *rt = s->priv_data; |
1654 RTSPStream *rtsp_st; | 1654 RTSPStream *rtsp_st; |
1655 fd_set rfds; | 1655 fd_set rfds; |
1656 int fd, fd_max, n, i, ret, tcp_fd, timeout_cnt = 0; | 1656 int fd, fd_rtcp, fd_max, n, i, ret, tcp_fd, timeout_cnt = 0; |
1657 struct timeval tv; | 1657 struct timeval tv; |
1658 | 1658 |
1659 for (;;) { | 1659 for (;;) { |
1660 if (url_interrupt_cb()) | 1660 if (url_interrupt_cb()) |
1661 return AVERROR(EINTR); | 1661 return AVERROR(EINTR); |
1668 tcp_fd = -1; | 1668 tcp_fd = -1; |
1669 } | 1669 } |
1670 for (i = 0; i < rt->nb_rtsp_streams; i++) { | 1670 for (i = 0; i < rt->nb_rtsp_streams; i++) { |
1671 rtsp_st = rt->rtsp_streams[i]; | 1671 rtsp_st = rt->rtsp_streams[i]; |
1672 if (rtsp_st->rtp_handle) { | 1672 if (rtsp_st->rtp_handle) { |
1673 /* currently, we cannot probe RTCP handle because of | |
1674 * blocking restrictions */ | |
1675 fd = url_get_file_handle(rtsp_st->rtp_handle); | 1673 fd = url_get_file_handle(rtsp_st->rtp_handle); |
1676 if (fd > fd_max) | 1674 fd_rtcp = rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); |
1677 fd_max = fd; | 1675 if (FFMAX(fd, fd_rtcp) > fd_max) |
1676 fd_max = FFMAX(fd, fd_rtcp); | |
1678 FD_SET(fd, &rfds); | 1677 FD_SET(fd, &rfds); |
1678 FD_SET(fd_rtcp, &rfds); | |
1679 } | 1679 } |
1680 } | 1680 } |
1681 tv.tv_sec = 0; | 1681 tv.tv_sec = 0; |
1682 tv.tv_usec = SELECT_TIMEOUT_MS * 1000; | 1682 tv.tv_usec = SELECT_TIMEOUT_MS * 1000; |
1683 n = select(fd_max + 1, &rfds, NULL, NULL, &tv); | 1683 n = select(fd_max + 1, &rfds, NULL, NULL, &tv); |
1685 timeout_cnt = 0; | 1685 timeout_cnt = 0; |
1686 for (i = 0; i < rt->nb_rtsp_streams; i++) { | 1686 for (i = 0; i < rt->nb_rtsp_streams; i++) { |
1687 rtsp_st = rt->rtsp_streams[i]; | 1687 rtsp_st = rt->rtsp_streams[i]; |
1688 if (rtsp_st->rtp_handle) { | 1688 if (rtsp_st->rtp_handle) { |
1689 fd = url_get_file_handle(rtsp_st->rtp_handle); | 1689 fd = url_get_file_handle(rtsp_st->rtp_handle); |
1690 if (FD_ISSET(fd, &rfds)) { | 1690 fd_rtcp = rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); |
1691 if (FD_ISSET(fd_rtcp, &rfds) || FD_ISSET(fd, &rfds)) { | |
1691 ret = url_read(rtsp_st->rtp_handle, buf, buf_size); | 1692 ret = url_read(rtsp_st->rtp_handle, buf, buf_size); |
1692 if (ret > 0) { | 1693 if (ret > 0) { |
1693 *prtsp_st = rtsp_st; | 1694 *prtsp_st = rtsp_st; |
1694 return ret; | 1695 return ret; |
1695 } | 1696 } |