MediaMixer
public final actor MediaMixer
extension MediaMixer: AsyncRunner
An actor that mixies audio and video for streaming.
-
The error domain codes.
See moreDeclaration
Swift
public enum Error : Swift.Error
-
The offscreen rendering object.
Declaration
Swift
@ScreenActor public private(set) lazy var screen: Screen { get set }
-
The device torch indicating wheter the turn on(TRUE) or not(FALSE).
Declaration
Swift
public var isTorchEnabled: Bool { get }
-
The feature to mix multiple audio tracks. For example, it is possible to mix .appAudio and .micAudio from ReplayKit.
Declaration
Swift
public var isMultiTrackAudioMixingEnabled: Bool { get }
-
The sessionPreset for the AVCaptureSession.
Declaration
Swift
@available(tvOS 17.0, *) public var sessionPreset: AVCaptureSession.Preset { get }
-
The audio monitoring enabled or not.
Declaration
Swift
public var isMonitoringEnabled: Bool { get }
-
The audio mixer settings.
Declaration
Swift
public var audioMixerSettings: AudioMixerSettings { get }
-
The video mixer settings.
Declaration
Swift
public var videoMixerSettings: VideoMixerSettings { get }
-
The audio input formats.
Declaration
Swift
public var audioInputFormats: [UInt8 : AVAudioFormat] { get }
-
The video input formats.
Declaration
Swift
public var videoInputFormats: [UInt8 : CMFormatDescription] { get }
-
The frame rate of a device capture.
Declaration
Swift
public var frameRate: Float64 { get }
-
The capture session is in a running state or not.
Declaration
Swift
@available(tvOS 17.0, *) public var isCapturing: Bool { get }
-
The video orientation for stream.
Declaration
Swift
public var videoOrientation: AVCaptureVideoOrientation { get }
-
Declaration
Swift
public private(set) var isRunning: Bool { get }
-
Creates a new instance.
Declaration
Swift
public init()
-
attachVideo(_:
Asynchronoustrack: configuration: ) Attaches a video device.
Declaration
Swift
@available(tvOS 17.0, *) public func attachVideo(_ device: AVCaptureDevice?, track: UInt8 = 0, configuration: VideoDeviceConfigurationBlock? = nil) async throws
-
Configurations for a video device.
Declaration
Swift
@available(tvOS 17.0, *) public func configuration(video track: UInt8, configuration: VideoDeviceConfigurationBlock) throws
-
attachAudio(_:
Asynchronoustrack: configuration: ) Attaches an audio device.
Attention
You can perform multi-microphone capture by specifying as follows on macOS. Unfortunately, it seems that only one microphone is available on iOS.mixer.setMultiTrackAudioMixingEnabled(true) var audios = AVCaptureDevice.devices(for: .audio) if let device = audios.removeFirst() { mixer.attachAudio(device, track: 0) } if let device = audios.removeFirst() { mixer.attachAudio(device, track: 1) }
Declaration
Swift
@available(tvOS 17.0, *) public func attachAudio(_ device: AVCaptureDevice?, track: UInt8 = 0, configuration: AudioDeviceConfigurationBlock? = nil) async throws
-
Configurations for an audio device.
Declaration
Swift
@available(tvOS 17.0, *) public func configuration(audio track: UInt8, configuration: AudioDeviceConfigurationBlock) throws
-
Sets the device torch indicating wheter the turn on(TRUE) or not(FALSE).
Declaration
Swift
public func setTorchEnabled(_ torchEnabled: Bool)
-
Sets the sessionPreset for the AVCaptureSession.
Declaration
Swift
@available(tvOS 17.0, *) public func setSessionPreset(_ sessionPreset: AVCaptureSession.Preset)
-
Sets the video orientation for stream.
Declaration
Swift
public func setVideoOrientation(_ videoOrientation: AVCaptureVideoOrientation)
-
Appends a CMSampleBuffer.
Declaration
Swift
public func append(_ sampleBuffer: CMSampleBuffer, track: UInt8 = 0)
Parameters
sampleBuffer
The sample buffer to append.
track
Track number used for mixing
-
Sets the video mixier settings.
Declaration
Swift
public func setVideoMixerSettings(_ settings: VideoMixerSettings)
-
Sets the frame rate of a device capture.
Declaration
Swift
public func setFrameRate(_ frameRate: Float64)
-
Sets the audio mixer settings.
Declaration
Swift
public func setAudioMixerSettings(_ settings: AudioMixerSettings)
-
Sets the audio monitoring enabled or not.
Declaration
Swift
public func setMonitoringEnabled(_ monitoringEnabled: Bool)
-
Starts capturing from input devices.
Internally, it is called either when the view is attached or just before publishing. In other cases, please call this method if you want to manually start the capture.
Declaration
Swift
@available(tvOS 17.0, *) public func startCapturing()
-
Stops capturing from input devices.
Declaration
Swift
@available(tvOS 17.0, *) public func stopCapturing()
-
Specifies the AVCaptureMultiCamSession enabled.
Attention
If there is a possibility of using multiple cameras, please set it to true initially. -
Specifies the feature to mix multiple audio tracks. For example, it is possible to mix .appAudio and .micAudio from ReplayKit.
Attention
If there is a possibility of this feature, please set it to true initially.Declaration
Swift
public func setMultiTrackAudioMixingEnabled(_ multiTrackAudioMixingEnabled: Bool)
-
Appends an AVAudioBuffer.
Declaration
Swift
public func append(_ audioBuffer: AVAudioBuffer, when: AVAudioTime, track: UInt8 = 0)
Parameters
audioBuffer
The audio buffer to append.
when
The audio time to append.
track
Track number used for mixing.
-
Configurations for the AVCaptureSession.
Attention
Internally, there is no need for developers to call beginConfiguration() and func commitConfiguration() as they are called automatically.Declaration
Swift
@available(tvOS 17.0, *) public func configuration(_ lambda: @Sendable (_ session: AVCaptureSession) throws -> Void) rethrows
-
Adds an output observer.
Declaration
Swift
public func addOutput(_ output: some MediaMixerOutput)
-
Removes an output observer.
Declaration
Swift
public func removeOutput(_ output: some MediaMixerOutput)
-
Declaration
Swift
public func startRunning()
-
Declaration
Swift
public func stopRunning()