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

stream#videoCapture performance improvement. #1351

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
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
31 changes: 12 additions & 19 deletions Sources/IO/IOVideoUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,14 @@ final class IOVideoUnit: NSObject, IOUnit {
try capture.attachDevice(nil, videoUnit: self)
}
try capture(for: channel)?.attachDevice(device, videoUnit: self)
}
if device != nil {
if drawable != nil {
// Start captureing if not running.
mixer?.session.startRunning()
}
} else {
lockQueue.async {
self.videoMixer.detach(channel)
if device == nil {
videoMixer.detach(channel)
}
}
if device != nil && drawable != nil {
// Start captureing if not running.
mixer?.session.startRunning()
}
}

@available(tvOS 17.0, *)
Expand All @@ -258,19 +255,15 @@ final class IOVideoUnit: NSObject, IOUnit {
@available(tvOS 17.0, *)
func capture(for channel: UInt8) -> IOVideoCaptureUnit? {
#if os(tvOS)
return lockQueue.sync {
if _captures[channel] == nil {
_captures[channel] = IOVideoCaptureUnit()
}
return _captures[channel] as? IOVideoCaptureUnit
if _captures[channel] == nil {
_captures[channel] = IOVideoCaptureUnit()
}
return _captures[channel] as? IOVideoCaptureUnit
#else
return lockQueue.sync {
if captures[channel] == nil {
captures[channel] = .init()
}
return captures[channel]
if captures[channel] == nil {
captures[channel] = .init()
}
return captures[channel]
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Net/NetStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ open class NetStream: NSObject {
/// Returns the IOVideoCaptureUnit by index.
@available(tvOS 17.0, *)
public func videoCapture(for channel: UInt8) -> IOVideoCaptureUnit? {
return lockQueue.sync {
return mixer.videoIO.lockQueue.sync {
return self.mixer.videoIO.capture(for: channel)
}
}
Expand Down