mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
multihandlesink: finish refactor
This commit is contained in:
parent
029b9b49de
commit
b11c895efe
7 changed files with 576 additions and 2586 deletions
File diff suppressed because it is too large
Load diff
|
@ -70,44 +70,21 @@ struct _GstMultiFdSink {
|
|||
GstPoll *fdset;
|
||||
|
||||
gboolean handle_read;
|
||||
|
||||
guint8 header_flags;
|
||||
};
|
||||
|
||||
struct _GstMultiFdSinkClass {
|
||||
GstMultiHandleSinkClass parent_class;
|
||||
|
||||
/* element methods */
|
||||
void (*add) (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void (*add_full) (GstMultiFdSink *sink, GstMultiSinkHandle handle, GstSyncMethod sync,
|
||||
GstFormat format, guint64 value,
|
||||
GstFormat max_format, guint64 max_value);
|
||||
void (*remove) (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void (*remove_flush) (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void (*clear) (GstMultiFdSink *sink);
|
||||
GValueArray* (*get_stats) (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
/* vtable */
|
||||
gboolean (*wait) (GstMultiFdSink *sink, GstPoll *set);
|
||||
void (*removed) (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
/* signals */
|
||||
void (*client_added) (GstElement *element, GstMultiSinkHandle handle);
|
||||
void (*client_removed) (GstElement *element, GstMultiSinkHandle handle, GstClientStatus status);
|
||||
void (*client_fd_removed) (GstElement *element, GstMultiSinkHandle handle);
|
||||
};
|
||||
|
||||
GType gst_multi_fd_sink_get_type (void);
|
||||
|
||||
void gst_multi_fd_sink_add (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_fd_sink_add_full (GstMultiFdSink *sink, GstMultiSinkHandle handle, GstSyncMethod sync,
|
||||
GstFormat min_format, guint64 min_value,
|
||||
GstFormat max_format, guint64 max_value);
|
||||
void gst_multi_fd_sink_remove (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_fd_sink_remove_flush (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_fd_sink_clear (GstMultiHandleSink *sink);
|
||||
GValueArray* gst_multi_fd_sink_get_stats (GstMultiFdSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_MULTI_FD_SINK_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -123,6 +123,7 @@ typedef enum
|
|||
// FIXME: is it better to use GSocket * or a gpointer here ?
|
||||
typedef union
|
||||
{
|
||||
gpointer pointer;
|
||||
int fd;
|
||||
GSocket *socket;
|
||||
} GstMultiSinkHandle;
|
||||
|
@ -169,34 +170,15 @@ typedef struct {
|
|||
guint64 last_buffer_ts;
|
||||
} GstMultiHandleClient;
|
||||
|
||||
// FIXME: remove cast ?
|
||||
#define CLIENTS_LOCK_INIT(mhsink) (g_rec_mutex_init(&(GST_MULTI_HANDLE_SINK(mhsink))->clientslock))
|
||||
#define CLIENTS_LOCK_CLEAR(mhsink) (g_rec_mutex_clear(&(GST_MULTI_HANDLE_SINK(mhsink))->clientslock))
|
||||
#define CLIENTS_LOCK(mhsink) (g_rec_mutex_lock(&(GST_MULTI_HANDLE_SINK(mhsink))->clientslock))
|
||||
#define CLIENTS_UNLOCK(mhsink) (g_rec_mutex_unlock(&(GST_MULTI_HANDLE_SINK(mhsink))->clientslock))
|
||||
#define CLIENTS_LOCK_INIT(mhsink) (g_rec_mutex_init(&(mhsink)->clientslock))
|
||||
#define CLIENTS_LOCK_CLEAR(mhsink) (g_rec_mutex_clear(&(mhsink)->clientslock))
|
||||
#define CLIENTS_LOCK(mhsink) (g_rec_mutex_lock(&(mhsink)->clientslock))
|
||||
#define CLIENTS_UNLOCK(mhsink) (g_rec_mutex_unlock(&(mhsink)->clientslock))
|
||||
|
||||
// FIXME: internalize in .c file ?
|
||||
gint
|
||||
find_syncframe (GstMultiHandleSink * sink, gint idx, gint direction);
|
||||
#define find_next_syncframe(s,i) find_syncframe(s,i,1)
|
||||
#define find_prev_syncframe(s,i) find_syncframe(s,i,-1)
|
||||
gboolean is_sync_frame (GstMultiHandleSink * sink, GstBuffer * buffer);
|
||||
gboolean gst_multi_handle_sink_stop (GstBaseSink * bsink);
|
||||
gboolean gst_multi_handle_sink_start (GstBaseSink * bsink);
|
||||
void gst_multi_handle_sink_setup_dscp (GstMultiHandleSink * mhsink);
|
||||
gint gst_multi_handle_sink_setup_dscp_client (GstMultiHandleSink * sink, GstMultiHandleClient * client);
|
||||
gint get_buffers_max (GstMultiHandleSink * sink, gint64 max);
|
||||
gint
|
||||
gst_multi_handle_sink_recover_client (GstMultiHandleSink * sink,
|
||||
gst_multi_handle_sink_new_client_position (GstMultiHandleSink * sink,
|
||||
GstMultiHandleClient * client);
|
||||
gint
|
||||
gst_multi_handle_sink_new_client (GstMultiHandleSink * sink,
|
||||
GstMultiHandleClient * client);
|
||||
gboolean
|
||||
find_limits (GstMultiHandleSink * sink,
|
||||
gint * min_idx, gint bytes_min, gint buffers_min, gint64 time_min,
|
||||
gint * max_idx, gint bytes_max, gint buffers_max, gint64 time_max);
|
||||
|
||||
|
||||
/**
|
||||
* GstMultiHandleSink:
|
||||
|
@ -254,10 +236,22 @@ struct _GstMultiHandleSink {
|
|||
gint buffers_queued; /* number of queued buffers */
|
||||
gint bytes_queued; /* number of queued bytes */
|
||||
gint time_queued; /* number of queued time */
|
||||
|
||||
guint8 header_flags;
|
||||
};
|
||||
|
||||
/* MultiHandleSink signals implemented in base class and declared
|
||||
* in subclass
|
||||
*/
|
||||
enum
|
||||
{
|
||||
/* signals */
|
||||
GST_MULTI_HANDLE_SIGNAL_CLIENT_ADDED,
|
||||
GST_MULTI_HANDLE_SIGNAL_CLIENT_REMOVED,
|
||||
GST_MULTI_HANDLE_SIGNAL_CLIENT_HANDLE_REMOVED,
|
||||
|
||||
GST_MULTI_HANDLE_LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
||||
struct _GstMultiHandleSinkClass {
|
||||
GstBaseSinkClass parent_class;
|
||||
|
||||
|
@ -268,25 +262,31 @@ struct _GstMultiHandleSinkClass {
|
|||
GstFormat max_format, guint64 max_value);
|
||||
void (*remove) (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
void (*remove_flush) (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
void (*clear) (GstMultiHandleSink *sink);
|
||||
void (*clear_post) (GstMultiHandleSink *sink);
|
||||
void (*stop_pre) (GstMultiHandleSink *sink);
|
||||
void (*stop_post) (GstMultiHandleSink *sink);
|
||||
gboolean (*start_pre) (GstMultiHandleSink *sink);
|
||||
gpointer (*thread) (GstMultiHandleSink *sink);
|
||||
void (*queue_buffer) (GstMultiHandleSink *sink,
|
||||
GstBuffer *buffer);
|
||||
/* called by subclass when it has a new buffer to queue for a client */
|
||||
gboolean (*client_queue_buffer)
|
||||
(GstMultiHandleSink *sink,
|
||||
GstMultiHandleClient *client,
|
||||
GstBuffer *buffer);
|
||||
int (*client_get_fd)
|
||||
(GstMultiHandleClient *client);
|
||||
void (*client_free)
|
||||
(GstMultiHandleClient *client);
|
||||
void (*handle_debug) (GstMultiSinkHandle handle, gchar debug[30]);
|
||||
gpointer (*handle_hash_key) (GstMultiSinkHandle handle);
|
||||
/* called when the client hash/list has been changed */
|
||||
void (*hash_changed) (GstMultiHandleSink *mhsink);
|
||||
void (*hash_adding) (GstMultiHandleSink *mhsink, GstMultiHandleClient *client);
|
||||
void (*hash_removing) (GstMultiHandleSink *mhsink, GstMultiHandleClient *client);
|
||||
GstMultiHandleClient* (*new_client) (GstMultiHandleSink *mhsink, GstMultiSinkHandle handle, GstSyncMethod sync_method);
|
||||
|
||||
|
||||
GstStructure* (*get_stats) (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
void (*remove_client_link) (GstMultiHandleSink * sink, GList * link);
|
||||
|
||||
|
||||
/* vtable */
|
||||
|
@ -297,31 +297,31 @@ struct _GstMultiHandleSinkClass {
|
|||
/* signals */
|
||||
void (*client_added) (GstElement *element, GstMultiSinkHandle handle);
|
||||
void (*client_removed) (GstElement *element, GstMultiSinkHandle handle, GstClientStatus status);
|
||||
void (*client_socket_removed) (GstElement *element, GstMultiSinkHandle handle);
|
||||
void (*client_handle_removed) (GstElement *element, GstMultiSinkHandle handle);
|
||||
|
||||
guint signals[GST_MULTI_HANDLE_LAST_SIGNAL];
|
||||
};
|
||||
|
||||
GType gst_multi_handle_sink_get_type (void);
|
||||
|
||||
void gst_multi_handle_sink_add (GstMultiHandleSink *sink, GSocket *socket);
|
||||
void gst_multi_handle_sink_add_full (GstMultiHandleSink *sink, GSocket *socket, GstSyncMethod sync,
|
||||
void gst_multi_handle_sink_add (GstMultiHandleSink *sink, GstMultiSinkHandle);
|
||||
void gst_multi_handle_sink_add_full (GstMultiHandleSink *sink, GstMultiSinkHandle, GstSyncMethod sync,
|
||||
GstFormat min_format, guint64 min_value,
|
||||
GstFormat max_format, guint64 max_value);
|
||||
void gst_multi_handle_sink_remove (GstMultiHandleSink *sink, GSocket *socket);
|
||||
void gst_multi_handle_sink_remove_flush (GstMultiHandleSink *sink, GSocket *socket);
|
||||
GstStructure* gst_multi_handle_sink_get_stats (GstMultiHandleSink *sink, GSocket *socket);
|
||||
void gst_multi_handle_sink_remove (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_handle_sink_remove_flush (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
GstStructure* gst_multi_handle_sink_get_stats (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_handle_sink_remove_client_link (GstMultiHandleSink * sink,
|
||||
GList * link);
|
||||
|
||||
void gst_multi_handle_sink_client_init (GstMultiHandleClient * client, GstSyncMethod sync_method);
|
||||
|
||||
// FIXME: make static again after refactoring
|
||||
#define GST_TYPE_RECOVER_POLICY (gst_multi_handle_sink_recover_policy_get_type())
|
||||
GType
|
||||
gst_multi_handle_sink_recover_policy_get_type (void);
|
||||
GType gst_multi_handle_sink_recover_policy_get_type (void);
|
||||
#define GST_TYPE_SYNC_METHOD (gst_multi_handle_sink_sync_method_get_type())
|
||||
GType
|
||||
gst_multi_handle_sink_sync_method_get_type (void);
|
||||
GType gst_multi_handle_sink_sync_method_get_type (void);
|
||||
#define GST_TYPE_CLIENT_STATUS (gst_multi_handle_sink_client_status_get_type())
|
||||
GType
|
||||
gst_multi_handle_sink_client_status_get_type (void);
|
||||
GType gst_multi_handle_sink_client_status_get_type (void);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -69,43 +69,18 @@ struct _GstMultiSocketSink {
|
|||
/*< private >*/
|
||||
GMainContext *main_context;
|
||||
GCancellable *cancellable;
|
||||
|
||||
guint8 header_flags;
|
||||
};
|
||||
|
||||
struct _GstMultiSocketSinkClass {
|
||||
GstMultiHandleSinkClass parent_class;
|
||||
|
||||
/* element methods */
|
||||
void (*add) (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void (*add_full) (GstMultiSocketSink *sink, GstMultiSinkHandle handle, GstSyncMethod sync,
|
||||
GstFormat format, guint64 value,
|
||||
GstFormat max_format, guint64 max_value);
|
||||
void (*remove) (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void (*remove_flush) (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void (*clear) (GstMultiSocketSink *sink);
|
||||
GstStructure* (*get_stats) (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
/* vtable */
|
||||
void (*removed) (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
/* signals */
|
||||
void (*client_added) (GstElement *element, GstMultiSinkHandle handle);
|
||||
void (*client_removed) (GstElement *element, GstMultiSinkHandle handle, GstClientStatus status);
|
||||
void (*client_socket_removed) (GstElement *element, GstMultiSinkHandle handle);
|
||||
};
|
||||
|
||||
GType gst_multi_socket_sink_get_type (void);
|
||||
|
||||
void gst_multi_socket_sink_add (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_socket_sink_add_full (GstMultiSocketSink *sink, GstMultiSinkHandle handle, GstSyncMethod sync,
|
||||
GstFormat min_format, guint64 min_value,
|
||||
GstFormat max_format, guint64 max_value);
|
||||
void gst_multi_socket_sink_remove (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_socket_sink_remove_flush (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
void gst_multi_socket_sink_clear (GstMultiHandleSink *sink);
|
||||
GstStructure* gst_multi_socket_sink_get_stats (GstMultiSocketSink *sink, GstMultiSinkHandle handle);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_MULTI_SOCKET_SINK_H__ */
|
||||
|
|
|
@ -77,12 +77,10 @@ gst_tcp_server_sink_class_init (GstTCPServerSinkClass * klass)
|
|||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstMultiHandleSinkClass *gstmultihandlesink_class;
|
||||
GstMultiSocketSinkClass *gstmultifdsink_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstmultihandlesink_class = (GstMultiHandleSinkClass *) klass;
|
||||
gstmultifdsink_class = (GstMultiSocketSinkClass *) klass;
|
||||
|
||||
gobject_class->set_property = gst_tcp_server_sink_set_property;
|
||||
gobject_class->get_property = gst_tcp_server_sink_get_property;
|
||||
|
@ -103,7 +101,7 @@ gst_tcp_server_sink_class_init (GstTCPServerSinkClass * klass)
|
|||
|
||||
gstmultihandlesink_class->init = gst_tcp_server_sink_init_send;
|
||||
gstmultihandlesink_class->close = gst_tcp_server_sink_close;
|
||||
gstmultifdsink_class->removed = gst_tcp_server_sink_removed;
|
||||
gstmultihandlesink_class->removed = gst_tcp_server_sink_removed;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (tcpserversink_debug, "tcpserversink", 0, "TCP sink");
|
||||
}
|
||||
|
@ -147,7 +145,7 @@ gst_tcp_server_sink_handle_server_read (GstTCPServerSink * sink)
|
|||
if (!client_socket)
|
||||
goto accept_failed;
|
||||
|
||||
gst_multi_socket_sink_add (GST_MULTI_SOCKET_SINK (sink),
|
||||
gst_multi_handle_sink_add (GST_MULTI_HANDLE_SINK (sink),
|
||||
(GstMultiSinkHandle) client_socket);
|
||||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
|
|
Loading…
Reference in a new issue