diff --git a/src/gst/gstfddepay.c b/src/gst/gstfddepay.c index 830a1fd35..f81932d00 100644 --- a/src/gst/gstfddepay.c +++ b/src/gst/gstfddepay.c @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -115,7 +115,7 @@ gst_fddepay_class_init (GstFddepayClass * klass) static void gst_fddepay_init (GstFddepay * fddepay) { - fddepay->dmabuf_allocator = gst_dmabuf_allocator_new (); + fddepay->fd_allocator = gst_fd_allocator_new (); } void @@ -126,9 +126,9 @@ gst_fddepay_dispose (GObject * object) GST_DEBUG_OBJECT (fddepay, "dispose"); /* clean up as possible. may be called multiple times */ - if (fddepay->dmabuf_allocator != NULL) { - g_object_unref (G_OBJECT (fddepay->dmabuf_allocator)); - fddepay->dmabuf_allocator = NULL; + if (fddepay->fd_allocator != NULL) { + g_object_unref (G_OBJECT (fddepay->fd_allocator)); + fddepay->fd_allocator = NULL; } G_OBJECT_CLASS (gst_fddepay_parent_class)->dispose (object); @@ -169,7 +169,7 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf) { GstFddepay *fddepay = GST_FDDEPAY (trans); FDMessage msg; - GstMemory *dmabufmem = NULL; + GstMemory *fdmem = NULL; GstNetControlMessageMeta * meta; int *fds = NULL; int fds_len = 0; @@ -215,15 +215,17 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf) /* FIXME: Use stat to find out the size of the file, to make sure that the * size we've been told is the true size for safety and security. */ - dmabufmem = gst_dmabuf_allocator_alloc (fddepay->dmabuf_allocator, fd, - msg.offset + msg.size); - gst_memory_resize (dmabufmem, msg.offset, msg.size); + fdmem = gst_fd_allocator_alloc (fddepay->fd_allocator, fd, + msg.offset + msg.size, GST_FD_MEMORY_FLAG_NONE); + gst_memory_resize (fdmem, msg.offset, msg.size); gst_buffer_remove_all_memory (buf); gst_buffer_remove_meta (buf, gst_buffer_get_meta (buf, GST_NET_CONTROL_MESSAGE_META_API_TYPE)); - gst_buffer_append_memory (buf, dmabufmem); - dmabufmem = NULL; + gst_buffer_append_memory (buf, fdmem); + fdmem = NULL; + + GST_BUFFER_OFFSET (buf) = msg.seq; return GST_FLOW_OK; error: diff --git a/src/gst/gstfddepay.h b/src/gst/gstfddepay.h index c31e789d4..d74ed6998 100644 --- a/src/gst/gstfddepay.h +++ b/src/gst/gstfddepay.h @@ -34,7 +34,7 @@ typedef struct _GstFddepayClass GstFddepayClass; struct _GstFddepay { GstBaseTransform base_fddepay; - GstAllocator *dmabuf_allocator; + GstAllocator *fd_allocator; }; struct _GstFddepayClass diff --git a/src/gst/gstfdpay.c b/src/gst/gstfdpay.c index 4b3787e2c..56b23769f 100644 --- a/src/gst/gstfdpay.c +++ b/src/gst/gstfdpay.c @@ -40,8 +40,6 @@ #include "config.h" #endif -#include "wire-protocol.h" - #include #include #include @@ -55,6 +53,8 @@ #include #include +#include "wire-protocol.h" + GST_DEBUG_CATEGORY_STATIC (gst_fdpay_debug_category); #define GST_CAT_DEFAULT gst_fdpay_debug_category @@ -242,12 +242,16 @@ gst_fdpay_transform (GstBaseTransform * trans, GstBuffer * inbuf, GstMapInfo info; GError *err = NULL; GSocketControlMessage *fdmsg = NULL; - FDMessage msg = { 0, 0 }; + FDMessage msg = { 0, }; GST_DEBUG_OBJECT (fdpay, "transform_ip"); fdmem = gst_fdpay_get_fd_memory (fdpay, inbuf); + msg.flags = 0; + msg.seq = GST_BUFFER_OFFSET (inbuf); + msg.pts = GST_BUFFER_TIMESTAMP (inbuf); + msg.dts_offset = 0; msg.size = fdmem->size; msg.offset = fdmem->offset; diff --git a/src/gst/gsttmpfileallocator.c b/src/gst/gsttmpfileallocator.c index 7dfae0749..bcb31e134 100644 --- a/src/gst/gsttmpfileallocator.c +++ b/src/gst/gsttmpfileallocator.c @@ -83,8 +83,6 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size, GstAllocationParams * params) { GstTmpFileAllocator *alloc = (GstTmpFileAllocator *) allocator; - GstFdAllocator *fdalloc = GST_FD_ALLOCATOR_CAST (allocator); - GstFdAllocatorClass *klass = GST_FD_ALLOCATOR_GET_CLASS (alloc); GstMemory *mem; int fd; gsize maxsize; @@ -99,7 +97,7 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size, if (fd < 0) return NULL; - mem = klass->alloc (fdalloc, fd, maxsize, GST_FD_MEMORY_FLAG_NONE); + mem = gst_fd_allocator_alloc (allocator, fd, maxsize, GST_FD_MEMORY_FLAG_NONE); gst_memory_resize (mem, pad (params->prefix, params->align), size); return mem; @@ -121,6 +119,8 @@ gst_tmpfile_allocator_init (GstTmpFileAllocator * allocator) GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator); alloc->mem_type = GST_ALLOCATOR_TMPFILE; + + GST_OBJECT_FLAG_UNSET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC); } GstAllocator * diff --git a/src/gst/wire-protocol.h b/src/gst/wire-protocol.h index 79735a56c..cad4ae422 100644 --- a/src/gst/wire-protocol.h +++ b/src/gst/wire-protocol.h @@ -22,12 +22,24 @@ #include -/* Almost the simplest possible FD passing protocol. Each message should have +/** + * @flags: possible flags + * @seq: a sequence number + * @pts: a PTS or presentation timestamp + * @dts_offset: an offset to @pts to get the DTS + * @offset: offset in fd + * @size: size of data in fd + * + * Almost the simplest possible FD passing protocol. Each message should have * a file-descriptor attached which should be mmapable. The data in the FD can * be found at offset and is size bytes long. */ typedef struct { - uint64_t offset; - uint64_t size; + guint32 flags; + guint32 seq; + gint64 pts; + gint64 dts_offset; + guint64 offset; + guint64 size; } FDMessage; #endif