WIP: Start binding LiveKit

This commit is contained in:
Antonio Scandurra 2022-09-01 17:52:12 +02:00
parent b51abc5a63
commit 6c28b21728
9 changed files with 517 additions and 52 deletions

28
LiveKitObjC/LKRoom.m Normal file
View file

@ -0,0 +1,28 @@
//
// LKRoom.m
// LiveKitObjC
//
// Created by Antonio Scandurra on 01/09/22.
//
#import <Foundation/Foundation.h>
#import <LiveKitObjC-Swift.h>
@interface LKRoom: NSObject {
}
@property (nonatomic, retain) SLKRoom* room;
@end
@implementation LKRoom
-(id)init {
if (self = [super init]) {
self.room = [[SLKRoom alloc] init];
}
return self;
}
-(void)connectWithURL:(NSString *)url token:(NSString *)token callback:(void(^)(void))callback {
[self.room connectWithUrl:url token:token callback:callback];
}
@end

View file

@ -0,0 +1,3 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

View file

@ -0,0 +1,342 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 55;
objects = {
/* Begin PBXBuildFile section */
AFA4DBD628C0F839001AD7BE /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = AFA4DBD528C0F839001AD7BE /* LiveKit */; };
AFA4DBD928C0F87F001AD7BE /* Room.swift in Sources */ = {isa = PBXBuildFile; fileRef = AFA4DBD828C0F87F001AD7BE /* Room.swift */; };
AFA4DBDB28C0FBC0001AD7BE /* LKRoom.m in Sources */ = {isa = PBXBuildFile; fileRef = AFA4DBDA28C0FBC0001AD7BE /* LKRoom.m */; };
AFA4DBDE28C121E6001AD7BE /* LiveKit in Frameworks */ = {isa = PBXBuildFile; productRef = AFA4DBDD28C121E6001AD7BE /* LiveKit */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
AFA4DBCD28C0F7F5001AD7BE /* libLiveKitObjC.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLiveKitObjC.a; sourceTree = BUILT_PRODUCTS_DIR; };
AFA4DBD728C0F87F001AD7BE /* LiveKitObjC-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LiveKitObjC-Bridging-Header.h"; sourceTree = "<group>"; };
AFA4DBD828C0F87F001AD7BE /* Room.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Room.swift; sourceTree = "<group>"; };
AFA4DBDA28C0FBC0001AD7BE /* LKRoom.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LKRoom.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
AFA4DBCB28C0F7F5001AD7BE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
AFA4DBD628C0F839001AD7BE /* LiveKit in Frameworks */,
AFA4DBDE28C121E6001AD7BE /* LiveKit in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
AFA4DBC428C0F7F5001AD7BE = {
isa = PBXGroup;
children = (
AFA4DBDA28C0FBC0001AD7BE /* LKRoom.m */,
AFA4DBD828C0F87F001AD7BE /* Room.swift */,
AFA4DBCE28C0F7F5001AD7BE /* Products */,
AFA4DBD728C0F87F001AD7BE /* LiveKitObjC-Bridging-Header.h */,
);
sourceTree = "<group>";
};
AFA4DBCE28C0F7F5001AD7BE /* Products */ = {
isa = PBXGroup;
children = (
AFA4DBCD28C0F7F5001AD7BE /* libLiveKitObjC.a */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
AFA4DBC928C0F7F5001AD7BE /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
AFA4DBCC28C0F7F5001AD7BE /* LiveKitObjC */ = {
isa = PBXNativeTarget;
buildConfigurationList = AFA4DBD128C0F7F5001AD7BE /* Build configuration list for PBXNativeTarget "LiveKitObjC" */;
buildPhases = (
AFA4DBC928C0F7F5001AD7BE /* Headers */,
AFA4DBCA28C0F7F5001AD7BE /* Sources */,
AFA4DBCB28C0F7F5001AD7BE /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = LiveKitObjC;
packageProductDependencies = (
AFA4DBD528C0F839001AD7BE /* LiveKit */,
AFA4DBDD28C121E6001AD7BE /* LiveKit */,
);
productName = LiveKitObjC;
productReference = AFA4DBCD28C0F7F5001AD7BE /* libLiveKitObjC.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
AFA4DBC528C0F7F5001AD7BE /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastUpgradeCheck = 1340;
TargetAttributes = {
AFA4DBCC28C0F7F5001AD7BE = {
CreatedOnToolsVersion = 13.4.1;
LastSwiftMigration = 1340;
};
};
};
buildConfigurationList = AFA4DBC828C0F7F5001AD7BE /* Build configuration list for PBXProject "LiveKitObjC" */;
compatibilityVersion = "Xcode 13.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = AFA4DBC428C0F7F5001AD7BE;
packageReferences = (
AFA4DBD428C0F839001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */,
AFA4DBDC28C121E6001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */,
);
productRefGroup = AFA4DBCE28C0F7F5001AD7BE /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
AFA4DBCC28C0F7F5001AD7BE /* LiveKitObjC */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
AFA4DBCA28C0F7F5001AD7BE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
AFA4DBD928C0F87F001AD7BE /* Room.swift in Sources */,
AFA4DBDB28C0FBC0001AD7BE /* LKRoom.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
AFA4DBCF28C0F7F5001AD7BE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
AFA4DBD028C0F7F5001AD7BE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.3;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
};
name = Release;
};
AFA4DBD228C0F7F5001AD7BE /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = NO;
EXECUTABLE_PREFIX = lib;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "LiveKitObjC-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
};
name = Debug;
};
AFA4DBD328C0F7F5001AD7BE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
DEFINES_MODULE = NO;
EXECUTABLE_PREFIX = lib;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
"@loader_path/../Frameworks",
);
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "LiveKitObjC-Bridging-Header.h";
SWIFT_VERSION = 5.0;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
AFA4DBC828C0F7F5001AD7BE /* Build configuration list for PBXProject "LiveKitObjC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AFA4DBCF28C0F7F5001AD7BE /* Debug */,
AFA4DBD028C0F7F5001AD7BE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
AFA4DBD128C0F7F5001AD7BE /* Build configuration list for PBXNativeTarget "LiveKitObjC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
AFA4DBD228C0F7F5001AD7BE /* Debug */,
AFA4DBD328C0F7F5001AD7BE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
AFA4DBD428C0F839001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/livekit/client-sdk-swift";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
};
};
AFA4DBDC28C121E6001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/livekit/client-sdk-swift";
requirement = {
branch = main;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
AFA4DBD528C0F839001AD7BE /* LiveKit */ = {
isa = XCSwiftPackageProductDependency;
package = AFA4DBD428C0F839001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */;
productName = LiveKit;
};
AFA4DBDD28C121E6001AD7BE /* LiveKit */ = {
isa = XCSwiftPackageProductDependency;
package = AFA4DBDC28C121E6001AD7BE /* XCRemoteSwiftPackageReference "client-sdk-swift" */;
productName = LiveKit;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = AFA4DBC528C0F7F5001AD7BE /* Project object */;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View file

@ -0,0 +1,50 @@
{
"pins" : [
{
"identity" : "client-sdk-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/livekit/client-sdk-swift",
"state" : {
"branch" : "main",
"revision" : "e3de0d06e14825a7c9f1204f18f66898afb56cd6"
}
},
{
"identity" : "promises",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/promises.git",
"state" : {
"revision" : "3e4e743631e86c8c70dbc6efdc7beaa6e90fd3bb",
"version" : "2.1.1"
}
},
{
"identity" : "specs",
"kind" : "remoteSourceControl",
"location" : "https://github.com/webrtc-sdk/Specs.git",
"state" : {
"revision" : "5225f2de4b6d0098803b3a0e55b255a41f293dad",
"version" : "104.5112.2"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version" : "1.4.4"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf.git",
"state" : {
"revision" : "b8230909dedc640294d7324d37f4c91ad3dcf177",
"version" : "1.20.1"
}
}
],
"version" : 2
}

23
LiveKitObjC/Room.swift Normal file
View file

@ -0,0 +1,23 @@
//
// LKRoom.swift
// LiveKitObjC
//
// Created by Antonio Scandurra on 01/09/22.
//
import Foundation
import LiveKit
@objc public class SLKRoom: NSObject, RoomDelegate {
lazy var room = Room(delegate: self)
@objc public func connect(
url: String,
token: String,
callback: @convention(block) @escaping () -> Void
) {
self.room.connect(url, token).then { room in
callback()
}
}
}

View file

@ -1,6 +1,8 @@
use std::{env, path::PathBuf, process::Command};
fn main() {
println!("cargo:rustc-link-search=/Users/as-cii/Library/Developer/Xcode/DerivedData/LiveKitObjC-ftgpxknhsgkrocbhhgjkyyvkgkbj/Build/Products/Debug");
println!("cargo:rustc-link-lib=static=LiveKitObjC");
println!("cargo:rustc-link-lib=framework=ScreenCaptureKit");
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=12.3");

View file

@ -48,6 +48,8 @@ const NSUTF8StringEncoding: NSUInteger = 4;
actions!(capture, [Quit]);
fn main() {
class!(LKRoom);
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
gpui::App::new(()).unwrap().run(|cx| {
@ -97,60 +99,60 @@ impl ScreenCaptureView {
let display_width: usize = msg_send![display, width];
let display_height: usize = msg_send![display, height];
let mut compression_buffer = BytesMut::new();
let compression_session = CompressionSession::new(
display_width,
display_height,
kCMVideoCodecType_H264,
move |status, flags, sample_buffer| {
if status != 0 {
println!("error encoding frame, code: {}", status);
return;
}
let sample_buffer = CMSampleBuffer::wrap_under_get_rule(sample_buffer);
// let compression_session = CompressionSession::new(
// display_width,
// display_height,
// kCMVideoCodecType_H264,
// move |status, flags, sample_buffer| {
// if status != 0 {
// println!("error encoding frame, code: {}", status);
// return;
// }
// let sample_buffer = CMSampleBuffer::wrap_under_get_rule(sample_buffer);
let mut is_iframe = false;
let attachments = sample_buffer.attachments();
if let Some(attachments) = attachments.first() {
is_iframe = attachments
.find(kCMSampleAttachmentKey_NotSync as CFStringRef)
.map_or(true, |not_sync| {
CFBooleanGetValue(*not_sync as CFBooleanRef)
});
}
// let mut is_iframe = false;
// let attachments = sample_buffer.attachments();
// if let Some(attachments) = attachments.first() {
// is_iframe = attachments
// .find(kCMSampleAttachmentKey_NotSync as CFStringRef)
// .map_or(true, |not_sync| {
// CFBooleanGetValue(*not_sync as CFBooleanRef)
// });
// }
const START_CODE: [u8; 4] = [0x00, 0x00, 0x00, 0x01];
if is_iframe {
let format_description = sample_buffer.format_description();
for ix in 0..format_description.h264_parameter_set_count() {
let parameter_set =
format_description.h264_parameter_set_at_index(ix).unwrap();
compression_buffer.extend_from_slice(&START_CODE);
compression_buffer.extend_from_slice(parameter_set);
let nal_unit = compression_buffer.split();
}
}
// const START_CODE: [u8; 4] = [0x00, 0x00, 0x00, 0x01];
// if is_iframe {
// let format_description = sample_buffer.format_description();
// for ix in 0..format_description.h264_parameter_set_count() {
// let parameter_set =
// format_description.h264_parameter_set_at_index(ix).unwrap();
// compression_buffer.extend_from_slice(&START_CODE);
// compression_buffer.extend_from_slice(parameter_set);
// let nal_unit = compression_buffer.split();
// }
// }
let data = sample_buffer.data();
let mut data = data.bytes();
// let data = sample_buffer.data();
// let mut data = data.bytes();
const AVCC_HEADER_LENGTH: usize = 4;
while data.len() - AVCC_HEADER_LENGTH > 0 {
let nal_unit_len = match data.read_u32::<BigEndian>() {
Ok(len) => len as usize,
Err(error) => {
log::error!("error decoding nal unit length: {}", error);
return;
}
};
compression_buffer.extend_from_slice(&START_CODE);
compression_buffer.extend_from_slice(&data[..nal_unit_len as usize]);
data = &data[nal_unit_len..];
// const AVCC_HEADER_LENGTH: usize = 4;
// while data.len() - AVCC_HEADER_LENGTH > 0 {
// let nal_unit_len = match data.read_u32::<BigEndian>() {
// Ok(len) => len as usize,
// Err(error) => {
// log::error!("error decoding nal unit length: {}", error);
// return;
// }
// };
// compression_buffer.extend_from_slice(&START_CODE);
// compression_buffer.extend_from_slice(&data[..nal_unit_len as usize]);
// data = &data[nal_unit_len..];
let nal_unit = compression_buffer.split();
}
},
)
.unwrap();
// let nal_unit = compression_buffer.split();
// }
// },
// )
// .unwrap();
let mut decl = ClassDecl::new("CaptureOutput", class!(NSObject)).unwrap();
decl.add_ivar::<*mut c_void>("callback");
@ -182,9 +184,9 @@ impl ScreenCaptureView {
let timing_info = buffer.sample_timing_info(0).unwrap();
let image_buffer = buffer.image_buffer();
compression_session
.encode_frame(&image_buffer, timing_info)
.unwrap();
// compression_session
// .encode_frame(&image_buffer, timing_info)
// .unwrap();
*surface_tx.lock().borrow_mut() = Some(image_buffer);
}) as Box<dyn FnMut(CMSampleBufferRef)>;
let callback = Box::into_raw(Box::new(callback));