AVSamples
public final class AVSamples
Undocumented
-
Undocumented
Declaration
Swift
public let data: UnsafeMutableBufferPointer<UnsafeMutablePointer<UInt8>?>
-
Undocumented
Declaration
Swift
public let size: Int
-
Undocumented
Declaration
Swift
public let linesize: Int
-
Undocumented
Declaration
Swift
public let channelCount: Int
-
Undocumented
Declaration
Swift
public let sampleCount: Int
-
Undocumented
Declaration
Swift
public let sampleFormat: AVSampleFormat
-
Create a samples buffer for
sampleCount
samples, and fill data pointers and linesize accordingly.Declaration
Swift
public init( channelCount: Int, sampleCount: Int, sampleFormat: AVSampleFormat, align: Int = 0 )
Parameters
data
array to be filled with the pointer for each channel
linesize
aligned size for audio buffer(s)
channelCount
the number of channels
sampleCount
the number of samples in a single channel
sampleFormat
the sample format
align
buffer size alignment (0 = default, 1 = no alignment)
-
Fill an audio buffer with silence.
Declaration
Swift
public func setSilence()
-
Reformat samples using the given
SwrContext
.Throws
AVErrorDeclaration
Swift
@discardableResult public func reformat(using context: SwrContext, to samples: AVSamples) throws -> Int
Return Value
number of samples output per channel
-
Get the required buffer size for the given audio parameters.
Throws
AVErrorDeclaration
Swift
public static func getBufferSize( channelCount: Int, sampleCount: Int, sampleFormat: AVSampleFormat, align: Int ) throws -> (Int, Int)
Parameters
channelCount
the number of channels
sampleCount
the number of samples in a single channel
sampleFormat
the sample format
align
buffer size alignment (0 = default, 1 = no alignment)
Return Value
required buffer size and calculated linesize
-
Fill plane data pointers and linesize for samples with sample format.
The data array is filled with the pointers to the samples data planes:
- for planar, set the start point of each channel’s data within the buffer,
- for packed, set the start point of the entire buffer only.
The value pointed to by linesize is set to the aligned size of each channel’s data buffer for planar layout, or to the aligned size of the buffer for all channels for packed layout.
The buffer in buf must be big enough to contain all the samples (use
getBufferSize(channelCount:sampleCount:sampleFormat:align:)
to compute its minimum size), otherwise the data pointers will point to invalid data.Throws
AVErrorDeclaration
Swift
public static func fillArrays( _ data: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, buffer: UnsafeMutablePointer<UInt8>?, channelCount: Int, sampleCount: Int, sampleFormat: AVSampleFormat, align: Int = 0 ) throws -> (Int, Int)
Parameters
data
array to be filled with the pointer for each channel
buffer
the pointer to a buffer containing the samples
channelCount
the number of channels
sampleCount
the number of samples in a single channel
sampleFormat
the sample format
align
buffer size alignment (0 = default, 1 = no alignment)
Return Value
the size in bytes required for the audio buffer, calculated linesize,