SFBAudioEncoding

@protocol SFBAudioEncoding

Protocol defining the interface for audio encoders

Output

  • The \c SFBOutputSource consuming data from this decoder

    Declaration

    Objective-C

    @property (nonatomic, readonly) SFBOutputSource *_Nonnull outputSource;

Audio Format Information

  • The source audio format

    Declaration

    Objective-C

    @property (nonatomic, readonly) AVAudioFormat *_Nonnull sourceFormat;
  • The format of audio of data consumed by \c -encodeFromBuffer:error:

    Declaration

    Objective-C

    @property (nonatomic, readonly) AVAudioFormat *_Nonnull processingFormat;
  • The format of the encoded audio data

    Declaration

    Objective-C

    @property (nonatomic, readonly) AVAudioFormat *_Nonnull outputFormat;
  • \c YES if encoding allows the original signal to be perfectly reconstructed

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL encodingIsLossless;
  • Returns the processing format used for the given source format

    Declaration

    Objective-C

    - (nullable AVAudioFormat *)processingFormatForSourceFormat:
        (nonnull AVAudioFormat *)sourceFormat;

    Parameters

    sourceFormat

    The source audio format

    Return Value

    The processing format corresponding to \c sourceFormat, or \c nil if \c sourceFormat is not supported

Setup and Teardown

  • Sets the source audio format for the encoder

    Note

    If supported, the source format is used to determine the appropriate \c processingFormat

    Declaration

    Objective-C

    - (BOOL)setSourceFormat:(nonnull AVAudioFormat *)sourceFormat
                      error:(NSError *_Nullable *_Nullable)error;

    Parameters

    sourceFormat

    The source audio format

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Opens the encoder for writing

    Declaration

    Objective-C

    - (BOOL)openReturningError:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Closes the encoder

    Declaration

    Objective-C

    - (BOOL)closeReturningError:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Returns \c YES if the encoder is open

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL isOpen;

Encoding

  • Encoder settings

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSDictionary<SFBAudioEncodingSettingsKey, SFBAudioEncodingSettingsValue> *settings;
  • Encodes audio

    Declaration

    Objective-C

    - (BOOL)encodeFromBuffer:(nonnull AVAudioBuffer *)buffer
                       error:(NSError *_Nullable *_Nullable)error;

    Parameters

    buffer

    A buffer to receive the decoded audio

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise

  • Finishes encoding

    Declaration

    Objective-C

    - (BOOL)finishEncodingReturningError:(NSError *_Nullable *_Nullable)error;

    Parameters

    error

    An optional pointer to an \c NSError object to receive error information

    Return Value

    \c YES on success, \c NO otherwise