File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
LinkSDKDemo/Video/P2P/Controller Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -207,7 +207,13 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
207207 NSString *channelNum = self.selectedModel .Channel ?:@" 0" ;
208208 channel = [NSString stringWithFormat: @" channel=%d " ,channelNum.intValue];
209209 }
210- [[TIoTCoreXP2PBridge sharedInstance ] sendVoiceToServer: self .deviceName?:@" " channel: channel];
210+
211+ AWAudioConfig *config = [[AWAudioConfig alloc ] init ];
212+ config.bitrate = 100000 ;
213+ config.channelCount = 1 ;
214+ config.sampleSize = 16 ;
215+ config.sampleRate = 44100 ;
216+ [[TIoTCoreXP2PBridge sharedInstance ] sendVoiceToServer: self .deviceName?:@" " channel: channel audioConfig: config];
211217 }
212218
213219 }else {
Original file line number Diff line number Diff line change 55//
66
77#import < Foundation/Foundation.h>
8+ #import " AWSystemAVCapture.h"
89#include " AppWrapper.h"
910
1011NS_ASSUME_NONNULL_BEGIN
@@ -72,7 +73,10 @@ NS_ASSUME_NONNULL_BEGIN
7273/*
7374 * 语音对讲开始结束接口
7475 */
76+ // 对讲音频默认采样率
7577- (void )sendVoiceToServer : (NSString *)dev_name channel : (NSString *)channel_number ;
78+ // 可通过此接口 audio_onfig 参数既可设置对讲音频码率(bitrate)、采样率(sampleRate)、channelCount、sampleSize
79+ - (void )sendVoiceToServer : (NSString *)dev_name channel : (NSString *)channel_number audioConfig : (AWAudioConfig *)audio_onfig ;
7680- (XP2PErrCode)stopVoiceToServer ;
7781
7882/*
Original file line number Diff line number Diff line change 66
77#import " TIoTCoreXP2PBridge.h"
88#include < string.h>
9- #import " AWSystemAVCapture.h"
109#import < CocoaLumberjack/CocoaLumberjack.h>
1110
1211#ifdef DEBUG
@@ -169,6 +168,12 @@ - (XP2PErrCode)stopAvRecvService:(NSString *)dev_name {
169168}
170169
171170- (void )sendVoiceToServer : (NSString *)dev_name channel : (NSString *)channel_number {
171+ AWAudioConfig *config = [[AWAudioConfig alloc ] init ];
172+ [self sendVoiceToServer: dev_name channel: channel_number audioConfig: config];
173+ }
174+
175+ - (void )sendVoiceToServer : (NSString *)dev_name channel : (NSString *)channel_number audioConfig : (AWAudioConfig *)audio_onfig {
176+ // 设置码率
172177 [[AVAudioSession sharedInstance ] setCategory: AVAudioSessionCategoryPlayAndRecord withOptions: AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth error: nil ];
173178 [[AVAudioSession sharedInstance ] setActive: YES error: nil ];
174179
@@ -178,8 +183,7 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
178183 const char *channel = [channel_number UTF8String ];
179184 _serverHandle = runSendService (dev_name.UTF8String , channel, false ); // 发送数据前需要告知http proxy
180185
181- AWAudioConfig *config = [[AWAudioConfig alloc ] init ];
182- systemAvCapture = [[AWSystemAVCapture alloc ] initWithAudioConfig: config];
186+ systemAvCapture = [[AWSystemAVCapture alloc ] initWithAudioConfig: audio_onfig];
183187 systemAvCapture.delegate = self;
184188 systemAvCapture.audioEncoderType = AWAudioEncoderTypeSWFAAC;
185189 [systemAvCapture startCapture ];
You can’t perform that action at this time.
0 commit comments