g_rand_free (rand); \
} G_STMT_END
+/* Push buffer_list containing num_buffers number of buffers with size
+ * num_bytes bytes
+ * Example: PUSH_BUFFER_LIST(2,10) will push the buffer list containing
+ * 2 buffers with size 10 bytes each */
+#define PUSH_BUFFER_LIST(num_buffers, num_bytes) \
+ G_STMT_START { \
+ guint i; \
+ GstBufferList* buf_list = gst_buffer_list_new(); \
+ for(i = 0; i < num_buffers; ++i){ \
+ GstBuffer *buf = gst_buffer_new_and_alloc(num_bytes); \
+ GRand *rand = g_rand_new_with_seed (num_bytes); \
+ GstMapInfo info; \
+ guint j; \
+ fail_unless (gst_buffer_map (buf, &info, GST_MAP_WRITE)); \
+ for (j = 0; j < num_bytes; ++j) \
+ ((guint8 *)info.data)[j] = (g_rand_int (rand) >> 24) & 0xff; \
+ gst_buffer_unmap (buf, &info); \
+ gst_buffer_list_add(buf_list,buf); \
+ g_rand_free (rand); \
+ } \
+ fail_unless_equals_int (gst_pad_push_list (mysrcpad, buf_list), GST_FLOW_OK); \
+ } G_STMT_END
+
#define CHECK_WRITTEN_BYTES(offset,written,file_size) \
G_STMT_START { \
gchar *data = NULL; \
PUSH_BYTES (8800);
CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 8900);
+ /* Push buffer list with 2 buffers each of size 50 bytes */
+ PUSH_BUFFER_LIST (2, 50);
+ CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 9000);
+ /* Push buffer list with 3 buffers each of size 10 bytes */
+ PUSH_BUFFER_LIST (3, 10);
+ CHECK_QUERY_POSITION (filesink, GST_FORMAT_BYTES, 9030);
+ /* Check bytes written using push buffer list */
+ CHECK_WRITTEN_BYTES (8900, 50, 9030);
+ CHECK_WRITTEN_BYTES (8950, 50, 9030);
+ CHECK_WRITTEN_BYTES (9000, 10, 9030);
+ CHECK_WRITTEN_BYTES (9010, 10, 9030);
+ CHECK_WRITTEN_BYTES (9020, 10, 9030);
+
segment.start = 8800;
if (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment))) {
GST_LOG ("seek ok");