Skip to content

Commit

Permalink
优化对讲模块
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleychen committed Aug 22, 2024
1 parent f51567a commit c8f00a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Source/SDK/LinkVideo/FLV/TIoTAVCaptionFLV.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ - (void)setupAudioCapture {
self.aacEncoder.audioType = _audioRate;
return;
}
NSString* NSmodel_file = [[NSBundle mainBundle] pathForResource:@"GvoiceSE_v1_239-119-oneref-e.nn" ofType:nil];
const char *model_file = [NSmodel_file cStringUsingEncoding : NSUTF8StringEncoding];
self.trae_is_valid = [GVoiceSE voice_handle_open:model_file];

static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString* NSmodel_file = [[NSBundle mainBundle] pathForResource:@"GvoiceSE_v1_239-119-oneref-e.nn" ofType:nil];
const char *model_file = [NSmodel_file cStringUsingEncoding : NSUTF8StringEncoding];
self.trae_is_valid = [GVoiceSE voice_handle_open:model_file];
});

AudioStreamBasicDescription inAudioStreamBasicDescription;

Expand Down
8 changes: 8 additions & 0 deletions Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @interface TIoTCoreXP2PBridge ()<TIoTAVCaptionFLVDelegate>
@property (nonatomic, strong) NSTimer *getBufTimer;
@property (nonatomic, strong) NSMutableDictionary *uniReqStartTime;
@property (nonatomic, strong) TIoTCoreLogger *logger;
@property (nonatomic, assign) CFTimeInterval start_voice_time;
- (void)cancelTimer;
- (void)doTick:(data_report_t)data_buf;
@end
Expand Down Expand Up @@ -210,6 +211,7 @@ - (instancetype)init {
if (self) {
//默认关log开关
_logEnable = NO;
_start_voice_time = 0;

NSString *logFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"TIoTXP2P.log"];
[[NSFileManager defaultManager] removeItemAtPath:logFile error:nil];
Expand Down Expand Up @@ -404,6 +406,12 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
// [[NSFileManager defaultManager] removeItemAtPath:audioFile error:nil];
// [[NSFileManager defaultManager] createFileAtPath:audioFile contents:nil attributes:nil];
// fileHandle = [NSFileHandle fileHandleForWritingAtPath:audioFile];
CFTimeInterval timestamp = CACurrentMediaTime();
if ((timestamp - self.start_voice_time)<1.5) {
return;
}
self.start_voice_time = timestamp;

audio_config.channels = 1;
self.isSending = YES;

Expand Down

0 comments on commit c8f00a6

Please sign in to comment.