Mercurial > libavformat.hg
comparison rtpproto.c @ 5750:0f9c0db923e5 libavformat
Check url_interrupt_cb in rtp_read, wait in select for max 100 ms before rechecking url_interrupt_cb
author | mstorsjo |
---|---|
date | Thu, 04 Mar 2010 15:08:54 +0000 |
parents | 334f223fc455 |
children | cb840f900fef |
comparison
equal
deleted
inserted
replaced
5749:dfbaca29e6fd | 5750:0f9c0db923e5 |
---|---|
191 RTPContext *s = h->priv_data; | 191 RTPContext *s = h->priv_data; |
192 struct sockaddr_in from; | 192 struct sockaddr_in from; |
193 socklen_t from_len; | 193 socklen_t from_len; |
194 int len, fd_max, n; | 194 int len, fd_max, n; |
195 fd_set rfds; | 195 fd_set rfds; |
196 struct timeval tv; | |
196 #if 0 | 197 #if 0 |
197 for(;;) { | 198 for(;;) { |
198 from_len = sizeof(from); | 199 from_len = sizeof(from); |
199 len = recvfrom (s->rtp_fd, buf, size, 0, | 200 len = recvfrom (s->rtp_fd, buf, size, 0, |
200 (struct sockaddr *)&from, &from_len); | 201 (struct sockaddr *)&from, &from_len); |
206 } | 207 } |
207 break; | 208 break; |
208 } | 209 } |
209 #else | 210 #else |
210 for(;;) { | 211 for(;;) { |
212 if (url_interrupt_cb()) | |
213 return AVERROR(EINTR); | |
211 /* build fdset to listen to RTP and RTCP packets */ | 214 /* build fdset to listen to RTP and RTCP packets */ |
212 FD_ZERO(&rfds); | 215 FD_ZERO(&rfds); |
213 fd_max = s->rtp_fd; | 216 fd_max = s->rtp_fd; |
214 FD_SET(s->rtp_fd, &rfds); | 217 FD_SET(s->rtp_fd, &rfds); |
215 if (s->rtcp_fd > fd_max) | 218 if (s->rtcp_fd > fd_max) |
216 fd_max = s->rtcp_fd; | 219 fd_max = s->rtcp_fd; |
217 FD_SET(s->rtcp_fd, &rfds); | 220 FD_SET(s->rtcp_fd, &rfds); |
218 n = select(fd_max + 1, &rfds, NULL, NULL, NULL); | 221 tv.tv_sec = 0; |
222 tv.tv_usec = 100 * 1000; | |
223 n = select(fd_max + 1, &rfds, NULL, NULL, &tv); | |
219 if (n > 0) { | 224 if (n > 0) { |
220 /* first try RTCP */ | 225 /* first try RTCP */ |
221 if (FD_ISSET(s->rtcp_fd, &rfds)) { | 226 if (FD_ISSET(s->rtcp_fd, &rfds)) { |
222 from_len = sizeof(from); | 227 from_len = sizeof(from); |
223 len = recvfrom (s->rtcp_fd, buf, size, 0, | 228 len = recvfrom (s->rtcp_fd, buf, size, 0, |