Download this file
| 1 | import CallsKit |
| 2 | import Foundation |
| 3 | import LiveKitWebRTC |
| 4 | |
| 5 | // Test-only audio device. No samples are captured or rendered. WebRTC invokes |
| 6 | // this protocol serially on its audio thread, as specified by RTCAudioDevice. |
| 7 | final class SilentAudioDevice: NSObject, RTCAudioDevice { |
| 8 | let deviceInputSampleRate = 48000.0 |
| 9 | let deviceOutputSampleRate = 48000.0 |
| 10 | let inputIOBufferDuration = 0.01 |
| 11 | let outputIOBufferDuration = 0.01 |
| 12 | let inputNumberOfChannels = 1 |
| 13 | let outputNumberOfChannels = 1 |
| 14 | let inputLatency = 0.0 |
| 15 | let outputLatency = 0.0 |
| 16 | var isInitialized = false |
| 17 | var isPlayoutInitialized = false |
| 18 | var isRecordingInitialized = false |
| 19 | var isPlaying = false |
| 20 | var isRecording = false |
| 21 | func initialize(with delegate: RTCAudioDeviceDelegate) -> Bool { |
| 22 | isInitialized = true |
| 23 | return true |
| 24 | } |
| 25 | func terminateDevice() -> Bool { |
| 26 | isInitialized = false |
| 27 | isPlaying = false |
| 28 | isRecording = false |
| 29 | return true |
| 30 | } |
| 31 | func initializePlayout() -> Bool { |
| 32 | isPlayoutInitialized = true |
| 33 | return true |
| 34 | } |
| 35 | func startPlayout() -> Bool { |
| 36 | isPlaying = true |
| 37 | return true |
| 38 | } |
| 39 | func stopPlayout() -> Bool { |
| 40 | isPlaying = false |
| 41 | return true |
| 42 | } |
| 43 | func initializeRecording() -> Bool { |
| 44 | isRecordingInitialized = true |
| 45 | return true |
| 46 | } |
| 47 | func startRecording() -> Bool { |
| 48 | isRecording = true |
| 49 | return true |
| 50 | } |
| 51 | func stopRecording() -> Bool { |
| 52 | isRecording = false |
| 53 | return true |
| 54 | } |
| 55 | } |
| 56 | |