xref: /haiku/headers/os/media/MediaAddOn.h (revision 1d9d47fc72028bb71b5f232a877231e59cfe2438)
1 /*******************************************************************************
2 /
3 /	File:			MediaAddOn.h
4 /
5 /   Description:   A BMediaAddOn is created by Media Kit add-ons to instantiate and
6 /	handle "latent" Nodes.
7 /
8 /	Copyright 1997-98, Be Incorporated, All Rights Reserved
9 /
10 *******************************************************************************/
11 
12 #if !defined(_MEDIA_ADD_ON_H)
13 #define _MEDIA_ADD_ON_H
14 
15 #include <image.h>
16 
17 #include <MediaDefs.h>
18 #include <Flattenable.h>
19 
20 
21 struct dormant_node_info {
22 	dormant_node_info();
23 	~dormant_node_info();
24 
25 	media_addon_id addon;
26 	int32 flavor_id;
27 	char name[B_MEDIA_NAME_LENGTH];
28 private:
29 	char reserved[128];
30 };
31 
32 enum
33 {	//	flavor_flags
34 	B_FLAVOR_IS_GLOBAL = 0x100000L,	//	force in media_addon_server, only one instance
35 	B_FLAVOR_IS_LOCAL = 0x200000L	//	force in loading app, many instances
36 									//	if none is set, could go either way
37 };
38 
39 struct flavor_info {
40 	char *				name;
41 	char *				info;
42 	uint64				kinds;			/* node_kind */
43 	uint32				flavor_flags;
44 	int32				internal_id;	/* For BMediaAddOn internal use */
45 	int32				possible_count;	/* 0 for "any number" */
46 
47 	int32				in_format_count;	/* for BufferConsumer kinds */
48 	uint32				in_format_flags;	/* set to 0 */
49 	const media_format *	in_formats;
50 
51 	int32				out_format_count;	/* for BufferProducer kinds */
52 	uint32				out_format_flags;	/* set to 0 */
53 	const media_format *	out_formats;
54 
55 	uint32				_reserved_[16];
56 
57 private:
58 	flavor_info & operator=(const flavor_info & other);
59 };
60 
61 struct dormant_flavor_info : public flavor_info, public BFlattenable {
62 
63 		dormant_flavor_info();
64 virtual	~dormant_flavor_info();
65 		dormant_flavor_info(const dormant_flavor_info &);
66 		dormant_flavor_info& operator=(const dormant_flavor_info &);
67 		dormant_flavor_info& operator=(const flavor_info &);
68 
69 		dormant_node_info	node_info;
70 
71 		void set_name(const char * in_name);
72 		void set_info(const char * in_info);
73 		void add_in_format(const media_format & in_format);
74 		void add_out_format(const media_format & out_format);
75 
76 virtual	bool		IsFixedSize() const;
77 virtual	type_code	TypeCode() const;
78 virtual	ssize_t		FlattenedSize() const;
79 virtual	status_t	Flatten(void *buffer, ssize_t size) const;
80 virtual	status_t	Unflatten(type_code c, const void *buf, ssize_t size);
81 };
82 
83 namespace BPrivate {
84 namespace media {
85 	class DormantNodeManager;
86 };
87 };
88 
89 /* a MediaAddOn is something which can manufacture MediaNodes */
90 class BMediaAddOn
91 {
92 public:
93 explicit	BMediaAddOn(
94 				image_id image);
95 virtual	~BMediaAddOn();
96 
97 virtual	status_t InitCheck(
98 				const char ** out_failure_text);
99 virtual	int32 CountFlavors();
100 virtual	status_t GetFlavorAt(
101 				int32 n,
102 				const flavor_info ** out_info);
103 virtual	BMediaNode * InstantiateNodeFor(
104 				const flavor_info * info,
105 				BMessage * config,
106 				status_t * out_error);
107 virtual	status_t GetConfigurationFor(
108 				BMediaNode * your_node,
109 				BMessage * into_message);
110 virtual	bool WantsAutoStart();
111 virtual	status_t AutoStart(
112 				int in_index,
113 				BMediaNode ** out_node,
114 				int32 * out_internal_id,
115 				bool * out_has_more);
116 /* only implement if you have a B_FILE_INTERFACE node */
117 virtual	status_t SniffRef(
118 				const entry_ref & file,
119 				BMimeType * io_mime_type,
120 				float * out_quality,
121 				int32 * out_internal_id);
122 virtual	status_t SniffType(					//	This is broken if you deal with producers
123 				const BMimeType & type,		//	and consumers both. Use SniffTypeKind instead.
124 				float * out_quality,		//	If you implement SniffTypeKind, this doesn't
125 				int32 * out_internal_id);	//	get called.
126 virtual	status_t GetFileFormatList(
127 				int32 flavor_id,			//	for this node flavor (if it matters)
128 				media_file_format * out_writable_formats, 	//	don't write here if NULL
129 				int32 in_write_items,		//	this many slots in out_writable_formats
130 				int32 * out_write_items,	//	set this to actual # available, even if bigger than in count
131 				media_file_format * out_readable_formats, 	//	don't write here if NULL
132 				int32 in_read_items,		//	this many slots in out_readable_formats
133 				int32 * out_read_items,		//	set this to actual # available, even if bigger than in count
134 				void * _reserved);			//	ignore until further notice
135 virtual	status_t SniffTypeKind(				//	Like SniffType, but for the specific kind(s)
136 				const BMimeType & type,
137 				uint64 in_kinds,
138 				float * out_quality,
139 				int32 * out_internal_id,
140 				void * _reserved);
141 
142 		image_id ImageID();
143 		media_addon_id AddonID();
144 
145 protected:
146 
147 		//	Calling this will cause everyone to get notified, and also
148 		//	cause the server to re-scan your flavor info. It is thread safe.
149 		status_t			NotifyFlavorChange();
150 
151 private:
152 		BMediaAddOn();	/* private unimplemented */
153 		BMediaAddOn(const BMediaAddOn & clone);
154 		BMediaAddOn & operator=(const BMediaAddOn & clone);
155 
156 		friend class BPrivate::media::DormantNodeManager;
157 
158 		/* Mmmh, stuffing! */
159 virtual		status_t _Reserved_MediaAddOn_2(void *);
160 virtual		status_t _Reserved_MediaAddOn_3(void *);
161 virtual		status_t _Reserved_MediaAddOn_4(void *);
162 virtual		status_t _Reserved_MediaAddOn_5(void *);
163 virtual		status_t _Reserved_MediaAddOn_6(void *);
164 virtual		status_t _Reserved_MediaAddOn_7(void *);
165 
166 	image_id 		fImage;
167 	media_addon_id	fAddon;
168 	uint32			_reserved_media_add_on_[7];
169 };
170 
171 
172 #if BUILDING_MEDIA_ADDON
173 extern "C" _EXPORT BMediaAddOn * make_media_addon(image_id you);
174 #endif
175 
176 
177 #endif /* _MEDIA_ADD_ON_H */
178 
179