xref: /haiku/headers/private/media/DataExchange.h (revision 1299bfb29f6155daaa6117fec04f9054e0dc24b6)
1 /*
2  * Copyright 2002, Marcus Overhagen. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #ifndef _DATA_EXCHANGE_H
7 #define _DATA_EXCHANGE_H
8 
9 #include <MediaDefs.h>
10 #include <MediaNode.h>
11 #include <MediaAddOn.h>
12 #include <Entry.h>
13 
14 namespace BPrivate {
15 namespace media {
16 namespace dataexchange {
17 
18 struct reply_data;
19 struct request_data;
20 
21 // BMessage based data exchange with the media_server
22 status_t SendToServer(BMessage *msg);
23 status_t QueryServer(BMessage *request, BMessage *reply);
24 
25 // Raw data based data exchange with the media_server
26 status_t SendToServer(int32 msgcode, void *msg, int size);
27 status_t QueryServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
28 
29 // Raw data based data exchange with the media_addon_server
30 status_t SendToAddonServer(int32 msgcode, void *msg, int size);
31 status_t QueryAddonServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
32 
33 // Raw data based data exchange with the media_server
34 status_t SendToPort(port_id sendport, int32 msgcode, void *msg, int size);
35 status_t QueryPort(port_id requestport, int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
36 
37 // The base struct used for all raw requests
38 struct request_data
39 {
40 	port_id reply_port;
41 
42 	status_t SendReply(status_t result, reply_data *reply, int replysize) const;
43 };
44 
45 // The base struct used for all raw replys
46 struct reply_data
47 {
48 	status_t result;
49 };
50 
51 
52 }; // dataexchange
53 }; // media
54 }; // BPrivate
55 
56 using namespace BPrivate::media::dataexchange;
57 
58 // BMessage based server communication
59 enum {
60 
61 	// BMediaRoster notification service
62 	MEDIA_SERVER_REQUEST_NOTIFICATIONS = 1000,
63 	MEDIA_SERVER_CANCEL_NOTIFICATIONS,
64 	MEDIA_SERVER_SEND_NOTIFICATIONS
65 
66 };
67 
68 // Raw port based communication
69 enum {
70 	SERVER_GET_NODE = 0x1000,
71 	SERVER_SET_NODE,
72 	SERVER_PUBLISH_INPUTS,
73 	SERVER_PUBLISH_OUTPUTS,
74 	SERVER_NODE_ID_FOR,
75 	SERVER_GET_LIVE_NODE_INFO,
76 	SERVER_GET_LIVE_NODES,
77 	SERVER_GET_NODE_FOR,
78 	SERVER_RELEASE_NODE,
79 	SERVER_REGISTER_NODE,
80 	SERVER_UNREGISTER_NODE,
81 	SERVER_GET_DORMANT_NODE_FOR,
82 	SERVER_GET_INSTANCES_FOR,
83 	CONSUMER_GET_NEXT_INPUT = 0x2000,
84 	CONSUMER_DISPOSE_INPUT_COOKIE,
85 	CONSUMER_ACCEPT_FORMAT,
86 	CONSUMER_CONNECTED,
87 	CONSUMER_DISCONNECTED,
88 	PRODUCER_GET_NEXT_OUTPUT = 0x3000,
89 	PRODUCER_DISPOSE_OUTPUT_COOKIE,
90 	PRODUCER_FORMAT_PROPOSAL,
91 	PRODUCER_PREPARE_TO_CONNECT,
92 	PRODUCER_CONNECT,
93 	PRODUCER_DISCONNECT,
94 };
95 
96 // used by SERVER_GET_NODE and SERVER_SET_NODE
97 enum node_type
98 {
99 	VIDEO_INPUT,
100 	AUDIO_INPUT,
101 	VIDEO_OUTPUT,
102 	AUDIO_MIXER,
103 	AUDIO_OUTPUT,
104 	AUDIO_OUTPUT_EX,
105 	TIME_SOURCE,
106 	SYSTEM_TIME_SOURCE
107 };
108 
109 // used by SERVER_PUBLISH_INPUTS and SERVER_PUBLISH_OUTPUTS
110 enum
111 {
112 	MAX_OUTPUTS = 48,
113 	MAX_INPUTS = 48,
114 };
115 
116 // used by SERVER_GET_LIVE_NODES
117 enum
118 {
119 	MAX_LIVE_INFO = 62,
120 };
121 
122 // used by SERVER_GET_INSTANCES_FOR
123 enum
124 {
125 	MAX_NODE_ID = 4000,
126 };
127 
128 struct addonserver_instantiate_dormant_node_request : public request_data
129 {
130 	dormant_node_info info;
131 };
132 
133 struct addonserver_instantiate_dormant_node_reply : public reply_data
134 {
135 	media_node node;
136 };
137 
138 struct server_set_node_request : public request_data
139 {
140 	node_type type;
141 	bool use_node;
142 	media_node node;
143 	bool use_dni;
144 	dormant_node_info dni;
145 	bool use_input;
146 	media_input input;
147 };
148 
149 struct server_set_node_reply : public reply_data
150 {
151 };
152 
153 struct server_get_node_request : public request_data
154 {
155 	node_type type;
156 	team_id team;
157 };
158 
159 struct server_get_node_reply : public reply_data
160 {
161 	media_node node;
162 
163 	// for AUDIO_OUTPUT_EX
164 	char input_name[B_MEDIA_NAME_LENGTH];
165 	int32 input_id;
166 };
167 
168 struct producer_format_proposal_request : public request_data
169 {
170 	media_source output;
171 	media_format format;
172 };
173 
174 struct producer_format_proposal_reply : public reply_data
175 {
176 	media_format format;
177 };
178 
179 struct producer_prepare_to_connect_request : public request_data
180 {
181 	media_source source;
182 	media_destination destination;
183 	media_format format;
184 	char name[B_MEDIA_NAME_LENGTH];
185 };
186 
187 struct producer_prepare_to_connect_reply : public reply_data
188 {
189 	media_format format;
190 	media_source out_source;
191 	char name[B_MEDIA_NAME_LENGTH];
192 };
193 
194 struct producer_connect_request : public request_data
195 {
196 	status_t error;
197 	media_source source;
198 	media_destination destination;
199 	media_format format;
200 	char name[B_MEDIA_NAME_LENGTH];
201 };
202 
203 struct producer_connect_reply : public reply_data
204 {
205 	char name[B_MEDIA_NAME_LENGTH];
206 };
207 
208 struct consumer_accept_format_request : public request_data
209 {
210 	media_destination dest;
211 	media_format format;
212 };
213 
214 struct consumer_accept_format_reply : public reply_data
215 {
216 	media_format format;
217 };
218 
219 struct consumer_connected_request : public request_data
220 {
221 	media_source producer;
222 	media_destination where;
223 	media_format with_format;
224 };
225 
226 struct consumer_connected_reply : public reply_data
227 {
228 	media_input input;
229 };
230 
231 struct server_publish_inputs_request : public request_data
232 {
233 	media_node node;
234 	int32 count;
235 	area_id area;	// if count > MAX_INPUTS, inputs are in the area
236 					// area is created in the library, and also deleted
237 					// in the library after the reply has been received
238 	media_input inputs[MAX_INPUTS];
239 };
240 
241 struct server_publish_inputs_reply : public reply_data
242 {
243 };
244 
245 struct server_publish_outputs_request : public request_data
246 {
247 	media_node node;
248 	int32 count;
249 	area_id area; // if count > MAX_OUTPUTS, outputs are in the area
250 					// area is created in the library, and also deleted
251 					// in the library after the reply has been received
252 	media_output outputs[MAX_OUTPUTS];
253 };
254 
255 struct server_publish_outputs_reply : public reply_data
256 {
257 };
258 
259 struct producer_get_next_output_request : public request_data
260 {
261 	int32 cookie;
262 };
263 
264 struct producer_get_next_output_reply : public reply_data
265 {
266 	int32 cookie;
267 	media_output output;
268 };
269 
270 struct producer_dispose_output_cookie_request : public request_data
271 {
272 	int32 cookie;
273 };
274 
275 struct producer_dispose_output_cookie_reply : public reply_data
276 {
277 };
278 
279 struct consumer_get_next_input_request : public request_data
280 {
281 	int32 cookie;
282 };
283 
284 struct consumer_get_next_input_reply : public reply_data
285 {
286 	int32 cookie;
287 	media_input input;
288 };
289 
290 struct consumer_dispose_input_cookie_request : public request_data
291 {
292 	int32 cookie;
293 };
294 
295 struct consumer_dispose_input_cookie_reply : public reply_data
296 {
297 };
298 
299 struct consumer_disconnected_request : public request_data
300 {
301 	media_source source;
302 	media_destination destination;
303 };
304 
305 struct consumer_disconnected_reply : public reply_data
306 {
307 };
308 
309 struct producer_disconnect_request : public request_data
310 {
311 	media_source source;
312 	media_destination destination;
313 };
314 
315 struct producer_disconnect_reply : public reply_data
316 {
317 };
318 
319 struct server_register_node_request : public request_data
320 {
321 	media_addon_id addon_id;
322 	int32 addon_flavor_id;
323 	char name[B_MEDIA_NAME_LENGTH];
324 	uint64 kinds;
325 	port_id port;
326 	team_id team;
327 };
328 
329 struct server_register_node_reply : public reply_data
330 {
331 	media_node_id nodeid;
332 };
333 
334 struct server_unregister_node_request : public request_data
335 {
336 	media_node_id nodeid;
337 	team_id team;
338 };
339 
340 struct server_unregister_node_reply : public reply_data
341 {
342 	media_addon_id addon_id;
343 };
344 
345 struct server_get_live_node_info_request : public request_data
346 {
347 	media_node node;
348 };
349 
350 struct server_get_live_node_info_reply : public reply_data
351 {
352 	live_node_info live_info;
353 };
354 
355 struct server_get_live_nodes_request : public request_data
356 {
357 	int32 maxcount;
358 	bool has_input;
359 	bool has_output;
360 	bool has_name;
361 	media_format inputformat;
362 	media_format outputformat;
363 	char name[B_MEDIA_NAME_LENGTH + 1]; // 1 for a trailing "*"
364 	uint64 require_kinds;
365 };
366 
367 struct server_get_live_nodes_reply : public reply_data
368 {
369 	int32 count;
370 	area_id area; 	// if count > MAX_LIVE_INFO, live_node_infos are in the area
371 					// area is created in the server, but deleted in the library
372 	live_node_info live_info[MAX_LIVE_INFO];
373 };
374 
375 struct server_node_id_for_request : public request_data
376 {
377 	port_id port;
378 };
379 
380 struct server_node_id_for_reply : public reply_data
381 {
382 	media_node_id nodeid;
383 };
384 
385 struct server_get_node_for_request : public request_data
386 {
387 	media_node_id nodeid;
388 	team_id team;
389 };
390 
391 struct server_get_node_for_reply : public reply_data
392 {
393 	media_node clone;
394 };
395 
396 struct server_release_node_request : public request_data
397 {
398 	media_node node;
399 	team_id team;
400 };
401 
402 struct server_release_node_reply : public reply_data
403 {
404 };
405 
406 struct server_get_dormant_node_for_request : public request_data
407 {
408 	media_node node;
409 };
410 
411 struct server_get_dormant_node_for_reply : public reply_data
412 {
413 	dormant_node_info node_info;
414 };
415 
416 struct server_get_instances_for_request : public request_data
417 {
418 	int32 maxcount;
419 	media_addon_id addon_id;
420 	int32 addon_flavor_id;
421 };
422 
423 struct server_get_instances_for_reply : public reply_data
424 {
425 	int32 count;
426 	media_node_id node_id[MAX_NODE_ID]; // no area here, MAX_NODE_ID is really large
427 };
428 
429 
430 #endif // _DATA_EXCHANGE_H
431