xref: /haiku/headers/private/media/DataExchange.h (revision 7120e97489acbf17d86d3f33e3b2e68974fd4b23)
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 <Messenger.h>
13 #include <Buffer.h>
14 #include <Entry.h>
15 
16 namespace BPrivate {
17 namespace media {
18 namespace dataexchange {
19 
20 struct reply_data;
21 struct request_data;
22 struct command_data;
23 
24 // BMessage based data exchange with the media_server
25 status_t SendToServer(BMessage *msg);
26 //status_t QueryServer(BMessage *request, BMessage *reply);
27 
28 // Raw data based data exchange with the media_server
29 status_t SendToServer(int32 msgcode, command_data *msg, int size);
30 status_t QueryServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
31 
32 // Raw data based data exchange with the media_addon_server
33 status_t SendToAddonServer(int32 msgcode, command_data *msg, int size);
34 status_t QueryAddonServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
35 
36 // Raw data based data exchange with the media_server
37 status_t SendToPort(port_id sendport, int32 msgcode, command_data *msg, int size);
38 status_t QueryPort(port_id requestport, int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
39 
40 // The base struct used for all raw requests
41 struct request_data
42 {
43 	port_id reply_port;
44 
45 	status_t SendReply(status_t result, reply_data *reply, int replysize) const;
46 };
47 
48 // The base struct used for all raw replys
49 struct reply_data
50 {
51 	status_t result;
52 };
53 
54 // The base struct used for all raw commands (asynchronous, no answer)
55 struct command_data
56 {
57 	// yes, it's empty ;)
58 };
59 
60 }; // dataexchange
61 }; // media
62 }; // BPrivate
63 
64 using namespace BPrivate::media::dataexchange;
65 
66 // BMessage based server communication
67 enum {
68 
69 	// BMediaRoster notification service
70 	MEDIA_SERVER_REQUEST_NOTIFICATIONS = 1000,
71 	MEDIA_SERVER_CANCEL_NOTIFICATIONS,
72 	MEDIA_SERVER_SEND_NOTIFICATIONS
73 
74 };
75 
76 // Raw port based communication
77 enum {
78 	ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS = 0x50,
79 
80 	SERVER_MESSAGE_START = 0x100,
81 	SERVER_REGISTER_ADDONSERVER,
82 	SERVER_REGISTER_APP,
83 	SERVER_UNREGISTER_APP,
84 	SERVER_GET_NODE,
85 	SERVER_SET_NODE,
86 	SERVER_PUBLISH_INPUTS,
87 	SERVER_PUBLISH_OUTPUTS,
88 	SERVER_NODE_ID_FOR,
89 	SERVER_GET_LIVE_NODE_INFO,
90 	SERVER_GET_LIVE_NODES,
91 	SERVER_GET_NODE_FOR,
92 	SERVER_RELEASE_NODE,
93 	SERVER_REGISTER_NODE,
94 	SERVER_UNREGISTER_NODE,
95 	SERVER_GET_DORMANT_NODE_FOR,
96 	SERVER_GET_INSTANCES_FOR,
97 	SERVER_GET_SHARED_BUFFER_AREA,
98 	SERVER_REGISTER_BUFFER,
99 	SERVER_UNREGISTER_BUFFER,
100 	SERVER_MESSAGE_END,
101 	NODE_MESSAGE_START = 0x200,
102 
103 	NODE_START,
104 	NODE_STOP,
105 	NODE_SEEK,
106 	NODE_SET_RUN_MODE,
107 	NODE_TIME_WARP,
108 	NODE_PREROLL,
109 	NODE_SET_TIMESOURCE,
110 	NODE_REQUEST_COMPLETED,
111 
112 	NODE_MESSAGE_END,
113 	CONSUMER_MESSAGE_START = 0x300,
114 	CONSUMER_GET_NEXT_INPUT,
115 	CONSUMER_DISPOSE_INPUT_COOKIE,
116 	CONSUMER_ACCEPT_FORMAT,
117 	CONSUMER_CONNECTED,
118 	CONSUMER_DISCONNECTED,
119 
120 	CONSUMER_BUFFER_RECEIVED,
121 	CONSUMER_PRODUCER_DATA_STATUS,
122 	CONSUMER_GET_LATENCY_FOR,
123 	CONSUMER_FORMAT_CHANGED,
124 	CONSUMER_SEEK_TAG_REQUESTED,
125 
126 	CONSUMER_MESSAGE_END,
127 	PRODUCER_MESSAGE_START = 0x400,
128 	PRODUCER_GET_NEXT_OUTPUT,
129 	PRODUCER_DISPOSE_OUTPUT_COOKIE,
130 	PRODUCER_FORMAT_PROPOSAL,
131 	PRODUCER_PREPARE_TO_CONNECT,
132 	PRODUCER_CONNECT,
133 	PRODUCER_DISCONNECT,
134 
135 	PRODUCER_LATE_NOTICE_RECEIVED,
136 	PRODUCER_LATENCY_CHANGED,
137 	PRODUCER_ADDITIONAL_BUFFER_REQUESTED,
138 	PRODUCER_VIDEO_CLIPPING_CHANGED,
139 	PRODUCER_FORMAT_CHANGE_REQUESTED,
140 	PRODUCER_SET_BUFFER_GROUP,
141 	PRODUCER_GET_LATENCY,
142 	PRODUCER_GET_INITIAL_LATENCY,
143 	PRODUCER_FORMAT_SUGGESTION_REQUESTED,
144 	PRODUCER_SET_PLAY_RATE,
145 	PRODUCER_ENABLE_OUTPUT,
146 
147 	PRODUCER_MESSAGE_END,
148 	FILEINTERFACE_MESSAGE_START = 0x500,
149 	FILEINTERFACE_MESSAGE_END,
150 	CONTROLLABLE_MESSAGE_START = 0x600,
151 	CONTROLLABLE_MESSAGE_END,
152 	TIMESOURECE_MESSAGE_START = 0x700,
153 
154 	TIMESOURCE_OP, // datablock is a struct time_source_op_info
155 
156 	TIMESOURECE_MESSAGE_END,
157 };
158 
159 
160 /* We can't send an entry_ref through a port to another team,
161  * but we can assign it to an xfer_entry_ref and send this one,
162  * when we receive it we can assign it to a normal entry_ref
163  */
164 struct xfer_entry_ref
165 {
166 public:
167 	xfer_entry_ref()
168 		{
169 			device = -1;
170 			directory = -1;
171 			name[0] = 0;
172 		}
173 	operator entry_ref() const
174 		{
175 			entry_ref ref(device, directory, name);
176 			return ref;
177 		}
178 	void operator=(const entry_ref &ref)
179 		{
180 			device = ref.device;
181 			directory = ref.directory;
182 			strcpy(name, ref.name);
183 		}
184 private:
185 	dev_t	device;
186 	ino_t	directory;
187 	char	name[B_FILE_NAME_LENGTH];
188 };
189 
190 
191 
192 // used by SERVER_GET_NODE and SERVER_SET_NODE
193 enum node_type
194 {
195 	VIDEO_INPUT,
196 	AUDIO_INPUT,
197 	VIDEO_OUTPUT,
198 	AUDIO_MIXER,
199 	AUDIO_OUTPUT,
200 	AUDIO_OUTPUT_EX,
201 	TIME_SOURCE,
202 	SYSTEM_TIME_SOURCE
203 };
204 
205 // used by SERVER_PUBLISH_INPUTS and SERVER_PUBLISH_OUTPUTS
206 enum
207 {
208 	MAX_OUTPUTS = 48,
209 	MAX_INPUTS = 48,
210 };
211 
212 // used by SERVER_GET_LIVE_NODES
213 enum
214 {
215 	MAX_LIVE_INFO = 62,
216 };
217 
218 // used by SERVER_GET_INSTANCES_FOR
219 enum
220 {
221 	MAX_NODE_ID = 4000,
222 };
223 
224 struct addonserver_instantiate_dormant_node_request : public request_data
225 {
226 	dormant_node_info info;
227 };
228 
229 struct addonserver_instantiate_dormant_node_reply : public reply_data
230 {
231 	media_node node;
232 };
233 
234 struct server_set_node_request : public request_data
235 {
236 	node_type type;
237 	bool use_node;
238 	media_node node;
239 	bool use_dni;
240 	dormant_node_info dni;
241 	bool use_input;
242 	media_input input;
243 };
244 
245 struct server_set_node_reply : public reply_data
246 {
247 };
248 
249 struct server_get_node_request : public request_data
250 {
251 	node_type type;
252 	team_id team;
253 };
254 
255 struct server_get_node_reply : public reply_data
256 {
257 	media_node node;
258 
259 	// for AUDIO_OUTPUT_EX
260 	char input_name[B_MEDIA_NAME_LENGTH];
261 	int32 input_id;
262 };
263 
264 struct producer_format_proposal_request : public request_data
265 {
266 	media_source output;
267 	media_format format;
268 };
269 
270 struct producer_format_proposal_reply : public reply_data
271 {
272 	media_format format;
273 };
274 
275 struct producer_prepare_to_connect_request : public request_data
276 {
277 	media_source source;
278 	media_destination destination;
279 	media_format format;
280 	char name[B_MEDIA_NAME_LENGTH];
281 };
282 
283 struct producer_prepare_to_connect_reply : public reply_data
284 {
285 	media_format format;
286 	media_source out_source;
287 	char name[B_MEDIA_NAME_LENGTH];
288 };
289 
290 struct producer_connect_request : public request_data
291 {
292 	status_t error;
293 	media_source source;
294 	media_destination destination;
295 	media_format format;
296 	char name[B_MEDIA_NAME_LENGTH];
297 };
298 
299 struct producer_connect_reply : public reply_data
300 {
301 	char name[B_MEDIA_NAME_LENGTH];
302 };
303 
304 struct producer_disconnect_request : public request_data
305 {
306 	media_source source;
307 	media_destination destination;
308 };
309 
310 struct producer_disconnect_reply : public reply_data
311 {
312 };
313 
314 
315 
316 
317 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329 
330 struct producer_format_suggestion_requested_request : public request_data
331 {
332 	media_type type;
333 	int32 quality;
334 };
335 
336 struct producer_format_suggestion_requested_reply : public reply_data
337 {
338 	media_format format;
339 };
340 
341 struct producer_set_play_rate_request : public request_data
342 {
343 	int32 numer;
344 	int32 denom;
345 };
346 
347 struct producer_set_play_rate_reply : public reply_data
348 {
349 };
350 
351 struct producer_get_initial_latency_request : public request_data
352 {
353 };
354 
355 struct producer_get_initial_latency_reply : public reply_data
356 {
357 	bigtime_t initial_latency;
358 	uint32 flags;
359 };
360 
361 struct producer_get_latency_request : public request_data
362 {
363 };
364 
365 struct producer_get_latency_reply : public reply_data
366 {
367 	bigtime_t latency;
368 };
369 
370 struct producer_set_buffer_group_command : public command_data
371 {
372 	media_source source;
373 	media_destination destination;
374 	void *user_data;
375 	int32 change_tag;
376 	int32 buffer_count;
377 	media_buffer_id buffers[1];
378 };
379 
380 struct producer_format_change_requested_command : public command_data
381 {
382 	media_source source;
383 	media_destination destination;
384 	media_format format;
385 	void *user_data;
386 	int32 change_tag;
387 };
388 
389 struct producer_video_clipping_changed_command : public command_data
390 {
391 	media_source source;
392 	media_destination destination;
393 	media_video_display_info display;
394 	void *user_data;
395 	int32 change_tag;
396 	int32 short_count;
397 	int16 shorts[1];
398 };
399 
400 struct producer_additional_buffer_requested_command : public command_data
401 {
402 	media_source source;
403 	media_buffer_id prev_buffer;
404 	bigtime_t prev_time;
405 	bool has_seek_tag;
406 	media_seek_tag prev_tag;
407 };
408 
409 struct producer_latency_changed_command : public command_data
410 {
411 	media_source source;
412 	media_destination destination;
413 	bigtime_t latency;
414 	uint32 flags;
415 };
416 
417 struct producer_enable_output_command : public command_data
418 {
419 	media_source source;
420 	media_destination destination;
421 	bool enabled;
422 	void *user_data;
423 	int32 change_tag;
424 };
425 
426 struct producer_late_notice_received_command : public command_data
427 {
428 	media_source source;
429 	bigtime_t how_much;
430 	bigtime_t performance_time;
431 };
432 
433 
434 
435 
436 
437 
438 
439 
440 
441 
442 
443 
444 
445 
446 
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 struct consumer_accept_format_request : public request_data
464 {
465 	media_destination dest;
466 	media_format format;
467 };
468 
469 struct consumer_accept_format_reply : public reply_data
470 {
471 	media_format format;
472 };
473 
474 struct consumer_connected_request : public request_data
475 {
476 	media_source producer;
477 	media_destination where;
478 	media_format with_format;
479 };
480 
481 struct consumer_connected_reply : public reply_data
482 {
483 	media_input input;
484 };
485 
486 struct server_publish_inputs_request : public request_data
487 {
488 	media_node node;
489 	int32 count;
490 	area_id area;	// if count > MAX_INPUTS, inputs are in the area
491 					// area is created in the library, and also deleted
492 					// in the library after the reply has been received
493 	media_input inputs[MAX_INPUTS];
494 };
495 
496 struct server_publish_inputs_reply : public reply_data
497 {
498 };
499 
500 struct server_publish_outputs_request : public request_data
501 {
502 	media_node node;
503 	int32 count;
504 	area_id area; // if count > MAX_OUTPUTS, outputs are in the area
505 					// area is created in the library, and also deleted
506 					// in the library after the reply has been received
507 	media_output outputs[MAX_OUTPUTS];
508 };
509 
510 struct server_publish_outputs_reply : public reply_data
511 {
512 };
513 
514 struct producer_get_next_output_request : public request_data
515 {
516 	int32 cookie;
517 };
518 
519 struct producer_get_next_output_reply : public reply_data
520 {
521 	int32 cookie;
522 	media_output output;
523 };
524 
525 struct producer_dispose_output_cookie_request : public request_data
526 {
527 	int32 cookie;
528 };
529 
530 struct producer_dispose_output_cookie_reply : public reply_data
531 {
532 };
533 
534 struct consumer_get_next_input_request : public request_data
535 {
536 	int32 cookie;
537 };
538 
539 struct consumer_get_next_input_reply : public reply_data
540 {
541 	int32 cookie;
542 	media_input input;
543 };
544 
545 struct consumer_dispose_input_cookie_request : public request_data
546 {
547 	int32 cookie;
548 };
549 
550 struct consumer_dispose_input_cookie_reply : public reply_data
551 {
552 };
553 
554 struct consumer_disconnected_request : public request_data
555 {
556 	media_source source;
557 	media_destination destination;
558 };
559 
560 struct consumer_disconnected_reply : public reply_data
561 {
562 };
563 
564 
565 
566 
567 
568 
569 
570 
571 
572 
573 
574 
575 
576 
577 
578 
579 
580 struct consumer_buffer_received_command : public command_data
581 {
582 	media_buffer_id buffer;
583 	media_header header;
584 };
585 
586 struct consumer_producer_data_status_command : public command_data
587 {
588 	media_destination for_whom;
589 	int32 status;
590 	bigtime_t at_performance_time;
591 };
592 
593 struct consumer_get_latency_for_request : public request_data
594 {
595 	media_destination for_whom;
596 };
597 
598 struct consumer_get_latency_for_reply : public reply_data
599 {
600 	bigtime_t latency;
601 	media_node_id timesource;
602 };
603 
604 struct consumer_format_changed_request : public request_data
605 {
606 	media_source producer;
607 	media_destination consumer;
608 	int32 change_tag;
609 	media_format format;
610 };
611 
612 struct consumer_format_changed_reply : public reply_data
613 {
614 };
615 
616 struct consumer_seek_tag_requested_request : public request_data
617 {
618 	media_destination destination;
619 	bigtime_t target_time;
620 	uint32 flags;
621 };
622 
623 struct consumer_seek_tag_requested_reply : public reply_data
624 {
625 	media_seek_tag seek_tag;
626 	bigtime_t tagged_time;
627 	uint32 flags;
628 };
629 
630 
631 
632 
633 
634 
635 
636 struct server_register_addonserver_request : public request_data
637 {
638 	team_id team;
639 };
640 
641 struct server_register_addonserver_reply : public reply_data
642 {
643 };
644 
645 struct server_register_app_request : public request_data
646 {
647 	team_id team;
648 	BMessenger messenger;
649 };
650 
651 struct server_register_app_reply : public reply_data
652 {
653 };
654 
655 struct server_unregister_app_request : public request_data
656 {
657 	team_id team;
658 };
659 
660 struct server_unregister_app_reply : public reply_data
661 {
662 };
663 
664 
665 
666 struct server_register_node_request : public request_data
667 {
668 	media_addon_id addon_id;
669 	int32 addon_flavor_id;
670 	char name[B_MEDIA_NAME_LENGTH];
671 	uint64 kinds;
672 	port_id port;
673 	team_id team;
674 };
675 
676 struct server_register_node_reply : public reply_data
677 {
678 	media_node_id nodeid;
679 };
680 
681 struct server_unregister_node_request : public request_data
682 {
683 	media_node_id nodeid;
684 	team_id team;
685 };
686 
687 struct server_unregister_node_reply : public reply_data
688 {
689 	media_addon_id addon_id;
690 };
691 
692 struct server_get_live_node_info_request : public request_data
693 {
694 	media_node node;
695 };
696 
697 struct server_get_live_node_info_reply : public reply_data
698 {
699 	live_node_info live_info;
700 };
701 
702 struct server_get_live_nodes_request : public request_data
703 {
704 	int32 maxcount;
705 	bool has_input;
706 	bool has_output;
707 	bool has_name;
708 	media_format inputformat;
709 	media_format outputformat;
710 	char name[B_MEDIA_NAME_LENGTH + 1]; // 1 for a trailing "*"
711 	uint64 require_kinds;
712 };
713 
714 struct server_get_live_nodes_reply : public reply_data
715 {
716 	int32 count;
717 	area_id area; 	// if count > MAX_LIVE_INFO, live_node_infos are in the area
718 					// area is created in the server, but deleted in the library
719 	live_node_info live_info[MAX_LIVE_INFO];
720 };
721 
722 struct server_node_id_for_request : public request_data
723 {
724 	port_id port;
725 };
726 
727 struct server_node_id_for_reply : public reply_data
728 {
729 	media_node_id nodeid;
730 };
731 
732 struct server_get_node_for_request : public request_data
733 {
734 	media_node_id nodeid;
735 	team_id team;
736 };
737 
738 struct server_get_node_for_reply : public reply_data
739 {
740 	media_node clone;
741 };
742 
743 struct server_release_node_request : public request_data
744 {
745 	media_node node;
746 	team_id team;
747 };
748 
749 struct server_release_node_reply : public reply_data
750 {
751 };
752 
753 struct server_get_dormant_node_for_request : public request_data
754 {
755 	media_node node;
756 };
757 
758 struct server_get_dormant_node_for_reply : public reply_data
759 {
760 	dormant_node_info node_info;
761 };
762 
763 struct server_get_instances_for_request : public request_data
764 {
765 	int32 maxcount;
766 	media_addon_id addon_id;
767 	int32 addon_flavor_id;
768 };
769 
770 struct server_get_instances_for_reply : public reply_data
771 {
772 	int32 count;
773 	media_node_id node_id[MAX_NODE_ID]; // no area here, MAX_NODE_ID is really large
774 };
775 
776 
777 
778 
779 
780 
781 
782 struct addonserver_rescan_mediaaddon_flavors_command : public command_data
783 {
784 	media_addon_id addonid;
785 };
786 
787 struct server_register_mediaaddon_request : public request_data
788 {
789 	xfer_entry_ref	ref; // a ref to the file
790 };
791 
792 struct server_register_mediaaddon_reply : public reply_data
793 {
794 	media_addon_id addonid;
795 };
796 
797 struct server_unregister_mediaaddon_command : public command_data
798 {
799 	media_addon_id addonid;
800 };
801 
802 struct server_get_mediaaddon_ref_request : public request_data
803 {
804 	media_addon_id addonid;
805 };
806 
807 struct server_get_mediaaddon_ref_reply : public reply_data
808 {
809 	xfer_entry_ref	ref; // a ref to the file
810 };
811 
812 struct server_get_shared_buffer_area_request : public request_data
813 {
814 };
815 
816 struct server_get_shared_buffer_area_reply : public reply_data
817 {
818 	area_id area;
819 };
820 
821 struct server_register_buffer_request : public request_data
822 {
823 	team_id team;
824 	//either info.buffer is != 0, or the area, size, offset is used
825 	buffer_clone_info info;
826 };
827 
828 struct server_register_buffer_reply : public reply_data
829 {
830 	buffer_clone_info info;
831 };
832 
833 struct server_unregister_buffer_command : public command_data
834 {
835 	team_id team;
836 	media_buffer_id bufferid;
837 };
838 
839 struct node_request_completed_command : public command_data
840 {
841 	media_request_info info;
842 };
843 
844 struct node_start_command : public command_data
845 {
846 	bigtime_t performance_time;
847 };
848 
849 struct node_stop_command : public command_data
850 {
851 	bigtime_t performance_time;
852 	bool immediate;
853 };
854 
855 struct node_seek_command : public command_data
856 {
857 	bigtime_t media_time;
858 	bigtime_t performance_time;
859 };
860 
861 struct node_set_run_mode_command : public command_data
862 {
863 	BMediaNode::run_mode mode;
864 };
865 
866 struct node_time_warp_command : public command_data
867 {
868 	bigtime_t at_real_time;
869 	bigtime_t to_performance_time;
870 };
871 
872 struct node_set_timesource_command : public command_data
873 {
874 	media_node_id timesource_id;
875 };
876 
877 
878 
879 
880 #endif // _DATA_EXCHANGE_H
881