diff options
Diffstat (limited to 'src/main/extractor_ipc.h')
-rw-r--r-- | src/main/extractor_ipc.h | 222 |
1 files changed, 186 insertions, 36 deletions
diff --git a/src/main/extractor_ipc.h b/src/main/extractor_ipc.h index 2b1ea47..212d30d 100644 --- a/src/main/extractor_ipc.h +++ b/src/main/extractor_ipc.h | |||
@@ -41,20 +41,120 @@ | |||
41 | #define MAX_SHM_NAME 255 | 41 | #define MAX_SHM_NAME 255 |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Sent from LE to a plugin to initialize it (open shm, | 44 | * Sent from LE to a plugin to initialize it (opens shm). |
45 | * reset position counters etc). | ||
46 | */ | 45 | */ |
47 | #define MESSAGE_INIT_STATE 0x01 | 46 | #define MESSAGE_INIT_STATE 0x00 |
47 | |||
48 | /** | ||
49 | * IPC message send to plugin to initialize SHM. | ||
50 | */ | ||
51 | struct InitMessage | ||
52 | { | ||
53 | /** | ||
54 | * Set to MESSAGE_INIT_STATE. | ||
55 | */ | ||
56 | unsigned char opcode; | ||
57 | |||
58 | /** | ||
59 | * Always zero. | ||
60 | */ | ||
61 | unsigned char reserved; | ||
62 | |||
63 | /** | ||
64 | * Name of the shared-memory name. | ||
65 | */ | ||
66 | uint32_t shm_name_length; | ||
67 | |||
68 | /** | ||
69 | * Maximum size of the shm map. | ||
70 | */ | ||
71 | uint32_t shm_map_size; | ||
72 | |||
73 | /* followed by name of the SHM */ | ||
74 | }; | ||
75 | |||
76 | |||
77 | /** | ||
78 | * Sent from LE to a plugin to tell it extracting | ||
79 | * can now start. The SHM will point to offset 0 | ||
80 | * of the file. | ||
81 | */ | ||
82 | #define MESSAGE_EXTRACT_START 0x01 | ||
83 | |||
84 | /** | ||
85 | * IPC message send to plugin to start extracting. | ||
86 | */ | ||
87 | struct StartMessage | ||
88 | { | ||
89 | /** | ||
90 | * Set to MESSAGE_EXTRACT_START. | ||
91 | */ | ||
92 | unsigned char opcode; | ||
93 | |||
94 | /** | ||
95 | * Always zero. | ||
96 | */ | ||
97 | unsigned char reserved; | ||
98 | |||
99 | /** | ||
100 | * Always zero. | ||
101 | */ | ||
102 | uint16_t reserved2; | ||
103 | |||
104 | /** | ||
105 | * Number of bytes ready in SHM. | ||
106 | */ | ||
107 | uint32_t shm_ready_bytes; | ||
108 | |||
109 | /** | ||
110 | * Overall size of the file. | ||
111 | */ | ||
112 | uint64_t file_size; | ||
113 | |||
114 | }; | ||
48 | 115 | ||
49 | /** | 116 | /** |
50 | * Sent from LE to a plugin to tell it that shm contents | 117 | * Sent from LE to a plugin to tell it that shm contents |
51 | * were updated. Only used for OPMODE_COMPRESS. | 118 | * were updated. |
52 | */ | 119 | */ |
53 | #define MESSAGE_UPDATED_SHM 0x02 | 120 | #define MESSAGE_UPDATED_SHM 0x02 |
54 | 121 | ||
55 | /** | 122 | /** |
123 | * IPC message send to plugin to notify it about a change in the SHM. | ||
124 | */ | ||
125 | struct UpdateMessage | ||
126 | { | ||
127 | /** | ||
128 | * Set to MESSAGE_UPDATED_SHM. | ||
129 | */ | ||
130 | unsigned char opcode; | ||
131 | |||
132 | /** | ||
133 | * Always zero. | ||
134 | */ | ||
135 | unsigned char reserved; | ||
136 | |||
137 | /** | ||
138 | * Always zero. | ||
139 | */ | ||
140 | uint16_t reserved2; | ||
141 | |||
142 | /** | ||
143 | * Number of bytes ready in SHM. | ||
144 | */ | ||
145 | uint32_t shm_ready_bytes; | ||
146 | |||
147 | /** | ||
148 | * Overall size of the file. | ||
149 | */ | ||
150 | uint64_t file_size; | ||
151 | |||
152 | }; | ||
153 | |||
154 | /** | ||
56 | * Sent from plugin to LE to tell LE that plugin is done | 155 | * Sent from plugin to LE to tell LE that plugin is done |
57 | * analyzing current file and will send no more data. | 156 | * analyzing current file and will send no more data. |
157 | * No message format as this is only one byte. | ||
58 | */ | 158 | */ |
59 | #define MESSAGE_DONE 0x03 | 159 | #define MESSAGE_DONE 0x03 |
60 | 160 | ||
@@ -65,58 +165,103 @@ | |||
65 | #define MESSAGE_SEEK 0x04 | 165 | #define MESSAGE_SEEK 0x04 |
66 | 166 | ||
67 | /** | 167 | /** |
68 | * Sent from plugin to LE to tell LE about metadata discovered. | 168 | * IPC message send to plugin to start extracting. |
69 | */ | 169 | */ |
70 | #define MESSAGE_META 0x05 | 170 | struct SeekRequestMessage |
171 | { | ||
172 | /** | ||
173 | * Set to MESSAGE_SEEK. | ||
174 | */ | ||
175 | unsigned char opcode; | ||
71 | 176 | ||
72 | /** | 177 | /** |
73 | * Sent from LE to plugin to make plugin discard its state (unmap | 178 | * Always zero. |
74 | * and close shm). | 179 | */ |
75 | */ | 180 | unsigned char reserved; |
76 | #define MESSAGE_DISCARD_STATE 0x06 | ||
77 | 181 | ||
182 | /** | ||
183 | * Always zero. | ||
184 | */ | ||
185 | uint16_t reserved2; | ||
78 | 186 | ||
79 | /** | 187 | /** |
80 | * Definition of an IPC communication channel with | 188 | * Number of bytes requested for SHM. |
81 | * some plugin. | 189 | */ |
82 | */ | 190 | uint32_t requested_bytes; |
83 | struct EXTRACTOR_Channel; | 191 | |
192 | /** | ||
193 | * Requested offset. | ||
194 | */ | ||
195 | uint64_t file_offset; | ||
196 | |||
197 | }; | ||
84 | 198 | ||
85 | /** | 199 | /** |
86 | * Definition of a shared memory area. | 200 | * Sent from plugin to LE to tell LE about metadata discovered. |
87 | */ | 201 | */ |
88 | struct EXTRACTOR_SharedMemory; | 202 | #define MESSAGE_META 0x05 |
89 | |||
90 | 203 | ||
91 | /** | 204 | /** |
92 | * Header used for our IPC replies. A header | 205 | * Plugin to parent: metadata discovered |
93 | * with all fields being zero is used to indicate | ||
94 | * the end of the stream. | ||
95 | */ | 206 | */ |
96 | struct IpcHeader | 207 | struct MetaMessage |
97 | { | 208 | { |
98 | /** | 209 | /** |
99 | * Type of the meta data. | 210 | * Set to MESSAGE_META. |
100 | */ | 211 | */ |
101 | enum EXTRACTOR_MetaType meta_type; | 212 | unsigned char opcode; |
102 | 213 | ||
103 | /** | 214 | /** |
104 | * Format of the meta data. | 215 | * Always zero. |
105 | */ | 216 | */ |
106 | enum EXTRACTOR_MetaFormat meta_format; | 217 | unsigned char reserved; |
107 | 218 | ||
108 | /** | 219 | /** |
109 | * Number of bytes of meta data (value) | 220 | * An 'enum EXTRACTOR_MetaFormat' in 16 bits. |
110 | */ | 221 | */ |
111 | size_t data_len; | 222 | uint16_t meta_format; |
112 | 223 | ||
224 | /** | ||
225 | * An 'enum EXTRACTOR_MetaType' in 16 bits. | ||
226 | */ | ||
227 | uint16_t meta_type; | ||
228 | |||
113 | /** | 229 | /** |
114 | * Length of the mime type string describing the meta data value's mime type, | 230 | * Length of the mime type string. |
115 | * including 0-terminator, 0 for mime type of "NULL". | ||
116 | */ | 231 | */ |
117 | size_t mime_len; | 232 | uint16_t mime_length; |
233 | |||
234 | /** | ||
235 | * Size of the value. | ||
236 | */ | ||
237 | uint32_t value_size; | ||
238 | |||
239 | /* followed by mime_length bytes of 0-terminated | ||
240 | mime-type (unless mime_length is 0) */ | ||
241 | |||
242 | /* followed by value_size bytes of value */ | ||
243 | |||
118 | }; | 244 | }; |
119 | 245 | ||
246 | /** | ||
247 | * Sent from LE to plugin to make plugin discard its state | ||
248 | * (extraction aborted by application). Only one byte. | ||
249 | * Plugin should get ready for next 'StartMessage' after this. | ||
250 | */ | ||
251 | #define MESSAGE_DISCARD_STATE 0x06 | ||
252 | |||
253 | |||
254 | /** | ||
255 | * Definition of an IPC communication channel with | ||
256 | * some plugin. | ||
257 | */ | ||
258 | struct EXTRACTOR_Channel; | ||
259 | |||
260 | /** | ||
261 | * Definition of a shared memory area. | ||
262 | */ | ||
263 | struct EXTRACTOR_SharedMemory; | ||
264 | |||
120 | 265 | ||
121 | /** | 266 | /** |
122 | * Create a shared memory area. | 267 | * Create a shared memory area. |
@@ -196,17 +341,22 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel, | |||
196 | * Handler for a message from one of the plugins. | 341 | * Handler for a message from one of the plugins. |
197 | * | 342 | * |
198 | * @param cls closure | 343 | * @param cls closure |
199 | * @param short_libname library name of the channel sending the message | 344 | * @param plugin plugin of the channel sending the message |
200 | * @param msg header of the message from the plugin | 345 | * @param meta_type type of the meta data |
346 | * @param meta_format format of the meta data | ||
347 | * @param value_len number of bytes in 'value' | ||
201 | * @param value 'data' send from the plugin | 348 | * @param value 'data' send from the plugin |
202 | * @param mime mime string send from the plugin | 349 | * @param mime mime string send from the plugin |
203 | */ | 350 | */ |
204 | typedef void (*EXTRACTOR_ChannelMessageProcessor) (void *cls, | 351 | typedef void (*EXTRACTOR_ChannelMessageProcessor) (void *cls, |
205 | struct EXTRACTOR_PluginList *plugin, | 352 | struct EXTRACTOR_PluginList *plugin, |
206 | const struct IpcHeader *msg, | 353 | enum EXTRACTOR_MetaType meta_type, |
354 | enum EXTRACTOR_MetaFormat meta_format, | ||
355 | size_t value_len, | ||
207 | const void *value, | 356 | const void *value, |
208 | const char *mime); | 357 | const char *mime); |
209 | 358 | ||
359 | |||
210 | /** | 360 | /** |
211 | * Process a reply from channel (seek request, metadata and done message) | 361 | * Process a reply from channel (seek request, metadata and done message) |
212 | * | 362 | * |