react-native-webrtc-nitro 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/webrtc/HybridCamera.kt +0 -1
- package/android/src/main/java/com/webrtc/HybridMicrophone.kt +0 -1
- package/android/src/main/java/com/webrtc/HybridPermissions.kt +95 -0
- package/cpp/FFmpeg/Muxer.cpp +1 -1
- package/cpp/Hybrid/HybridMediaDevices.cpp +23 -19
- package/cpp/Hybrid/HybridMediaRecorder.cpp +118 -0
- package/cpp/Hybrid/HybridMediaRecorder.hpp +36 -0
- package/cpp/__tests__/FFmpeg/testMuxer.cpp +18 -32
- package/ios/HybridCamera.swift +1 -3
- package/ios/HybridMicrophone.swift +1 -3
- package/ios/HybridPermissions.swift +63 -0
- package/lib/commonjs/index.js +22 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/MediaRecorder.nitro.js +16 -0
- package/lib/commonjs/specs/MediaRecorder.nitro.js.map +1 -0
- package/lib/commonjs/specs/Permissions.nitro.js +9 -0
- package/lib/commonjs/specs/Permissions.nitro.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/MediaRecorder.nitro.js +13 -0
- package/lib/module/specs/MediaRecorder.nitro.js.map +1 -0
- package/lib/module/specs/Permissions.nitro.js +6 -0
- package/lib/module/specs/Permissions.nitro.js.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/MediaRecorder.nitro.d.ts +17 -0
- package/lib/typescript/src/specs/MediaRecorder.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/Permissions.nitro.d.ts +17 -0
- package/lib/typescript/src/specs/Permissions.nitro.d.ts.map +1 -0
- package/nitro.json +7 -0
- package/nitrogen/generated/android/Webrtc+autolinking.cmake +3 -0
- package/nitrogen/generated/android/WebrtcOnLoad.cpp +20 -0
- package/nitrogen/generated/android/c++/JHybridPermissionsSpec.cpp +91 -0
- package/nitrogen/generated/android/c++/JHybridPermissionsSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JPermissionDescriptor.hpp +58 -0
- package/nitrogen/generated/android/c++/JPermissionName.hpp +59 -0
- package/nitrogen/generated/android/c++/JPermissionState.hpp +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/HybridPermissionsSpec.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionDescriptor.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionName.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/webrtc/PermissionState.kt +22 -0
- package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Bridge.cpp +25 -0
- package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Bridge.hpp +63 -0
- package/nitrogen/generated/ios/Webrtc-Swift-Cxx-Umbrella.hpp +14 -0
- package/nitrogen/generated/ios/WebrtcAutolinking.mm +18 -0
- package/nitrogen/generated/ios/WebrtcAutolinking.swift +15 -0
- package/nitrogen/generated/ios/c++/HybridPermissionsSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridPermissionsSpecSwift.hpp +92 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionState.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridPermissionsSpec.swift +57 -0
- package/nitrogen/generated/ios/swift/HybridPermissionsSpec_cxx.swift +157 -0
- package/nitrogen/generated/ios/swift/PermissionDescriptor.swift +36 -0
- package/nitrogen/generated/ios/swift/PermissionName.swift +40 -0
- package/nitrogen/generated/ios/swift/PermissionState.swift +44 -0
- package/nitrogen/generated/shared/c++/HybridMediaRecorderSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridMediaRecorderSpec.hpp +69 -0
- package/nitrogen/generated/shared/c++/HybridPermissionsSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridPermissionsSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/PermissionDescriptor.hpp +76 -0
- package/nitrogen/generated/shared/c++/PermissionName.hpp +76 -0
- package/nitrogen/generated/shared/c++/PermissionState.hpp +80 -0
- package/package.json +4 -5
- package/src/index.ts +2 -0
- package/src/specs/MediaRecorder.nitro.ts +24 -0
- package/src/specs/Permissions.nitro.ts +22 -0
- package/android/src/main/java/com/webrtc/Permission.kt +0 -58
- package/ios/Permission.swift +0 -26
|
@@ -12,21 +12,29 @@
|
|
|
12
12
|
namespace margelo::nitro::webrtc { class HybridCameraSpec; }
|
|
13
13
|
// Forward declaration of `HybridMicrophoneSpec` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::webrtc { class HybridMicrophoneSpec; }
|
|
15
|
+
// Forward declaration of `HybridPermissionsSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::webrtc { class HybridPermissionsSpec; }
|
|
15
17
|
// Forward declaration of `HybridWebrtcViewSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::webrtc { class HybridWebrtcViewSpec; }
|
|
19
|
+
// Forward declaration of `PermissionState` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::webrtc { enum class PermissionState; }
|
|
17
21
|
|
|
18
22
|
// Forward declarations of Swift defined types
|
|
19
23
|
// Forward declaration of `HybridCameraSpec_cxx` to properly resolve imports.
|
|
20
24
|
namespace Webrtc { class HybridCameraSpec_cxx; }
|
|
21
25
|
// Forward declaration of `HybridMicrophoneSpec_cxx` to properly resolve imports.
|
|
22
26
|
namespace Webrtc { class HybridMicrophoneSpec_cxx; }
|
|
27
|
+
// Forward declaration of `HybridPermissionsSpec_cxx` to properly resolve imports.
|
|
28
|
+
namespace Webrtc { class HybridPermissionsSpec_cxx; }
|
|
23
29
|
// Forward declaration of `HybridWebrtcViewSpec_cxx` to properly resolve imports.
|
|
24
30
|
namespace Webrtc { class HybridWebrtcViewSpec_cxx; }
|
|
25
31
|
|
|
26
32
|
// Include C++ defined types
|
|
27
33
|
#include "HybridCameraSpec.hpp"
|
|
28
34
|
#include "HybridMicrophoneSpec.hpp"
|
|
35
|
+
#include "HybridPermissionsSpec.hpp"
|
|
29
36
|
#include "HybridWebrtcViewSpec.hpp"
|
|
37
|
+
#include "PermissionState.hpp"
|
|
30
38
|
#include <NitroModules/Promise.hpp>
|
|
31
39
|
#include <NitroModules/PromiseHolder.hpp>
|
|
32
40
|
#include <NitroModules/Result.hpp>
|
|
@@ -131,6 +139,61 @@ namespace margelo::nitro::webrtc::bridge::swift {
|
|
|
131
139
|
using std__weak_ptr_HybridMicrophoneSpec_ = std::weak_ptr<HybridMicrophoneSpec>;
|
|
132
140
|
inline std__weak_ptr_HybridMicrophoneSpec_ weakify_std__shared_ptr_HybridMicrophoneSpec_(const std::shared_ptr<HybridMicrophoneSpec>& strong) noexcept { return strong; }
|
|
133
141
|
|
|
142
|
+
// pragma MARK: std::shared_ptr<Promise<PermissionState>>
|
|
143
|
+
/**
|
|
144
|
+
* Specialized version of `std::shared_ptr<Promise<PermissionState>>`.
|
|
145
|
+
*/
|
|
146
|
+
using std__shared_ptr_Promise_PermissionState__ = std::shared_ptr<Promise<PermissionState>>;
|
|
147
|
+
inline std::shared_ptr<Promise<PermissionState>> create_std__shared_ptr_Promise_PermissionState__() noexcept {
|
|
148
|
+
return Promise<PermissionState>::create();
|
|
149
|
+
}
|
|
150
|
+
inline PromiseHolder<PermissionState> wrap_std__shared_ptr_Promise_PermissionState__(std::shared_ptr<Promise<PermissionState>> promise) noexcept {
|
|
151
|
+
return PromiseHolder<PermissionState>(std::move(promise));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// pragma MARK: std::function<void(PermissionState /* result */)>
|
|
155
|
+
/**
|
|
156
|
+
* Specialized version of `std::function<void(PermissionState)>`.
|
|
157
|
+
*/
|
|
158
|
+
using Func_void_PermissionState = std::function<void(PermissionState /* result */)>;
|
|
159
|
+
/**
|
|
160
|
+
* Wrapper class for a `std::function<void(PermissionState / * result * /)>`, this can be used from Swift.
|
|
161
|
+
*/
|
|
162
|
+
class Func_void_PermissionState_Wrapper final {
|
|
163
|
+
public:
|
|
164
|
+
explicit Func_void_PermissionState_Wrapper(std::function<void(PermissionState /* result */)>&& func): _function(std::make_unique<std::function<void(PermissionState /* result */)>>(std::move(func))) {}
|
|
165
|
+
inline void call(int result) const noexcept {
|
|
166
|
+
_function->operator()(static_cast<PermissionState>(result));
|
|
167
|
+
}
|
|
168
|
+
private:
|
|
169
|
+
std::unique_ptr<std::function<void(PermissionState /* result */)>> _function;
|
|
170
|
+
} SWIFT_NONCOPYABLE;
|
|
171
|
+
Func_void_PermissionState create_Func_void_PermissionState(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
172
|
+
inline Func_void_PermissionState_Wrapper wrap_Func_void_PermissionState(Func_void_PermissionState value) noexcept {
|
|
173
|
+
return Func_void_PermissionState_Wrapper(std::move(value));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// pragma MARK: std::shared_ptr<HybridPermissionsSpec>
|
|
177
|
+
/**
|
|
178
|
+
* Specialized version of `std::shared_ptr<HybridPermissionsSpec>`.
|
|
179
|
+
*/
|
|
180
|
+
using std__shared_ptr_HybridPermissionsSpec_ = std::shared_ptr<HybridPermissionsSpec>;
|
|
181
|
+
std::shared_ptr<HybridPermissionsSpec> create_std__shared_ptr_HybridPermissionsSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
182
|
+
void* NON_NULL get_std__shared_ptr_HybridPermissionsSpec_(std__shared_ptr_HybridPermissionsSpec_ cppType);
|
|
183
|
+
|
|
184
|
+
// pragma MARK: std::weak_ptr<HybridPermissionsSpec>
|
|
185
|
+
using std__weak_ptr_HybridPermissionsSpec_ = std::weak_ptr<HybridPermissionsSpec>;
|
|
186
|
+
inline std__weak_ptr_HybridPermissionsSpec_ weakify_std__shared_ptr_HybridPermissionsSpec_(const std::shared_ptr<HybridPermissionsSpec>& strong) noexcept { return strong; }
|
|
187
|
+
|
|
188
|
+
// pragma MARK: Result<std::shared_ptr<Promise<PermissionState>>>
|
|
189
|
+
using Result_std__shared_ptr_Promise_PermissionState___ = Result<std::shared_ptr<Promise<PermissionState>>>;
|
|
190
|
+
inline Result_std__shared_ptr_Promise_PermissionState___ create_Result_std__shared_ptr_Promise_PermissionState___(const std::shared_ptr<Promise<PermissionState>>& value) noexcept {
|
|
191
|
+
return Result<std::shared_ptr<Promise<PermissionState>>>::withValue(value);
|
|
192
|
+
}
|
|
193
|
+
inline Result_std__shared_ptr_Promise_PermissionState___ create_Result_std__shared_ptr_Promise_PermissionState___(const std::exception_ptr& error) noexcept {
|
|
194
|
+
return Result<std::shared_ptr<Promise<PermissionState>>>::withError(error);
|
|
195
|
+
}
|
|
196
|
+
|
|
134
197
|
// pragma MARK: std::optional<std::string>
|
|
135
198
|
/**
|
|
136
199
|
* Specialized version of `std::optional<std::string>`.
|
|
@@ -12,13 +12,25 @@
|
|
|
12
12
|
namespace margelo::nitro::webrtc { class HybridCameraSpec; }
|
|
13
13
|
// Forward declaration of `HybridMicrophoneSpec` to properly resolve imports.
|
|
14
14
|
namespace margelo::nitro::webrtc { class HybridMicrophoneSpec; }
|
|
15
|
+
// Forward declaration of `HybridPermissionsSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::webrtc { class HybridPermissionsSpec; }
|
|
15
17
|
// Forward declaration of `HybridWebrtcViewSpec` to properly resolve imports.
|
|
16
18
|
namespace margelo::nitro::webrtc { class HybridWebrtcViewSpec; }
|
|
19
|
+
// Forward declaration of `PermissionDescriptor` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::webrtc { struct PermissionDescriptor; }
|
|
21
|
+
// Forward declaration of `PermissionName` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::webrtc { enum class PermissionName; }
|
|
23
|
+
// Forward declaration of `PermissionState` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::webrtc { enum class PermissionState; }
|
|
17
25
|
|
|
18
26
|
// Include C++ defined types
|
|
19
27
|
#include "HybridCameraSpec.hpp"
|
|
20
28
|
#include "HybridMicrophoneSpec.hpp"
|
|
29
|
+
#include "HybridPermissionsSpec.hpp"
|
|
21
30
|
#include "HybridWebrtcViewSpec.hpp"
|
|
31
|
+
#include "PermissionDescriptor.hpp"
|
|
32
|
+
#include "PermissionName.hpp"
|
|
33
|
+
#include "PermissionState.hpp"
|
|
22
34
|
#include <NitroModules/Promise.hpp>
|
|
23
35
|
#include <NitroModules/Result.hpp>
|
|
24
36
|
#include <exception>
|
|
@@ -40,6 +52,8 @@ namespace margelo::nitro::webrtc { class HybridWebrtcViewSpec; }
|
|
|
40
52
|
namespace Webrtc { class HybridCameraSpec_cxx; }
|
|
41
53
|
// Forward declaration of `HybridMicrophoneSpec_cxx` to properly resolve imports.
|
|
42
54
|
namespace Webrtc { class HybridMicrophoneSpec_cxx; }
|
|
55
|
+
// Forward declaration of `HybridPermissionsSpec_cxx` to properly resolve imports.
|
|
56
|
+
namespace Webrtc { class HybridPermissionsSpec_cxx; }
|
|
43
57
|
// Forward declaration of `HybridWebrtcViewSpec_cxx` to properly resolve imports.
|
|
44
58
|
namespace Webrtc { class HybridWebrtcViewSpec_cxx; }
|
|
45
59
|
|
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
#import "Webrtc-Swift-Cxx-Umbrella.hpp"
|
|
11
11
|
#import <type_traits>
|
|
12
12
|
|
|
13
|
+
#include "HybridPermissionsSpecSwift.hpp"
|
|
13
14
|
#include "HybridMicrophoneSpecSwift.hpp"
|
|
14
15
|
#include "HybridCameraSpecSwift.hpp"
|
|
15
16
|
#include "HybridMediaStreamTrack.hpp"
|
|
16
17
|
#include "HybridMediaStream.hpp"
|
|
17
18
|
#include "HybridWebrtcViewSpecSwift.hpp"
|
|
18
19
|
#include "HybridMediaDevices.hpp"
|
|
20
|
+
#include "HybridMediaRecorder.hpp"
|
|
19
21
|
#include "HybridRTCRtpSender.hpp"
|
|
20
22
|
#include "HybridRTCRtpReceiver.hpp"
|
|
21
23
|
#include "HybridRTCRtpTransceiver.hpp"
|
|
@@ -30,6 +32,13 @@
|
|
|
30
32
|
using namespace margelo::nitro;
|
|
31
33
|
using namespace margelo::nitro::webrtc;
|
|
32
34
|
|
|
35
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
36
|
+
"Permissions",
|
|
37
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
38
|
+
std::shared_ptr<HybridPermissionsSpec> hybridObject = Webrtc::WebrtcAutolinking::createPermissions();
|
|
39
|
+
return hybridObject;
|
|
40
|
+
}
|
|
41
|
+
);
|
|
33
42
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
34
43
|
"Microphone",
|
|
35
44
|
[]() -> std::shared_ptr<HybridObject> {
|
|
@@ -78,6 +87,15 @@
|
|
|
78
87
|
return std::make_shared<HybridMediaDevices>();
|
|
79
88
|
}
|
|
80
89
|
);
|
|
90
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
91
|
+
"MediaRecorder",
|
|
92
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
93
|
+
static_assert(std::is_default_constructible_v<HybridMediaRecorder>,
|
|
94
|
+
"The HybridObject \"HybridMediaRecorder\" is not default-constructible! "
|
|
95
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
96
|
+
return std::make_shared<HybridMediaRecorder>();
|
|
97
|
+
}
|
|
98
|
+
);
|
|
81
99
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
82
100
|
"RTCRtpSender",
|
|
83
101
|
[]() -> std::shared_ptr<HybridObject> {
|
|
@@ -8,6 +8,21 @@
|
|
|
8
8
|
public final class WebrtcAutolinking {
|
|
9
9
|
public typealias bridge = margelo.nitro.webrtc.bridge.swift
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridPermissionsSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridPermissionsSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridPermissions`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createPermissions() -> bridge.std__shared_ptr_HybridPermissionsSpec_ {
|
|
19
|
+
let hybridObject = HybridPermissions()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridPermissionsSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
/**
|
|
12
27
|
* Creates an instance of a Swift class that implements `HybridMicrophoneSpec`,
|
|
13
28
|
* and wraps it in a Swift class that can directly interop with C++ (`HybridMicrophoneSpec_cxx`)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPermissionsSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridPermissionsSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::webrtc {
|
|
11
|
+
} // namespace margelo::nitro::webrtc
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPermissionsSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridPermissionsSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridPermissionsSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace Webrtc { class HybridPermissionsSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `PermissionState` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::webrtc { enum class PermissionState; }
|
|
17
|
+
// Forward declaration of `PermissionDescriptor` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::webrtc { struct PermissionDescriptor; }
|
|
19
|
+
// Forward declaration of `PermissionName` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::webrtc { enum class PermissionName; }
|
|
21
|
+
|
|
22
|
+
#include "PermissionState.hpp"
|
|
23
|
+
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include "PermissionDescriptor.hpp"
|
|
25
|
+
#include "PermissionName.hpp"
|
|
26
|
+
|
|
27
|
+
#include "Webrtc-Swift-Cxx-Umbrella.hpp"
|
|
28
|
+
|
|
29
|
+
namespace margelo::nitro::webrtc {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The C++ part of HybridPermissionsSpec_cxx.swift.
|
|
33
|
+
*
|
|
34
|
+
* HybridPermissionsSpecSwift (C++) accesses HybridPermissionsSpec_cxx (Swift), and might
|
|
35
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
36
|
+
*
|
|
37
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
38
|
+
* the future, HybridPermissionsSpec_cxx can directly inherit from the C++ class HybridPermissionsSpec
|
|
39
|
+
* to simplify the whole structure and memory management.
|
|
40
|
+
*/
|
|
41
|
+
class HybridPermissionsSpecSwift: public virtual HybridPermissionsSpec {
|
|
42
|
+
public:
|
|
43
|
+
// Constructor from a Swift instance
|
|
44
|
+
explicit HybridPermissionsSpecSwift(const Webrtc::HybridPermissionsSpec_cxx& swiftPart):
|
|
45
|
+
HybridObject(HybridPermissionsSpec::TAG),
|
|
46
|
+
_swiftPart(swiftPart) { }
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Get the Swift part
|
|
50
|
+
inline Webrtc::HybridPermissionsSpec_cxx& getSwiftPart() noexcept {
|
|
51
|
+
return _swiftPart;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
56
|
+
return _swiftPart.getMemorySize();
|
|
57
|
+
}
|
|
58
|
+
void dispose() noexcept override {
|
|
59
|
+
_swiftPart.dispose();
|
|
60
|
+
}
|
|
61
|
+
std::string toString() override {
|
|
62
|
+
return _swiftPart.toString();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Properties
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
// Methods
|
|
71
|
+
inline std::shared_ptr<Promise<PermissionState>> query(const PermissionDescriptor& permissionDesc) override {
|
|
72
|
+
auto __result = _swiftPart.query(std::forward<decltype(permissionDesc)>(permissionDesc));
|
|
73
|
+
if (__result.hasError()) [[unlikely]] {
|
|
74
|
+
std::rethrow_exception(__result.error());
|
|
75
|
+
}
|
|
76
|
+
auto __value = std::move(__result.value());
|
|
77
|
+
return __value;
|
|
78
|
+
}
|
|
79
|
+
inline std::shared_ptr<Promise<PermissionState>> request(const PermissionDescriptor& permissionDesc) override {
|
|
80
|
+
auto __result = _swiftPart.request(std::forward<decltype(permissionDesc)>(permissionDesc));
|
|
81
|
+
if (__result.hasError()) [[unlikely]] {
|
|
82
|
+
std::rethrow_exception(__result.error());
|
|
83
|
+
}
|
|
84
|
+
auto __value = std::move(__result.value());
|
|
85
|
+
return __value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private:
|
|
89
|
+
Webrtc::HybridPermissionsSpec_cxx _swiftPart;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} // namespace margelo::nitro::webrtc
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_PermissionState.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ value: PermissionState) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_PermissionState {
|
|
16
|
+
public typealias bridge = margelo.nitro.webrtc.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ value: PermissionState) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ value: PermissionState) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(value: Int32) -> Void {
|
|
26
|
+
self.closure(margelo.nitro.webrtc.PermissionState(rawValue: value)!)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_PermissionState`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_PermissionState>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_PermissionState {
|
|
45
|
+
return Unmanaged<Func_void_PermissionState>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPermissionsSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridPermissionsSpec``
|
|
12
|
+
public protocol HybridPermissionsSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func query(permissionDesc: PermissionDescriptor) throws -> Promise<PermissionState>
|
|
18
|
+
func request(permissionDesc: PermissionDescriptor) throws -> Promise<PermissionState>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public extension HybridPermissionsSpec_protocol {
|
|
22
|
+
/// Default implementation of ``HybridObject.toString``
|
|
23
|
+
func toString() -> String {
|
|
24
|
+
return "[HybridObject Permissions]"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// See ``HybridPermissionsSpec``
|
|
29
|
+
open class HybridPermissionsSpec_base {
|
|
30
|
+
private weak var cxxWrapper: HybridPermissionsSpec_cxx? = nil
|
|
31
|
+
public init() { }
|
|
32
|
+
public func getCxxWrapper() -> HybridPermissionsSpec_cxx {
|
|
33
|
+
#if DEBUG
|
|
34
|
+
guard self is HybridPermissionsSpec else {
|
|
35
|
+
fatalError("`self` is not a `HybridPermissionsSpec`! Did you accidentally inherit from `HybridPermissionsSpec_base` instead of `HybridPermissionsSpec`?")
|
|
36
|
+
}
|
|
37
|
+
#endif
|
|
38
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
39
|
+
return cxxWrapper
|
|
40
|
+
} else {
|
|
41
|
+
let cxxWrapper = HybridPermissionsSpec_cxx(self as! HybridPermissionsSpec)
|
|
42
|
+
self.cxxWrapper = cxxWrapper
|
|
43
|
+
return cxxWrapper
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A Swift base-protocol representing the Permissions HybridObject.
|
|
50
|
+
* Implement this protocol to create Swift-based instances of Permissions.
|
|
51
|
+
* ```swift
|
|
52
|
+
* class HybridPermissions : HybridPermissionsSpec {
|
|
53
|
+
* // ...
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
public typealias HybridPermissionsSpec = HybridPermissionsSpec_protocol & HybridPermissionsSpec_base
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPermissionsSpec_cxx.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridPermissionsSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridPermissionsSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::webrtc::bridge::swift`)
|
|
23
|
+
* from `Webrtc-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.webrtc.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridPermissionsSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridPermissionsSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridPermissionsSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridPermissionsSpec_cxx` that wraps the given `HybridPermissionsSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridPermissionsSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridPermissionsSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridPermissionsSpec() -> any HybridPermissionsSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridPermissionsSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridPermissionsSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridPermissionsSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridPermissionsSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridPermissionsSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridPermissionsSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridPermissionsSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridPermissionsSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func query(permissionDesc: PermissionDescriptor) -> bridge.Result_std__shared_ptr_Promise_PermissionState___ {
|
|
122
|
+
do {
|
|
123
|
+
let __result = try self.__implementation.query(permissionDesc: permissionDesc)
|
|
124
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionState__ in
|
|
125
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PermissionState__()
|
|
126
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionState__(__promise)
|
|
127
|
+
__result
|
|
128
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
129
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
130
|
+
return __promise
|
|
131
|
+
}()
|
|
132
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__resultCpp)
|
|
133
|
+
} catch (let __error) {
|
|
134
|
+
let __exceptionPtr = __error.toCpp()
|
|
135
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__exceptionPtr)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@inline(__always)
|
|
140
|
+
public final func request(permissionDesc: PermissionDescriptor) -> bridge.Result_std__shared_ptr_Promise_PermissionState___ {
|
|
141
|
+
do {
|
|
142
|
+
let __result = try self.__implementation.request(permissionDesc: permissionDesc)
|
|
143
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_PermissionState__ in
|
|
144
|
+
let __promise = bridge.create_std__shared_ptr_Promise_PermissionState__()
|
|
145
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_PermissionState__(__promise)
|
|
146
|
+
__result
|
|
147
|
+
.then({ __result in __promiseHolder.resolve(__result) })
|
|
148
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
149
|
+
return __promise
|
|
150
|
+
}()
|
|
151
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__resultCpp)
|
|
152
|
+
} catch (let __error) {
|
|
153
|
+
let __exceptionPtr = __error.toCpp()
|
|
154
|
+
return bridge.create_Result_std__shared_ptr_Promise_PermissionState___(__exceptionPtr)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionDescriptor.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents an instance of `PermissionDescriptor`, backed by a C++ struct.
|
|
13
|
+
*/
|
|
14
|
+
public typealias PermissionDescriptor = margelo.nitro.webrtc.PermissionDescriptor
|
|
15
|
+
|
|
16
|
+
public extension PermissionDescriptor {
|
|
17
|
+
private typealias bridge = margelo.nitro.webrtc.bridge.swift
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new instance of `PermissionDescriptor`.
|
|
21
|
+
*/
|
|
22
|
+
init(name: PermissionName) {
|
|
23
|
+
self.init(name)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var name: PermissionName {
|
|
27
|
+
@inline(__always)
|
|
28
|
+
get {
|
|
29
|
+
return self.__name
|
|
30
|
+
}
|
|
31
|
+
@inline(__always)
|
|
32
|
+
set {
|
|
33
|
+
self.__name = newValue
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionName.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `PermissionName`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias PermissionName = margelo.nitro.webrtc.PermissionName
|
|
12
|
+
|
|
13
|
+
public extension PermissionName {
|
|
14
|
+
/**
|
|
15
|
+
* Get a PermissionName for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "camera":
|
|
21
|
+
self = .camera
|
|
22
|
+
case "microphone":
|
|
23
|
+
self = .microphone
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this PermissionName represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .camera:
|
|
35
|
+
return "camera"
|
|
36
|
+
case .microphone:
|
|
37
|
+
return "microphone"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PermissionState.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `PermissionState`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias PermissionState = margelo.nitro.webrtc.PermissionState
|
|
12
|
+
|
|
13
|
+
public extension PermissionState {
|
|
14
|
+
/**
|
|
15
|
+
* Get a PermissionState for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "denied":
|
|
21
|
+
self = .denied
|
|
22
|
+
case "granted":
|
|
23
|
+
self = .granted
|
|
24
|
+
case "prompt":
|
|
25
|
+
self = .prompt
|
|
26
|
+
default:
|
|
27
|
+
return nil
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the String value this PermissionState represents.
|
|
33
|
+
*/
|
|
34
|
+
var stringValue: String {
|
|
35
|
+
switch self {
|
|
36
|
+
case .denied:
|
|
37
|
+
return "denied"
|
|
38
|
+
case .granted:
|
|
39
|
+
return "granted"
|
|
40
|
+
case .prompt:
|
|
41
|
+
return "prompt"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|