* @short_description: manage RTSP connections
* @see_also: gstrtspurl
*
- * <refsect2>
- * <para>
* This object manages the RTSP connection to the server. It provides function
* to receive and send bytes and messages.
- * </para>
- * </refsect2>
*
* Last reviewed on 2007-07-24 (0.10.14)
*/
getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &errno, &len);
#endif
goto sys_error;
+ } else {
+#ifdef __APPLE__
+ /* osx wakes up select with POLLOUT if the connection is refused... */
+ socklen_t len = sizeof (errno);
+ getsockopt (fd, SOL_SOCKET, SO_ERROR, (char *) &errno, &len);
+ if (errno != 0)
+ goto sys_error;
+#endif
}
gst_poll_fd_ignored (fdset, fdout);
if (gst_poll_fd_has_error (conn->fdset, conn->writefd))
goto socket_error;
- gst_poll_set_controllable (conn->fdset, FALSE);
+ /* once we start reading the wait cannot be controlled */
+ if (builder.state != STATE_START)
+ gst_poll_set_controllable (conn->fdset, FALSE);
}
/* we have a message here */
gdouble elapsed;
glong sec;
gulong usec;
+ gint ctimeout;
g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);
g_return_val_if_fail (timeout != NULL, GST_RTSP_EINVAL);
+ ctimeout = conn->timeout;
+ if (ctimeout >= 20) {
+ /* Because we should act before the timeout we timeout 5
+ * seconds in advance. */
+ ctimeout -= 5;
+ } else if (ctimeout >= 5) {
+ /* else timeout 20% earlier */
+ ctimeout -= ctimeout / 5;
+ } else if (ctimeout >= 1) {
+ /* else timeout 1 second earlier */
+ ctimeout -= 1;
+ }
+
elapsed = g_timer_elapsed (conn->timer, &usec);
- if (elapsed >= conn->timeout) {
+ if (elapsed >= ctimeout) {
sec = 0;
usec = 0;
} else {
- sec = conn->timeout - elapsed;
+ sec = ctimeout - elapsed;
if (usec <= G_USEC_PER_SEC)
usec = G_USEC_PER_SEC - usec;
else