summaryrefslogtreecommitdiff
path: root/ipc.h
diff options
context:
space:
mode:
authorJosep Torra <n770galaxy@gmail.com>2014-03-27 11:44:32 +0100
committerJosep Torra <n770galaxy@gmail.com>2014-03-27 11:44:32 +0100
commitd63c4f558fc0612e04125db09eebc115594d786b (patch)
treebec222908777267b6d6919ea5c666d93368636d2 /ipc.h
parentc5339b1dd002a95320f41855d652195bd48aee02 (diff)
Add IPC mini libraryHEADmaster
Diffstat (limited to 'ipc.h')
-rw-r--r--ipc.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/ipc.h b/ipc.h
new file mode 100644
index 0000000..1da5ced
--- /dev/null
+++ b/ipc.h
@@ -0,0 +1,97 @@
+/*
+ * IPC mini library
+ * Copyright (C) 2014 Fluendo S.A.
+ * @author: Josep Torra <josep@fluendo.com>
+ * *
+ * 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., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __MY_IPC_H__
+#define __MY_IPC_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "egl.h"
+
+typedef enum {
+ IPC_MSG_TYPE_EOS,
+ IPC_MSG_TYPE_REQUEST_POOL,
+ IPC_MSG_TYPE_RENDER_FRAME
+} IPCMsgType;
+
+typedef struct {
+ guint32 dummy;
+} IPCMsgEOS;
+
+typedef struct {
+ guint size;
+ guint width;
+ guint height;
+} IPCMsgPoolRequest;
+
+typedef struct {
+ EGLImageMemory *mem;
+} IPCMsgRenderFrame;
+
+typedef struct {
+ volatile gint refcount;
+
+ IPCMsgType type;
+ union {
+ IPCMsgEOS eos;
+ IPCMsgPoolRequest request_pool;
+ IPCMsgRenderFrame render_frame;
+ } u;
+ gpointer result;
+
+ volatile gint delivered;
+ gboolean synchronous;
+} IPCMessage;
+
+typedef struct
+{
+ volatile gint refcount;
+
+ GAsyncQueue *queue;
+ GMutex *lock;
+ GCond *cond;
+} IPCChannel;
+
+IPCMessage * ipc_message_new (IPCMsgType type);
+IPCMessage * ipc_message_ref (IPCMessage * message);
+IPCMessage * ipc_message_unref (IPCMessage * message);
+
+IPCMessage * ipc_message_eos_new();
+
+IPCMessage * ipc_message_request_pool_new (guint size, guint width, guint height);
+gboolean ipc_message_request_pool_parse (IPCMessage * message, guint * size,
+ guint * width, guint * height);
+
+IPCMessage * ipc_message_render_frame_new (EGLImageMemory * mem);
+gboolean ipc_message_render_frame_parse (IPCMessage * message, EGLImageMemory ** mem);
+
+IPCChannel * ipc_channel_new ();
+IPCChannel * ipc_channel_ref (IPCChannel * channel);
+IPCChannel * ipc_channel_unref (IPCChannel * channel);
+
+gpointer ipc_channel_send (IPCChannel * channel, IPCMessage * message);
+IPCMessage * ipc_channel_try_pop (IPCChannel * channel);
+void ipc_channel_delivered (IPCChannel * channel, IPCMessage * message,
+ gpointer result);
+
+#endif
+