Skip to content

Commit

Permalink
Fix photo using surface crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Grigoryev committed Nov 2, 2020
1 parent 2c45649 commit 4d6fb78
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = "gora.studio.SCNRecorder.Example.${DEVELOPMENT_TEAM}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -459,7 +459,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
PRODUCT_BUNDLE_IDENTIFIER = "gora.studio.SCNRecorder.Example.${DEVELOPMENT_TEAM}";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- SCNRecorder (2.1.2)
- SCNRecorder (2.1.3)

DEPENDENCIES:
- SCNRecorder (from `../`)
Expand All @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
SCNRecorder: 8fb988232b1ba508d36e64d743960ec259d67a35
SCNRecorder: d3ee579c3c4511774300689840b82cb4b7a9143f

PODFILE CHECKSUM: e392a018caa1209a22fbb64a189d92975244c2bf

Expand Down
4 changes: 2 additions & 2 deletions Example/Pods/Local Podspecs/SCNRecorder.podspec.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Example/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SCNRecorder.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SCNRecorder'
s.version = '2.1.2'
s.version = '2.1.3'
s.summary = 'A lags-free recorder of ARKit and SceneKit for iOS in Swift'
s.homepage = 'https://github.com/gorastudio/SCNRecorder'
s.license = { :type => 'MIT', :file => 'LICENSE.md' }
Expand Down
4 changes: 2 additions & 2 deletions SCNRecorder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
MODULEMAP_FILE = SCNRecorder.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = gora.studio.SCNRecorder;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand Down Expand Up @@ -848,7 +848,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 2.1.2;
MARKETING_VERSION = 2.1.3;
MODULEMAP_FILE = SCNRecorder.modulemap;
PRODUCT_BUNDLE_IDENTIFIER = gora.studio.SCNRecorder;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
Expand Down
3 changes: 3 additions & 0 deletions Sources/MediaSession/MediaSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ extension MediaSession {
}

func takeCoreImage(completionHandler handler: @escaping (CIImage) -> Void) {
guard let videoInput = videoInput else { return }

addVideoOutput(
ImageOutput.takeCIImage(
context: videoInput.context,
completionHandler: { [weak self] in
self?.removeVideoOutput($0)
handler($1)
Expand Down
18 changes: 11 additions & 7 deletions Sources/Outputs/ImageOutput/ImageOutput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import Foundation
import AVFoundation
import UIKit
import VideoToolbox

final class ImageOutput {

Expand All @@ -40,20 +41,23 @@ final class ImageOutput {
}
}

static func takeCGImage(
static func takeCIImage(
context: CIContext,
completionHandler handler: @escaping (ImageOutput, CGImage) -> Void
completionHandler handler: @escaping (ImageOutput, CIImage) -> Void
) -> ImageOutput {
takeCIImage {
handler($0, context.createCGImage($1, from: $1.extent)!)
takeCGImage(context: context) {
handler($0, CIImage(cgImage: $1))
}
}

static func takeCIImage(
completionHandler handler: @escaping (ImageOutput, CIImage) -> Void
static func takeCGImage(
context: CIContext,
completionHandler handler: @escaping (ImageOutput, CGImage) -> Void
) -> ImageOutput {
takePixelBuffer {
handler($0, CIImage(cvPixelBuffer: $1))
var image: CGImage?
VTCreateCGImageFromCVPixelBuffer($1, options: nil, imageOut: &image)
handler($0, image!)
}
}

Expand Down

0 comments on commit 4d6fb78

Please sign in to comment.