@sbhjt-gr/react-native-webrtc 124.0.1 → 124.0.2

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,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <WebRTC/RTCAudioDevice.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @interface WLVAudioDevice : NSObject <RTCAudioDevice>
7
+
8
+ - (void)pushAudioData:(NSData *)data sampleRate:(double)sampleRate channels:(NSInteger)channels;
9
+
10
+ @end
11
+
12
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,137 @@
1
+ #import "WLVAudioDevice.h"
2
+
3
+ #import <AudioUnit/AudioUnit.h>
4
+ #import <WebRTC/WebRTC.h>
5
+
6
+ @implementation WLVAudioDevice {
7
+ id<RTCAudioDeviceDelegate> _delegate;
8
+ double _sampleRate;
9
+ NSInteger _channels;
10
+ BOOL _isInitialized;
11
+ BOOL _isRecording;
12
+ }
13
+
14
+ #pragma mark - RTCAudioDevice properties
15
+
16
+ - (double)deviceInputSampleRate {
17
+ return _sampleRate > 0 ? _sampleRate : 48000.0;
18
+ }
19
+
20
+ - (NSTimeInterval)inputIOBufferDuration {
21
+ return 0.01;
22
+ }
23
+
24
+ - (NSInteger)inputNumberOfChannels {
25
+ return _channels > 0 ? _channels : 1;
26
+ }
27
+
28
+ - (NSTimeInterval)inputLatency {
29
+ return 0.0;
30
+ }
31
+
32
+ - (double)deviceOutputSampleRate {
33
+ return 48000.0;
34
+ }
35
+
36
+ - (NSTimeInterval)outputIOBufferDuration {
37
+ return 0.01;
38
+ }
39
+
40
+ - (NSInteger)outputNumberOfChannels {
41
+ return 1;
42
+ }
43
+
44
+ - (NSTimeInterval)outputLatency {
45
+ return 0.0;
46
+ }
47
+
48
+ - (BOOL)isInitialized {
49
+ return _isInitialized;
50
+ }
51
+
52
+ - (BOOL)initializeWithDelegate:(id<RTCAudioDeviceDelegate>)delegate {
53
+ _delegate = delegate;
54
+ _isInitialized = YES;
55
+ return YES;
56
+ }
57
+
58
+ - (BOOL)terminateDevice {
59
+ _delegate = nil;
60
+ _isInitialized = NO;
61
+ _isRecording = NO;
62
+ return YES;
63
+ }
64
+
65
+ - (BOOL)isPlayoutInitialized {
66
+ return YES;
67
+ }
68
+
69
+ - (BOOL)initializePlayout {
70
+ return YES;
71
+ }
72
+
73
+ - (BOOL)isPlaying {
74
+ return NO;
75
+ }
76
+
77
+ - (BOOL)startPlayout {
78
+ return YES;
79
+ }
80
+
81
+ - (BOOL)stopPlayout {
82
+ return YES;
83
+ }
84
+
85
+ - (BOOL)isRecordingInitialized {
86
+ return YES;
87
+ }
88
+
89
+ - (BOOL)initializeRecording {
90
+ return YES;
91
+ }
92
+
93
+ - (BOOL)isRecording {
94
+ return _isRecording;
95
+ }
96
+
97
+ - (BOOL)startRecording {
98
+ _isRecording = YES;
99
+ return YES;
100
+ }
101
+
102
+ - (BOOL)stopRecording {
103
+ _isRecording = NO;
104
+ return YES;
105
+ }
106
+
107
+ #pragma mark - Push API
108
+
109
+ - (void)pushAudioData:(NSData *)data sampleRate:(double)sampleRate channels:(NSInteger)channels {
110
+ id<RTCAudioDeviceDelegate> delegate = _delegate;
111
+ if (!delegate || data.length == 0 || channels <= 0) {
112
+ return;
113
+ }
114
+
115
+ _sampleRate = sampleRate;
116
+ _channels = channels;
117
+
118
+ NSUInteger frameCount = data.length / (sizeof(int16_t) * (NSUInteger)channels);
119
+ if (frameCount == 0) {
120
+ return;
121
+ }
122
+
123
+ AudioBufferList bufferList;
124
+ bufferList.mNumberBuffers = 1;
125
+ bufferList.mBuffers[0].mNumberChannels = (UInt32)channels;
126
+ bufferList.mBuffers[0].mDataByteSize = (UInt32)data.length;
127
+ bufferList.mBuffers[0].mData = (void *)data.bytes;
128
+
129
+ AudioUnitRenderActionFlags flags = 0;
130
+ AudioTimeStamp timestamp = {0};
131
+ timestamp.mFlags = kAudioTimeStampSampleTimeValid;
132
+
133
+ RTCAudioDeviceDeliverRecordedDataBlock deliverBlock = delegate.deliverRecordedData;
134
+ deliverBlock(&flags, &timestamp, 0, (UInt32)frameCount, &bufferList, nil, nil);
135
+ }
136
+
137
+ @end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbhjt-gr/react-native-webrtc",
3
- "version": "124.0.1",
3
+ "version": "124.0.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/livekit/react-native-webrtc.git"