Pipewireパッケージ(ちょっと変更)
Révision | 75d5fa91e2e8589bc279502ecc7cb39d23f2f472 (tree) |
---|---|
l'heure | 2015-04-17 17:44:03 |
Auteur | Wim Taymans <wtaymans@redh...> |
Commiter | Wim Taymans |
fdpay: use fd allocator
Use the fd allocator instead of the dmabuf allocator.
Update the wire protocol
@@ -40,7 +40,7 @@ | ||
40 | 40 | |
41 | 41 | #include <gst/gst.h> |
42 | 42 | #include <gst/base/gstbasetransform.h> |
43 | -#include <gst/allocators/gstdmabuf.h> | |
43 | +#include <gst/allocators/gstfdmemory.h> | |
44 | 44 | #include <gio/gunixfdmessage.h> |
45 | 45 | |
46 | 46 | #include <fcntl.h> |
@@ -115,7 +115,7 @@ gst_fddepay_class_init (GstFddepayClass * klass) | ||
115 | 115 | static void |
116 | 116 | gst_fddepay_init (GstFddepay * fddepay) |
117 | 117 | { |
118 | - fddepay->dmabuf_allocator = gst_dmabuf_allocator_new (); | |
118 | + fddepay->fd_allocator = gst_fd_allocator_new (); | |
119 | 119 | } |
120 | 120 | |
121 | 121 | void |
@@ -126,9 +126,9 @@ gst_fddepay_dispose (GObject * object) | ||
126 | 126 | GST_DEBUG_OBJECT (fddepay, "dispose"); |
127 | 127 | |
128 | 128 | /* clean up as possible. may be called multiple times */ |
129 | - if (fddepay->dmabuf_allocator != NULL) { | |
130 | - g_object_unref (G_OBJECT (fddepay->dmabuf_allocator)); | |
131 | - fddepay->dmabuf_allocator = NULL; | |
129 | + if (fddepay->fd_allocator != NULL) { | |
130 | + g_object_unref (G_OBJECT (fddepay->fd_allocator)); | |
131 | + fddepay->fd_allocator = NULL; | |
132 | 132 | } |
133 | 133 | |
134 | 134 | G_OBJECT_CLASS (gst_fddepay_parent_class)->dispose (object); |
@@ -169,7 +169,7 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf) | ||
169 | 169 | { |
170 | 170 | GstFddepay *fddepay = GST_FDDEPAY (trans); |
171 | 171 | FDMessage msg; |
172 | - GstMemory *dmabufmem = NULL; | |
172 | + GstMemory *fdmem = NULL; | |
173 | 173 | GstNetControlMessageMeta * meta; |
174 | 174 | int *fds = NULL; |
175 | 175 | int fds_len = 0; |
@@ -215,15 +215,17 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf) | ||
215 | 215 | |
216 | 216 | /* FIXME: Use stat to find out the size of the file, to make sure that the |
217 | 217 | * size we've been told is the true size for safety and security. */ |
218 | - dmabufmem = gst_dmabuf_allocator_alloc (fddepay->dmabuf_allocator, fd, | |
219 | - msg.offset + msg.size); | |
220 | - gst_memory_resize (dmabufmem, msg.offset, msg.size); | |
218 | + fdmem = gst_fd_allocator_alloc (fddepay->fd_allocator, fd, | |
219 | + msg.offset + msg.size, GST_FD_MEMORY_FLAG_NONE); | |
220 | + gst_memory_resize (fdmem, msg.offset, msg.size); | |
221 | 221 | |
222 | 222 | gst_buffer_remove_all_memory (buf); |
223 | 223 | gst_buffer_remove_meta (buf, |
224 | 224 | gst_buffer_get_meta (buf, GST_NET_CONTROL_MESSAGE_META_API_TYPE)); |
225 | - gst_buffer_append_memory (buf, dmabufmem); | |
226 | - dmabufmem = NULL; | |
225 | + gst_buffer_append_memory (buf, fdmem); | |
226 | + fdmem = NULL; | |
227 | + | |
228 | + GST_BUFFER_OFFSET (buf) = msg.seq; | |
227 | 229 | |
228 | 230 | return GST_FLOW_OK; |
229 | 231 | error: |
@@ -34,7 +34,7 @@ typedef struct _GstFddepayClass GstFddepayClass; | ||
34 | 34 | struct _GstFddepay |
35 | 35 | { |
36 | 36 | GstBaseTransform base_fddepay; |
37 | - GstAllocator *dmabuf_allocator; | |
37 | + GstAllocator *fd_allocator; | |
38 | 38 | }; |
39 | 39 | |
40 | 40 | struct _GstFddepayClass |
@@ -40,8 +40,6 @@ | ||
40 | 40 | #include "config.h" |
41 | 41 | #endif |
42 | 42 | |
43 | -#include "wire-protocol.h" | |
44 | - | |
45 | 43 | #include <gst/gst.h> |
46 | 44 | #include <gst/allocators/gstfdmemory.h> |
47 | 45 | #include <gst/base/gstbasetransform.h> |
@@ -55,6 +53,8 @@ | ||
55 | 53 | #include <string.h> |
56 | 54 | #include <unistd.h> |
57 | 55 | |
56 | +#include "wire-protocol.h" | |
57 | + | |
58 | 58 | GST_DEBUG_CATEGORY_STATIC (gst_fdpay_debug_category); |
59 | 59 | #define GST_CAT_DEFAULT gst_fdpay_debug_category |
60 | 60 |
@@ -242,12 +242,16 @@ gst_fdpay_transform (GstBaseTransform * trans, GstBuffer * inbuf, | ||
242 | 242 | GstMapInfo info; |
243 | 243 | GError *err = NULL; |
244 | 244 | GSocketControlMessage *fdmsg = NULL; |
245 | - FDMessage msg = { 0, 0 }; | |
245 | + FDMessage msg = { 0, }; | |
246 | 246 | |
247 | 247 | GST_DEBUG_OBJECT (fdpay, "transform_ip"); |
248 | 248 | |
249 | 249 | fdmem = gst_fdpay_get_fd_memory (fdpay, inbuf); |
250 | 250 | |
251 | + msg.flags = 0; | |
252 | + msg.seq = GST_BUFFER_OFFSET (inbuf); | |
253 | + msg.pts = GST_BUFFER_TIMESTAMP (inbuf); | |
254 | + msg.dts_offset = 0; | |
251 | 255 | msg.size = fdmem->size; |
252 | 256 | msg.offset = fdmem->offset; |
253 | 257 |
@@ -83,8 +83,6 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size, | ||
83 | 83 | GstAllocationParams * params) |
84 | 84 | { |
85 | 85 | GstTmpFileAllocator *alloc = (GstTmpFileAllocator *) allocator; |
86 | - GstFdAllocator *fdalloc = GST_FD_ALLOCATOR_CAST (allocator); | |
87 | - GstFdAllocatorClass *klass = GST_FD_ALLOCATOR_GET_CLASS (alloc); | |
88 | 86 | GstMemory *mem; |
89 | 87 | int fd; |
90 | 88 | gsize maxsize; |
@@ -99,7 +97,7 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size, | ||
99 | 97 | if (fd < 0) |
100 | 98 | return NULL; |
101 | 99 | |
102 | - mem = klass->alloc (fdalloc, fd, maxsize, GST_FD_MEMORY_FLAG_NONE); | |
100 | + mem = gst_fd_allocator_alloc (allocator, fd, maxsize, GST_FD_MEMORY_FLAG_NONE); | |
103 | 101 | gst_memory_resize (mem, pad (params->prefix, params->align), size); |
104 | 102 | |
105 | 103 | return mem; |
@@ -121,6 +119,8 @@ gst_tmpfile_allocator_init (GstTmpFileAllocator * allocator) | ||
121 | 119 | GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator); |
122 | 120 | |
123 | 121 | alloc->mem_type = GST_ALLOCATOR_TMPFILE; |
122 | + | |
123 | + GST_OBJECT_FLAG_UNSET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC); | |
124 | 124 | } |
125 | 125 | |
126 | 126 | GstAllocator * |
@@ -22,12 +22,24 @@ | ||
22 | 22 | |
23 | 23 | #include <stdint.h> |
24 | 24 | |
25 | -/* Almost the simplest possible FD passing protocol. Each message should have | |
25 | +/** | |
26 | + * @flags: possible flags | |
27 | + * @seq: a sequence number | |
28 | + * @pts: a PTS or presentation timestamp | |
29 | + * @dts_offset: an offset to @pts to get the DTS | |
30 | + * @offset: offset in fd | |
31 | + * @size: size of data in fd | |
32 | + * | |
33 | + * Almost the simplest possible FD passing protocol. Each message should have | |
26 | 34 | * a file-descriptor attached which should be mmapable. The data in the FD can |
27 | 35 | * be found at offset and is size bytes long. */ |
28 | 36 | typedef struct { |
29 | - uint64_t offset; | |
30 | - uint64_t size; | |
37 | + guint32 flags; | |
38 | + guint32 seq; | |
39 | + gint64 pts; | |
40 | + gint64 dts_offset; | |
41 | + guint64 offset; | |
42 | + guint64 size; | |
31 | 43 | } FDMessage; |
32 | 44 | |
33 | 45 | #endif |