mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-09 17:05:52 +00:00
Use a private stuct to not break ABI.
Original commit message from CVS: * 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.
This commit is contained in:
parent
8311350693
commit
0d37102cb8
6 changed files with 111 additions and 64 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
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>
|
2008-02-27 Wim Taymans <wim.taymans@collabora.co.uk>
|
||||||
|
|
||||||
Patch by: Peter Kjellerstedt <pkj at axis dot com>
|
Patch by: Peter Kjellerstedt <pkj at axis dot com>
|
||||||
|
|
|
@ -442,6 +442,7 @@ GstNetClientClock
|
||||||
gst_net_client_clock_new
|
gst_net_client_clock_new
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GstNetClientClockClass
|
GstNetClientClockClass
|
||||||
|
GstNetClientClockPrivate
|
||||||
GST_NET_CLIENT_CLOCK
|
GST_NET_CLIENT_CLOCK
|
||||||
GST_IS_NET_CLIENT_CLOCK
|
GST_IS_NET_CLIENT_CLOCK
|
||||||
GST_TYPE_NET_CLIENT_CLOCK
|
GST_TYPE_NET_CLIENT_CLOCK
|
||||||
|
@ -475,6 +476,7 @@ GstNetTimeProvider
|
||||||
gst_net_time_provider_new
|
gst_net_time_provider_new
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GstNetTimeProviderClass
|
GstNetTimeProviderClass
|
||||||
|
GstNetTimeProviderPrivate
|
||||||
GST_NET_TIME_PROVIDER
|
GST_NET_TIME_PROVIDER
|
||||||
GST_IS_NET_TIME_PROVIDER
|
GST_IS_NET_TIME_PROVIDER
|
||||||
GST_TYPE_NET_TIME_PROVIDER
|
GST_TYPE_NET_TIME_PROVIDER
|
||||||
|
|
|
@ -79,6 +79,15 @@ enum
|
||||||
PROP_PORT,
|
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) \
|
#define _do_init(type) \
|
||||||
GST_DEBUG_CATEGORY_INIT (ncc_debug, "netclock", 0, "Network client clock");
|
GST_DEBUG_CATEGORY_INIT (ncc_debug, "netclock", 0, "Network client clock");
|
||||||
|
|
||||||
|
@ -121,6 +130,8 @@ gst_net_client_clock_class_init (GstNetClientClockClass * klass)
|
||||||
|
|
||||||
gobject_class = G_OBJECT_CLASS (klass);
|
gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstNetClientClockPrivate));
|
||||||
|
|
||||||
gobject_class->finalize = gst_net_client_clock_finalize;
|
gobject_class->finalize = gst_net_client_clock_finalize;
|
||||||
gobject_class->get_property = gst_net_client_clock_get_property;
|
gobject_class->get_property = gst_net_client_clock_get_property;
|
||||||
gobject_class->set_property = gst_net_client_clock_set_property;
|
gobject_class->set_property = gst_net_client_clock_set_property;
|
||||||
|
@ -152,13 +163,14 @@ gst_net_client_clock_init (GstNetClientClock * self,
|
||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
self->priv = GST_NET_CLIENT_CLOCK_GET_PRIVATE (self);
|
||||||
|
|
||||||
self->port = DEFAULT_PORT;
|
self->port = DEFAULT_PORT;
|
||||||
self->address = g_strdup (DEFAULT_ADDRESS);
|
self->address = g_strdup (DEFAULT_ADDRESS);
|
||||||
|
|
||||||
clock->timeout = DEFAULT_TIMEOUT;
|
clock->timeout = DEFAULT_TIMEOUT;
|
||||||
|
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
self->thread = NULL;
|
self->thread = NULL;
|
||||||
|
|
||||||
self->servaddr = NULL;
|
self->servaddr = NULL;
|
||||||
|
@ -174,9 +186,9 @@ gst_net_client_clock_finalize (GObject * object)
|
||||||
g_assert (self->thread == NULL);
|
g_assert (self->thread == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->fdset) {
|
if (self->priv->fdset) {
|
||||||
gst_poll_free (self->fdset);
|
gst_poll_free (self->priv->fdset);
|
||||||
self->fdset = NULL;
|
self->priv->fdset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (self->address);
|
g_free (self->address);
|
||||||
|
@ -283,7 +295,7 @@ gst_net_client_clock_do_select (GstNetClientClock * self)
|
||||||
GST_LOG_OBJECT (self, "doing select");
|
GST_LOG_OBJECT (self, "doing select");
|
||||||
|
|
||||||
diff = gst_clock_get_internal_time (GST_CLOCK (self));
|
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;
|
diff = gst_clock_get_internal_time (GST_CLOCK (self)) - diff;
|
||||||
|
|
||||||
if (diff > self->current_timeout)
|
if (diff > self->current_timeout)
|
||||||
|
@ -343,7 +355,7 @@ gst_net_client_clock_thread (gpointer data)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "sending packet, local time = %" GST_TIME_FORMAT,
|
GST_DEBUG_OBJECT (self, "sending packet, local time = %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (packet->local_time));
|
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));
|
(struct sockaddr *) self->servaddr, sizeof (struct sockaddr_in));
|
||||||
|
|
||||||
g_free (packet);
|
g_free (packet);
|
||||||
|
@ -351,12 +363,12 @@ gst_net_client_clock_thread (gpointer data)
|
||||||
/* reset timeout */
|
/* reset timeout */
|
||||||
self->current_timeout = clock->timeout;
|
self->current_timeout = clock->timeout;
|
||||||
continue;
|
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 */
|
/* got data in */
|
||||||
GstClockTime new_local = gst_clock_get_internal_time (GST_CLOCK (self));
|
GstClockTime new_local = gst_clock_get_internal_time (GST_CLOCK (self));
|
||||||
|
|
||||||
len = sizeof (struct sockaddr);
|
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);
|
(struct sockaddr *) &tmpaddr, &len);
|
||||||
|
|
||||||
if (!packet)
|
if (!packet)
|
||||||
|
@ -418,10 +430,10 @@ gst_net_client_clock_start (GstNetClientClock * self)
|
||||||
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
goto no_socket;
|
goto no_socket;
|
||||||
|
|
||||||
self->sock.fd = ret;
|
self->priv->sock.fd = ret;
|
||||||
|
|
||||||
len = sizeof (myaddr);
|
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)
|
if (ret < 0)
|
||||||
goto getsockname_error;
|
goto getsockname_error;
|
||||||
|
|
||||||
|
@ -441,8 +453,8 @@ gst_net_client_clock_start (GstNetClientClock * self)
|
||||||
GST_DEBUG_OBJECT (self, "will communicate with %s:%d", self->address,
|
GST_DEBUG_OBJECT (self, "will communicate with %s:%d", self->address,
|
||||||
self->port);
|
self->port);
|
||||||
|
|
||||||
gst_poll_add_fd (self->fdset, &self->sock);
|
gst_poll_add_fd (self->priv->fdset, &self->priv->sock);
|
||||||
gst_poll_fd_ctl_read (self->fdset, &self->sock, TRUE);
|
gst_poll_fd_ctl_read (self->priv->fdset, &self->priv->sock, TRUE);
|
||||||
|
|
||||||
self->thread = g_thread_create (gst_net_client_clock_thread, self, TRUE,
|
self->thread = g_thread_create (gst_net_client_clock_thread, self, TRUE,
|
||||||
&error);
|
&error);
|
||||||
|
@ -462,24 +474,24 @@ getsockname_error:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
|
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bad_address:
|
bad_address:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (self, "inet_aton failed %d: %s (%d)", ret,
|
GST_ERROR_OBJECT (self, "inet_aton failed %d: %s (%d)", ret,
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
no_thread:
|
no_thread:
|
||||||
{
|
{
|
||||||
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
|
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
|
||||||
gst_poll_remove_fd (self->fdset, &self->sock);
|
gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
g_free (self->servaddr);
|
g_free (self->servaddr);
|
||||||
self->servaddr = NULL;
|
self->servaddr = NULL;
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
|
@ -490,14 +502,14 @@ no_thread:
|
||||||
static void
|
static void
|
||||||
gst_net_client_clock_stop (GstNetClientClock * self)
|
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);
|
g_thread_join (self->thread);
|
||||||
self->thread = NULL;
|
self->thread = NULL;
|
||||||
|
|
||||||
if (self->sock.fd != -1) {
|
if (self->priv->sock.fd != -1) {
|
||||||
gst_poll_remove_fd (self->fdset, &self->sock);
|
gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,7 +560,7 @@ gst_net_client_clock_new (gchar * name, const gchar * remote_address,
|
||||||
g_warning ("unable to set the base time, expect sync problems!");
|
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;
|
goto no_fdset;
|
||||||
|
|
||||||
if (!gst_net_client_clock_start (ret))
|
if (!gst_net_client_clock_start (ret))
|
||||||
|
|
|
@ -59,6 +59,7 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstNetClientClock GstNetClientClock;
|
typedef struct _GstNetClientClock GstNetClientClock;
|
||||||
typedef struct _GstNetClientClockClass GstNetClientClockClass;
|
typedef struct _GstNetClientClockClass GstNetClientClockClass;
|
||||||
|
typedef struct _GstNetClientClockPrivate GstNetClientClockPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstNetClientClock:
|
* GstNetClientClock:
|
||||||
|
@ -74,11 +75,8 @@ struct _GstNetClientClock {
|
||||||
gint port;
|
gint port;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* the size of _gst_reserved1 and sock must equal three ints since this used
|
int sock;
|
||||||
* to be int sock and int control_sock[2] */
|
int control_sock[2];
|
||||||
int _gst_reserved1;
|
|
||||||
GstPollFD sock;
|
|
||||||
GstPoll *fdset;
|
|
||||||
|
|
||||||
GstClockTime current_timeout;
|
GstClockTime current_timeout;
|
||||||
|
|
||||||
|
@ -87,6 +85,8 @@ struct _GstNetClientClock {
|
||||||
GThread *thread;
|
GThread *thread;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
GstNetClientClockPrivate *priv;
|
||||||
|
|
||||||
gpointer _gst_reserved[GST_PADDING - 1];
|
gpointer _gst_reserved[GST_PADDING - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,15 @@ enum
|
||||||
/* FILL ME */
|
/* 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 gboolean gst_net_time_provider_start (GstNetTimeProvider * bself);
|
||||||
static void gst_net_time_provider_stop (GstNetTimeProvider * bself);
|
static void gst_net_time_provider_stop (GstNetTimeProvider * bself);
|
||||||
|
|
||||||
|
@ -129,6 +138,8 @@ gst_net_time_provider_class_init (GstNetTimeProviderClass * klass)
|
||||||
|
|
||||||
g_assert (sizeof (GstClockTime) == 8);
|
g_assert (sizeof (GstClockTime) == 8);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstNetTimeProviderPrivate));
|
||||||
|
|
||||||
gobject_class->finalize = gst_net_time_provider_finalize;
|
gobject_class->finalize = gst_net_time_provider_finalize;
|
||||||
gobject_class->set_property = gst_net_time_provider_set_property;
|
gobject_class->set_property = gst_net_time_provider_set_property;
|
||||||
gobject_class->get_property = gst_net_time_provider_get_property;
|
gobject_class->get_property = gst_net_time_provider_get_property;
|
||||||
|
@ -166,9 +177,10 @@ gst_net_time_provider_init (GstNetTimeProvider * self,
|
||||||
WSACleanup ();
|
WSACleanup ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
self->priv = GST_NET_TIME_PROVIDER_GET_PRIVATE (self);
|
||||||
|
|
||||||
self->port = DEFAULT_PORT;
|
self->port = DEFAULT_PORT;
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
self->address = g_strdup (DEFAULT_ADDRESS);
|
self->address = g_strdup (DEFAULT_ADDRESS);
|
||||||
self->thread = NULL;
|
self->thread = NULL;
|
||||||
self->active.active = TRUE;
|
self->active.active = TRUE;
|
||||||
|
@ -184,9 +196,9 @@ gst_net_time_provider_finalize (GObject * object)
|
||||||
g_assert (self->thread == NULL);
|
g_assert (self->thread == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->fdset) {
|
if (self->priv->fdset) {
|
||||||
gst_poll_free (self->fdset);
|
gst_poll_free (self->priv->fdset);
|
||||||
self->fdset = NULL;
|
self->priv->fdset = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (self->address);
|
g_free (self->address);
|
||||||
|
@ -214,7 +226,7 @@ gst_net_time_provider_thread (gpointer data)
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
GST_LOG_OBJECT (self, "doing select");
|
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);
|
GST_LOG_OBJECT (self, "select returned %d", ret);
|
||||||
|
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
|
@ -229,7 +241,7 @@ gst_net_time_provider_thread (gpointer data)
|
||||||
/* got data in */
|
/* got data in */
|
||||||
len = sizeof (struct sockaddr);
|
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);
|
(struct sockaddr *) &tmpaddr, &len);
|
||||||
|
|
||||||
if (!packet)
|
if (!packet)
|
||||||
|
@ -240,7 +252,7 @@ gst_net_time_provider_thread (gpointer data)
|
||||||
packet->remote_time = gst_clock_get_time (self->clock);
|
packet->remote_time = gst_clock_get_time (self->clock);
|
||||||
|
|
||||||
/* ignore errors */
|
/* 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);
|
(struct sockaddr *) &tmpaddr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,10 +360,12 @@ gst_net_time_provider_start (GstNetTimeProvider * self)
|
||||||
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||||
goto no_socket;
|
goto no_socket;
|
||||||
|
|
||||||
self->sock.fd = ret;
|
self->priv->sock.fd = ret;
|
||||||
|
|
||||||
ru = 1;
|
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)
|
if (ret < 0)
|
||||||
goto setsockopt_error;
|
goto setsockopt_error;
|
||||||
|
|
||||||
|
@ -363,12 +377,14 @@ gst_net_time_provider_start (GstNetTimeProvider * self)
|
||||||
inet_aton (self->address, &my_addr.sin_addr);
|
inet_aton (self->address, &my_addr.sin_addr);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "binding on port %d", self->port);
|
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)
|
if (ret < 0)
|
||||||
goto bind_error;
|
goto bind_error;
|
||||||
|
|
||||||
len = sizeof (my_addr);
|
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)
|
if (ret < 0)
|
||||||
goto getsockname_error;
|
goto getsockname_error;
|
||||||
|
|
||||||
|
@ -381,8 +397,8 @@ gst_net_time_provider_start (GstNetTimeProvider * self)
|
||||||
g_object_notify (G_OBJECT (self), "port");
|
g_object_notify (G_OBJECT (self), "port");
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_poll_add_fd (self->fdset, &self->sock);
|
gst_poll_add_fd (self->priv->fdset, &self->priv->sock);
|
||||||
gst_poll_fd_ctl_read (self->fdset, &self->sock, TRUE);
|
gst_poll_fd_ctl_read (self->priv->fdset, &self->priv->sock, TRUE);
|
||||||
|
|
||||||
self->thread = g_thread_create (gst_net_time_provider_thread, self, TRUE,
|
self->thread = g_thread_create (gst_net_time_provider_thread, self, TRUE,
|
||||||
&error);
|
&error);
|
||||||
|
@ -400,33 +416,33 @@ no_socket:
|
||||||
}
|
}
|
||||||
setsockopt_error:
|
setsockopt_error:
|
||||||
{
|
{
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
GST_ERROR_OBJECT (self, "setsockopt failed %d: %s (%d)", ret,
|
GST_ERROR_OBJECT (self, "setsockopt failed %d: %s (%d)", ret,
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
bind_error:
|
bind_error:
|
||||||
{
|
{
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
GST_ERROR_OBJECT (self, "bind failed %d: %s (%d)", ret,
|
GST_ERROR_OBJECT (self, "bind failed %d: %s (%d)", ret,
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
getsockname_error:
|
getsockname_error:
|
||||||
{
|
{
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
|
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
|
||||||
g_strerror (errno), errno);
|
g_strerror (errno), errno);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
no_thread:
|
no_thread:
|
||||||
{
|
{
|
||||||
gst_poll_remove_fd (self->fdset, &self->sock);
|
gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
|
GST_ERROR_OBJECT (self, "could not create thread: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -436,14 +452,14 @@ no_thread:
|
||||||
static void
|
static void
|
||||||
gst_net_time_provider_stop (GstNetTimeProvider * self)
|
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);
|
g_thread_join (self->thread);
|
||||||
self->thread = NULL;
|
self->thread = NULL;
|
||||||
|
|
||||||
if (self->sock.fd != -1) {
|
if (self->priv->sock.fd != -1) {
|
||||||
gst_poll_remove_fd (self->fdset, &self->sock);
|
gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
|
||||||
close (self->sock.fd);
|
close (self->priv->sock.fd);
|
||||||
self->sock.fd = -1;
|
self->priv->sock.fd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,7 +485,7 @@ gst_net_time_provider_new (GstClock * clock, const gchar * address, gint port)
|
||||||
ret = g_object_new (GST_TYPE_NET_TIME_PROVIDER, "clock", clock, "address",
|
ret = g_object_new (GST_TYPE_NET_TIME_PROVIDER, "clock", clock, "address",
|
||||||
address, "port", port, NULL);
|
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;
|
goto no_fdset;
|
||||||
|
|
||||||
if (!gst_net_time_provider_start (ret))
|
if (!gst_net_time_provider_start (ret))
|
||||||
|
|
|
@ -57,6 +57,8 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstNetTimeProvider GstNetTimeProvider;
|
typedef struct _GstNetTimeProvider GstNetTimeProvider;
|
||||||
typedef struct _GstNetTimeProviderClass GstNetTimeProviderClass;
|
typedef struct _GstNetTimeProviderClass GstNetTimeProviderClass;
|
||||||
|
typedef struct _GstNetTimeProviderPrivate GstNetTimeProviderPrivate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstNetTimeProvider:
|
* GstNetTimeProvider:
|
||||||
|
@ -71,12 +73,8 @@ struct _GstNetTimeProvider {
|
||||||
gchar *address;
|
gchar *address;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
/* the size of _gst_reserved2 and sock must equal three ints since this used
|
int sock;
|
||||||
* to be int sock and int control_sock[2]. This relies on the fact that
|
int control_sock[2];
|
||||||
* GstPollFD happens to be two ints */
|
|
||||||
int _gst_reserved2;
|
|
||||||
GstPollFD sock;
|
|
||||||
GstPoll *fdset;
|
|
||||||
|
|
||||||
GThread *thread;
|
GThread *thread;
|
||||||
|
|
||||||
|
@ -89,6 +87,8 @@ struct _GstNetTimeProvider {
|
||||||
} active;
|
} active;
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
|
GstNetTimeProviderPrivate *priv;
|
||||||
|
|
||||||
gpointer _gst_reserved[GST_PADDING - 2];
|
gpointer _gst_reserved[GST_PADDING - 2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue