Skip to content

Commit

Permalink
fixed #994
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Nov 17, 2023
1 parent f805b71 commit f46191f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Sources/Media/IOVideoMixer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class IOVideoMixer<T: IOVideoMixerDelegate> {
private var pixelBuffer: CVPixelBuffer?
private var pixelBufferPool: CVPixelBufferPool?
private var multiCamSampleBuffer: CMSampleBuffer?
private(set) var effects: Set<VideoEffect> = []
private(set) var effects: [VideoEffect] = .init()

@inline(__always)
func effect(_ buffer: CVImageBuffer, info: CMSampleBuffer?) -> CIImage {
Expand All @@ -54,12 +54,20 @@ final class IOVideoMixer<T: IOVideoMixerDelegate> {

func registerEffect(_ effect: VideoEffect) -> Bool {
effect.ciContext = context
return effects.insert(effect).inserted
if effects.contains(effect) {
return false
}
effects.append(effect)
return true
}

func unregisterEffect(_ effect: VideoEffect) -> Bool {
effect.ciContext = nil
return effects.remove(effect) != nil
if let index = effects.firstIndex(of: effect) {
effects.remove(at: index)
return true
}
return false
}

func append(_ sampleBuffer: CMSampleBuffer, channel: Int, isVideoMirrored: Bool) {
Expand Down

0 comments on commit f46191f

Please sign in to comment.