xref: /haiku/src/servers/media/NodeManager.h (revision d7e489f80a82a0dc5974df1e780d7a908129bab4)
1 /*
2  * Copyright 2002, Marcus Overhagen. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #include "TList.h"
6 #include "TMap.h"
7 #include "TStack.h"
8 #include "DataExchange.h"
9 
10 struct registered_node
11 {
12 	media_node_id nodeid;
13 	media_addon_id addon_id;
14 	int32 addon_flavor_id;
15 	char name[B_MEDIA_NAME_LENGTH];
16 	uint64 kinds;
17 	port_id port;
18 	team_id team;
19 	int32 globalrefcount;
20 	Map<team_id, int32> teamrefcount;
21 	List<media_input> inputlist;
22 	List<media_output> outputlist;
23 };
24 
25 class BufferManager;
26 
27 class NodeManager
28 {
29 public:
30 	NodeManager();
31 	~NodeManager();
32 	status_t RegisterNode(BMessenger, media_node &, char const *, long *, char const *, long, char const *, long, media_type, media_type);
33 	status_t UnregisterNode(long);
34 	status_t GetNodes(BMessage &, char const *);
35 	status_t GetLiveNode(BMessage &, char const *, long);
36 	status_t GetLiveNodes(BMessage &, char const *, media_format const *, media_format const *, char const *, unsigned long);
37 	status_t FindNode(long, media_node &);
38 	status_t FindSaveInfo(long, char const **, long *, long *, char const **);
39 	status_t FindDormantNodeFor(long, dormant_node_info *);
40 	status_t FindNodesFor(long, long, BMessage &, char const *);
41 	status_t FindNodesForPort(long, BMessage &, char const *);
42 	status_t UnregisterTeamNodes(long, BMessage &, char const *, long *, BufferManager *);
43 	status_t DumpGlobalReferences(BMessage &, char const *);
44 	status_t BroadcastMessage(long, void *, long, long long);
45 	status_t LoadState();
46 	status_t SaveState();
47 
48 
49 	status_t RegisterNode(media_node_id *nodeid, media_addon_id addon_id, int32 addon_flavor_id, const char *name, uint64 kinds, port_id port, team_id team);
50 	status_t UnregisterNode(media_addon_id *addon_id, media_node_id nodeid, team_id team);
51 	status_t GetCloneForId(media_node *node, media_node_id nodeid, team_id team);
52 	status_t GetClone(media_node *node, char *input_name, int32 *input_id, node_type type, team_id team);
53 	status_t ReleaseNode(const media_node &node, team_id team);
54 	status_t PublishInputs(const media_node &node, const media_input *inputs, int32 count);
55 	status_t PublishOutputs(const media_node &node, const media_output *outputs, int32 count);
56 	status_t FindNodeId(media_node_id *nodeid, port_id port);
57 	status_t GetLiveNodeInfo(live_node_info *live_info, const media_node &node);
58 	status_t GetInstances(media_node_id *node_ids, int32* count, int32 maxcount, media_addon_id addon_id, int32 addon_flavor_id);
59 	status_t GetLiveNodes(Stack<live_node_info> *livenodes,	int32 maxcount, const media_format *inputformat = NULL, const media_format *outputformat = NULL, const char* name = NULL, uint64 require_kinds = 0);
60 	status_t GetDormantNodeInfo(dormant_node_info *node_info, const media_node &node);
61 	status_t IncrementGlobalRefCount(media_node_id nodeid, team_id team);
62 	status_t DecrementGlobalRefCount(media_node_id nodeid, team_id team);
63 
64 	/* Add media_node_id of all live nodes to the message
65 	 * int32 "media_node_id" (multiple items)
66 	 */
67 	status_t GetLiveNodes(BMessage *msg);
68 
69 	void AddDormantFlavorInfo(const dormant_flavor_info &dfi);
70 	void RemoveDormantFlavorInfo(media_addon_id id);
71 	void RegisterAddon(const entry_ref &ref, media_addon_id *newid);
72 	void UnregisterAddon(media_addon_id id);
73 	status_t GetAddonRef(entry_ref *ref, media_addon_id id);
74 	status_t GetDormantNodes(dormant_node_info * out_info,
75 							  int32 * io_count,
76 							  const media_format * has_input /* = NULL */,
77 							  const media_format * has_output /* = NULL */,
78 							  const char * name /* = NULL */,
79 							  uint64 require_kinds /* = NULL */,
80 							  uint64 deny_kinds /* = NULL */);
81 
82 	status_t GetDormantFlavorInfoFor(media_addon_id addon,
83 									 int32 flavor_id,
84 									 dormant_flavor_info *outFlavor);
85 
86 private:
87 	media_addon_id nextaddonid;
88 	media_node_id nextnodeid;
89 
90 	List<dormant_flavor_info> *fDormantFlavorList;
91 	Map<media_addon_id,entry_ref> *fAddonPathMap;
92 	Map<media_node_id,registered_node> *fRegisteredNodeMap;
93 };
94