2008-02-27 Wim Taymans <wim.taymans@collabora.co.uk>
+ * docs/libs/gstreamer-libs-sections.txt:
+ * libs/gst/net/gstnetclientclock.c:
+ (gst_net_client_clock_class_init), (gst_net_client_clock_init),
+ (gst_net_client_clock_finalize), (gst_net_client_clock_do_select),
+ (gst_net_client_clock_thread), (gst_net_client_clock_start),
+ (gst_net_client_clock_stop), (gst_net_client_clock_new):
+ * libs/gst/net/gstnetclientclock.h:
+ * libs/gst/net/gstnettimeprovider.c:
+ (gst_net_time_provider_class_init), (gst_net_time_provider_init),
+ (gst_net_time_provider_finalize), (gst_net_time_provider_thread),
+ (gst_net_time_provider_start), (gst_net_time_provider_stop),
+ (gst_net_time_provider_new):
+ * libs/gst/net/gstnettimeprovider.h:
+ Use a private stuct to not break ABI.
+
+2008-02-27 Wim Taymans <wim.taymans@collabora.co.uk>
+
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (gst_net_client_clock_init),
gst_net_client_clock_new
<SUBSECTION Standard>
GstNetClientClockClass
+GstNetClientClockPrivate
GST_NET_CLIENT_CLOCK
GST_IS_NET_CLIENT_CLOCK
GST_TYPE_NET_CLIENT_CLOCK
gst_net_time_provider_new
<SUBSECTION Standard>
GstNetTimeProviderClass
+GstNetTimeProviderPrivate
GST_NET_TIME_PROVIDER
GST_IS_NET_TIME_PROVIDER
GST_TYPE_NET_TIME_PROVIDER
PROP_PORT,
};
+#define GST_NET_CLIENT_CLOCK_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_NET_CLIENT_CLOCK, GstNetClientClockPrivate))
+
+struct _GstNetClientClockPrivate
+{
+ GstPollFD sock;
+ GstPoll *fdset;
+};
+
#define _do_init(type) \
GST_DEBUG_CATEGORY_INIT (ncc_debug, "netclock", 0, "Network client clock");
gobject_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (klass, sizeof (GstNetClientClockPrivate));
+
gobject_class->finalize = gst_net_client_clock_finalize;
gobject_class->get_property = gst_net_client_clock_get_property;
gobject_class->set_property = gst_net_client_clock_set_property;
WSACleanup ();
}
#endif
+ self->priv = GST_NET_CLIENT_CLOCK_GET_PRIVATE (self);
self->port = DEFAULT_PORT;
self->address = g_strdup (DEFAULT_ADDRESS);
clock->timeout = DEFAULT_TIMEOUT;
- self->sock.fd = -1;
+ self->priv->sock.fd = -1;
self->thread = NULL;
self->servaddr = NULL;
g_assert (self->thread == NULL);
}
- if (self->fdset) {
- gst_poll_free (self->fdset);
- self->fdset = NULL;
+ if (self->priv->fdset) {
+ gst_poll_free (self->priv->fdset);
+ self->priv->fdset = NULL;
}
g_free (self->address);
GST_LOG_OBJECT (self, "doing select");
diff = gst_clock_get_internal_time (GST_CLOCK (self));
- ret = gst_poll_wait (self->fdset, self->current_timeout);
+ ret = gst_poll_wait (self->priv->fdset, self->current_timeout);
diff = gst_clock_get_internal_time (GST_CLOCK (self)) - diff;
if (diff > self->current_timeout)
GST_DEBUG_OBJECT (self, "sending packet, local time = %" GST_TIME_FORMAT,
GST_TIME_ARGS (packet->local_time));
- gst_net_time_packet_send (packet, self->sock.fd,
+ gst_net_time_packet_send (packet, self->priv->sock.fd,
(struct sockaddr *) self->servaddr, sizeof (struct sockaddr_in));
g_free (packet);
/* reset timeout */
self->current_timeout = clock->timeout;
continue;
- } else if (gst_poll_fd_can_read (self->fdset, &self->sock)) {
+ } else if (gst_poll_fd_can_read (self->priv->fdset, &self->priv->sock)) {
/* got data in */
GstClockTime new_local = gst_clock_get_internal_time (GST_CLOCK (self));
len = sizeof (struct sockaddr);
- packet = gst_net_time_packet_receive (self->sock.fd,
+ packet = gst_net_time_packet_receive (self->priv->sock.fd,
(struct sockaddr *) &tmpaddr, &len);
if (!packet)
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
goto no_socket;
- self->sock.fd = ret;
+ self->priv->sock.fd = ret;
len = sizeof (myaddr);
- ret = getsockname (self->sock.fd, (struct sockaddr *) &myaddr, &len);
+ ret = getsockname (self->priv->sock.fd, (struct sockaddr *) &myaddr, &len);
if (ret < 0)
goto getsockname_error;
GST_DEBUG_OBJECT (self, "will communicate with %s:%d", self->address,
self->port);
- gst_poll_add_fd (self->fdset, &self->sock);
- gst_poll_fd_ctl_read (self->fdset, &self->sock, TRUE);
+ gst_poll_add_fd (self->priv->fdset, &self->priv->sock);
+ gst_poll_fd_ctl_read (self->priv->fdset, &self->priv->sock, TRUE);
self->thread = g_thread_create (gst_net_client_clock_thread, self, TRUE,
&error);
{
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
g_strerror (errno), errno);
- close (self->sock.fd);
- self->sock.fd = -1;
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
return FALSE;
}
bad_address:
{
GST_ERROR_OBJECT (self, "inet_aton failed %d: %s (%d)", ret,
g_strerror (errno), errno);
- close (self->sock.fd);
- self->sock.fd = -1;
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
return FALSE;
}
no_thread:
{
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
- gst_poll_remove_fd (self->fdset, &self->sock);
- close (self->sock.fd);
- self->sock.fd = -1;
+ gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
g_free (self->servaddr);
self->servaddr = NULL;
g_error_free (error);
static void
gst_net_client_clock_stop (GstNetClientClock * self)
{
- gst_poll_set_flushing (self->fdset, TRUE);
+ gst_poll_set_flushing (self->priv->fdset, TRUE);
g_thread_join (self->thread);
self->thread = NULL;
- if (self->sock.fd != -1) {
- gst_poll_remove_fd (self->fdset, &self->sock);
- close (self->sock.fd);
- self->sock.fd = -1;
+ if (self->priv->sock.fd != -1) {
+ gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
}
}
g_warning ("unable to set the base time, expect sync problems!");
}
- if ((ret->fdset = gst_poll_new (GST_POLL_MODE_AUTO, TRUE)) == NULL)
+ if ((ret->priv->fdset = gst_poll_new (GST_POLL_MODE_AUTO, TRUE)) == NULL)
goto no_fdset;
if (!gst_net_client_clock_start (ret))
typedef struct _GstNetClientClock GstNetClientClock;
typedef struct _GstNetClientClockClass GstNetClientClockClass;
+typedef struct _GstNetClientClockPrivate GstNetClientClockPrivate;
/**
* GstNetClientClock:
gint port;
/*< private >*/
- /* the size of _gst_reserved1 and sock must equal three ints since this used
- * to be int sock and int control_sock[2] */
- int _gst_reserved1;
- GstPollFD sock;
- GstPoll *fdset;
+ int sock;
+ int control_sock[2];
GstClockTime current_timeout;
GThread *thread;
/*< private >*/
+ GstNetClientClockPrivate *priv;
+
gpointer _gst_reserved[GST_PADDING - 1];
};
/* FILL ME */
};
+#define GST_NET_TIME_PROVIDER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_NET_TIME_PROVIDER, GstNetTimeProviderPrivate))
+
+struct _GstNetTimeProviderPrivate
+{
+ GstPollFD sock;
+ GstPoll *fdset;
+};
+
static gboolean gst_net_time_provider_start (GstNetTimeProvider * bself);
static void gst_net_time_provider_stop (GstNetTimeProvider * bself);
g_assert (sizeof (GstClockTime) == 8);
+ g_type_class_add_private (klass, sizeof (GstNetTimeProviderPrivate));
+
gobject_class->finalize = gst_net_time_provider_finalize;
gobject_class->set_property = gst_net_time_provider_set_property;
gobject_class->get_property = gst_net_time_provider_get_property;
WSACleanup ();
}
#endif
+ self->priv = GST_NET_TIME_PROVIDER_GET_PRIVATE (self);
self->port = DEFAULT_PORT;
- self->sock.fd = -1;
+ self->priv->sock.fd = -1;
self->address = g_strdup (DEFAULT_ADDRESS);
self->thread = NULL;
self->active.active = TRUE;
g_assert (self->thread == NULL);
}
- if (self->fdset) {
- gst_poll_free (self->fdset);
- self->fdset = NULL;
+ if (self->priv->fdset) {
+ gst_poll_free (self->priv->fdset);
+ self->priv->fdset = NULL;
}
g_free (self->address);
while (TRUE) {
GST_LOG_OBJECT (self, "doing select");
- ret = gst_poll_wait (self->fdset, GST_CLOCK_TIME_NONE);
+ ret = gst_poll_wait (self->priv->fdset, GST_CLOCK_TIME_NONE);
GST_LOG_OBJECT (self, "select returned %d", ret);
if (ret <= 0) {
/* got data in */
len = sizeof (struct sockaddr);
- packet = gst_net_time_packet_receive (self->sock.fd,
+ packet = gst_net_time_packet_receive (self->priv->sock.fd,
(struct sockaddr *) &tmpaddr, &len);
if (!packet)
packet->remote_time = gst_clock_get_time (self->clock);
/* ignore errors */
- gst_net_time_packet_send (packet, self->sock.fd,
+ gst_net_time_packet_send (packet, self->priv->sock.fd,
(struct sockaddr *) &tmpaddr, len);
}
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
goto no_socket;
- self->sock.fd = ret;
+ self->priv->sock.fd = ret;
ru = 1;
- ret = setsockopt (self->sock.fd, SOL_SOCKET, SO_REUSEADDR, &ru, sizeof (ru));
+ ret =
+ setsockopt (self->priv->sock.fd, SOL_SOCKET, SO_REUSEADDR, &ru,
+ sizeof (ru));
if (ret < 0)
goto setsockopt_error;
inet_aton (self->address, &my_addr.sin_addr);
GST_DEBUG_OBJECT (self, "binding on port %d", self->port);
- ret = bind (self->sock.fd, (struct sockaddr *) &my_addr, sizeof (my_addr));
+ ret =
+ bind (self->priv->sock.fd, (struct sockaddr *) &my_addr,
+ sizeof (my_addr));
if (ret < 0)
goto bind_error;
len = sizeof (my_addr);
- ret = getsockname (self->sock.fd, (struct sockaddr *) &my_addr, &len);
+ ret = getsockname (self->priv->sock.fd, (struct sockaddr *) &my_addr, &len);
if (ret < 0)
goto getsockname_error;
g_object_notify (G_OBJECT (self), "port");
}
- gst_poll_add_fd (self->fdset, &self->sock);
- gst_poll_fd_ctl_read (self->fdset, &self->sock, TRUE);
+ gst_poll_add_fd (self->priv->fdset, &self->priv->sock);
+ gst_poll_fd_ctl_read (self->priv->fdset, &self->priv->sock, TRUE);
self->thread = g_thread_create (gst_net_time_provider_thread, self, TRUE,
&error);
}
setsockopt_error:
{
- close (self->sock.fd);
- self->sock.fd = -1;
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
GST_ERROR_OBJECT (self, "setsockopt failed %d: %s (%d)", ret,
g_strerror (errno), errno);
return FALSE;
}
bind_error:
{
- close (self->sock.fd);
- self->sock.fd = -1;
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
GST_ERROR_OBJECT (self, "bind failed %d: %s (%d)", ret,
g_strerror (errno), errno);
return FALSE;
}
getsockname_error:
{
- close (self->sock.fd);
- self->sock.fd = -1;
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
g_strerror (errno), errno);
return FALSE;
}
no_thread:
{
- gst_poll_remove_fd (self->fdset, &self->sock);
- close (self->sock.fd);
- self->sock.fd = -1;
+ gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
g_error_free (error);
return FALSE;
static void
gst_net_time_provider_stop (GstNetTimeProvider * self)
{
- gst_poll_set_flushing (self->fdset, TRUE);
+ gst_poll_set_flushing (self->priv->fdset, TRUE);
g_thread_join (self->thread);
self->thread = NULL;
- if (self->sock.fd != -1) {
- gst_poll_remove_fd (self->fdset, &self->sock);
- close (self->sock.fd);
- self->sock.fd = -1;
+ if (self->priv->sock.fd != -1) {
+ gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
+ close (self->priv->sock.fd);
+ self->priv->sock.fd = -1;
}
}
ret = g_object_new (GST_TYPE_NET_TIME_PROVIDER, "clock", clock, "address",
address, "port", port, NULL);
- if ((ret->fdset = gst_poll_new (GST_POLL_MODE_AUTO, TRUE)) == NULL)
+ if ((ret->priv->fdset = gst_poll_new (GST_POLL_MODE_AUTO, TRUE)) == NULL)
goto no_fdset;
if (!gst_net_time_provider_start (ret))
typedef struct _GstNetTimeProvider GstNetTimeProvider;
typedef struct _GstNetTimeProviderClass GstNetTimeProviderClass;
+typedef struct _GstNetTimeProviderPrivate GstNetTimeProviderPrivate;
+
/**
* GstNetTimeProvider:
gchar *address;
int port;
- /* the size of _gst_reserved2 and sock must equal three ints since this used
- * to be int sock and int control_sock[2]. This relies on the fact that
- * GstPollFD happens to be two ints */
- int _gst_reserved2;
- GstPollFD sock;
- GstPoll *fdset;
+ int sock;
+ int control_sock[2];
GThread *thread;
} active;
/*< private >*/
+ GstNetTimeProviderPrivate *priv;
+
gpointer _gst_reserved[GST_PADDING - 2];
};