c8cde3f7d449b57d3e62be321f442d0f48be281f
[platform/upstream/gstreamer.git] / libs / gst / net / gstnettimeprovider.h
1 /* GStreamer
2  * Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
3  *               2006 Joni Valtanen <joni.valtanen@movial.fi>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21
22 #ifndef __GST_NET_TIME_PROVIDER_H__
23 #define __GST_NET_TIME_PROVIDER_H__
24
25 /* to determinate os */
26 #include <glib.h>
27
28 #include <gst/gst.h>
29
30 G_BEGIN_DECLS
31
32 #include <errno.h>
33 #include <string.h>
34 #include <sys/types.h>
35
36 #ifdef G_OS_WIN32
37 #include <winsock2.h>
38 #include <ws2tcpip.h>
39 #ifndef socklen_t
40 #define socklen_t int
41 #endif
42 #else
43 #include <netdb.h>
44 #include <sys/socket.h>
45 #include <netinet/in.h>
46 #include <arpa/inet.h>
47 #endif
48
49 #include <fcntl.h>
50
51 #define GST_TYPE_NET_TIME_PROVIDER \
52   (gst_net_time_provider_get_type())
53 #define GST_NET_TIME_PROVIDER(obj) \
54   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_NET_TIME_PROVIDER,GstNetTimeProvider))
55 #define GST_NET_TIME_PROVIDER_CLASS(klass) \
56   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_NET_TIME_PROVIDER,GstNetTimeProviderClass))
57 #define GST_IS_NET_TIME_PROVIDER(obj) \
58   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_NET_TIME_PROVIDER))
59 #define GST_IS_NET_TIME_PROVIDER_CLASS(klass) \
60   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NET_TIME_PROVIDER))
61
62 typedef struct _GstNetTimeProvider GstNetTimeProvider;
63 typedef struct _GstNetTimeProviderClass GstNetTimeProviderClass;
64 typedef struct _GstNetTimeProviderPrivate GstNetTimeProviderPrivate;
65
66 /**
67  * GstNetTimeProvider:
68  *
69  * Opaque #GstNetTimeProvider structure.
70  */
71 struct _GstNetTimeProvider {
72   GstObject parent;
73
74   /*< private >*/
75   gchar *address;
76   int port;
77
78   int sock;
79   int control_sock[2];
80
81   GThread *thread;
82
83   GstClock *clock;
84
85   /* has to be a gint, we use atomic ops here */
86   gint active;
87
88   /*< private >*/
89   GstNetTimeProviderPrivate *priv;
90
91   gpointer _gst_reserved[GST_PADDING];
92 };
93
94 struct _GstNetTimeProviderClass {
95   GstObjectClass parent_class;
96
97   gpointer _gst_reserved[GST_PADDING];
98 };
99
100 GType                   gst_net_time_provider_get_type  (void);
101 GstNetTimeProvider*     gst_net_time_provider_new       (GstClock *clock,
102                                                          const gchar *address,
103                                                          gint port);
104
105 G_END_DECLS
106
107
108 #endif /* __GST_NET_TIME_PROVIDER_H__ */