2022-02-07 05:49:27 +00:00
// Plugins! HOORAY!
2007-02-24 20:36:27 +00:00
2007-03-02 01:36:52 +00:00
@ protocol CogSource < NSObject >
2022-02-07 05:49:27 +00:00
+ ( NSArray * ) schemes ; // http, file, etc
2007-02-24 20:36:27 +00:00
2007-03-04 04:36:10 +00:00
- ( NSURL * ) url ;
2007-10-14 17:31:20 +00:00
- ( NSString * ) mimeType ;
2007-02-24 20:36:27 +00:00
- ( BOOL ) open : ( NSURL * ) url ;
2007-03-02 01:36:52 +00:00
- ( BOOL ) seekable ;
- ( BOOL ) seek : ( long ) position whence : ( int ) whence ;
- ( long ) tell ;
2022-02-07 05:49:27 +00:00
- ( long ) read : ( void * ) buffer amount : ( long ) amount ; // reads UP TO amount, returns amount read.
2007-03-02 01:36:52 +00:00
- ( void ) close ;
2016-06-19 19:57:18 +00:00
- ( void ) dealloc ;
2007-03-02 01:36:52 +00:00
@ end
2021-12-28 01:46:09 +00:00
@ protocol CogVersionCheck < NSObject >
+ ( BOOL ) shouldLoadForOSVersion : ( NSOperatingSystemVersion ) version ;
@ end
2022-02-07 05:49:27 +00:00
@ protocol CogContainer < NSObject >
+ ( NSArray * ) fileTypes ; // mp3, ogg, etc
2007-10-14 18:56:23 +00:00
+ ( NSArray * ) mimeTypes ;
2015-04-13 07:39:24 +00:00
+ ( float ) priority ;
2007-10-09 01:20:46 +00:00
+ ( NSArray * ) urlsForContainerURL : ( NSURL * ) url ;
@ end
2022-02-07 05:49:27 +00:00
@ protocol CogDecoder < NSObject >
2007-11-24 20:16:27 +00:00
@ required
2007-10-14 17:31:20 +00:00
+ ( NSArray * ) mimeTypes ;
2022-02-07 05:49:27 +00:00
+ ( NSArray * ) fileTypes ; // mp3, ogg, etc
2022-01-18 11:06:03 +00:00
+ ( NSArray * ) fileTypeAssociations ; // array of NSArray of NSString, where first item in array is the type name, the second is the icon name, and the rest are the extensions
Implemented support for multiple decoders per file name extension, with a floating point priority control per interface. In the event that more than one input is registered to a given extension, and we match that extension, it will be passed off to an instance of the multi-decoder wrapper, which will try opening the file with all of the decoders in order of priority, until either one of them accepts it, or all of them have failed. This paves the way for adding a VGMSTREAM input, so I can give it a very low priority, since it has several formats that are verified by file name extension only. All current inputs have been given a priority of 1.0, except for CoreAudio, which was given a priority of 0.5, because it contains an MP3 and AC3 decoders that I'd rather not use if I don't have to.
2013-10-21 17:54:11 +00:00
+ ( float ) priority ; // should be 0.0 ... 1.0, higher means you get selected first, should default to 1.0 unless you know a reason why any of your extensions may behave badly, ie. greedily taking over some file type extension without performing any header validation on it
2007-03-02 01:36:52 +00:00
2022-02-07 05:49:27 +00:00
// For KVO
2007-03-03 17:19:37 +00:00
//- (void)setProperties:(NSDictionary *)p;
2007-02-24 20:36:27 +00:00
- ( NSDictionary * ) properties ;
2022-02-09 03:56:39 +00:00
- ( NSDictionary * ) metadata ; // Only to be implemented for dynamic metadata, send events on change
2007-03-03 17:19:37 +00:00
2007-11-24 20:16:27 +00:00
- ( int ) readAudio : ( void * ) buffer frames : ( UInt32 ) frames ;
2007-03-03 17:19:37 +00:00
- ( BOOL ) open : ( id < CogSource > ) source ;
2007-11-24 20:16:27 +00:00
- ( long ) seek : ( long ) frame ;
2007-02-24 20:36:27 +00:00
- ( void ) close ;
2007-11-24 20:16:27 +00:00
@ optional
2016-06-19 19:57:18 +00:00
- ( void ) dealloc ;
2007-11-24 20:16:27 +00:00
- ( BOOL ) setTrack : ( NSURL * ) track ;
2022-02-07 05:49:27 +00:00
// These are in NSObject, so as long as you are a subclass of that, you are ok.
2007-11-24 20:16:27 +00:00
- ( void ) addObserver : ( NSObject * ) observer forKeyPath : ( NSString * ) keyPath options : ( NSKeyValueObservingOptions ) options context : ( void * ) context ;
- ( void ) removeObserver : ( NSObject * ) observer forKeyPath : ( NSString * ) keyPath ;
2022-02-10 10:15:48 +00:00
- ( BOOL ) isSilence ;
2007-02-24 20:36:27 +00:00
@ end
2007-03-02 01:36:52 +00:00
@ protocol CogMetadataReader < NSObject >
2007-02-24 20:36:27 +00:00
+ ( NSArray * ) fileTypes ;
2007-10-14 18:56:23 +00:00
+ ( NSArray * ) mimeTypes ;
2015-04-13 07:39:24 +00:00
+ ( float ) priority ;
2007-10-09 01:20:46 +00:00
+ ( NSDictionary * ) metadataForURL : ( NSURL * ) url ;
2007-02-24 20:36:27 +00:00
@ end
2008-11-21 15:14:23 +00:00
@ protocol CogMetadataWriter < NSObject >
//+ (NSArray *)fileTypes;
//+ (NSArray *)mimeTypes;
2013-10-03 08:00:58 +00:00
+ ( int ) putMetadataInURL : ( NSURL * ) url tagData : ( NSDictionary * ) tagData ;
2008-11-21 15:14:23 +00:00
@ end
2007-03-02 01:36:52 +00:00
@ protocol CogPropertiesReader < NSObject >
2007-02-24 20:36:27 +00:00
+ ( NSArray * ) fileTypes ;
2007-10-14 17:31:20 +00:00
+ ( NSArray * ) mimeTypes ;
2015-04-13 07:39:24 +00:00
+ ( float ) priority ;
2007-03-02 01:36:52 +00:00
+ ( NSDictionary * ) propertiesForSource : ( id < CogSource > ) source ;
2007-02-24 20:36:27 +00:00
@ end
2007-10-09 01:20:46 +00:00
@ protocol CogPluginController < NSObject >
2007-10-20 15:53:52 +00:00
+ ( id < CogPluginController > ) sharedPluginController ;
2007-10-20 15:46:39 +00:00
- ( NSDictionary * ) sources ;
- ( NSDictionary * ) containers ;
- ( NSDictionary * ) metadataReaders ;
- ( NSDictionary * ) propertiesReadersByExtension ;
- ( NSDictionary * ) propertiesReadersByMimeType ;
- ( NSDictionary * ) decodersByExtension ;
- ( NSDictionary * ) decodersByMimeType ;
2022-02-07 05:49:27 +00:00
- ( id < CogSource > ) audioSourceForURL : ( NSURL * ) url ;
- ( NSArray * ) urlsForContainerURL : ( NSURL * ) url ;
- ( NSDictionary * ) metadataForURL : ( NSURL * ) url skipCue : ( BOOL ) skip ;
2022-02-13 20:18:58 +00:00
- ( NSDictionary * ) propertiesForURL : ( NSURL * ) url skipCue : ( BOOL ) skip ;
2022-02-07 05:49:27 +00:00
- ( id < CogDecoder > ) audioDecoderForSource : ( id < CogSource > ) source skipCue : ( BOOL ) skip ;
2008-11-21 15:14:23 +00:00
2022-02-07 05:49:27 +00:00
- ( int ) putMetadataInURL : ( NSURL * ) url ;
2007-10-09 01:20:46 +00:00
@ end
2022-05-24 08:05:43 +00:00
static NSString * guess_encoding_of_string ( const char * input ) {
NSString * ret = @ " " ;
NSData * stringData = [ NSData dataWithBytes : input length : strlen ( input ) ] ;
[ NSString stringEncodingForData : stringData encodingOptions : nil convertedString : & ret usedLossyConversion : nil ] ;
return ret ;
}