• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Pipewireパッケージ(ちょっと変更)


Commit MetaInfo

Révision75d5fa91e2e8589bc279502ecc7cb39d23f2f472 (tree)
l'heure2015-04-17 17:44:03
AuteurWim Taymans <wtaymans@redh...>
CommiterWim Taymans

Message de Log

fdpay: use fd allocator

Use the fd allocator instead of the dmabuf allocator.
Update the wire protocol

Change Summary

Modification

--- a/src/gst/gstfddepay.c
+++ b/src/gst/gstfddepay.c
@@ -40,7 +40,7 @@
4040
4141 #include <gst/gst.h>
4242 #include <gst/base/gstbasetransform.h>
43-#include <gst/allocators/gstdmabuf.h>
43+#include <gst/allocators/gstfdmemory.h>
4444 #include <gio/gunixfdmessage.h>
4545
4646 #include <fcntl.h>
@@ -115,7 +115,7 @@ gst_fddepay_class_init (GstFddepayClass * klass)
115115 static void
116116 gst_fddepay_init (GstFddepay * fddepay)
117117 {
118- fddepay->dmabuf_allocator = gst_dmabuf_allocator_new ();
118+ fddepay->fd_allocator = gst_fd_allocator_new ();
119119 }
120120
121121 void
@@ -126,9 +126,9 @@ gst_fddepay_dispose (GObject * object)
126126 GST_DEBUG_OBJECT (fddepay, "dispose");
127127
128128 /* 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;
132132 }
133133
134134 G_OBJECT_CLASS (gst_fddepay_parent_class)->dispose (object);
@@ -169,7 +169,7 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
169169 {
170170 GstFddepay *fddepay = GST_FDDEPAY (trans);
171171 FDMessage msg;
172- GstMemory *dmabufmem = NULL;
172+ GstMemory *fdmem = NULL;
173173 GstNetControlMessageMeta * meta;
174174 int *fds = NULL;
175175 int fds_len = 0;
@@ -215,15 +215,17 @@ gst_fddepay_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
215215
216216 /* FIXME: Use stat to find out the size of the file, to make sure that the
217217 * 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);
221221
222222 gst_buffer_remove_all_memory (buf);
223223 gst_buffer_remove_meta (buf,
224224 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;
227229
228230 return GST_FLOW_OK;
229231 error:
--- a/src/gst/gstfddepay.h
+++ b/src/gst/gstfddepay.h
@@ -34,7 +34,7 @@ typedef struct _GstFddepayClass GstFddepayClass;
3434 struct _GstFddepay
3535 {
3636 GstBaseTransform base_fddepay;
37- GstAllocator *dmabuf_allocator;
37+ GstAllocator *fd_allocator;
3838 };
3939
4040 struct _GstFddepayClass
--- a/src/gst/gstfdpay.c
+++ b/src/gst/gstfdpay.c
@@ -40,8 +40,6 @@
4040 #include "config.h"
4141 #endif
4242
43-#include "wire-protocol.h"
44-
4543 #include <gst/gst.h>
4644 #include <gst/allocators/gstfdmemory.h>
4745 #include <gst/base/gstbasetransform.h>
@@ -55,6 +53,8 @@
5553 #include <string.h>
5654 #include <unistd.h>
5755
56+#include "wire-protocol.h"
57+
5858 GST_DEBUG_CATEGORY_STATIC (gst_fdpay_debug_category);
5959 #define GST_CAT_DEFAULT gst_fdpay_debug_category
6060
@@ -242,12 +242,16 @@ gst_fdpay_transform (GstBaseTransform * trans, GstBuffer * inbuf,
242242 GstMapInfo info;
243243 GError *err = NULL;
244244 GSocketControlMessage *fdmsg = NULL;
245- FDMessage msg = { 0, 0 };
245+ FDMessage msg = { 0, };
246246
247247 GST_DEBUG_OBJECT (fdpay, "transform_ip");
248248
249249 fdmem = gst_fdpay_get_fd_memory (fdpay, inbuf);
250250
251+ msg.flags = 0;
252+ msg.seq = GST_BUFFER_OFFSET (inbuf);
253+ msg.pts = GST_BUFFER_TIMESTAMP (inbuf);
254+ msg.dts_offset = 0;
251255 msg.size = fdmem->size;
252256 msg.offset = fdmem->offset;
253257
--- a/src/gst/gsttmpfileallocator.c
+++ b/src/gst/gsttmpfileallocator.c
@@ -83,8 +83,6 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size,
8383 GstAllocationParams * params)
8484 {
8585 GstTmpFileAllocator *alloc = (GstTmpFileAllocator *) allocator;
86- GstFdAllocator *fdalloc = GST_FD_ALLOCATOR_CAST (allocator);
87- GstFdAllocatorClass *klass = GST_FD_ALLOCATOR_GET_CLASS (alloc);
8886 GstMemory *mem;
8987 int fd;
9088 gsize maxsize;
@@ -99,7 +97,7 @@ gst_tmpfile_allocator_alloc (GstAllocator * allocator, gsize size,
9997 if (fd < 0)
10098 return NULL;
10199
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);
103101 gst_memory_resize (mem, pad (params->prefix, params->align), size);
104102
105103 return mem;
@@ -121,6 +119,8 @@ gst_tmpfile_allocator_init (GstTmpFileAllocator * allocator)
121119 GstAllocator *alloc = GST_ALLOCATOR_CAST (allocator);
122120
123121 alloc->mem_type = GST_ALLOCATOR_TMPFILE;
122+
123+ GST_OBJECT_FLAG_UNSET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC);
124124 }
125125
126126 GstAllocator *
--- a/src/gst/wire-protocol.h
+++ b/src/gst/wire-protocol.h
@@ -22,12 +22,24 @@
2222
2323 #include <stdint.h>
2424
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
2634 * a file-descriptor attached which should be mmapable. The data in the FD can
2735 * be found at offset and is size bytes long. */
2836 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;
3143 } FDMessage;
3244
3345 #endif