Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add (start|stop)Capturing() api. #1537

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Sources/IO/IOStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ open class IOStream: NSObject {
}
}

/// The capture session is in a running state or not.
@available(tvOS 17.0, *)
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 +115,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 +474,24 @@ 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.
@available(tvOS 17.0, *)
public func startCapturing() {
lockQueue.async {
self.mixer.session.startRunning()
}
}

/// Stops capturing from input devices.
@available(tvOS 17.0, *)
public func stopCapturing() {
lockQueue.async {
self.mixer.session.stopRunning()
}
}

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