Skip to content

Commit 65d20a8

Browse files
committed
添加刷新localview&新增回音消除接口
Change-Id: I460e180d7e38ef9fe6558b5430ec7b6184c96f4f
2 parents 2627ef7 + ee10867 commit 65d20a8

File tree

7 files changed

+66
-38
lines changed

7 files changed

+66
-38
lines changed

Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ platform :ios, '9.0'
22
#inhibit_all_warnings!
33
use_frameworks!
44
#source 'https://cdn.cocoapods.org/'
5+
#source 'https://github.com/CocoaPods/Specs.git'
56
def common_all_pods
67
pod 'Masonry', '1.1.0'
78
pod 'MBProgressHUD', '1.1.0'

Podfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ PODS:
3030
- TXLiteAVSDK_TRTC (= 8.0.9644)
3131
- YYModel (= 1.0.4)
3232
- TIoTLinkKit_FLV (2.2.3)
33-
- TIoTLinkKit_IJKPlayer (1.0.7-beta.202207121233)
33+
- TIoTLinkKit_IJKPlayer (1.0.7)
3434
- TIoTLinkKit_TPNS (1.0.1)
3535
- TIoTLinkKit_WechatOpenSDK (1.0.1)
36-
- TIoTLinkKit_XP2P (2.4.26-beta.202205260939)
36+
- TIoTLinkKit_XP2P (2.4.27)
3737
- TIoTLinkVideo (1.0.0):
3838
- CocoaAsyncSocket (= 7.6.5)
3939
- TIoTLinkKit_FLV (= 2.2.3)
40-
- TIoTLinkKit_XP2P (= 2.4.26-beta.202205260939)
40+
- TIoTLinkKit_XP2P (= 2.4.27)
4141
- TrueTime (5.0.3)
4242
- TXLiteAVSDK_TRTC (8.0.9644)
4343
- TZImagePickerController (3.2.1)
@@ -60,7 +60,7 @@ DEPENDENCIES:
6060
- Tencent-MapSDK (= 4.3.9)
6161
- TIoTLinkKit (from `./`)
6262
- TIoTLinkKit/LinkRTC (from `./`)
63-
- TIoTLinkKit_IJKPlayer (~> 1.0.7-beta.202207121233)
63+
- TIoTLinkKit_IJKPlayer (= 1.0.7)
6464
- TIoTLinkKit_TPNS (= 1.0.1)
6565
- TIoTLinkKit_WechatOpenSDK (= 1.0.1)
6666
- TIoTLinkVideo (from `./`)
@@ -119,16 +119,16 @@ SPEC CHECKSUMS:
119119
Tencent-MapSDK: 6dfbee53b46131deb4c4bb02b3edc5ce7fb630dc
120120
TIoTLinkKit: 0386fb583c61765a02ad5cca810c7661d5a0bc53
121121
TIoTLinkKit_FLV: aec2b2ec9664990ec6c5b9f760fc1a9043d5a9a5
122-
TIoTLinkKit_IJKPlayer: 0956f2e09012c6b050ac33e3a66fbe71d5442617
122+
TIoTLinkKit_IJKPlayer: 0431299f267d188c0a26ef79111085b638c6fc97
123123
TIoTLinkKit_TPNS: 7cea4fc1d20ef6c4c11c4f0b66bbb10ecf4ed968
124124
TIoTLinkKit_WechatOpenSDK: 7822d68cc5c46edf3f6020422202e7b65ea87614
125-
TIoTLinkKit_XP2P: 2c0d8b66ab3e075d8cda1cf5608b425593101346
126-
TIoTLinkVideo: d93da089474f14ef182f6f4cf54cdfe3bd82ff49
125+
TIoTLinkKit_XP2P: 645a54568e9ecd9915c392a2bd07413a5a79c72f
126+
TIoTLinkVideo: 2be39eb99a6c39e21a390302b50d4b36e1fcd4e3
127127
TrueTime: b49551ffafb28a9dee04e51b226f42a416010842
128128
TXLiteAVSDK_TRTC: e3383a81565e8bb2aaaaab4bd099ad5239cd5b2d
129129
TZImagePickerController: bf4c57b98d8707fce41ea6be872414a71c7a8c9d
130130
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
131131

