SwrContext
public final class SwrContext
Undocumented
-
Create
SwrContext.If you use this function you will need to set the parameters before calling
initialize().Declaration
Swift
public init() -
init(dstChannelLayout:dstSampleFormat:dstSampleRate:srcChannelLayout:srcSampleFormat:srcSampleRate:)Create
SwrContextif needed and set/reset common parameters.Declaration
Swift
public init( dstChannelLayout: AVChannelLayout, dstSampleFormat: AVSampleFormat, dstSampleRate: Int, srcChannelLayout: AVChannelLayout, srcSampleFormat: AVSampleFormat, srcSampleRate: Int )Parameters
dstChannelLayoutoutput channel layout
dstSampleFormatoutput sample format
dstSampleRateoutput sample rate (frequency in Hz)
srcChannelLayoutinput channel layout
srcSampleFormatinput sample format
srcSampleRateinput sample rate (frequency in Hz)
-
A Boolean value indicating whether the context has been initialized or not.
Declaration
Swift
public var isInitialized: Bool { get } -
setOptions(dstChannelLayout:dstSampleFormat:dstSampleRate:srcChannelLayout:srcSampleFormat:srcSampleRate:)Set/reset common parameters.
Throws
AVError
Declaration
Swift
public func setOptions( dstChannelLayout: AVChannelLayout, dstSampleFormat: AVSampleFormat, dstSampleRate: Int, srcChannelLayout: AVChannelLayout, srcSampleFormat: AVSampleFormat, srcSampleRate: Int ) throwsParameters
dstChannelLayoutoutput channel layout
dstSampleFormatoutput sample format
dstSampleRateoutput sample rate (frequency in Hz)
srcChannelLayoutinput channel layout
srcSampleFormatinput sample format
srcSampleRateinput sample rate (frequency in Hz)
-
Initialize context after user parameters have been set.
Throws
AVErrorDeclaration
Swift
public func initialize() throws -
Closes the context so that
isInitializedreturnsfalse.The context can be brought back to life by running
initialize(),initialize()can also be used withoutclose(). This function is mainly provided for simplifying the usecase where one tries to support libavresample and libswresample.Declaration
Swift
public func close() -
Gets the delay the next input sample will experience relative to the next output sample.
Declaration
Swift
public func getDelay(_ timebase: Int64) -> IntParameters
timebasetimebase in which the returned delay will be
- if it’s set to 1 the returned delay is in seconds
- if it’s set to 1000 the returned delay is in milliseconds
- if it’s set to the input sample rate then the returned delay is in input samples
- if it’s set to the output sample rate then the returned delay is in output samples
- if it’s the least common multiple of
in_sample_rateandout_sample_ratethen an exact rounding-free delay will be returned
Return Value
the delay in 1 / base units.
-
Find an upper bound on the number of samples that the next
convert(dst:dstCount:src:srcCount:)call will output, if called withsampleCountof input samples. This depends on the internal state, and anything changing the internal state (like furtherconvert(dst:dstCount:src:srcCount:)calls) will may change the number of samplesgetOutSamples(_:)returns for the same number of input samples.Note
any call to swr_inject_silence(), swr_convert(), swr_next_pts() or swr_set_compensation() invalidates this limit
Note
it is recommended to pass the correct available buffer size to all functions like
convert(dst:dstCount:src:srcCount:)even ifgetOutSamples(_:)indicates that less would be used.Throws
AVError
Declaration
Swift
public func getOutSamples(_ sampleCount: Int64) throws -> IntParameters
sampleCountnumber of input samples
Return Value
an upper bound on the number of samples that the next
convert(dst:dstCount:src:srcCount:)will output -
Convert audio.
dstanddstCountcan be set to 0 to flush the last few samples out at the end.If more input is provided than output space, then the input will be buffered. You can avoid this buffering by using
getOutSamples(_:)to retrieve an upper bound on the required number of output samples for the given number of input samples. Conversion will run directly without copying whenever possible.Throws
AVErrorDeclaration
Swift
@discardableResult public func convert( dst: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, dstCount: Int, src: UnsafeMutablePointer<UnsafePointer<UInt8>?>, srcCount: Int ) throws -> IntParameters
dstoutput buffers, only the first one need be set in case of packed audio
dstCountamount of space available for output in samples per channel
srcinput buffers, only the first one need to be set in case of packed audio
srcCountnumber of input samples available in one channel
Return Value
number of samples output per channel
-
Undocumented
Declaration
Swift
public static let `class`: AVClass -
Undocumented
Declaration
Swift
public func withUnsafeClassObjectPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T
-
Undocumented
Declaration
Swift
public func withUnsafeObjectPointer<T>(_ body: (UnsafeMutableRawPointer) throws -> T) rethrows -> T
View on GitHub
Install in Dash
SwrContext Class Reference