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 creator; // team that created the node 19 team_id team; // team that contains the node object 20 int32 globalrefcount; 21 Map<team_id, int32> teamrefcount; 22 List<media_input> inputlist; 23 List<media_output> outputlist; 24 }; 25 26 struct dormant_addon_flavor_info 27 { 28 media_addon_id AddonID; 29 int32 AddonFlavorID; 30 31 int32 MaxInstancesCount; 32 int32 GlobalInstancesCount; 33 34 Map<team_id, int32> TeamInstancesCount; 35 36 bool InfoValid; 37 dormant_flavor_info Info; 38 }; 39 40 class DefaultManager; 41 class BufferManager; 42 43 class NodeManager 44 { 45 public: 46 NodeManager(); 47 ~NodeManager(); 48 49 status_t LoadState(); 50 status_t SaveState(); 51 52 void Dump(); 53 54 /* Management of system wide default nodes */ 55 status_t SetDefaultNode(node_type type, const media_node *node, const dormant_node_info *info, const media_input *input); 56 status_t GetDefaultNode(media_node_id *nodeid, char *input_name, int32 *input_id, node_type type); 57 status_t RescanDefaultNodes(); 58 59 /* Management of live nodes */ 60 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); 61 status_t UnregisterNode(media_addon_id *addonid, int32 *flavorid, media_node_id nodeid, team_id team); 62 status_t GetCloneForId(media_node *node, media_node_id nodeid, team_id team); 63 status_t GetClone(media_node *node, char *input_name, int32 *input_id, node_type type, team_id team); 64 status_t ReleaseNode(const media_node &node, team_id team); 65 status_t PublishInputs(const media_node &node, const media_input *inputs, int32 count); 66 status_t PublishOutputs(const media_node &node, const media_output *outputs, int32 count); 67 status_t FindNodeId(media_node_id *nodeid, port_id port); 68 status_t GetLiveNodeInfo(live_node_info *live_info, const media_node &node); 69 status_t GetInstances(media_node_id *node_ids, int32* count, int32 maxcount, media_addon_id addon_id, int32 addon_flavor_id); 70 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); 71 status_t GetDormantNodeInfo(dormant_node_info *node_info, const media_node &node); 72 status_t IncrementGlobalRefCount(media_node_id nodeid, team_id team); 73 status_t DecrementGlobalRefCount(media_node_id nodeid, team_id team); 74 status_t SetNodeCreator(media_node_id nodeid, team_id creator); 75 void FinalReleaseNode(media_node_id nodeid); 76 77 /* Add media_node_id of all live nodes to the message 78 * int32 "media_node_id" (multiple items) 79 */ 80 status_t GetLiveNodes(BMessage *msg); 81 82 void RegisterAddon(const entry_ref &ref, media_addon_id *newid); 83 void UnregisterAddon(media_addon_id id); 84 85 void AddDormantFlavorInfo(const dormant_flavor_info &dfi); 86 void InvalidateDormantFlavorInfo(media_addon_id id); 87 void RemoveDormantFlavorInfo(media_addon_id id); 88 void CleanupDormantFlavorInfos(); 89 90 status_t IncrementAddonFlavorInstancesCount(media_addon_id addonid, int32 flavorid, team_id team); 91 status_t DecrementAddonFlavorInstancesCount(media_addon_id addonid, int32 flavorid, team_id team); 92 93 status_t GetAddonRef(entry_ref *ref, media_addon_id id); 94 status_t GetDormantNodes(dormant_node_info * out_info, 95 int32 * io_count, 96 const media_format * has_input /* = NULL */, 97 const media_format * has_output /* = NULL */, 98 const char * name /* = NULL */, 99 uint64 require_kinds /* = NULL */, 100 uint64 deny_kinds /* = NULL */); 101 102 status_t GetDormantFlavorInfoFor(media_addon_id addon, 103 int32 flavor_id, 104 dormant_flavor_info *outFlavor); 105 106 void CleanupTeam(team_id team); 107 108 private: 109 media_addon_id fNextAddOnID; 110 media_node_id fNextNodeID; 111 112 BLocker *fLocker; 113 List<dormant_addon_flavor_info> *fDormantAddonFlavorList; 114 Map<media_addon_id,entry_ref> *fAddonPathMap; 115 Map<media_node_id,registered_node> *fRegisteredNodeMap; 116 DefaultManager *fDefaultManager; 117 }; 118