Skip to content

Commit 9429a5a

Browse files
committed
添加设置对讲音频参数接口
Change-Id: I8015167164a7133e9ed01e9e9870bf328dc300e3
1 parent f9c94cb commit 9429a5a

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

Source/LinkSDKDemo/Video/P2P/Controller/TIoTDemoPreviewDeviceVC.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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 {

Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
//
66

77
#import <Foundation/Foundation.h>
8+
#import "AWSystemAVCapture.h"
89
#include "AppWrapper.h"
910

1011
NS_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
/*

Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
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];

0 commit comments

Comments
 (0)