132-
PODFILE CHECKSUM: 6739ce81e9a22e68a26f72ece75f92211b352595
132+
PODFILE CHECKSUM: d9bf43bd125a00ed5aef22ac21dd584dc5505281
133133

134134
COCOAPODS: 1.9.3

Source/LinkApp/Classes/Module/EquipmentPanel/Controller/TIoTAVP2PPlayCaptureVC.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ - (void)deviceP2PVideoReport:(NSNotification *)reportInfo {
400400
NSError *outError;
401401
AVAudioSessionSetActiveOptions options = active ? 0 : AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation;
402402

403-
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionAllowBluetooth error:&outError];
403+
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker|AVAudioSessionCategoryOptionAllowBluetooth|AVAudioSessionCategoryOptionMixWithOthers error:&outError];
404404
[session setMode:AVAudioSessionModeVoiceChat error:&outError];
405405
[session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:&outError];
406406
[session setActive:active withOptions:options error:nil];

Source/SDK/LinkVideo/FLV/TIoTAVCaptionFLV.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ typedef NS_ENUM(NSInteger, TIoTAVCaptionFLVAudioType) {
2020
-(instancetype) initWithAudioConfig:(TIoTAVCaptionFLVAudioType)audioSampleRate;
2121

2222
- (void)preStart;
23-
-(BOOL) startCapture;
24-
-(void) stopCapture;
25-
-(void)changeCameraPositon;
23+
- (BOOL)startCapture;
24+
- (void)stopCapture;
25+
- (void)refreshLocalPreviewView;
26+
- (void)changeCameraPositon;
2627
- (void)setResolutionRatio:(AVCaptureSessionPreset)resolutionValue;
2728
- (void)setVideoBitRate:(int32_t)bitRate;
2829
- (int32_t)getVideoBitRate;

Source/SDK/LinkVideo/FLV/TIoTAVCaptionFLV.mm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,16 @@ - (void)configEncode {
246246
[self.h264Encoder initEncode:720 height:1280];
247247
}else if ([self.resolutionRatioValue isEqualToString: AVCaptureSessionPreset1920x1080]) {
248248
[self.h264Encoder initEncode:1080 height:1920];
249+
}else {
250+
[self.h264Encoder initEncode:288 height:352];
249251
}
250252
}
251253

252254
- (void)setVideoBitRate:(int32_t)bitRate {
253255

254256
int32_t ret = bitRate;
255257
[self.h264Encoder setEncoderBitrateBps:ret];
256-
NSLog(@"-------------------------setEncoderBitrateBps---%d-----------------",ret);
258+
// NSLog(@"-------------------------setEncoderBitrateBps---%d-----------------",ret);
257259
}
258260

259261
- (int32_t)getVideoBitRate {
@@ -531,6 +533,15 @@ - (void) startCamera
531533
}
532534
}
533535

