Skip to content

Commit

Permalink
Add (start|stop)Capturing()
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Aug 15, 2024
1 parent 3d69e5a commit fbf94a5
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion Sources/IO/IOStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ open class IOStream: NSObject {
}
}

/// The capture session is in a running state or not.
public var isCapturing: Bool {
lockQueue.sync {
mixer.session.isRunning.value
}
}

/// Specifies the audio monitoring enabled or not.
public var isMonitoringEnabled: Bool {
get {
Expand All @@ -107,7 +114,7 @@ open class IOStream: NSObject {
}

#if os(iOS) || os(macOS) || os(tvOS)
/// Specifiet the device torch indicating wheter the turn on(TRUE) or not(FALSE).
/// Specifies the device torch indicating wheter the turn on(TRUE) or not(FALSE).
public var torch: Bool {
get {
return lockQueue.sync { self.mixer.videoIO.torch }
Expand Down Expand Up @@ -466,6 +473,22 @@ open class IOStream: NSObject {
}
}

/// 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.
public func startCapturing() {
lockQueue.async {
self.mixer.session.startRunning()
}
}

/// Stops capturing from input devices.
public func stopCapturing() {
lockQueue.async {
self.mixer.session.stopRunning()
}
}

#if os(iOS) || os(tvOS) || os(visionOS)
@objc
private func didEnterBackground(_ notification: Notification) {
Expand Down

0 comments on commit fbf94a5

Please sign in to comment.