@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.
- package/README.md +19 -3
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/mentra/glassesmedia/GlassesMediaRelayModule.kt +113 -0
- package/android/src/main/java/com/mentra/glassesmedia/network/ScopedNetworkChangeDetector.kt +34 -4
- package/android/src/main/java/com/mentra/glassesmedia/network/ScopedNetworkObserver.kt +11 -4
- package/android/src/main/java/com/mentra/glassesmedia/network/ScopedNetworkRegistry.kt +16 -0
- package/android/src/main/java/com/mentra/glassesmedia/publisher/PhoneWhipPublisher.kt +263 -0
- package/android/src/main/java/com/mentra/glassesmedia/publisher/RelayPcmBuffer.kt +54 -0
- package/android/src/main/java/com/mentra/glassesmedia/source/LocalWhipIngestSource.kt +16 -3
- package/android/src/main/java/com/mentra/glassesmedia/source/WhipIngestServer.kt +31 -15
- package/expo-module.config.json +6 -2
- package/ios/CoreKit/Sources/GlassesMediaCore/LocalMediaPolicy.swift +8 -0
- package/ios/CoreKit/Sources/GlassesMediaCore/RelayAudioClock.swift +56 -0
- package/ios/CoreKit/Sources/GlassesMediaCore/RelayPcmBuffer.swift +57 -0
- package/ios/GlassesHotspotNetwork.swift +11 -3
- package/ios/GlassesMedia.podspec +1 -0
- package/ios/GlassesMediaRelayModule.swift +133 -0
- package/ios/PhoneWhipPublisher.swift +202 -0
- package/ios/RelayAudioDevice.swift +70 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|