mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
multifdsink: Move multifdsink from gst-plugins-base to gst-plugins-bad
This commit is contained in:
parent
699677ed8a
commit
90c075b1f6
7 changed files with 4133 additions and 0 deletions
16
configure.ac
16
configure.ac
|
@ -144,6 +144,20 @@ if test "x$HAVE_UNISTD_H" != "xyes"; then
|
||||||
GST_PLUGINS_SELECTED=`echo $GST_PLUGINS_SELECTED | $SED -e s/festival//`
|
GST_PLUGINS_SELECTED=`echo $GST_PLUGINS_SELECTED | $SED -e s/festival//`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
dnl used in gst/multifdsink
|
||||||
|
AC_CHECK_HEADERS([sys/socket.h],
|
||||||
|
HAVE_SYS_SOCKET_H="yes", HAVE_SYS_SOCKET_H="no")
|
||||||
|
AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "x$HAVE_SYS_SOCKET_H" = "xyes")
|
||||||
|
|
||||||
|
dnl disable plug-ins that require sys/socket.h if it is not available
|
||||||
|
if test "x$HAVE_SYS_SOCKET_H" != "xyes"; then
|
||||||
|
AG_GST_DISABLE_PLUGIN(multifdsink)
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Check for FIONREAD ioctl declaration
|
||||||
|
dnl used in gst/multifdsink
|
||||||
|
GST_CHECK_FIONREAD
|
||||||
|
|
||||||
dnl used by camerabin
|
dnl used by camerabin
|
||||||
AC_CHECK_HEADERS([sys/time.h])
|
AC_CHECK_HEADERS([sys/time.h])
|
||||||
|
|
||||||
|
@ -354,6 +368,7 @@ AG_GST_CHECK_PLUGIN(mpegtsdemux)
|
||||||
AG_GST_CHECK_PLUGIN(mpegtsmux)
|
AG_GST_CHECK_PLUGIN(mpegtsmux)
|
||||||
AG_GST_CHECK_PLUGIN(mpegpsmux)
|
AG_GST_CHECK_PLUGIN(mpegpsmux)
|
||||||
AG_GST_CHECK_PLUGIN(mpegvideoparse)
|
AG_GST_CHECK_PLUGIN(mpegvideoparse)
|
||||||
|
AG_GST_CHECK_PLUGIN(multifdsink)
|
||||||
AG_GST_CHECK_PLUGIN(mve)
|
AG_GST_CHECK_PLUGIN(mve)
|
||||||
AG_GST_CHECK_PLUGIN(mxf)
|
AG_GST_CHECK_PLUGIN(mxf)
|
||||||
AG_GST_CHECK_PLUGIN(nsf)
|
AG_GST_CHECK_PLUGIN(nsf)
|
||||||
|
@ -1967,6 +1982,7 @@ gst/mpegtsmux/Makefile
|
||||||
gst/mpegtsmux/tsmux/Makefile
|
gst/mpegtsmux/tsmux/Makefile
|
||||||
gst/mpegpsmux/Makefile
|
gst/mpegpsmux/Makefile
|
||||||
gst/mpegvideoparse/Makefile
|
gst/mpegvideoparse/Makefile
|
||||||
|
gst/multifdsink/Makefile
|
||||||
gst/mve/Makefile
|
gst/mve/Makefile
|
||||||
gst/mxf/Makefile
|
gst/mxf/Makefile
|
||||||
gst/nsf/Makefile
|
gst/nsf/Makefile
|
||||||
|
|
47
gst/multifdsink/Makefile.am
Normal file
47
gst/multifdsink/Makefile.am
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
plugin_LTLIBRARIES = libgstmultifdsink.la
|
||||||
|
|
||||||
|
# variables used for enum/marshal generation
|
||||||
|
glib_enum_headers = gstmultifdsink.h
|
||||||
|
glib_enum_define = GST_MULTI_FD_SINK
|
||||||
|
glib_gen_prefix = gst_multi_fd_sink
|
||||||
|
glib_gen_basename = gstmultifdsink
|
||||||
|
|
||||||
|
include $(top_srcdir)/common/gst-glib-gen.mak
|
||||||
|
|
||||||
|
built_sources = gstmultifdsink-enumtypes.c gstmultifdsink-marshal.c
|
||||||
|
built_headers = gstmultifdsink-enumtypes.h gstmultifdsink-marshal.h
|
||||||
|
|
||||||
|
BUILT_SOURCES = $(built_sources) $(built_headers)
|
||||||
|
|
||||||
|
libgstmultifdsink_la_SOURCES = \
|
||||||
|
gstmultifdsink.c
|
||||||
|
|
||||||
|
nodist_libgstmultifdsink_la_SOURCES = \
|
||||||
|
$(built_sources)
|
||||||
|
|
||||||
|
libgstmultifdsink_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||||
|
libgstmultifdsink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
|
libgstmultifdsink_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
|
||||||
|
libgstmultifdsink_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
||||||
|
noinst_HEADERS = \
|
||||||
|
gstmultifdsink.h
|
||||||
|
|
||||||
|
CLEANFILES = $(BUILT_SOURCES)
|
||||||
|
|
||||||
|
EXTRA_DIST = gstmultifdsink-marshal.list
|
||||||
|
|
||||||
|
Android.mk: Makefile.am $(BUILT_SOURCES)
|
||||||
|
androgenizer \
|
||||||
|
-:PROJECT libgstmultifdsink -:SHARED libgstmultifdsink \
|
||||||
|
-:TAGS eng debug \
|
||||||
|
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
|
||||||
|
-:SOURCES $(libgstmultifdsink_la_SOURCES) \
|
||||||
|
$(nodist_libgstmultifdsink_la_SOURCES) \
|
||||||
|
-:CFLAGS $(DEFS) $(DEFAULT_INCLUDES) $(libgstmultifdsink_la_CFLAGS) \
|
||||||
|
-:LDFLAGS $(libgstmultifdsink_la_LDFLAGS) \
|
||||||
|
$(libgstmultifdsink_la_LIBADD) \
|
||||||
|
-ldl \
|
||||||
|
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
|
||||||
|
LOCAL_MODULE_PATH:='$$(TARGET_OUT)/lib/gstreamer-0.10' \
|
||||||
|
> $@
|
5
gst/multifdsink/gstmultifdsink-marshal.list
Normal file
5
gst/multifdsink/gstmultifdsink-marshal.list
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
VOID:STRING,UINT
|
||||||
|
VOID:INT
|
||||||
|
VOID:INT,ENUM
|
||||||
|
VOID:INT,ENUM,INT,UINT64,INT,UINT64
|
||||||
|
BOXED:INT
|
2915
gst/multifdsink/gstmultifdsink.c
Normal file
2915
gst/multifdsink/gstmultifdsink.c
Normal file
File diff suppressed because it is too large
Load diff
283
gst/multifdsink/gstmultifdsink.h
Normal file
283
gst/multifdsink/gstmultifdsink.h
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||||
|
* Copyright (C) <2004> Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __GST_MULTI_FD_SINK_H__
|
||||||
|
#define __GST_MULTI_FD_SINK_H__
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#include <gst/base/gstbasesink.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_MULTI_FD_SINK \
|
||||||
|
(gst_multi_fd_sink_get_type())
|
||||||
|
#define GST_MULTI_FD_SINK(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTI_FD_SINK,GstMultiFdSink))
|
||||||
|
#define GST_MULTI_FD_SINK_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTI_FD_SINK,GstMultiFdSinkClass))
|
||||||
|
#define GST_IS_MULTI_FD_SINK(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTI_FD_SINK))
|
||||||
|
#define GST_IS_MULTI_FD_SINK_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTI_FD_SINK))
|
||||||
|
#define GST_MULTI_FD_SINK_GET_CLASS(klass) \
|
||||||
|
(G_TYPE_INSTANCE_GET_CLASS ((klass), GST_TYPE_MULTI_FD_SINK, GstMultiFdSinkClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GstMultiFdSink GstMultiFdSink;
|
||||||
|
typedef struct _GstMultiFdSinkClass GstMultiFdSinkClass;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
GST_MULTI_FD_SINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
|
||||||
|
|
||||||
|
GST_MULTI_FD_SINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
|
||||||
|
} GstMultiFdSinkFlags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstRecoverPolicy:
|
||||||
|
* @GST_RECOVER_POLICY_NONE : no recovering is done
|
||||||
|
* @GST_RECOVER_POLICY_RESYNC_LATEST : client is moved to last buffer
|
||||||
|
* @GST_RECOVER_POLICY_RESYNC_SOFT_LIMIT: client is moved to the soft limit
|
||||||
|
* @GST_RECOVER_POLICY_RESYNC_KEYFRAME : client is moved to latest keyframe
|
||||||
|
*
|
||||||
|
* Possible values for the recovery procedure to use when a client consumes
|
||||||
|
* data too slow and has a backlag of more that soft-limit buffers.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_RECOVER_POLICY_NONE,
|
||||||
|
GST_RECOVER_POLICY_RESYNC_LATEST,
|
||||||
|
GST_RECOVER_POLICY_RESYNC_SOFT_LIMIT,
|
||||||
|
GST_RECOVER_POLICY_RESYNC_KEYFRAME
|
||||||
|
} GstRecoverPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstSyncMethod:
|
||||||
|
* @GST_SYNC_METHOD_LATEST : client receives most recent buffer
|
||||||
|
* @GST_SYNC_METHOD_NEXT_KEYFRAME : client receives next keyframe
|
||||||
|
* @GST_SYNC_METHOD_LATEST_KEYFRAME : client receives latest keyframe (burst)
|
||||||
|
* @GST_SYNC_METHOD_BURST : client receives specific amount of data
|
||||||
|
* @GST_SYNC_METHOD_BURST_KEYFRAME : client receives specific amount of data
|
||||||
|
* starting from latest keyframe
|
||||||
|
* @GST_SYNC_METHOD_BURST_WITH_KEYFRAME : client receives specific amount of data from
|
||||||
|
* a keyframe, or if there is not enough data after
|
||||||
|
* the keyframe, starting before the keyframe
|
||||||
|
*
|
||||||
|
* This enum defines the selection of the first buffer that is sent
|
||||||
|
* to a new client.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_SYNC_METHOD_LATEST,
|
||||||
|
GST_SYNC_METHOD_NEXT_KEYFRAME,
|
||||||
|
GST_SYNC_METHOD_LATEST_KEYFRAME,
|
||||||
|
GST_SYNC_METHOD_BURST,
|
||||||
|
GST_SYNC_METHOD_BURST_KEYFRAME,
|
||||||
|
GST_SYNC_METHOD_BURST_WITH_KEYFRAME
|
||||||
|
} GstSyncMethod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstTCPUnitType:
|
||||||
|
* @GST_TCP_UNIT_TYPE_UNDEFINED: undefined
|
||||||
|
* @GST_TCP_UNIT_TYPE_BUFFERS : buffers
|
||||||
|
* @GST_TCP_UNIT_TYPE_TIME : timeunits (in nanoseconds)
|
||||||
|
* @GST_TCP_UNIT_TYPE_BYTES : bytes
|
||||||
|
*
|
||||||
|
* The units used to specify limits.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_TCP_UNIT_TYPE_UNDEFINED,
|
||||||
|
GST_TCP_UNIT_TYPE_BUFFERS,
|
||||||
|
GST_TCP_UNIT_TYPE_TIME,
|
||||||
|
GST_TCP_UNIT_TYPE_BYTES
|
||||||
|
} GstTCPUnitType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstClientStatus:
|
||||||
|
* @GST_CLIENT_STATUS_OK : client is ok
|
||||||
|
* @GST_CLIENT_STATUS_CLOSED : client closed the socket
|
||||||
|
* @GST_CLIENT_STATUS_REMOVED : client is removed
|
||||||
|
* @GST_CLIENT_STATUS_SLOW : client is too slow
|
||||||
|
* @GST_CLIENT_STATUS_ERROR : client is in error
|
||||||
|
* @GST_CLIENT_STATUS_DUPLICATE: same client added twice
|
||||||
|
* @GST_CLIENT_STATUS_FLUSHING : client is flushing out the remaining buffers.
|
||||||
|
*
|
||||||
|
* This specifies the reason why a client was removed from
|
||||||
|
* multifdsink and is received in the "client-removed" signal.
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GST_CLIENT_STATUS_OK = 0,
|
||||||
|
GST_CLIENT_STATUS_CLOSED = 1,
|
||||||
|
GST_CLIENT_STATUS_REMOVED = 2,
|
||||||
|
GST_CLIENT_STATUS_SLOW = 3,
|
||||||
|
GST_CLIENT_STATUS_ERROR = 4,
|
||||||
|
GST_CLIENT_STATUS_DUPLICATE = 5,
|
||||||
|
GST_CLIENT_STATUS_FLUSHING = 6
|
||||||
|
} GstClientStatus;
|
||||||
|
|
||||||
|
/* structure for a client
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
GstPollFD fd;
|
||||||
|
|
||||||
|
gint bufpos; /* position of this client in the global queue */
|
||||||
|
gint flushcount; /* the remaining number of buffers to flush out or -1 if the
|
||||||
|
client is not flushing. */
|
||||||
|
|
||||||
|
GstClientStatus status;
|
||||||
|
gboolean is_socket;
|
||||||
|
|
||||||
|
GSList *sending; /* the buffers we need to send */
|
||||||
|
gint bufoffset; /* offset in the first buffer */
|
||||||
|
|
||||||
|
gboolean discont;
|
||||||
|
|
||||||
|
gboolean caps_sent;
|
||||||
|
gboolean new_connection;
|
||||||
|
|
||||||
|
gboolean currently_removing;
|
||||||
|
|
||||||
|
/* method to sync client when connecting */
|
||||||
|
GstSyncMethod sync_method;
|
||||||
|
GstTCPUnitType burst_min_unit;
|
||||||
|
guint64 burst_min_value;
|
||||||
|
GstTCPUnitType burst_max_unit;
|
||||||
|
guint64 burst_max_value;
|
||||||
|
|
||||||
|
GstCaps *caps; /* caps of last queued buffer */
|
||||||
|
|
||||||
|
/* stats */
|
||||||
|
guint64 bytes_sent;
|
||||||
|
guint64 connect_time;
|
||||||
|
guint64 disconnect_time;
|
||||||
|
guint64 last_activity_time;
|
||||||
|
guint64 dropped_buffers;
|
||||||
|
guint64 avg_queue_size;
|
||||||
|
guint64 first_buffer_ts;
|
||||||
|
guint64 last_buffer_ts;
|
||||||
|
} GstTCPClient;
|
||||||
|
|
||||||
|
#define CLIENTS_LOCK_INIT(fdsink) (g_static_rec_mutex_init(&fdsink->clientslock))
|
||||||
|
#define CLIENTS_LOCK_FREE(fdsink) (g_static_rec_mutex_free(&fdsink->clientslock))
|
||||||
|
#define CLIENTS_LOCK(fdsink) (g_static_rec_mutex_lock(&fdsink->clientslock))
|
||||||
|
#define CLIENTS_UNLOCK(fdsink) (g_static_rec_mutex_unlock(&fdsink->clientslock))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstMultiFdSink:
|
||||||
|
*
|
||||||
|
* The multifdsink object structure.
|
||||||
|
*/
|
||||||
|
struct _GstMultiFdSink {
|
||||||
|
GstBaseSink element;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
guint64 bytes_to_serve; /* how much bytes we must serve */
|
||||||
|
guint64 bytes_served; /* how much bytes have we served */
|
||||||
|
|
||||||
|
GStaticRecMutex clientslock; /* lock to protect the clients list */
|
||||||
|
GList *clients; /* list of clients we are serving */
|
||||||
|
GHashTable *fd_hash; /* index on fd to client */
|
||||||
|
guint clients_cookie; /* Cookie to detect changes to the clients list */
|
||||||
|
|
||||||
|
gint mode;
|
||||||
|
GstPoll *fdset;
|
||||||
|
|
||||||
|
GSList *streamheader; /* GSList of GstBuffers to use as streamheader */
|
||||||
|
gboolean previous_buffer_in_caps;
|
||||||
|
|
||||||
|
guint mtu;
|
||||||
|
gint qos_dscp;
|
||||||
|
gboolean handle_read;
|
||||||
|
|
||||||
|
GArray *bufqueue; /* global queue of buffers */
|
||||||
|
|
||||||
|
gboolean running; /* the thread state */
|
||||||
|
GThread *thread; /* the sender thread */
|
||||||
|
|
||||||
|
/* these values are used to check if a client is reading fast
|
||||||
|
* enough and to control receovery */
|
||||||
|
GstTCPUnitType unit_type;/* the type of the units */
|
||||||
|
gint64 units_max; /* max units to queue for a client */
|
||||||
|
gint64 units_soft_max; /* max units a client can lag before recovery starts */
|
||||||
|
GstRecoverPolicy recover_policy;
|
||||||
|
GstClockTime timeout; /* max amount of nanoseconds to remain idle */
|
||||||
|
|
||||||
|
GstSyncMethod def_sync_method; /* what method to use for connecting clients */
|
||||||
|
GstTCPUnitType def_burst_unit;
|
||||||
|
guint64 def_burst_value;
|
||||||
|
|
||||||
|
/* these values are used to control the amount of data
|
||||||
|
* kept in the queues. It allows clients to perform a burst
|
||||||
|
* on connect. */
|
||||||
|
gint bytes_min; /* min number of bytes to queue */
|
||||||
|
gint64 time_min; /* min time to queue */
|
||||||
|
gint buffers_min; /* min number of buffers to queue */
|
||||||
|
|
||||||
|
gboolean resend_streamheader; /* resend streamheader if it changes */
|
||||||
|
|
||||||
|
/* stats */
|
||||||
|
gint buffers_queued; /* number of queued buffers */
|
||||||
|
gint bytes_queued; /* number of queued bytes */
|
||||||
|
gint time_queued; /* number of queued time */
|
||||||
|
|
||||||
|
guint8 header_flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GstMultiFdSinkClass {
|
||||||
|
GstBaseSinkClass parent_class;
|
||||||
|
|
||||||
|
/* element methods */
|
||||||
|
void (*add) (GstMultiFdSink *sink, int fd);
|
||||||
|
void (*add_full) (GstMultiFdSink *sink, int fd, GstSyncMethod sync,
|
||||||
|
GstTCPUnitType format, guint64 value,
|
||||||
|
GstTCPUnitType max_unit, guint64 max_value);
|
||||||
|
void (*remove) (GstMultiFdSink *sink, int fd);
|
||||||
|
void (*remove_flush) (GstMultiFdSink *sink, int fd);
|
||||||
|
void (*clear) (GstMultiFdSink *sink);
|
||||||
|
GValueArray* (*get_stats) (GstMultiFdSink *sink, int fd);
|
||||||
|
|
||||||
|
/* vtable */
|
||||||
|
gboolean (*init) (GstMultiFdSink *sink);
|
||||||
|
gboolean (*wait) (GstMultiFdSink *sink, GstPoll *set);
|
||||||
|
gboolean (*close) (GstMultiFdSink *sink);
|
||||||
|
void (*removed) (GstMultiFdSink *sink, int fd);
|
||||||
|
|
||||||
|
/* signals */
|
||||||
|
void (*client_added) (GstElement *element, gint fd);
|
||||||
|
void (*client_removed) (GstElement *element, gint fd, GstClientStatus status);
|
||||||
|
void (*client_fd_removed) (GstElement *element, gint fd);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_multi_fd_sink_get_type (void);
|
||||||
|
|
||||||
|
void gst_multi_fd_sink_add (GstMultiFdSink *sink, int fd);
|
||||||
|
void gst_multi_fd_sink_add_full (GstMultiFdSink *sink, int fd, GstSyncMethod sync,
|
||||||
|
GstTCPUnitType min_unit, guint64 min_value,
|
||||||
|
GstTCPUnitType max_unit, guint64 max_value);
|
||||||
|
void gst_multi_fd_sink_remove (GstMultiFdSink *sink, int fd);
|
||||||
|
void gst_multi_fd_sink_remove_flush (GstMultiFdSink *sink, int fd);
|
||||||
|
void gst_multi_fd_sink_clear (GstMultiFdSink *sink);
|
||||||
|
GValueArray* gst_multi_fd_sink_get_stats (GstMultiFdSink *sink, int fd);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_MULTI_FD_SINK_H__ */
|
|
@ -193,6 +193,7 @@ check_PROGRAMS = \
|
||||||
elements/mpegtsmux \
|
elements/mpegtsmux \
|
||||||
elements/mpegvideoparse \
|
elements/mpegvideoparse \
|
||||||
elements/mpeg4videoparse \
|
elements/mpeg4videoparse \
|
||||||
|
elements/multifdsink \
|
||||||
elements/mxfdemux \
|
elements/mxfdemux \
|
||||||
elements/mxfmux \
|
elements/mxfmux \
|
||||||
elements/id3mux \
|
elements/id3mux \
|
||||||
|
|
866
tests/check/elements/multifdsink.c
Normal file
866
tests/check/elements/multifdsink.c
Normal file
|
@ -0,0 +1,866 @@
|
||||||
|
/* GStreamer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#ifdef HAVE_FIONREAD_IN_SYS_FILIO
|
||||||
|
#include <sys/filio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <gst/check/gstcheck.h>
|
||||||
|
|
||||||
|
static GstPad *mysrcpad;
|
||||||
|
|
||||||
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
GST_PAD_SRC,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("application/x-gst-check")
|
||||||
|
);
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
setup_multifdsink (void)
|
||||||
|
{
|
||||||
|
GstElement *multifdsink;
|
||||||
|
|
||||||
|
GST_DEBUG ("setup_multifdsink");
|
||||||
|
multifdsink = gst_check_setup_element ("multifdsink");
|
||||||
|
mysrcpad = gst_check_setup_src_pad (multifdsink, &srctemplate);
|
||||||
|
|
||||||
|
return multifdsink;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup_multifdsink (GstElement * multifdsink)
|
||||||
|
{
|
||||||
|
GST_DEBUG ("cleanup_multifdsink");
|
||||||
|
|
||||||
|
gst_check_teardown_src_pad (multifdsink);
|
||||||
|
gst_check_teardown_element (multifdsink);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
wait_bytes_served (GstElement * sink, guint64 bytes)
|
||||||
|
{
|
||||||
|
guint64 bytes_served = 0;
|
||||||
|
|
||||||
|
while (bytes_served != bytes) {
|
||||||
|
g_object_get (sink, "bytes-served", &bytes_served, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: possibly racy, since if it would write, we may not get it
|
||||||
|
* immediately ? */
|
||||||
|
#define fail_if_can_read(msg,fd) \
|
||||||
|
G_STMT_START { \
|
||||||
|
long avail; \
|
||||||
|
\
|
||||||
|
fail_if (ioctl (fd, FIONREAD, &avail) < 0, "%s: could not ioctl", msg); \
|
||||||
|
fail_if (avail > 0, "%s: has bytes available to read"); \
|
||||||
|
} G_STMT_END;
|
||||||
|
|
||||||
|
|
||||||
|
GST_START_TEST (test_no_clients)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
buffer = gst_buffer_new_and_alloc (4);
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_add_client)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd[2];
|
||||||
|
gchar data[4];
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
|
||||||
|
fail_if (pipe (pfd) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
/* add the client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd[1]);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||||
|
buffer = gst_buffer_new_and_alloc (4);
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
|
||||||
|
gst_buffer_fill (buffer, 0, "dead", 4);
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
|
||||||
|
GST_DEBUG ("reading");
|
||||||
|
fail_if (read (pfd[0], data, 4) < 4);
|
||||||
|
fail_unless (strncmp (data, "dead", 4) == 0);
|
||||||
|
wait_bytes_served (sink, 4);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
#define fail_unless_read(msg,fd,size,ref) \
|
||||||
|
G_STMT_START { \
|
||||||
|
char data[size + 1]; \
|
||||||
|
int nbytes; \
|
||||||
|
\
|
||||||
|
GST_DEBUG ("%s: reading %d bytes", msg, size); \
|
||||||
|
nbytes = read (fd, data, size); \
|
||||||
|
data[size] = 0; \
|
||||||
|
GST_DEBUG ("%s: read %d bytes", msg, nbytes); \
|
||||||
|
fail_if (nbytes < size); \
|
||||||
|
fail_unless (memcmp (data, ref, size) == 0, \
|
||||||
|
"data read '%s' differs from '%s'", data, ref); \
|
||||||
|
} G_STMT_END;
|
||||||
|
|
||||||
|
/* from the given two data buffers, create two streamheader buffers and
|
||||||
|
* some caps that match it, and store them in the given pointers
|
||||||
|
* returns one ref to each of the buffers and the caps */
|
||||||
|
static void
|
||||||
|
gst_multifdsink_create_streamheader (const gchar * data1,
|
||||||
|
const gchar * data2, GstBuffer ** hbuf1, GstBuffer ** hbuf2,
|
||||||
|
GstCaps ** caps)
|
||||||
|
{
|
||||||
|
GstBuffer *buf;
|
||||||
|
GValue array = { 0 };
|
||||||
|
GValue value = { 0 };
|
||||||
|
GstStructure *structure;
|
||||||
|
guint size1 = strlen (data1);
|
||||||
|
guint size2 = strlen (data2);
|
||||||
|
|
||||||
|
fail_if (hbuf1 == NULL);
|
||||||
|
fail_if (hbuf2 == NULL);
|
||||||
|
fail_if (caps == NULL);
|
||||||
|
|
||||||
|
/* create caps with streamheader, set the caps, and push the IN_CAPS
|
||||||
|
* buffers */
|
||||||
|
*hbuf1 = gst_buffer_new_and_alloc (size1);
|
||||||
|
GST_BUFFER_FLAG_SET (*hbuf1, GST_BUFFER_FLAG_IN_CAPS);
|
||||||
|
gst_buffer_fill (*hbuf1, 0, data1, size1);
|
||||||
|
*hbuf2 = gst_buffer_new_and_alloc (size2);
|
||||||
|
GST_BUFFER_FLAG_SET (*hbuf2, GST_BUFFER_FLAG_IN_CAPS);
|
||||||
|
gst_buffer_fill (*hbuf2, 0, data2, size2);
|
||||||
|
|
||||||
|
g_value_init (&array, GST_TYPE_ARRAY);
|
||||||
|
|
||||||
|
g_value_init (&value, GST_TYPE_BUFFER);
|
||||||
|
/* we take a copy, set it on the array (which refs it), then unref our copy */
|
||||||
|
buf = gst_buffer_copy (*hbuf1);
|
||||||
|
gst_value_set_buffer (&value, buf);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (buf, "copied buffer", 2);
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
gst_value_array_append_value (&array, &value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
|
g_value_init (&value, GST_TYPE_BUFFER);
|
||||||
|
buf = gst_buffer_copy (*hbuf2);
|
||||||
|
gst_value_set_buffer (&value, buf);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (buf, "copied buffer", 2);
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
gst_value_array_append_value (&array, &value);
|
||||||
|
g_value_unset (&value);
|
||||||
|
|
||||||
|
*caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
structure = gst_caps_get_structure (*caps, 0);
|
||||||
|
|
||||||
|
gst_structure_set_value (structure, "streamheader", &array);
|
||||||
|
g_value_unset (&array);
|
||||||
|
ASSERT_CAPS_REFCOUNT (*caps, "streamheader caps", 1);
|
||||||
|
|
||||||
|
/* we want to keep them around for the tests */
|
||||||
|
gst_buffer_ref (*hbuf1);
|
||||||
|
gst_buffer_ref (*hbuf2);
|
||||||
|
|
||||||
|
GST_DEBUG ("created streamheader caps %p %" GST_PTR_FORMAT, *caps, *caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* this test:
|
||||||
|
* - adds a first client
|
||||||
|
* - sets streamheader caps on the pad
|
||||||
|
* - pushes the IN_CAPS buffers
|
||||||
|
* - pushes a buffer
|
||||||
|
* - verifies that the client received all the data correctly, and did not
|
||||||
|
* get multiple copies of the streamheader
|
||||||
|
* - adds a second client
|
||||||
|
* - verifies that this second client receives the streamheader caps too, plus
|
||||||
|
* - the new buffer
|
||||||
|
*/
|
||||||
|
GST_START_TEST (test_streamheader)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *hbuf1, *hbuf2, *buf;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2], pfd2[2];
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
fail_if (pipe (pfd2) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
/* add the first client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
|
||||||
|
/* create caps with streamheader, set the caps, and push the IN_CAPS
|
||||||
|
* buffers */
|
||||||
|
gst_multifdsink_create_streamheader ("babe", "deadbeef", &hbuf1, &hbuf2,
|
||||||
|
&caps);
|
||||||
|
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||||
|
/* one is ours, two on the buffers, and one now on the pad */
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 4);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf1) == GST_FLOW_OK);
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf2) == GST_FLOW_OK);
|
||||||
|
|
||||||
|
//FIXME:
|
||||||
|
//fail_if_can_read ("first client", pfd1[0]);
|
||||||
|
|
||||||
|
/* push a non-IN_CAPS buffer, this should trigger the client receiving the
|
||||||
|
* first three buffers */
|
||||||
|
buf = gst_buffer_new_and_alloc (4);
|
||||||
|
gst_buffer_fill (buf, 0, "f00d", 4);
|
||||||
|
gst_pad_push (mysrcpad, buf);
|
||||||
|
|
||||||
|
fail_unless_read ("first client", pfd1[0], 4, "babe");
|
||||||
|
fail_unless_read ("first client", pfd1[0], 8, "deadbeef");
|
||||||
|
fail_unless_read ("first client", pfd1[0], 4, "f00d");
|
||||||
|
wait_bytes_served (sink, 16);
|
||||||
|
|
||||||
|
/* now add the second client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd2[1]);
|
||||||
|
//FIXME:
|
||||||
|
//fail_if_can_read ("second client", pfd2[0]);
|
||||||
|
|
||||||
|
/* now push another buffer, which will trigger streamheader for second
|
||||||
|
* client */
|
||||||
|
buf = gst_buffer_new_and_alloc (4);
|
||||||
|
gst_buffer_fill (buf, 0, "deaf", 4);
|
||||||
|
gst_pad_push (mysrcpad, buf);
|
||||||
|
|
||||||
|
fail_unless_read ("first client", pfd1[0], 4, "deaf");
|
||||||
|
|
||||||
|
fail_unless_read ("second client", pfd2[0], 4, "babe");
|
||||||
|
fail_unless_read ("second client", pfd2[0], 8, "deadbeef");
|
||||||
|
/* we missed the f00d buffer */
|
||||||
|
fail_unless_read ("second client", pfd2[0], 4, "deaf");
|
||||||
|
wait_bytes_served (sink, 36);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
|
||||||
|
g_signal_emit_by_name (sink, "remove", pfd1[1]);
|
||||||
|
g_signal_emit_by_name (sink, "remove", pfd2[1]);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf1, "hbuf1", 1);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf2, "hbuf2", 1);
|
||||||
|
gst_buffer_unref (hbuf1);
|
||||||
|
gst_buffer_unref (hbuf2);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* this tests changing of streamheaders
|
||||||
|
* - set streamheader caps on the pad
|
||||||
|
* - pushes the IN_CAPS buffers
|
||||||
|
* - pushes a buffer
|
||||||
|
* - add a first client
|
||||||
|
* - verifies that this first client receives the first streamheader caps,
|
||||||
|
* plus a new buffer
|
||||||
|
* - change streamheader caps
|
||||||
|
* - verify that the first client receives the new streamheader buffers as well
|
||||||
|
*/
|
||||||
|
GST_START_TEST (test_change_streamheader)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *hbuf1, *hbuf2, *buf;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2], pfd2[2];
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
fail_if (pipe (pfd2) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
/* create caps with streamheader, set the caps, and push the IN_CAPS
|
||||||
|
* buffers */
|
||||||
|
gst_multifdsink_create_streamheader ("first", "header", &hbuf1, &hbuf2,
|
||||||
|
&caps);
|
||||||
|
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||||
|
/* one is ours, two on the buffers, and one now on the pad */
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 4);
|
||||||
|
|
||||||
|
/* one to hold for the test and one to give away */
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf1, "hbuf1", 2);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf2, "hbuf2", 2);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf1) == GST_FLOW_OK);
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf2) == GST_FLOW_OK);
|
||||||
|
|
||||||
|
/* add the first client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
|
||||||
|
/* verify this hasn't triggered a write yet */
|
||||||
|
/* FIXME: possibly racy, since if it would write, we may not get it
|
||||||
|
* immediately ? */
|
||||||
|
//fail_if_can_read ("first client, no buffer", pfd1[0]);
|
||||||
|
|
||||||
|
/* now push a buffer and read */
|
||||||
|
buf = gst_buffer_new_and_alloc (4);
|
||||||
|
gst_buffer_fill (buf, 0, "f00d", 4);
|
||||||
|
gst_pad_push (mysrcpad, buf);
|
||||||
|
|
||||||
|
fail_unless_read ("change: first client", pfd1[0], 5, "first");
|
||||||
|
fail_unless_read ("change: first client", pfd1[0], 6, "header");
|
||||||
|
fail_unless_read ("change: first client", pfd1[0], 4, "f00d");
|
||||||
|
//wait_bytes_served (sink, 16);
|
||||||
|
|
||||||
|
/* now add the second client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd2[1]);
|
||||||
|
//fail_if_can_read ("second client, no buffer", pfd2[0]);
|
||||||
|
|
||||||
|
/* change the streamheader */
|
||||||
|
|
||||||
|
/* before we change, multifdsink still has a list of the old streamheaders */
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf1, "hbuf1", 2);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf2, "hbuf2", 2);
|
||||||
|
gst_buffer_unref (hbuf1);
|
||||||
|
gst_buffer_unref (hbuf2);
|
||||||
|
|
||||||
|
/* drop our ref to the previous caps */
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
gst_multifdsink_create_streamheader ("second", "header", &hbuf1, &hbuf2,
|
||||||
|
&caps);
|
||||||
|
fail_unless (gst_pad_set_caps (mysrcpad, caps));
|
||||||
|
/* one to hold for the test and one to give away */
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf1, "hbuf1", 2);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf2, "hbuf2", 2);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf1) == GST_FLOW_OK);
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, hbuf2) == GST_FLOW_OK);
|
||||||
|
|
||||||
|
/* verify neither client has new data available to read */
|
||||||
|
//fail_if_can_read ("first client, changed streamheader", pfd1[0]);
|
||||||
|
//fail_if_can_read ("second client, changed streamheader", pfd2[0]);
|
||||||
|
|
||||||
|
/* now push another buffer, which will trigger streamheader for second
|
||||||
|
* client, but should also send new streamheaders to first client */
|
||||||
|
buf = gst_buffer_new_and_alloc (8);
|
||||||
|
gst_buffer_fill (buf, 0, "deadbabe", 8);
|
||||||
|
gst_pad_push (mysrcpad, buf);
|
||||||
|
|
||||||
|
fail_unless_read ("first client", pfd1[0], 6, "second");
|
||||||
|
fail_unless_read ("first client", pfd1[0], 6, "header");
|
||||||
|
fail_unless_read ("first client", pfd1[0], 8, "deadbabe");
|
||||||
|
|
||||||
|
/* new streamheader data */
|
||||||
|
fail_unless_read ("second client", pfd2[0], 6, "second");
|
||||||
|
fail_unless_read ("second client", pfd2[0], 6, "header");
|
||||||
|
/* we missed the f00d buffer */
|
||||||
|
fail_unless_read ("second client", pfd2[0], 8, "deadbabe");
|
||||||
|
//wait_bytes_served (sink, 36);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
g_signal_emit_by_name (sink, "remove", pfd1[1]);
|
||||||
|
g_signal_emit_by_name (sink, "remove", pfd2[1]);
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
|
||||||
|
/* setting to NULL should have cleared the streamheader */
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf1, "hbuf1", 1);
|
||||||
|
ASSERT_BUFFER_REFCOUNT (hbuf2, "hbuf2", 1);
|
||||||
|
gst_buffer_unref (hbuf1);
|
||||||
|
gst_buffer_unref (hbuf2);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* keep 100 bytes and burst 80 bytes to clients */
|
||||||
|
GST_START_TEST (test_burst_client_bytes)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2];
|
||||||
|
int pfd2[2];
|
||||||
|
int pfd3[2];
|
||||||
|
gchar data[16];
|
||||||
|
gint i;
|
||||||
|
guint buffers_queued;
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
/* make sure we keep at least 100 bytes at all times */
|
||||||
|
g_object_set (sink, "bytes-min", 100, NULL);
|
||||||
|
g_object_set (sink, "sync-method", 3, NULL); /* 3 = burst */
|
||||||
|
g_object_set (sink, "burst-unit", 3, NULL); /* 3 = bytes */
|
||||||
|
g_object_set (sink, "burst-value", (guint64) 80, NULL);
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
fail_if (pipe (pfd2) == -1);
|
||||||
|
fail_if (pipe (pfd3) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||||
|
|
||||||
|
/* push buffers in, 9 * 16 bytes = 144 bytes */
|
||||||
|
for (i = 0; i < 9; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that at least 7 buffers (112 bytes) are in the queue */
|
||||||
|
g_object_get (sink, "buffers-queued", &buffers_queued, NULL);
|
||||||
|
fail_if (buffers_queued != 7);
|
||||||
|
|
||||||
|
/* now add the clients */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd2[1], 3,
|
||||||
|
3, (guint64) 50, 3, (guint64) 200);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd3[1], 3,
|
||||||
|
3, (guint64) 50, 3, (guint64) 50);
|
||||||
|
|
||||||
|
/* push last buffer to make client fds ready for reading */
|
||||||
|
for (i = 9; i < 10; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now we should only read the last 5 buffers (5 * 16 = 80 bytes) */
|
||||||
|
GST_DEBUG ("Reading from client 1");
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000005", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000006", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* second client only bursts 50 bytes = 4 buffers (we get 4 buffers since
|
||||||
|
* the max alows it) */
|
||||||
|
GST_DEBUG ("Reading from client 2");
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000006", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* third client only bursts 50 bytes = 4 buffers, we can't send
|
||||||
|
* more than 50 bytes so we only get 3 buffers (48 bytes). */
|
||||||
|
GST_DEBUG ("Reading from client 3");
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* keep 100 bytes and burst 80 bytes to clients */
|
||||||
|
GST_START_TEST (test_burst_client_bytes_keyframe)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2];
|
||||||
|
int pfd2[2];
|
||||||
|
int pfd3[2];
|
||||||
|
gchar data[16];
|
||||||
|
gint i;
|
||||||
|
guint buffers_queued;
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
/* make sure we keep at least 100 bytes at all times */
|
||||||
|
g_object_set (sink, "bytes-min", 100, NULL);
|
||||||
|
g_object_set (sink, "sync-method", 4, NULL); /* 3 = burst_keyframe */
|
||||||
|
g_object_set (sink, "burst-unit", 3, NULL); /* 3 = bytes */
|
||||||
|
g_object_set (sink, "burst-value", (guint64) 80, NULL);
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
fail_if (pipe (pfd2) == -1);
|
||||||
|
fail_if (pipe (pfd3) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
|
||||||
|
/* push buffers in, 9 * 16 bytes = 144 bytes */
|
||||||
|
for (i = 0; i < 9; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
|
||||||
|
/* mark most buffers as delta */
|
||||||
|
if (i != 0 && i != 4 && i != 8)
|
||||||
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that at least 7 buffers (112 bytes) are in the queue */
|
||||||
|
g_object_get (sink, "buffers-queued", &buffers_queued, NULL);
|
||||||
|
fail_if (buffers_queued != 7);
|
||||||
|
|
||||||
|
/* now add the clients */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd2[1], 4,
|
||||||
|
3, (guint64) 50, 3, (guint64) 90);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd3[1], 4,
|
||||||
|
3, (guint64) 50, 3, (guint64) 50);
|
||||||
|
|
||||||
|
/* push last buffer to make client fds ready for reading */
|
||||||
|
for (i = 9; i < 10; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now we should only read the last 6 buffers (min 5 * 16 = 80 bytes),
|
||||||
|
* keyframe at buffer 4 */
|
||||||
|
GST_DEBUG ("Reading from client 1");
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000004", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000005", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000006", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* second client only bursts 50 bytes = 4 buffers, there is
|
||||||
|
* no keyframe above min and below max, so get one below min */
|
||||||
|
GST_DEBUG ("Reading from client 2");
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* third client only bursts 50 bytes = 4 buffers, we can't send
|
||||||
|
* more than 50 bytes so we only get 2 buffers (32 bytes). */
|
||||||
|
GST_DEBUG ("Reading from client 3");
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* keep 100 bytes and burst 80 bytes to clients */
|
||||||
|
GST_START_TEST (test_burst_client_bytes_with_keyframe)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2];
|
||||||
|
int pfd2[2];
|
||||||
|
int pfd3[2];
|
||||||
|
gchar data[16];
|
||||||
|
gint i;
|
||||||
|
guint buffers_queued;
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
/* make sure we keep at least 100 bytes at all times */
|
||||||
|
g_object_set (sink, "bytes-min", 100, NULL);
|
||||||
|
g_object_set (sink, "sync-method", 5, NULL); /* 3 = burst_with_keyframe */
|
||||||
|
g_object_set (sink, "burst-unit", 3, NULL); /* 3 = bytes */
|
||||||
|
g_object_set (sink, "burst-value", (guint64) 80, NULL);
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
fail_if (pipe (pfd2) == -1);
|
||||||
|
fail_if (pipe (pfd3) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||||
|
|
||||||
|
/* push buffers in, 9 * 16 bytes = 144 bytes */
|
||||||
|
for (i = 0; i < 9; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
|
||||||
|
/* mark most buffers as delta */
|
||||||
|
if (i != 0 && i != 4 && i != 8)
|
||||||
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check that at least 7 buffers (112 bytes) are in the queue */
|
||||||
|
g_object_get (sink, "buffers-queued", &buffers_queued, NULL);
|
||||||
|
fail_if (buffers_queued != 7);
|
||||||
|
|
||||||
|
/* now add the clients */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd2[1], 5,
|
||||||
|
3, (guint64) 50, 3, (guint64) 90);
|
||||||
|
g_signal_emit_by_name (sink, "add_full", pfd3[1], 5,
|
||||||
|
3, (guint64) 50, 3, (guint64) 50);
|
||||||
|
|
||||||
|
/* push last buffer to make client fds ready for reading */
|
||||||
|
for (i = 9; i < 10; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now we should only read the last 6 buffers (min 5 * 16 = 80 bytes),
|
||||||
|
* keyframe at buffer 4 */
|
||||||
|
GST_DEBUG ("Reading from client 1");
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000004", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000005", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000006", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* second client only bursts 50 bytes = 4 buffers, there is
|
||||||
|
* no keyframe above min and below max, so send min */
|
||||||
|
GST_DEBUG ("Reading from client 2");
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000006", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd2[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
/* third client only bursts 50 bytes = 4 buffers, we can't send
|
||||||
|
* more than 50 bytes so we only get 3 buffers (48 bytes). */
|
||||||
|
GST_DEBUG ("Reading from client 3");
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000007", 16) == 0);
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000008", 16) == 0);
|
||||||
|
fail_if (read (pfd3[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000009", 16) == 0);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* Check that we can get data when multifdsink is configured in next-keyframe
|
||||||
|
* mode */
|
||||||
|
GST_START_TEST (test_client_next_keyframe)
|
||||||
|
{
|
||||||
|
GstElement *sink;
|
||||||
|
GstBuffer *buffer;
|
||||||
|
GstCaps *caps;
|
||||||
|
int pfd1[2];
|
||||||
|
gchar data[16];
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
sink = setup_multifdsink ();
|
||||||
|
g_object_set (sink, "sync-method", 1, NULL); /* 1 = next-keyframe */
|
||||||
|
|
||||||
|
fail_if (pipe (pfd1) == -1);
|
||||||
|
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_PLAYING, GST_STATE_CHANGE_ASYNC);
|
||||||
|
|
||||||
|
caps = gst_caps_from_string ("application/x-gst-check");
|
||||||
|
gst_pad_set_caps (mysrcpad, caps);
|
||||||
|
GST_DEBUG ("Created test caps %p %" GST_PTR_FORMAT, caps, caps);
|
||||||
|
|
||||||
|
/* now add our client */
|
||||||
|
g_signal_emit_by_name (sink, "add", pfd1[1]);
|
||||||
|
|
||||||
|
/* push buffers in: keyframe, then non-keyframe */
|
||||||
|
for (i = 0; i < 2; i++) {
|
||||||
|
gchar *data;
|
||||||
|
|
||||||
|
buffer = gst_buffer_new_and_alloc (16);
|
||||||
|
|
||||||
|
/* copy some id */
|
||||||
|
data = gst_buffer_map (buffer, NULL, NULL, GST_MAP_WRITE);
|
||||||
|
g_snprintf (data, 16, "deadbee%08x", i);
|
||||||
|
gst_buffer_unmap (buffer, data, 16);
|
||||||
|
if (i > 0)
|
||||||
|
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
|
||||||
|
|
||||||
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now we should be able to read some data */
|
||||||
|
GST_DEBUG ("Reading from client 1");
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000000", 16) == 0);
|
||||||
|
fail_if (read (pfd1[0], data, 16) < 16);
|
||||||
|
fail_unless (strncmp (data, "deadbee00000001", 16) == 0);
|
||||||
|
|
||||||
|
GST_DEBUG ("cleaning up multifdsink");
|
||||||
|
ASSERT_SET_STATE (sink, GST_STATE_NULL, GST_STATE_CHANGE_SUCCESS);
|
||||||
|
cleanup_multifdsink (sink);
|
||||||
|
|
||||||
|
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
/* FIXME: add test simulating chained oggs where:
|
||||||
|
* sync-method is burst-on-connect
|
||||||
|
* (when multifdsink actually does burst-on-connect based on byte size, not
|
||||||
|
"last keyframe" which any frame for audio :))
|
||||||
|
* an old client still needs to read from before the new streamheaders
|
||||||
|
* a new client gets the new streamheaders
|
||||||
|
*/
|
||||||
|
static Suite *
|
||||||
|
multifdsink_suite (void)
|
||||||
|
{
|
||||||
|
Suite *s = suite_create ("multifdsink");
|
||||||
|
TCase *tc_chain = tcase_create ("general");
|
||||||
|
|
||||||
|
suite_add_tcase (s, tc_chain);
|
||||||
|
tcase_add_test (tc_chain, test_no_clients);
|
||||||
|
tcase_add_test (tc_chain, test_add_client);
|
||||||
|
tcase_add_test (tc_chain, test_streamheader);
|
||||||
|
tcase_add_test (tc_chain, test_change_streamheader);
|
||||||
|
tcase_add_test (tc_chain, test_burst_client_bytes);
|
||||||
|
tcase_add_test (tc_chain, test_burst_client_bytes_keyframe);
|
||||||
|
tcase_add_test (tc_chain, test_burst_client_bytes_with_keyframe);
|
||||||
|
tcase_add_test (tc_chain, test_client_next_keyframe);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_CHECK_MAIN (multifdsink);
|
Loading…
Reference in a new issue