1 /* MediaFormats.h */ 2 /* Copyright 1998 Be Incorporated. All rights reserved. */ 3 4 #if !defined(_MEDIA_TYPES_H) 5 #define _MEDIA_TYPES_H 6 7 #if defined(__cplusplus) 8 #include <MediaDefs.h> 9 10 #include <Messenger.h> 11 #include <List.h> 12 #include <Locker.h> 13 #endif 14 15 16 struct media_codec_info { 17 char pretty_name[96]; // eg: "SuperSqueeze Encoder by Foo Inc" 18 char short_name[32]; // eg: "supersqueeze" 19 20 int32 id; // opaque id passed to BMediaFile::CreateTrack 21 int32 sub_id; 22 23 int32 pad[63]; 24 }; 25 26 // 27 // Use this to iterate through the available encoders for a file format. 28 // 29 status_t get_next_encoder(int32 *cookie, 30 const media_file_format *fileFormat,// this comes from get_next_file_format() 31 const media_format *inFormat, // this is the type of data given to the encoder 32 media_format *_outFormat, // this is the type of data encoder will output 33 media_codec_info *_codecInfo); // information about the encoder 34 35 status_t get_next_encoder( 36 int32 *cookie, 37 const media_file_format *fileFormat,// this comes from get_next_file_format() 38 // pass NULL if you don't care 39 const media_format *inFormat, // this is the type of data given to the 40 // encoder, wildcards are accepted 41 const media_format *_outFormat, // this is the type of data encoder 42 // you want the encoder to output. 43 // Wildcards are accepted 44 media_codec_info *codecInfo, // information about the encoder 45 media_format *_acceptedInputFormat, // this is the type of data that the 46 // encoder will accept as input. 47 // Wildcards in input_format will be 48 // specialized here. 49 media_format *_acceptedOutputFormat // this is the type of data that the 50 // encoder will output. 51 // Wildcards in output_format will be 52 // specialized here. 53 ); 54 55 status_t get_next_encoder(int32 *cookie, media_codec_info *_codecInfo); 56 57 58 enum media_file_accept_format_flags { 59 B_MEDIA_REJECT_WILDCARDS = 0x1 60 }; 61 62 bool does_file_accept_format(const media_file_format *fileFormat, 63 media_format *format, uint32 flags = 0); 64 65 66 typedef struct { 67 uint8 data[16]; 68 } GUID; 69 70 enum beos_format { 71 B_BEOS_FORMAT_RAW_AUDIO = 'rawa', 72 B_BEOS_FORMAT_RAW_VIDEO = 'rawv' 73 }; 74 typedef struct { 75 int32 format; 76 } media_beos_description; 77 78 typedef struct { 79 uint32 codec; 80 uint32 vendor; 81 } media_quicktime_description; 82 83 typedef struct { 84 uint32 codec; 85 } media_avi_description; 86 87 typedef struct { 88 uint32 id; 89 } media_avr_description; 90 91 typedef struct { 92 GUID guid; 93 } media_asf_description; 94 95 enum mpeg_id { 96 B_MPEG_ANY = 0, 97 B_MPEG_1_AUDIO_LAYER_1 = 0x101, 98 B_MPEG_1_AUDIO_LAYER_2 = 0x102, 99 B_MPEG_1_AUDIO_LAYER_3 = 0x103, // "MP3" 100 B_MPEG_1_VIDEO = 0x111, 101 B_MPEG_2_AUDIO_LAYER_1 = 0x201, 102 B_MPEG_2_AUDIO_LAYER_2 = 0x202, 103 B_MPEG_2_AUDIO_LAYER_3 = 0x203, 104 B_MPEG_2_VIDEO = 0x211, 105 B_MPEG_2_5_AUDIO_LAYER_1 = 0x301, 106 B_MPEG_2_5_AUDIO_LAYER_2 = 0x302, 107 B_MPEG_2_5_AUDIO_LAYER_3 = 0x303, 108 }; 109 typedef struct { 110 uint32 id; 111 } media_mpeg_description; 112 113 typedef struct { 114 uint32 codec; 115 } media_wav_description; 116 117 typedef struct { 118 uint32 codec; 119 } media_aiff_description; 120 121 typedef struct { 122 uint32 file_format; 123 uint32 codec; 124 } media_misc_description; 125 126 typedef struct _media_format_description { 127 #if defined(__cplusplus) 128 _media_format_description(); 129 ~_media_format_description(); 130 _media_format_description(const _media_format_description & other); 131 _media_format_description & operator=(const _media_format_description & other); 132 #endif 133 media_format_family family; 134 uint32 _reserved_[3]; 135 union { 136 media_beos_description beos; 137 media_quicktime_description quicktime; 138 media_avi_description avi; 139 media_asf_description asf; 140 media_mpeg_description mpeg; 141 media_wav_description wav; 142 media_aiff_description aiff; 143 media_misc_description misc; 144 media_avr_description avr; 145 uint32 _reserved_[12]; 146 } u; 147 } media_format_description; 148 149 150 #ifdef __cplusplus 151 152 153 class BMediaFormats { 154 public: 155 BMediaFormats(); 156 virtual ~BMediaFormats(); 157 158 status_t InitCheck(); 159 160 // Make sure you memset() your descs to 0 before you start filling 161 // them in! Else you may register some bogus value. 162 enum make_format_flags { 163 B_EXCLUSIVE = 0x1, // Fail if this format has already been registered 164 B_NO_MERGE = 0x2, // Don't re-number any formats if there are multiple 165 // clashing previous registrations, but fail instead 166 B_SET_DEFAULT = 0x4 // Set the first format to be the default for the 167 // format family (when registering more than one in 168 // the same family). Only use in Encoder add-ons. 169 }; 170 171 status_t MakeFormatFor(const media_format_description *descriptions, 172 int32 descriptionCount, media_format *inOutFormat, 173 uint32 flags = 0, void * _reserved = 0); 174 status_t GetFormatFor(const media_format_description &description, 175 media_format *_outFormat); 176 177 status_t GetCodeFor(const media_format &format, 178 media_format_family family, media_format_description *_outDescription); 179 180 status_t RewindFormats(); 181 status_t GetNextFormat(media_format *_outFormat, 182 media_format_description *_outDescription); 183 184 // You need to lock/unlock (only) when using RewindFormats()/GetNextFormat() 185 bool Lock(); 186 void Unlock(); 187 188 // convenience functions 189 static status_t GetBeOSFormatFor(uint32 fourcc, 190 media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE); 191 static status_t GetAVIFormatFor(uint32 fourcc, 192 media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE); 193 static status_t GetQuicktimeFormatFor(uint32 vendor, uint32 fourcc, 194 media_format *_outFormat, media_type type = B_MEDIA_UNKNOWN_TYPE); 195 196 /* --- begin deprecated API --- */ 197 198 status_t MakeFormatFor(const media_format_description &description, 199 const media_format &inFormat, media_format *_outFormat); 200 201 private: 202 int32 fIteratorIndex; 203 uint32 _reserved[30]; 204 }; 205 206 _IMPEXP_MEDIA bool operator==(const media_format_description & a, const media_format_description & b); 207 _IMPEXP_MEDIA bool operator<(const media_format_description & a, const media_format_description & b); 208 209 _IMPEXP_MEDIA bool operator==(const GUID & a, const GUID & b); 210 _IMPEXP_MEDIA bool operator<(const GUID & a, const GUID & b); 211 212 #endif /* __cplusplus */ 213 214 #endif /* _MEDIA_TYPES_H */ 215 216