macOS support (#33)

* mac os support 1

* entitlements

* fix updateTrack bug

* clean

* throws on mac

* simplify structure

* lock
This commit is contained in:
Hiroshi Horie
2021-11-24 21:32:40 +07:00
committed by GitHub
parent f9c2622b4e
commit 357213e7e4
14 changed files with 87 additions and 50 deletions
+5 -5
View File
@@ -8,7 +8,7 @@ PODS:
- livekit_client (0.5.3):
- Flutter
- WebRTC-SDK (~> 92.4515)
- path_provider (0.0.1):
- path_provider_ios (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- Flutter
@@ -18,7 +18,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`)
- flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`)
- livekit_client (from `.symlinks/plugins/livekit_client/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
SPEC REPOS:
@@ -33,8 +33,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_webrtc/ios"
livekit_client:
:path: ".symlinks/plugins/livekit_client/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_ios:
:path: ".symlinks/plugins/path_provider_ios/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
@@ -43,7 +43,7 @@ SPEC CHECKSUMS:
flutter_webrtc: a5a79904f0bca0ea23aff49c51ca765f70a0f703
Libyuv: 5f79ced0ee66e60a612ca97de1e6ccacd187a437
livekit_client: 2b15f8f6f37bc447184af227bd66d30ed1c5fd38
path_provider: d1e9807085df1f9cc9318206cd649dc0b76be3de
path_provider_ios: 7d7ce634493af4477d156294792024ec3485acd5
shared_preferences: 5033afbb22d372e15aff8ff766df9021b845f273
WebRTC-SDK: 21dbc6028a68f3a89718057a2caa970a4da8ebb7
@@ -6,11 +6,13 @@ import FlutterMacOS
import Foundation
import flutter_webrtc
import livekit_client
import path_provider_macos
import shared_preferences_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin"))
LiveKitPlugin.register(with: registry.registrar(forPlugin: "LiveKitPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
}
+12 -5
View File
@@ -1,17 +1,21 @@
PODS:
- flutter_webrtc (0.2.3):
- flutter_webrtc (0.7.1):
- FlutterMacOS
- WebRTC-SDK (= 92.4515.10)
- WebRTC-SDK (= 92.4515.11)
- FlutterMacOS (1.0.0)
- livekit_client (0.5.3):
- FlutterMacOS
- WebRTC-SDK (~> 92.4515)
- path_provider_macos (0.0.1):
- FlutterMacOS
- shared_preferences_macos (0.0.1):
- FlutterMacOS
- WebRTC-SDK (92.4515.10)
- WebRTC-SDK (92.4515.11)
DEPENDENCIES:
- flutter_webrtc (from `Flutter/ephemeral/.symlinks/plugins/flutter_webrtc/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- livekit_client (from `Flutter/ephemeral/.symlinks/plugins/livekit_client/macos`)
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
- shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`)
@@ -24,17 +28,20 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/flutter_webrtc/macos
FlutterMacOS:
:path: Flutter/ephemeral
livekit_client:
:path: Flutter/ephemeral/.symlinks/plugins/livekit_client/macos
path_provider_macos:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
shared_preferences_macos:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos
SPEC CHECKSUMS:
flutter_webrtc: 8d69a6819b422e5caf1c7b2844a05bc6a62b437b
flutter_webrtc: eb68063546a533bb98f0fbcc7b54daf62edea4ed
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
livekit_client: b137f094e90d910cfa846b282ad41e0e4a6a029b
path_provider_macos: 160cab0d5461f0c0e02995469a98f24bdb9a3f1f
shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e
WebRTC-SDK: dabc6471c193814aeb0ad9e6712052567acff601
WebRTC-SDK: 21dbc6028a68f3a89718057a2caa970a4da8ebb7
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
@@ -6,6 +6,10 @@
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
+4 -4
View File
@@ -2,8 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSMicrophoneUsageDescription</key>
<string>Please enable mic to publish.</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
@@ -26,13 +24,15 @@
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSCameraUsageDescription</key>
<string>Please enable camera to publish.</string>
<key>NSHumanReadableCopyright</key>
<string>$(PRODUCT_COPYRIGHT)</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSMicrophoneUsageDescription</key>
<string>Please enable mic to publish.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSCameraUsageDescription</key>
<string>Please enable camera to publish.</string>
</dict>
</plist>
@@ -4,6 +4,10 @@
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
-4
View File
@@ -1,4 +0,0 @@
#import <Flutter/Flutter.h>
@interface LiveKitPlugin : NSObject<FlutterPlugin>
@end
-15
View File
@@ -1,15 +0,0 @@
#import "LiveKitPlugin.h"
#if __has_include(<livekit_client/livekit_client-Swift.h>)
#import <livekit_client/livekit_client-Swift.h>
#else
// Support project import fallback if the generated compatibility header
// is not copied when this plugin is created as a library.
// https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816
#import "livekit_client-Swift.h"
#endif
@implementation LiveKitPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
[SwiftLiveKitPlugin registerWithRegistrar:registrar];
}
@end
+1
View File
@@ -0,0 +1 @@
../../shared_swift/LiveKitPlugin.swift
-6
View File
@@ -1,9 +1,3 @@
#
# LiveKit
# https://livekit.io/
# https://github.com/livekit
#
Pod::Spec.new do |s|
s.name = 'livekit_client'
s.version = '0.5.3'
+1
View File
@@ -0,0 +1 @@
../../shared_swift/LiveKitPlugin.swift
+20
View File
@@ -0,0 +1,20 @@
Pod::Spec.new do |s|
s.name = 'livekit_client'
s.version = '0.5.3'
s.summary = 'Open source platform for real-time audio and video.'
s.description = 'Open source platform for real-time audio and video.'
s.homepage = 'https://livekit.io/'
s.license = { :file => '../LICENSE' }
s.author = { 'LiveKit' => '[email protected]' }
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.platform = :osx, '10.11'
# Flutter.framework does not contain a i386 slice.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
s.swift_version = '5.0'
s.static_framework = true
s.dependency 'FlutterMacOS'
s.dependency 'WebRTC-SDK', '~> 92.4515'
end
+2
View File
@@ -35,6 +35,8 @@ flutter:
platforms:
ios:
pluginClass: LiveKitPlugin
macos:
pluginClass: LiveKitPlugin
android:
package: io.livekit.plugin
pluginClass: LiveKitPlugin
@@ -1,14 +1,29 @@
import Flutter
import UIKit
import WebRTC
public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
#if os(macOS)
import Cocoa
import FlutterMacOS
#else
import Flutter
import UIKit
#endif
public class LiveKitPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "livekit_client", binaryMessenger: registrar.messenger())
let instance = SwiftLiveKitPlugin()
#if os(macOS)
let messenger = registrar.messenger
#else
let messenger = registrar.messenger()
#endif
let channel = FlutterMethodChannel(name: "livekit_client", binaryMessenger: messenger)
let instance = LiveKitPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
#if !os(macOS)
// https://developer.apple.com/documentation/avfaudio/avaudiosession/category
let categoryMap: [String: AVAudioSession.Category] = [
"ambient": .ambient,
@@ -16,7 +31,7 @@ public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
"playAndRecord": .playAndRecord,
"playback": .playback,
"record": .record,
"soloAmbient": .soloAmbient,
"soloAmbient": .soloAmbient
]
// https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions
@@ -27,9 +42,9 @@ public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
"allowBluetooth": .allowBluetooth,
"allowBluetoothA2DP": .allowBluetoothA2DP,
"allowAirPlay": .allowAirPlay,
"defaultToSpeaker": .defaultToSpeaker,
// @available(iOS 14.5, *)
// "overrideMutedMicrophoneInterruption": .overrideMutedMicrophoneInterruption,
"defaultToSpeaker": .defaultToSpeaker
// @available(iOS 14.5, *)
// "overrideMutedMicrophoneInterruption": .overrideMutedMicrophoneInterruption,
]
// https://developer.apple.com/documentation/avfaudio/avaudiosession/mode
@@ -42,21 +57,26 @@ public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
"videoChat": .videoChat,
"videoRecording": .videoRecording,
"voiceChat": .voiceChat,
"voicePrompt": .voicePrompt,
"voicePrompt": .voicePrompt
]
private func categoryOptions(fromFlutter options: [String]) -> AVAudioSession.CategoryOptions {
var result: AVAudioSession.CategoryOptions = []
for option in categoryOptionsMap {
if (options.contains(option.key)) {
if options.contains(option.key) {
result.insert(option.value)
}
}
return result
}
#endif
public func handleConfigureNativeAudio(args: [String: Any?], result: @escaping FlutterResult) {
#if os(macOS)
result(FlutterMethodNotImplemented)
#else
let configuration = RTCAudioSessionConfiguration.webRTC()
// Category
@@ -117,6 +137,7 @@ public class SwiftLiveKitPlugin: NSObject, FlutterPlugin {
print("[LiveKit] Configure audio error: ", error)
result(FlutterError(code: "configure", message: error.localizedDescription, details: nil))
}
#endif
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {