node-mac-recorder 1.2.4 → 1.2.6
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/README.md +3 -2
- package/index.js +11 -2
- package/package.json +1 -1
- package/src/mac_recorder.mm +37 -1
package/README.md
CHANGED
|
@@ -92,6 +92,7 @@ await recorder.startRecording("./recording.mov", {
|
|
|
92
92
|
// Audio Controls
|
|
93
93
|
includeMicrophone: false, // Enable microphone (default: false)
|
|
94
94
|
includeSystemAudio: true, // Enable system audio (default: true)
|
|
95
|
+
audioDeviceId: "device-id", // Specific audio input device (default: system default)
|
|
95
96
|
|
|
96
97
|
// Display & Window Selection
|
|
97
98
|
displayId: 0, // Display index (null = main display)
|
|
@@ -159,14 +160,14 @@ console.log(displays);
|
|
|
159
160
|
|
|
160
161
|
#### `getAudioDevices()`
|
|
161
162
|
|
|
162
|
-
|
|
163
|
+
Returns a list of available audio input devices.
|
|
163
164
|
|
|
164
165
|
```javascript
|
|
165
166
|
const devices = await recorder.getAudioDevices();
|
|
166
167
|
console.log(devices);
|
|
167
168
|
// [
|
|
168
169
|
// {
|
|
169
|
-
// id: "device-id
|
|
170
|
+
// id: "device-id",
|
|
170
171
|
// name: "Built-in Microphone",
|
|
171
172
|
// manufacturer: "Apple Inc.",
|
|
172
173
|
// isDefault: true
|
package/index.js
CHANGED
|
@@ -99,8 +99,16 @@ class MacRecorder extends EventEmitter {
|
|
|
99
99
|
/**
|
|
100
100
|
* Kayıt seçeneklerini ayarlar
|
|
101
101
|
*/
|
|
102
|
-
setOptions(options) {
|
|
103
|
-
this.options = {
|
|
102
|
+
setOptions(options = {}) {
|
|
103
|
+
this.options = {
|
|
104
|
+
includeMicrophone: options.includeMicrophone || false,
|
|
105
|
+
includeSystemAudio: options.includeSystemAudio !== false, // Default true
|
|
106
|
+
captureCursor: options.captureCursor || false,
|
|
107
|
+
displayId: options.displayId || null, // null = ana ekran
|
|
108
|
+
windowId: options.windowId || null, // null = tam ekran
|
|
109
|
+
audioDeviceId: options.audioDeviceId || null, // null = default device
|
|
110
|
+
captureArea: options.captureArea || null,
|
|
111
|
+
};
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
/**
|
|
@@ -219,6 +227,7 @@ class MacRecorder extends EventEmitter {
|
|
|
219
227
|
captureCursor: this.options.captureCursor || false,
|
|
220
228
|
displayId: this.options.displayId || null, // null = ana ekran
|
|
221
229
|
windowId: this.options.windowId || null, // null = tam ekran
|
|
230
|
+
audioDeviceId: this.options.audioDeviceId || null, // null = default device
|
|
222
231
|
};
|
|
223
232
|
|
|
224
233
|
// Manuel captureArea varsa onu kullan
|
package/package.json
CHANGED
package/src/mac_recorder.mm
CHANGED
|
@@ -70,6 +70,7 @@ Napi::Value StartRecording(const Napi::CallbackInfo& info) {
|
|
|
70
70
|
bool includeMicrophone = false; // Default olarak mikrofon kapalı
|
|
71
71
|
bool includeSystemAudio = true; // Default olarak sistem sesi açık
|
|
72
72
|
CGDirectDisplayID displayID = CGMainDisplayID(); // Default ana ekran
|
|
73
|
+
NSString *audioDeviceId = nil; // Default audio device ID
|
|
73
74
|
|
|
74
75
|
if (info.Length() > 1 && info[1].IsObject()) {
|
|
75
76
|
Napi::Object options = info[1].As<Napi::Object>();
|
|
@@ -97,6 +98,12 @@ Napi::Value StartRecording(const Napi::CallbackInfo& info) {
|
|
|
97
98
|
includeMicrophone = options.Get("includeMicrophone").As<Napi::Boolean>();
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
// Audio device ID
|
|
102
|
+
if (options.Has("audioDeviceId") && !options.Get("audioDeviceId").IsNull()) {
|
|
103
|
+
std::string deviceId = options.Get("audioDeviceId").As<Napi::String>().Utf8Value();
|
|
104
|
+
audioDeviceId = [NSString stringWithUTF8String:deviceId.c_str()];
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
// System audio
|
|
101
108
|
if (options.Has("includeSystemAudio")) {
|
|
102
109
|
includeSystemAudio = options.Get("includeSystemAudio").As<Napi::Boolean>();
|
|
@@ -154,12 +161,41 @@ Napi::Value StartRecording(const Napi::CallbackInfo& info) {
|
|
|
154
161
|
|
|
155
162
|
// Add microphone input if requested
|
|
156
163
|
if (includeMicrophone) {
|
|
157
|
-
AVCaptureDevice *audioDevice =
|
|
164
|
+
AVCaptureDevice *audioDevice = nil;
|
|
165
|
+
|
|
166
|
+
if (audioDeviceId) {
|
|
167
|
+
// Try to find the specified device
|
|
168
|
+
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeAudio];
|
|
169
|
+
NSLog(@"[DEBUG] Looking for audio device with ID: %@", audioDeviceId);
|
|
170
|
+
NSLog(@"[DEBUG] Available audio devices:");
|
|
171
|
+
for (AVCaptureDevice *device in devices) {
|
|
172
|
+
NSLog(@"[DEBUG] - Device: %@ (ID: %@)", device.localizedName, device.uniqueID);
|
|
173
|
+
if ([device.uniqueID isEqualToString:audioDeviceId]) {
|
|
174
|
+
NSLog(@"[DEBUG] Found matching device: %@", device.localizedName);
|
|
175
|
+
audioDevice = device;
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!audioDevice) {
|
|
181
|
+
NSLog(@"[DEBUG] Specified audio device not found, falling back to default");
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Fallback to default device if specified device not found
|
|
186
|
+
if (!audioDevice) {
|
|
187
|
+
audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
|
|
188
|
+
NSLog(@"[DEBUG] Using default audio device: %@ (ID: %@)", audioDevice.localizedName, audioDevice.uniqueID);
|
|
189
|
+
}
|
|
190
|
+
|
|
158
191
|
if (audioDevice) {
|
|
159
192
|
NSError *error;
|
|
160
193
|
g_audioInput = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:&error];
|
|
161
194
|
if (g_audioInput && [g_captureSession canAddInput:g_audioInput]) {
|
|
162
195
|
[g_captureSession addInput:g_audioInput];
|
|
196
|
+
NSLog(@"[DEBUG] Successfully added audio input device");
|
|
197
|
+
} else {
|
|
198
|
+
NSLog(@"[DEBUG] Failed to add audio input device: %@", error);
|
|
163
199
|
}
|
|
164
200
|
}
|
|
165
201
|
}
|