1/******************************************************************************
2/
3/	File:			RadeonAddOn.h
4/
5/	Description:	ATI Radeon Video Capture Media AddOn for BeOS.
6/
7/	Copyright 2001, Carlos Hasan
8/
9*******************************************************************************/
10
11#ifndef __RADEON_ADDON_H__
12#define __RADEON_ADDON_H__
13
14#include <media/MediaAddOn.h>
15#include <Path.h>
16#include "benaphore.h"
17
18#define TOUCH(x) ((void)(x))
19
20extern "C" _EXPORT BMediaAddOn *make_media_addon(image_id you);
21
22class CRadeonAddOn;
23
24// descriptor of a possible Radeon node
25class CRadeonPlug {
26public:
27	CRadeonPlug( CRadeonAddOn *addon, const BPath &dev_path, int id );
28	~CRadeonPlug() {}
29
30	const char *getName() { return fFlavorInfo.name; }
31	const char *getDeviceName() { return dev_path.Path(); }
32	const char *getDeviceShortName() { return dev_path.Leaf(); }
33	flavor_info	*getFlavorInfo() { return &fFlavorInfo; }
34	BMediaNode	*getNode() { return node; }
35	void		setNode( BMediaNode *anode ) { node = anode; }
36	BMessage	*getSettings() { return &settings; }
37
38	void		writeSettings( BMessage *new_settings );
39
40private:
41	CRadeonAddOn	*addon;		// (global) addon (only needed for GetConfiguration())
42	BPath 			dev_path;		// path of device driver
43	int				id;				// id of plug
44	flavor_info		fFlavorInfo;	// flavor of plug (contains unique id)
45	BMediaNode		*node;			// active node (or NULL)
46	BMessage		settings;		// settings for this node
47	media_format	fMediaFormat[4];
48
49	void		readSettings();
50	BPath 		getSettingsPath();
51};
52
53class CRadeonAddOn : public BMediaAddOn
54{
55public:
56						CRadeonAddOn(image_id imid);
57	virtual 			~CRadeonAddOn();
58
59	virtual	status_t	InitCheck(const char **out_failure_text);
60
61	virtual	int32		CountFlavors();
62	virtual	status_t	GetFlavorAt(int32 n, const flavor_info ** out_info);
63	virtual	BMediaNode	*InstantiateNodeFor(
64							const flavor_info * info,
65							BMessage * config,
66							status_t * out_error);
67
68	virtual	status_t	SaveConfigInfo(BMediaNode *node, BMessage *message)
69								{ TOUCH(node); TOUCH(message); return B_OK; }
70
71	virtual	bool		WantsAutoStart() { return false; }
72	virtual	status_t	AutoStart(int in_count, BMediaNode **out_node,
73								int32 *out_internal_id, bool *out_has_more)
74								{	TOUCH(in_count); TOUCH(out_node);
75									TOUCH(out_internal_id); TOUCH(out_has_more);
76									return B_ERROR; }
77
78	virtual status_t	GetConfigurationFor(
79							BMediaNode *your_node,
80							BMessage *into_message );
81
82// private methods
83	void				UnregisterNode( BMediaNode *node, BMessage *settings );
84
85private:
86	status_t			fInitStatus;
87	BList				fDevices;		// list of BPath of found devices
88	thread_id			settings_thread;
89	sem_id				settings_thread_sem;
90	benaphore			plug_lock;
91	BMessage			settings;
92
93	status_t			RecursiveScan( const char* rootPath, BEntry *rootEntry = NULL );
94	static int32 		settings_writer( void *param );
95	void				settingsWriter();
96	void 				writeSettings();
97};
98
99#endif
100