@@ -29,6 +29,10 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor {
29
29
30
30
#pragma mark - getUserMedia
31
31
32
+ - (NSString *)convertBoolToString : (id )value {
33
+ return value ? @" true" : @" false" ;
34
+ }
35
+
32
36
/* *
33
37
* Initializes a new {@link RTCAudioTrack} which satisfies the given constraints.
34
38
*
@@ -37,7 +41,26 @@ - (void)setVideoEffectProcessor:(VideoEffectProcessor *)videoEffectProcessor {
37
41
*/
38
42
- (RTCAudioTrack *)createAudioTrack : (NSDictionary *)constraints {
39
43
NSString *trackId = [[NSUUID UUID ] UUIDString ];
40
- RTCAudioTrack *audioTrack = [self .peerConnectionFactory audioTrackWithTrackId: trackId];
44
+ NSDictionary *audioConstraints = constraints[@" audio" ];
45
+ NSMutableDictionary *optionalConstraints = [NSMutableDictionary dictionary ];
46
+ optionalConstraints[@" googAutoGainControl" ] = audioConstraints[@" autoGainControl" ] != nil
47
+ ? [self convertBoolToString: audioConstraints[@" autoGainControl" ]]
48
+ : @" true" ;
49
+ optionalConstraints[@" googNoiseSuppression" ] =
50
+ audioConstraints[@" noiseSuppression" ] != nil ? [self convertBoolToString: audioConstraints[@" noiseSuppression" ]]
51
+ : @" true" ;
52
+ optionalConstraints[@" googEchoCancellation" ] =
53
+ audioConstraints[@" echoCancellation" ] != nil ? [self convertBoolToString: audioConstraints[@" echoCancellation" ]]
54
+ : @" true" ;
55
+ optionalConstraints[@" googHighpassFilter" ] = audioConstraints[@" highpassFilter" ] != nil
56
+ ? [self convertBoolToString: audioConstraints[@" highpassFilter" ]]
57
+ : @" true" ;
58
+
59
+ RTCMediaConstraints *mediaConstraints =
60
+ [[RTCMediaConstraints alloc ] initWithMandatoryConstraints: nil optionalConstraints: optionalConstraints];
61
+
62
+ RTCAudioSource *audioSource = [self .peerConnectionFactory audioSourceWithConstraints: mediaConstraints];
63
+ RTCAudioTrack *audioTrack = [self .peerConnectionFactory audioTrackWithSource: audioSource trackId: trackId];
41
64
return audioTrack;
42
65
}
43
66
/* *
0 commit comments