2005-11-16 16:49:49 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstnettimeprovider
|
|
|
|
* @short_description: Special object that exposed the time of a clock
|
|
|
|
* on the network.
|
|
|
|
* @see_also: #GstClock, #GstNetClientClock, #GstPipeline
|
|
|
|
*
|
|
|
|
* This object exposes the time of a #GstClock on the network.
|
|
|
|
*
|
|
|
|
* A #GstNetTimeProvider is created with gst_net_time_provider_new() which
|
2006-03-12 20:40:19 +00:00
|
|
|
* takes a #GstClock, an address and a port number as arguments.
|
2005-11-24 09:44:07 +00:00
|
|
|
*
|
|
|
|
* After creating the object, a client clock such as #GstNetClientClock can
|
2006-03-12 20:40:19 +00:00
|
|
|
* query the exposed clock over the network for its values.
|
2005-11-24 09:44:07 +00:00
|
|
|
*
|
|
|
|
* The #GstNetTimeProvider typically wraps the clock used by a #GstPipeline.
|
|
|
|
*
|
|
|
|
* Last reviewed on 2005-11-23 (0.9.5)
|
|
|
|
*/
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "gstnettimeprovider.h"
|
2005-11-16 17:52:04 +00:00
|
|
|
#include "gstnettimepacket.h"
|
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2007-10-31 22:01:03 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-11-16 16:49:49 +00:00
|
|
|
#include <unistd.h>
|
2007-10-31 22:01:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (_MSC_VER) && _MSC_VER >= 1400
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifndef G_OS_WIN32
|
2005-11-16 16:49:49 +00:00
|
|
|
#include <sys/ioctl.h>
|
2006-09-05 08:35:20 +00:00
|
|
|
#endif
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_FIONREAD_IN_SYS_FILIO
|
|
|
|
#include <sys/filio.h>
|
|
|
|
#endif
|
|
|
|
|
2006-06-23 13:16:46 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (ntp_debug);
|
2005-11-16 16:49:49 +00:00
|
|
|
#define GST_CAT_DEFAULT (ntp_debug)
|
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#define close(sock) closesocket(sock)
|
|
|
|
#endif
|
|
|
|
|
2005-12-06 19:29:15 +00:00
|
|
|
#define DEFAULT_ADDRESS "0.0.0.0"
|
|
|
|
#define DEFAULT_PORT 5637
|
2005-11-16 16:49:49 +00:00
|
|
|
|
2005-12-12 15:02:02 +00:00
|
|
|
#define IS_ACTIVE(self) (g_atomic_int_get (&((self)->active.active)))
|
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#define setsockopt(sock, sol_flags, reuse_flags, ru, sizeofru) setsockopt (sock, sol_flags, reuse_flags, (char *)ru, sizeofru)
|
|
|
|
#endif
|
2005-11-16 16:49:49 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PORT,
|
|
|
|
PROP_ADDRESS,
|
2005-12-12 15:02:02 +00:00
|
|
|
PROP_CLOCK,
|
|
|
|
PROP_ACTIVE
|
2005-11-16 16:49:49 +00:00
|
|
|
/* FILL ME */
|
|
|
|
};
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
#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;
|
|
|
|
};
|
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
static gboolean gst_net_time_provider_start (GstNetTimeProvider * bself);
|
|
|
|
static void gst_net_time_provider_stop (GstNetTimeProvider * bself);
|
|
|
|
|
|
|
|
static gpointer gst_net_time_provider_thread (gpointer data);
|
|
|
|
|
|
|
|
static void gst_net_time_provider_finalize (GObject * object);
|
|
|
|
static void gst_net_time_provider_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_net_time_provider_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
#define _do_init(type) \
|
|
|
|
GST_DEBUG_CATEGORY_INIT (ntp_debug, "nettime", 0, "Network time provider");
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL (GstNetTimeProvider, gst_net_time_provider, GstObject,
|
|
|
|
GST_TYPE_OBJECT, _do_init);
|
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
static int
|
|
|
|
inet_aton (const char *c, struct in_addr *paddr)
|
|
|
|
{
|
|
|
|
paddr->s_addr = inet_addr (c);
|
|
|
|
if (paddr->s_addr == INADDR_NONE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
static void
|
|
|
|
gst_net_time_provider_base_init (gpointer g_class)
|
|
|
|
{
|
Don't use base_init where not absolutely necessary. For example it's not necessary anymore for adding pad templates o...
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_get_type), (gst_bin_class_init):
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init):
* libs/gst/base/gstbasesink.c: (gst_base_sink_get_type),
(gst_base_sink_class_init):
* libs/gst/base/gstbasesrc.c: (gst_base_src_get_type),
(gst_base_src_class_init):
* libs/gst/base/gstbasetransform.c: (gst_base_transform_get_type),
(gst_base_transform_class_init):
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_base_init),
(gst_collect_pads_class_init):
* libs/gst/base/gstdataqueue.c: (gst_data_queue_get_type):
* libs/gst/net/gstnettimeprovider.c:
(gst_net_time_provider_base_init),
(gst_net_time_provider_class_init):
* plugins/elements/gstcapsfilter.c: (gst_capsfilter_base_init),
(gst_capsfilter_class_init):
* plugins/elements/gstfakesink.c: (gst_fake_sink_base_init),
(gst_fake_sink_class_init):
* plugins/elements/gstfakesrc.c: (gst_fake_src_base_init),
(gst_fake_src_class_init):
* plugins/elements/gstfdsink.c: (gst_fd_sink_base_init),
(gst_fd_sink_class_init):
* plugins/elements/gstfdsrc.c: (gst_fd_src_base_init),
(gst_fd_src_class_init):
* plugins/elements/gstfilesink.c: (gst_file_sink_base_init),
(gst_file_sink_class_init):
* plugins/elements/gstfilesrc.c: (gst_file_src_base_init),
(gst_file_src_class_init):
* plugins/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_class_init):
* plugins/elements/gstmultiqueue.c: (gst_multi_queue_base_init),
(gst_multi_queue_class_init):
* plugins/elements/gstqueue.c: (gst_queue_base_init),
(gst_queue_class_init):
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_class_init):
* plugins/elements/gsttypefindelement.c:
(gst_type_find_element_base_init),
(gst_type_find_element_class_init):
Don't use base_init where not absolutely necessary. For example it's
not necessary anymore for adding pad templates or setting element
details.
Leave empty base_init functions in several places as GST_BOILERPLATE
still defines and uses them.
2008-02-03 12:04:37 +00:00
|
|
|
/* Do nothing here */
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_net_time_provider_class_init (GstNetTimeProviderClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
2006-05-11 18:10:34 +00:00
|
|
|
gobject_class = G_OBJECT_CLASS (klass);
|
2005-11-16 16:49:49 +00:00
|
|
|
|
Don't use base_init where not absolutely necessary. For example it's not necessary anymore for adding pad templates o...
Original commit message from CVS:
* gst/gstbin.c: (gst_bin_get_type), (gst_bin_class_init):
* gst/gstpipeline.c: (gst_pipeline_get_type),
(gst_pipeline_class_init):
* libs/gst/base/gstbasesink.c: (gst_base_sink_get_type),
(gst_base_sink_class_init):
* libs/gst/base/gstbasesrc.c: (gst_base_src_get_type),
(gst_base_src_class_init):
* libs/gst/base/gstbasetransform.c: (gst_base_transform_get_type),
(gst_base_transform_class_init):
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_base_init),
(gst_collect_pads_class_init):
* libs/gst/base/gstdataqueue.c: (gst_data_queue_get_type):
* libs/gst/net/gstnettimeprovider.c:
(gst_net_time_provider_base_init),
(gst_net_time_provider_class_init):
* plugins/elements/gstcapsfilter.c: (gst_capsfilter_base_init),
(gst_capsfilter_class_init):
* plugins/elements/gstfakesink.c: (gst_fake_sink_base_init),
(gst_fake_sink_class_init):
* plugins/elements/gstfakesrc.c: (gst_fake_src_base_init),
(gst_fake_src_class_init):
* plugins/elements/gstfdsink.c: (gst_fd_sink_base_init),
(gst_fd_sink_class_init):
* plugins/elements/gstfdsrc.c: (gst_fd_src_base_init),
(gst_fd_src_class_init):
* plugins/elements/gstfilesink.c: (gst_file_sink_base_init),
(gst_file_sink_class_init):
* plugins/elements/gstfilesrc.c: (gst_file_src_base_init),
(gst_file_src_class_init):
* plugins/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_class_init):
* plugins/elements/gstmultiqueue.c: (gst_multi_queue_base_init),
(gst_multi_queue_class_init):
* plugins/elements/gstqueue.c: (gst_queue_base_init),
(gst_queue_class_init):
* plugins/elements/gsttee.c: (gst_tee_base_init),
(gst_tee_class_init):
* plugins/elements/gsttypefindelement.c:
(gst_type_find_element_base_init),
(gst_type_find_element_class_init):
Don't use base_init where not absolutely necessary. For example it's
not necessary anymore for adding pad templates or setting element
details.
Leave empty base_init functions in several places as GST_BOILERPLATE
still defines and uses them.
2008-02-03 12:04:37 +00:00
|
|
|
g_assert (sizeof (GstClockTime) == 8);
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
g_type_class_add_private (klass, sizeof (GstNetTimeProviderPrivate));
|
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
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;
|
|
|
|
|
2006-05-11 18:10:34 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_PORT,
|
2005-11-16 16:49:49 +00:00
|
|
|
g_param_spec_int ("port", "port",
|
2005-11-18 11:57:30 +00:00
|
|
|
"The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
|
2008-03-22 14:56:17 +00:00
|
|
|
DEFAULT_PORT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-11-16 16:49:49 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_ADDRESS,
|
|
|
|
g_param_spec_string ("address", "address",
|
|
|
|
"The address to bind on, as a dotted quad (x.x.x.x)",
|
2008-03-22 14:56:17 +00:00
|
|
|
DEFAULT_ADDRESS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-11-16 16:49:49 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_CLOCK,
|
|
|
|
g_param_spec_object ("clock", "Clock",
|
|
|
|
"The clock to export over the network", GST_TYPE_CLOCK,
|
2008-03-22 14:56:17 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-12-12 15:02:02 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_ACTIVE,
|
|
|
|
g_param_spec_boolean ("active", "Active",
|
|
|
|
"TRUE if the clock will respond to queries over the network", TRUE,
|
2008-03-22 14:56:17 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_net_time_provider_init (GstNetTimeProvider * self,
|
|
|
|
GstNetTimeProviderClass * g_class)
|
|
|
|
{
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSADATA w;
|
|
|
|
int error = WSAStartup (0x0202, &w);
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
GST_DEBUG_OBJECT (self, "Error on WSAStartup");
|
|
|
|
}
|
|
|
|
if (w.wVersion != 0x0202) {
|
|
|
|
WSACleanup ();
|
|
|
|
}
|
|
|
|
#endif
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
self->priv = GST_NET_TIME_PROVIDER_GET_PRIVATE (self);
|
2006-09-05 08:35:20 +00:00
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
self->port = DEFAULT_PORT;
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
self->priv->sock.fd = -1;
|
2005-11-16 16:49:49 +00:00
|
|
|
self->address = g_strdup (DEFAULT_ADDRESS);
|
|
|
|
self->thread = NULL;
|
2005-12-12 15:02:02 +00:00
|
|
|
self->active.active = TRUE;
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_net_time_provider_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstNetTimeProvider *self = GST_NET_TIME_PROVIDER (object);
|
|
|
|
|
|
|
|
if (self->thread) {
|
|
|
|
gst_net_time_provider_stop (self);
|
|
|
|
g_assert (self->thread == NULL);
|
|
|
|
}
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
if (self->priv->fdset) {
|
|
|
|
gst_poll_free (self->priv->fdset);
|
|
|
|
self->priv->fdset = NULL;
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (self->address);
|
|
|
|
self->address = NULL;
|
|
|
|
|
|
|
|
if (self->clock)
|
|
|
|
gst_object_unref (self->clock);
|
|
|
|
self->clock = NULL;
|
2005-11-16 17:22:36 +00:00
|
|
|
|
2006-09-05 08:35:20 +00:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
WSACleanup ();
|
|
|
|
#endif
|
|
|
|
|
2005-11-16 17:22:36 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
gst_net_time_provider_thread (gpointer data)
|
|
|
|
{
|
|
|
|
GstNetTimeProvider *self = data;
|
|
|
|
struct sockaddr_in tmpaddr;
|
|
|
|
socklen_t len;
|
2005-11-16 17:52:04 +00:00
|
|
|
GstNetTimePacket *packet;
|
2005-11-16 16:49:49 +00:00
|
|
|
gint ret;
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
GST_LOG_OBJECT (self, "doing select");
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
ret = gst_poll_wait (self->priv->fdset, GST_CLOCK_TIME_NONE);
|
2005-11-16 16:49:49 +00:00
|
|
|
GST_LOG_OBJECT (self, "select returned %d", ret);
|
|
|
|
|
|
|
|
if (ret <= 0) {
|
libs/gst/net/: Massive code removal and cleanups because of GstPoll.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (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_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:
Massive code removal and cleanups because of GstPoll.
Fixes #505417.
2008-02-27 18:27:59 +00:00
|
|
|
if (errno == EBUSY) {
|
|
|
|
GST_LOG_OBJECT (self, "stop");
|
|
|
|
goto stopped;
|
|
|
|
} else if (errno != EAGAIN && errno != EINTR)
|
2005-11-16 16:49:49 +00:00
|
|
|
goto select_error;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
/* got data in */
|
|
|
|
len = sizeof (struct sockaddr);
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
packet = gst_net_time_packet_receive (self->priv->sock.fd,
|
2005-11-16 17:52:04 +00:00
|
|
|
(struct sockaddr *) &tmpaddr, &len);
|
2005-11-16 16:49:49 +00:00
|
|
|
|
2005-11-16 17:52:04 +00:00
|
|
|
if (!packet)
|
|
|
|
goto receive_error;
|
2005-11-16 16:49:49 +00:00
|
|
|
|
2005-12-12 15:02:02 +00:00
|
|
|
if (IS_ACTIVE (self)) {
|
|
|
|
/* do what we were asked to and send the packet back */
|
|
|
|
packet->remote_time = gst_clock_get_time (self->clock);
|
2005-11-16 16:49:49 +00:00
|
|
|
|
2005-12-12 15:02:02 +00:00
|
|
|
/* ignore errors */
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
gst_net_time_packet_send (packet, self->priv->sock.fd,
|
2005-12-12 15:02:02 +00:00
|
|
|
(struct sockaddr *) &tmpaddr, len);
|
|
|
|
}
|
2005-11-16 16:49:49 +00:00
|
|
|
|
2005-11-16 17:52:04 +00:00
|
|
|
g_free (packet);
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
/* log errors and keep going */
|
|
|
|
select_error:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (self, "select error %d: %s (%d)", ret,
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
stopped:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (self, "shutting down");
|
|
|
|
/* close socket */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
receive_error:
|
|
|
|
{
|
2005-11-16 17:52:04 +00:00
|
|
|
GST_DEBUG_OBJECT (self, "receive error");
|
2005-11-16 16:49:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_net_time_provider_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstNetTimeProvider *self = GST_NET_TIME_PROVIDER (object);
|
2006-03-21 14:14:49 +00:00
|
|
|
GstClock **clock_p = &self->clock;
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_PORT:
|
|
|
|
self->port = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_ADDRESS:
|
|
|
|
g_free (self->address);
|
|
|
|
if (g_value_get_string (value) == NULL)
|
|
|
|
self->address = g_strdup (DEFAULT_ADDRESS);
|
|
|
|
else
|
|
|
|
self->address = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case PROP_CLOCK:
|
2006-03-21 14:14:49 +00:00
|
|
|
gst_object_replace ((GstObject **) clock_p,
|
2005-11-16 16:49:49 +00:00
|
|
|
(GstObject *) g_value_get_object (value));
|
|
|
|
break;
|
2005-12-12 15:02:02 +00:00
|
|
|
case PROP_ACTIVE:
|
2008-04-17 07:14:46 +00:00
|
|
|
g_atomic_int_set (&self->active.active, g_value_get_boolean (value));
|
2005-12-12 15:02:02 +00:00
|
|
|
break;
|
2005-11-16 16:49:49 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_net_time_provider_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstNetTimeProvider *self = GST_NET_TIME_PROVIDER (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_PORT:
|
|
|
|
g_value_set_int (value, self->port);
|
|
|
|
break;
|
|
|
|
case PROP_ADDRESS:
|
|
|
|
g_value_set_string (value, self->address);
|
|
|
|
break;
|
|
|
|
case PROP_CLOCK:
|
|
|
|
g_value_set_object (value, self->clock);
|
|
|
|
break;
|
2005-12-12 15:02:02 +00:00
|
|
|
case PROP_ACTIVE:
|
|
|
|
g_value_set_boolean (value, IS_ACTIVE (self));
|
|
|
|
break;
|
2005-11-16 16:49:49 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_net_time_provider_start (GstNetTimeProvider * self)
|
|
|
|
{
|
|
|
|
gint ru;
|
|
|
|
struct sockaddr_in my_addr;
|
2011-01-29 17:02:11 +00:00
|
|
|
socklen_t len;
|
2005-11-16 16:49:49 +00:00
|
|
|
int port;
|
|
|
|
gint ret;
|
|
|
|
GError *error;
|
|
|
|
|
|
|
|
if ((ret = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
|
|
|
goto no_socket;
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
self->priv->sock.fd = ret;
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
ru = 1;
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
ret =
|
|
|
|
setsockopt (self->priv->sock.fd, SOL_SOCKET, SO_REUSEADDR, &ru,
|
|
|
|
sizeof (ru));
|
2005-11-16 16:49:49 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto setsockopt_error;
|
|
|
|
|
|
|
|
memset (&my_addr, 0, sizeof (my_addr));
|
|
|
|
my_addr.sin_family = AF_INET; /* host byte order */
|
2005-11-18 11:57:30 +00:00
|
|
|
my_addr.sin_port = htons ((gint16) self->port); /* short, network byte order */
|
2005-11-16 16:49:49 +00:00
|
|
|
my_addr.sin_addr.s_addr = INADDR_ANY;
|
2011-01-12 10:58:44 +00:00
|
|
|
if (self->address) {
|
|
|
|
ret = inet_aton (self->address, &my_addr.sin_addr);
|
|
|
|
if (ret == 0)
|
|
|
|
goto invalid_address_error;
|
|
|
|
}
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (self, "binding on port %d", self->port);
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
ret =
|
|
|
|
bind (self->priv->sock.fd, (struct sockaddr *) &my_addr,
|
|
|
|
sizeof (my_addr));
|
2005-11-16 16:49:49 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto bind_error;
|
|
|
|
|
|
|
|
len = sizeof (my_addr);
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
ret = getsockname (self->priv->sock.fd, (struct sockaddr *) &my_addr, &len);
|
2005-11-16 16:49:49 +00:00
|
|
|
if (ret < 0)
|
|
|
|
goto getsockname_error;
|
|
|
|
|
|
|
|
port = ntohs (my_addr.sin_port);
|
|
|
|
GST_DEBUG_OBJECT (self, "bound, on port %d", port);
|
2005-11-18 11:57:30 +00:00
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
if (port != self->port) {
|
|
|
|
self->port = port;
|
|
|
|
GST_DEBUG_OBJECT (self, "notifying %d", port);
|
|
|
|
g_object_notify (G_OBJECT (self), "port");
|
|
|
|
}
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
gst_poll_add_fd (self->priv->fdset, &self->priv->sock);
|
|
|
|
gst_poll_fd_ctl_read (self->priv->fdset, &self->priv->sock, TRUE);
|
libs/gst/net/: Massive code removal and cleanups because of GstPoll.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (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_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:
Massive code removal and cleanups because of GstPoll.
Fixes #505417.
2008-02-27 18:27:59 +00:00
|
|
|
|
2005-11-16 16:49:49 +00:00
|
|
|
self->thread = g_thread_create (gst_net_time_provider_thread, self, TRUE,
|
|
|
|
&error);
|
|
|
|
if (!self->thread)
|
|
|
|
goto no_thread;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_socket:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (self, "socket failed %d: %s (%d)", ret,
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
setsockopt_error:
|
|
|
|
{
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
close (self->priv->sock.fd);
|
|
|
|
self->priv->sock.fd = -1;
|
2005-11-16 16:49:49 +00:00
|
|
|
GST_ERROR_OBJECT (self, "setsockopt failed %d: %s (%d)", ret,
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-01-12 10:58:44 +00:00
|
|
|
invalid_address_error:
|
|
|
|
{
|
|
|
|
close (self->priv->sock.fd);
|
|
|
|
self->priv->sock.fd = -1;
|
|
|
|
GST_ERROR_OBJECT (self, "invalid network address %s: %s (%d)",
|
|
|
|
self->address, g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-11-16 16:49:49 +00:00
|
|
|
bind_error:
|
|
|
|
{
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
close (self->priv->sock.fd);
|
|
|
|
self->priv->sock.fd = -1;
|
2005-11-16 16:49:49 +00:00
|
|
|
GST_ERROR_OBJECT (self, "bind failed %d: %s (%d)", ret,
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
getsockname_error:
|
|
|
|
{
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
close (self->priv->sock.fd);
|
|
|
|
self->priv->sock.fd = -1;
|
2005-11-16 16:49:49 +00:00
|
|
|
GST_ERROR_OBJECT (self, "getsockname failed %d: %s (%d)", ret,
|
|
|
|
g_strerror (errno), errno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
no_thread:
|
|
|
|
{
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
gst_poll_remove_fd (self->priv->fdset, &self->priv->sock);
|
|
|
|
close (self->priv->sock.fd);
|
|
|
|
self->priv->sock.fd = -1;
|
2005-11-16 16:49:49 +00:00
|
|
|
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)
|
|
|
|
{
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
gst_poll_set_flushing (self->priv->fdset, TRUE);
|
2005-11-16 16:49:49 +00:00
|
|
|
g_thread_join (self->thread);
|
|
|
|
self->thread = NULL;
|
|
|
|
|
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.
2008-02-27 19:01:12 +00:00
|
|
|
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;
|
2005-11-16 16:49:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_net_time_provider_new:
|
|
|
|
* @clock: a #GstClock to export over the network
|
|
|
|
* @address: an address to bind on as a dotted quad (xxx.xxx.xxx.xxx), or NULL
|
|
|
|
* to bind to all addresses
|
2006-03-12 20:40:19 +00:00
|
|
|
* @port: a port to bind on, or 0 to let the kernel choose
|
2005-11-16 16:49:49 +00:00
|
|
|
*
|
|
|
|
* Allows network clients to get the current time of @clock.
|
|
|
|
*
|
2006-03-12 20:40:19 +00:00
|
|
|
* Returns: the new #GstNetTimeProvider, or NULL on error
|
2005-11-16 16:49:49 +00:00
|
|
|
*/
|
|
|
|
GstNetTimeProvider *
|
|
|
|
gst_net_time_provider_new (GstClock * clock, const gchar * address, gint port)
|
|
|
|
{
|
|
|
|
GstNetTimeProvider *ret;
|
|
|
|
|
|
|
|
g_return_val_if_fail (clock && GST_IS_CLOCK (clock), NULL);
|
2005-11-18 11:57:30 +00:00
|
|
|
g_return_val_if_fail (port >= 0 && port <= G_MAXUINT16, NULL);
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
ret = g_object_new (GST_TYPE_NET_TIME_PROVIDER, "clock", clock, "address",
|
|
|
|
address, "port", port, NULL);
|
|
|
|
|
Remove GstPollMode from the API, it does not make sense to let the application control this.
Original commit message from CVS:
Patch by: Ole André Vadla Ravnås
<ole dot andre dot ravnas at tandberg dot com>
* docs/gst/gstreamer-sections.txt:
* gst/gstpoll.c: (find_index), (gst_poll_free_winsock_event),
(gst_poll_update_winsock_event_mask), (gst_poll_new),
(gst_poll_free), (gst_poll_fd_init), (gst_poll_add_fd_unlocked),
(gst_poll_remove_fd), (gst_poll_fd_ctl_write),
(gst_poll_fd_ctl_read_unlocked), (gst_poll_fd_has_closed),
(gst_poll_fd_has_error), (gst_poll_fd_can_read_unlocked),
(gst_poll_fd_can_write), (gst_poll_wait),
(gst_poll_set_controllable), (gst_poll_restart),
(gst_poll_set_flushing):
* gst/gstpoll.h:
* libs/gst/net/gstnetclientclock.c: (gst_net_client_clock_new):
* libs/gst/net/gstnettimeprovider.c: (gst_net_time_provider_start),
(gst_net_time_provider_new):
* plugins/elements/gstfdsink.c: (gst_fd_sink_start):
* plugins/elements/gstfdsrc.c: (gst_fd_src_start):
* tests/benchmarks/gstpollstress.c: (main):
* tests/check/gst/gstpoll.c: (GST_START_TEST), (gst_poll_suite):
Remove GstPollMode from the API, it does not make sense to let the
application control this.
Add support for Win32.
Fix the testsuite. Fixes #520671.
2008-03-07 15:39:45 +00:00
|
|
|
if ((ret->priv->fdset = gst_poll_new (TRUE)) == NULL)
|
libs/gst/net/: Massive code removal and cleanups because of GstPoll.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (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_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:
Massive code removal and cleanups because of GstPoll.
Fixes #505417.
2008-02-27 18:27:59 +00:00
|
|
|
goto no_fdset;
|
2005-11-16 16:49:49 +00:00
|
|
|
|
|
|
|
if (!gst_net_time_provider_start (ret))
|
|
|
|
goto failed_start;
|
|
|
|
|
|
|
|
/* all systems go, cap'n */
|
|
|
|
return ret;
|
|
|
|
|
libs/gst/net/: Massive code removal and cleanups because of GstPoll.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (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_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:
Massive code removal and cleanups because of GstPoll.
Fixes #505417.
2008-02-27 18:27:59 +00:00
|
|
|
no_fdset:
|
2005-11-16 16:49:49 +00:00
|
|
|
{
|
libs/gst/net/: Massive code removal and cleanups because of GstPoll.
Original commit message from CVS:
Patch by: Peter Kjellerstedt <pkj at axis dot com>
* libs/gst/net/gstnetclientclock.c: (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_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:
Massive code removal and cleanups because of GstPoll.
Fixes #505417.
2008-02-27 18:27:59 +00:00
|
|
|
GST_ERROR_OBJECT (ret, "could not create an fdset: %s (%d)",
|
2005-11-16 16:49:49 +00:00
|
|
|
g_strerror (errno), errno);
|
|
|
|
gst_object_unref (ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
failed_start:
|
|
|
|
{
|
|
|
|
/* already printed a nice error */
|
|
|
|
gst_object_unref (ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|