2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
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.
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.
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.
22 #ifndef __GST_MULTIFDSINK_H__
23 #define __GST_MULTIFDSINK_H__
30 #endif /* __cplusplus */
38 #include <sys/types.h>
39 #include <netinet/in.h>
41 #include <sys/socket.h>
44 #include <arpa/inet.h>
47 #define GST_TYPE_MULTIFDSINK \
48 (gst_multifdsink_get_type())
49 #define GST_MULTIFDSINK(obj) \
50 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTIFDSINK,GstMultiFdSink))
51 #define GST_MULTIFDSINK_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTIFDSINK,GstMultiFdSink))
53 #define GST_IS_MULTIFDSINK(obj) \
54 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFDSINK))
55 #define GST_IS_MULTIFDSINK_CLASS(obj) \
56 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFDSINK))
57 #define GST_MULTIFDSINK_GET_CLASS(obj) \
58 (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MULTIFDSINK, GstMultiFdSinkClass))
61 typedef struct _GstMultiFdSink GstMultiFdSink;
62 typedef struct _GstMultiFdSinkClass GstMultiFdSinkClass;
65 GST_MULTIFDSINK_OPEN = GST_ELEMENT_FLAG_LAST,
67 GST_MULTIFDSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2,
68 } GstMultiFdSinkFlags;
72 GST_RECOVER_POLICY_NONE,
73 GST_RECOVER_POLICY_RESYNC_START,
74 GST_RECOVER_POLICY_RESYNC_SOFT,
75 GST_RECOVER_POLICY_RESYNC_KEYFRAME,
78 /* structure for a client
82 gint bufpos; /* position of this client in the global queue */
84 GList *sending; /* the buffers we need to send */
85 gint bufoffset; /* offset in the first buffer */
87 GstTCPProtocolType protocol;
90 gboolean streamheader_sent;
93 struct _GstMultiFdSink {
99 size_t data_written; /* how much bytes have we written ? */
101 GMutex *clientslock; /* lock to protect the clients list */
102 GList *clients; /* list of clients we are serving */
104 fd_set readfds; /* all the client file descriptors that we can read from */
105 fd_set writefds; /* all the client file descriptors that we can write to */
107 int control_sock[2]; /* sockets for controlling the select call */
109 GList *streamheader; /* GList of GstBuffers to use as streamheader */
110 GstTCPProtocolType protocol;
113 GArray *bufqueue; /* global queue of buffers */
115 gboolean running; /* the thread state */
116 GThread *thread; /* the sender thread */
118 gint buffers_max; /* max buffers to queue */
119 gint buffers_soft_max; /* max buffers a client can lay before recoevery starts */
120 GstRecoverPolicy recover_policy;
122 gint buffers_queued; /* number of queued buffers */
125 struct _GstMultiFdSinkClass {
126 GstElementClass parent_class;
128 gboolean (*init) (GstMultiFdSink *sink);
129 gboolean (*select) (GstMultiFdSink *sink, fd_set *readfds, fd_set *writefds);
130 gboolean (*close) (GstMultiFdSink *sink);
133 void (*client_added) (GstElement *element, gchar *host, gint fd);
134 void (*client_removed) (GstElement *element, gchar *host, gint fd);
137 GType gst_multifdsink_get_type (void);
142 #endif /* __cplusplus */
145 #endif /* __GST_MULTIFDSINK_H__ */