2 * Copyright 2002, Marcus Overhagen. All rights reserved.
3 * Distributed under the terms of the MIT License.
15 #include "DataExchange.h"
22 typedef std::map
<team_id
, int32
> TeamCountMap
;
23 typedef std::vector
<media_input
> InputList
;
24 typedef std::vector
<media_output
> OutputList
;
25 typedef std::vector
<live_node_info
> LiveNodeList
;
28 struct registered_node
{
29 media_node_id node_id
;
30 media_node_id timesource_id
;
31 media_addon_id add_on_id
;
33 char name
[B_MEDIA_NAME_LENGTH
];
36 team_id creator
; // team that created the node
37 team_id containing_team
;
39 TeamCountMap team_ref_count
;
41 OutputList output_list
;
44 struct dormant_add_on_flavor_info
{
45 media_addon_id add_on_id
;
48 int32 max_instances_count
;
49 int32 instances_count
;
51 TeamCountMap team_instances_count
;
54 dormant_flavor_info info
;
58 class NodeManager
: BLocker
{
63 // Management of system wide default nodes
64 status_t
SetDefaultNode(node_type type
,
65 const media_node
* node
,
66 const dormant_node_info
* info
,
67 const media_input
* input
);
68 status_t
GetDefaultNode(node_type type
,
69 media_node_id
* _nodeID
, char* inputName
,
71 status_t
RescanDefaultNodes();
73 // Management of live nodes
74 status_t
RegisterNode(media_addon_id addOnID
,
75 int32 flavorID
, const char* name
,
76 uint64 kinds
, port_id port
, team_id team
,
77 media_node_id timesource
,
78 media_node_id
* _nodeID
);
79 status_t
UnregisterNode(media_node_id nodeID
,
80 team_id team
, media_addon_id
* addOnID
,
82 status_t
ReleaseNodeReference(media_node_id id
,
84 status_t
ReleaseNodeAll(media_node_id id
);
85 status_t
GetCloneForID(media_node_id id
, team_id team
,
87 status_t
GetClone(node_type type
, team_id team
,
88 media_node
* node
, char* inputName
,
90 status_t
ReleaseNode(const media_node
& node
,
92 status_t
PublishInputs(const media_node
& node
,
93 const media_input
* inputs
, int32 count
);
94 status_t
PublishOutputs(const media_node
& node
,
95 const media_output
* outputs
, int32 count
);
96 status_t
FindNodeID(port_id port
, media_node_id
* _id
);
97 status_t
GetLiveNodeInfo(const media_node
& node
,
98 live_node_info
* liveInfo
);
99 status_t
GetInstances(media_addon_id addOnID
,
100 int32 flavorID
, media_node_id
* ids
,
101 int32
* _count
, int32 maxCount
);
102 status_t
GetLiveNodes(LiveNodeList
& liveNodes
,
104 const media_format
* inputFormat
= NULL
,
105 const media_format
* outputFormat
= NULL
,
106 const char* name
= NULL
,
107 uint64 requireKinds
= 0);
108 status_t
GetDormantNodeInfo(const media_node
& node
,
109 dormant_node_info
* nodeInfo
);
110 status_t
SetNodeCreator(media_node_id id
,
113 // Add media_node_id of all live nodes to the message
114 // int32 "media_node_id" (multiple items)
115 status_t
GetLiveNodes(BMessage
* message
);
117 void RegisterAddOn(const entry_ref
& ref
,
118 media_addon_id
* _newID
);
119 void UnregisterAddOn(media_addon_id id
);
121 status_t
AddDormantFlavorInfo(
122 const dormant_flavor_info
& flavorInfo
);
123 void InvalidateDormantFlavorInfo(media_addon_id id
);
124 void RemoveDormantFlavorInfo(media_addon_id id
);
125 void CleanupDormantFlavorInfos();
127 status_t
IncrementFlavorInstancesCount(
128 media_addon_id addOnID
, int32 flavorID
,
130 status_t
DecrementFlavorInstancesCount(
131 media_addon_id addOnID
, int32 flavorID
,
134 status_t
GetAddOnRef(media_addon_id addOnID
,
136 status_t
GetDormantNodes(dormant_node_info
* infos
,
137 int32
* _count
, const media_format
* hasInput
,
138 const media_format
* hasOutput
,
139 const char* name
, uint64 requireKinds
,
142 status_t
GetDormantFlavorInfoFor(media_addon_id addOnID
,
144 dormant_flavor_info
* flavorInfo
);
146 status_t
SetNodeTimeSource(media_node_id node
,
147 media_node_id timesource
);
149 void CleanupTeam(team_id team
);
151 status_t
LoadState();
152 status_t
SaveState();
157 status_t
_AcquireNodeReference(media_node_id id
,
159 void _NotifyTimeSource(registered_node
& node
);
162 typedef std::map
<media_addon_id
, registered_node
> NodeMap
;
163 typedef std::vector
<dormant_add_on_flavor_info
> DormantFlavorList
;
164 typedef std::map
<media_addon_id
, entry_ref
> PathMap
;
166 media_addon_id fNextAddOnID
;
167 media_node_id fNextNodeID
;
169 DormantFlavorList fDormantFlavors
;
172 DefaultManager
* fDefaultManager
;
175 #endif // NODE_MANAGER_H