@mentra/glasses-media 3.2.0-dev.225 → 3.2.0-dev.227

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.
@@ -0,0 +1,70 @@
1
+ import AudioToolbox
2
+ import Foundation
3
+ import WebRTC
4
+
5
+ /// WebRTC recording device driven by decoded glasses PCM. No phone mic or AVAudioSession capture.
6
+ final class RelayAudioDevice: NSObject, RTCAudioDevice {
7
+ let pcm = RelayPcmBuffer()
8
+ let deviceInputSampleRate: Double = 48000
9
+ let inputIOBufferDuration: TimeInterval = 0.01
10
+ let inputNumberOfChannels = 1
11
+ let inputLatency: TimeInterval = 0
12
+ let deviceOutputSampleRate: Double = 48000
13
+ let outputIOBufferDuration: TimeInterval = 0.01
14
+ let outputNumberOfChannels = 1
15
+ let outputLatency: TimeInterval = 0
16
+ private(set) var isInitialized = false
17
+ private(set) var isRecordingInitialized = false
18
+ private(set) var isRecording = false
19
+ let isPlayoutInitialized = false
20
+ let isPlaying = false
21
+ private let clock = RelayAudioClock()
22
+
23
+ func initialize(with delegate: RTCAudioDeviceDelegate) -> Bool {
24
+ let storage = UnsafeMutablePointer<Int16>.allocate(capacity: 480)
25
+ let pcm = pcm
26
+ clock.start(render: { sampleTime in
27
+ pcm.read(into: UnsafeMutableBufferPointer(start: storage, count: 480))
28
+ var flags = AudioUnitRenderActionFlags()
29
+ var stamp = AudioTimeStamp()
30
+ stamp.mSampleTime = sampleTime
31
+ stamp.mFlags = .sampleTimeValid
32
+ var buffers = AudioBufferList(mNumberBuffers: 1, mBuffers: AudioBuffer(mNumberChannels: 1, mDataByteSize: 960, mData: storage))
33
+ _ = delegate.deliverRecordedData(&flags, &stamp, 0, 480, &buffers, nil, nil)
34
+ }, finish: { storage.deallocate() })
35
+ isInitialized = true
36
+ return true
37
+ }
38
+
39
+ func terminateDevice() -> Bool {
40
+ clock.stop()
41
+ isInitialized = false; isRecording = false; isRecordingInitialized = false
42
+ return true
43
+ }
44
+
45
+ func initializeRecording() -> Bool {
46
+ isRecordingInitialized = true; return true
47
+ }
48
+
49
+ func startRecording() -> Bool {
50
+ clock.setEnabled(true)
51
+ isRecording = true; return true
52
+ }
53
+
54
+ func stopRecording() -> Bool {
55
+ clock.setEnabled(false)
56
+ isRecording = false; return true
57
+ }
58
+
59
+ func initializePlayout() -> Bool {
60
+ false
61
+ }
62
+
63
+ func startPlayout() -> Bool {
64
+ false
65
+ }
66
+
67
+ func stopPlayout() -> Bool {
68
+ true
69
+ }
70
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentra/glasses-media",
3
- "version": "3.2.0-dev.225",
3
+ "version": "3.2.0-dev.227",
4
4
  "description": "Shared native glasses media receivers and local network transport",
5
5
  "license": "MIT",
6
6
  "author": "Mentra Community",