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