• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2015-2017 YouView TV Ltd
3  *   Author: Vincent Penquerch <vincent.penquerch@collabora.co.uk>
4  *
5  * gstipcpipelinecomm.h:
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 
24 #ifndef __GST_IPC_PIPELINE_COMM_H__
25 #define __GST_IPC_PIPELINE_COMM_H__
26 
27 #include <gst/gst.h>
28 #include <gst/base/gstadapter.h>
29 
30 G_BEGIN_DECLS
31 
32 #define GST_FLOW_COMM_ERROR GST_FLOW_CUSTOM_ERROR_1
33 
34 extern GQuark QUARK_ID;
35 
36 typedef enum {
37   GST_IPC_PIPELINE_COMM_STATE_TYPE = 0,
38   /* for the rest of the states we use directly the data type enums below */
39 } GstIpcPipelineCommState;
40 
41 typedef enum {
42   /* reply types */
43   GST_IPC_PIPELINE_COMM_DATA_TYPE_ACK = 1,
44   GST_IPC_PIPELINE_COMM_DATA_TYPE_QUERY_RESULT,
45   /* data send types */
46   GST_IPC_PIPELINE_COMM_DATA_TYPE_BUFFER,
47   GST_IPC_PIPELINE_COMM_DATA_TYPE_EVENT,
48   GST_IPC_PIPELINE_COMM_DATA_TYPE_SINK_MESSAGE_EVENT,
49   GST_IPC_PIPELINE_COMM_DATA_TYPE_QUERY,
50   GST_IPC_PIPELINE_COMM_DATA_TYPE_STATE_CHANGE,
51   GST_IPC_PIPELINE_COMM_DATA_TYPE_STATE_LOST,
52   GST_IPC_PIPELINE_COMM_DATA_TYPE_MESSAGE,
53   GST_IPC_PIPELINE_COMM_DATA_TYPE_GERROR_MESSAGE,
54 } GstIpcPipelineCommDataType;
55 
56 typedef struct
57 {
58   GstElement *element;
59 
60   GMutex mutex;
61   int fdin;
62   int fdout;
63   GHashTable *waiting_ids;
64 
65   GThread *reader_thread;
66   GstPoll *poll;
67   GstPollFD pollFDin;
68 
69   GstAdapter *adapter;
70   guint8 state;
71   guint32 send_id;
72 
73   guint32 payload_length;
74   guint32 id;
75 
76   guint read_chunk_size;
77   GstClockTime ack_time;
78 
79   void (*on_buffer) (guint32, GstBuffer *, gpointer);
80   void (*on_event) (guint32, GstEvent *, gboolean, gpointer);
81   void (*on_query) (guint32, GstQuery *, gboolean, gpointer);
82   void (*on_state_change) (guint32, GstStateChange, gpointer);
83   void (*on_state_lost) (gpointer);
84   void (*on_message) (guint32, GstMessage *, gpointer);
85   gpointer user_data;
86 
87 } GstIpcPipelineComm;
88 
89 void gst_ipc_pipeline_comm_plugin_init (void);
90 
91 void gst_ipc_pipeline_comm_init (GstIpcPipelineComm *comm, GstElement *e);
92 void gst_ipc_pipeline_comm_clear (GstIpcPipelineComm *comm);
93 void gst_ipc_pipeline_comm_cancel (GstIpcPipelineComm * comm,
94     gboolean flushing);
95 
96 void gst_ipc_pipeline_comm_write_flow_ack_to_fd (GstIpcPipelineComm * comm,
97     guint32 id, GstFlowReturn ret);
98 void gst_ipc_pipeline_comm_write_boolean_ack_to_fd (GstIpcPipelineComm * comm,
99     guint32 id, gboolean ret);
100 void gst_ipc_pipeline_comm_write_state_change_ack_to_fd (
101     GstIpcPipelineComm * comm, guint32 id, GstStateChangeReturn ret);
102 
103 void gst_ipc_pipeline_comm_write_query_result_to_fd (GstIpcPipelineComm * comm,
104     guint32 id, gboolean result, GstQuery *query);
105 
106 GstFlowReturn gst_ipc_pipeline_comm_write_buffer_to_fd (
107     GstIpcPipelineComm * comm, GstBuffer * buffer);
108 gboolean gst_ipc_pipeline_comm_write_event_to_fd (GstIpcPipelineComm * comm,
109     gboolean upstream, GstEvent * event);
110 gboolean gst_ipc_pipeline_comm_write_query_to_fd (GstIpcPipelineComm * comm,
111     gboolean upstream, GstQuery * query);
112 GstStateChangeReturn gst_ipc_pipeline_comm_write_state_change_to_fd (
113     GstIpcPipelineComm * comm, GstStateChange transition);
114 void gst_ipc_pipeline_comm_write_state_lost_to_fd (GstIpcPipelineComm * comm);
115 gboolean gst_ipc_pipeline_comm_write_message_to_fd (GstIpcPipelineComm * comm,
116     GstMessage *message);
117 
118 gboolean gst_ipc_pipeline_comm_start_reader_thread (GstIpcPipelineComm * comm,
119     void (*on_buffer) (guint32, GstBuffer *, gpointer),
120     void (*on_event) (guint32, GstEvent *, gboolean, gpointer),
121     void (*on_query) (guint32, GstQuery *, gboolean, gpointer),
122     void (*on_state_change) (guint32, GstStateChange, gpointer),
123     void (*on_state_lost) (gpointer),
124     void (*on_message) (guint32, GstMessage *, gpointer),
125     gpointer user_data);
126 void gst_ipc_pipeline_comm_stop_reader_thread (GstIpcPipelineComm * comm);
127 
128 G_END_DECLS
129 
130 #endif
131 
132