-
Notifications
You must be signed in to change notification settings - Fork 86
/
SFBAudioDecoding.h
73 lines (51 loc) · 2.58 KB
/
SFBAudioDecoding.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// Copyright (c) 2006-2024 Stephen F. Booth <[email protected]>
// Part of https://github.com/sbooth/SFBAudioEngine
// MIT license
//
#import <Foundation/Foundation.h>
#import <AVFAudio/AVFAudio.h>
#import <SFBAudioEngine/SFBAudioEngineTypes.h>
#import <SFBAudioEngine/SFBInputSource.h>
NS_ASSUME_NONNULL_BEGIN
/// A key in an audio decoder's properties dictionary
typedef NSString * SFBAudioDecodingPropertiesKey NS_TYPED_ENUM NS_SWIFT_NAME(AudioDecodingPropertiesKey);
/// A value in an audio decoder's properties dictionary
typedef id SFBAudioDecodingPropertiesValue NS_SWIFT_NAME(AudioDecodingPropertiesValue);
/// Protocol defining the interface for audio decoders
NS_SWIFT_NAME(AudioDecoding) @protocol SFBAudioDecoding
#pragma mark - Input
/// The `SFBInputSource` providing data to this decoder
@property (nonatomic, readonly) SFBInputSource *inputSource;
#pragma mark - Audio Format Information
/// The format of the encoded audio data
@property (nonatomic, readonly) AVAudioFormat *sourceFormat;
/// The format of audio data produced by `-decodeIntoBuffer:error:`
@property (nonatomic, readonly) AVAudioFormat *processingFormat;
/// `YES` if decoding allows the original signal to be perfectly reconstructed
@property (nonatomic, readonly) BOOL decodingIsLossless;
/// Returns a dictionary containing decoder-specific properties
/// - note: Properties are read when the decoder is opened
@property (nonatomic, readonly) NSDictionary<SFBAudioDecodingPropertiesKey, SFBAudioDecodingPropertiesValue> *properties;
#pragma mark - Setup and Teardown
/// Opens the decoder for reading
/// - parameter error: An optional pointer to an `NSError` object to receive error information
/// - returns: `YES` on success, `NO` otherwise
- (BOOL)openReturningError:(NSError **)error NS_SWIFT_NAME(open());
/// Closes the decoder
/// - parameter error: An optional pointer to an `NSError` object to receive error information
/// - returns: `YES` on success, `NO` otherwise
- (BOOL)closeReturningError:(NSError **)error NS_SWIFT_NAME(close());
/// Returns `YES` if the decoder is open
@property (nonatomic, readonly) BOOL isOpen;
#pragma mark - Decoding
/// Decodes audio
/// - parameter buffer: A buffer to receive the decoded audio
/// - parameter error: An optional pointer to an `NSError` object to receive error information
/// - returns: `YES` on success, `NO` otherwise
- (BOOL)decodeIntoBuffer:(AVAudioBuffer *)buffer error:(NSError **)error NS_SWIFT_NAME(decode(into:));
#pragma mark - Seeking
/// Returns `YES` if the decoder is seekable
@property (nonatomic, readonly) BOOL supportsSeeking;
@end
NS_ASSUME_NONNULL_END