536+
- (void)refreshLocalPreviewView {
537+
if (self.videoLocalView) {
538+
_previewLayer.frame = self.videoLocalView.bounds;
539+
[self.videoLocalView.layer addSublayer:_previewLayer];
540+
}else {
541+
_previewLayer.frame = CGRectZero;
542+
}
543+
}
544+
534545
- (void) stopCarmera
535546
{
536547
// [_h264Encoder End];

Source/SDK/LinkVideo/TIoTCoreXP2PBridge.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern NSNotificationName const TIoTCoreXP2PBridgeNotificationStreamEnd;
5454
@property (nonatomic, assign)BOOL writeFile;
5555

5656
/*
57-
* 是否打印 SDK Log,默认打开
57+
* 是否打印 SDK Log,默认关
5858
*/
5959
@property (nonatomic, assign)BOOL logEnable;
6060

@@ -110,8 +110,12 @@ extern NSNotificationName const TIoTCoreXP2PBridgeNotificationStreamEnd;
110110
//音视频采样
111111
- (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_number audioConfig:(TIoTAVCaptionFLVAudioType)audio_rate withLocalPreviewView:(UIView *)localView;
112112
- (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_number audioConfig:(TIoTAVCaptionFLVAudioType)audio_rate withLocalPreviewView:(UIView *)localView videoPosition:(AVCaptureDevicePosition)videoPosition;
113+
- (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_number audioConfig:(TIoTAVCaptionFLVAudioType)audio_rate withLocalPreviewView:(UIView *)localView videoPosition:(AVCaptureDevicePosition)videoPosition isEchoCancel:(BOOL)isEchoCancel;
114+
//刷新本地预览视图
115+
- (void)refreshLocalView:(UIView *)localView;
113116

114117
- (XP2PErrCode)stopVoiceToServer;
118+
//切换前后摄像头
115119
- (void)changeCameraPositon;
116120

117121
//设置分辨率,需在开启通话前设置

Source/SDK/LinkVideo/TIoTCoreXP2PBridge.mm

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
NSNotificationName const TIoTCoreXP2PBridgeNotificationStreamEnd = @"XP2PTypeStreamEnd"; // 设备主动停止推流,或者由于达到设备最大连接数,拒绝推流
1414

1515
NSFileHandle *p2pOutLogFile;
16-
NSFileHandle *fileHandle;
16+
//NSFileHandle *fileHandle;
1717

1818
@interface TIoTCoreXP2PBridge ()<TIoTAVCaptionFLVDelegate>
1919
@property (nonatomic, strong) NSString *dev_name;
@@ -28,18 +28,18 @@ - (void)cancelTimer;
2828
return nullptr;
2929
}
3030
NSString *message = [NSString stringWithCString:msg encoding:[NSString defaultCStringEncoding]];
31-
// BOOL logEnable = [TIoTCoreXP2PBridge sharedInstance].logEnable;
32-
// if (logEnable) {
33-
// NSLog(@"XP2P log: %@\n", message);
34-
// }
35-
//
36-
// if (type == XP2PTypeLog) {
37-
// if (logEnable) {
38-
// dispatch_async(dispatch_get_main_queue(), ^{
39-
// [p2pOutLogFile writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
40-
// });
41-
// }
42-
// }
31+
BOOL logEnable = [TIoTCoreXP2PBridge sharedInstance].logEnable;
32+
if (logEnable) {
33+
NSLog(@"XP2P log: %@\n", message);
34+
}
35+
36+
if (type == XP2PTypeLog) {
37+
if (logEnable) {
38+
dispatch_async(dispatch_get_main_queue(), ^{
39+
[p2pOutLogFile writeData:[message dataUsingEncoding:NSUTF8StringEncoding]];
40+
});
41+
}
42+
}
4343

4444
NSString *DeviceName = [NSString stringWithCString:idd encoding:[NSString defaultCStringEncoding]]?:@"";
4545

@@ -192,8 +192,8 @@ + (instancetype)sharedInstance {
192192
- (instancetype)init {
193193
self = [super init];
194194
if (self) {
195-
//默认打开log开关
196-
_logEnable = YES;
195+
//默认关log开关
196+
_logEnable = NO;
197197

198198
NSString *logFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"TIoTXP2P.log"];
199199
[[NSFileManager defaultManager] removeItemAtPath:logFile error:nil];
@@ -319,10 +319,14 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
319319
}
320320

321321
- (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_number audioConfig:(TIoTAVCaptionFLVAudioType)audio_rate withLocalPreviewView:(UIView *)localView videoPosition:(AVCaptureDevicePosition)videoPosition {
322-
NSString *audioFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"testVideoStreamfile.flv"];
323-
[[NSFileManager defaultManager] removeItemAtPath:audioFile error:nil];
324-
[[NSFileManager defaultManager] createFileAtPath:audioFile contents:nil attributes:nil];
325-
fileHandle = [NSFileHandle fileHandleForWritingAtPath:audioFile];
322+
[self sendVoiceToServer:dev_name channel:channel_number audioConfig:audio_rate withLocalPreviewView:localView videoPosition:videoPosition isEchoCancel:NO];
323+
}
324+
325+
- (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_number audioConfig:(TIoTAVCaptionFLVAudioType)audio_rate withLocalPreviewView:(UIView *)localView videoPosition:(AVCaptureDevicePosition)videoPosition isEchoCancel:(BOOL)isEchoCancel {
326+
// NSString *audioFile = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"testVideoStreamfile.flv"];
327+
// [[NSFileManager defaultManager] removeItemAtPath:audioFile error:nil];
328+
// [[NSFileManager defaultManager] createFileAtPath:audioFile contents:nil attributes:nil];
329+
// fileHandle = [NSFileHandle fileHandleForWritingAtPath:audioFile];
326330

327331
self.isSending = YES;
328332

@@ -334,7 +338,7 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
334338
if (systemAvCapture == nil) {
335339
systemAvCapture = [[TIoTAVCaptionFLV alloc] initWithAudioConfig:audio_rate];
336340
systemAvCapture.videoLocalView = localView;
337-
systemAvCapture.isEchoCancel = YES;
341+
systemAvCapture.isEchoCancel = isEchoCancel;
338342
}
339343
systemAvCapture.devicePosition = videoPosition;
340344
systemAvCapture.videoLocalView = localView;
@@ -348,7 +352,9 @@ - (void)sendVoiceToServer:(NSString *)dev_name channel:(NSString *)channel_numbe
348352
_p2p_wl_avg_ctx.len = MAX_AVG_LENGTH;
349353
//每次send时,先销毁之前已存在timer,保证多次send内部只持有一个timer
350354
[self cancelTimer];
351-
_getBufTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(getSendBufSize) userInfo:nil repeats:YES];
355+
if (localView != nil) {
356+
_getBufTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(getSendBufSize) userInfo:nil repeats:YES];
357+
}
352358
}
353359

354360

@@ -365,7 +371,7 @@ - (void)getSendBufSize {
365371
// for (int i =0; i < _p2p_wl_avg_ctx.len; i++) {
366372
// printf("\n stream_buf_con==%d \n",_p2p_wl_avg_ctx.buf[i]);
367373
// }
368-
NSLog(@"send_bufsize==%d, now_video_rate==%d, avg_index==%d",bufsize, now_video_rate, p2p_wl_avg);
374+
// NSLog(@"send_bufsize==%d, now_video_rate==%d, avg_index==%d",bufsize, now_video_rate, p2p_wl_avg);
369375

370376
// 降码率
371377
// 当发现p2p的水线超过一定值时,降低视频码率,这是一个经验值,一般来说要大于 [视频码率/2]
@@ -391,6 +397,11 @@ - (void)resolutionRatio:(AVCaptureSessionPreset)resolutionValue {
391397
self.resolution = resolutionValue;
392398
}
393399

400+
- (void)refreshLocalView:(UIView *)localView {
401+
systemAvCapture.videoLocalView = localView;
402+
[systemAvCapture refreshLocalPreviewView];
403+
}
404+
394405
- (void)changeCameraPositon {
395406
[systemAvCapture changeCameraPositon];
396407
}
@@ -416,8 +427,8 @@ - (void)stopService:(NSString *)dev_name {
416427

417428
[p2pOutLogFile synchronizeFile];
418429
//关闭文件
419-
[fileHandle closeFile];
420-
fileHandle = NULL;
430+
// [fileHandle closeFile];
431+
// fileHandle = NULL;
421432
}
422433

423434
- (void)cancelTimer {

0 commit comments

Comments
 (0)