Skip to content

Commit c8f00a6

Browse files
author
eagleychen
committed
优化对讲模块
1 parent f51567a commit c8f00a6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Source/SDK/LinkVideo/FLV/TIoTAVCaptionFLV.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,13 @@ - (void)setupAudioCapture {
8484
self.aacEncoder.audioType = _audioRate;
8585
return;
8686
}
87-
NSString* NSmodel_file = [[NSBundle mainBundle] pathForResource:@"GvoiceSE_v1_239-119-oneref-e.nn" ofType:nil];
88-
const char *model_file = [NSmodel_file cStringUsingEncoding : NSUTF8StringEncoding];
89-
self.trae_is_valid = [GVoiceSE voice_handle_open:model_file];
87+
88+
static dispatch_once_t onceToken;
89+
dispatch_once(&onceToken, ^{
90+
NSString* NSmodel_file = [[NSBundle mainBundle] pathForResource:@"GvoiceSE_v1_239-119-oneref-e.nn" ofType:nil];
91+
const char *model_file = [NSmodel_file cStringUsingEncoding : NSUTF8StringEncoding];
92+
self.trae_is_valid = [GVoiceSE voice_handle_open:model_file];
93+
});
9094

9195
AudioStreamBasicDescription inAudioStreamBasicDescription;
9296

Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ @interface TIoTCoreXP2PBridge ()<TIoTAVCaptionFLVDelegate>
2525
@property (nonatomic, strong) NSTimer *getBufTimer;
2626
@property (nonatomic, strong) NSMutableDictionary *uniReqStartTime;
2727
@property (nonatomic, strong) TIoTCoreLogger *logger;
28+
@property (nonatomic, assign) CFTimeInterval start_voice_time;
2829
- (void)cancelTimer;
2930
- (void)doTick:(data_report_t)data_buf;
3031
@end
@@ -210,6 +211,7 @@ - (instancetype)init {
210211
if (self) {
211212
//默认关log开关
212213
_logEnable = NO;
214+
_start_voice_time = 0;
213215

214216
NSString *logFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"TIoTXP2P.log"];
215217
[[NSFileManager defaultManager] removeItemAtPath:logFile error:nil];
@@ -404,6 +406,12 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
404406
// [[NSFileManager defaultManager] removeItemAtPath:audioFile error:nil];
405407
// [[NSFileManager defaultManager] createFileAtPath:audioFile contents:nil attributes:nil];
406408
// fileHandle = [NSFileHandle fileHandleForWritingAtPath:audioFile];
409+
CFTimeInterval timestamp = CACurrentMediaTime();
410+
if ((timestamp - self.start_voice_time)<1.5) {
411+
return;
412+
}
413+
self.start_voice_time = timestamp;
414+
407415
audio_config.channels = 1;
408416
self.isSending = YES;
409417

0 commit comments

Comments
 (0)