Skip to content

Commit

Permalink
update to v2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ksysdkci committed Sep 1, 2017
1 parent 89dfa89 commit 884c1fd
Show file tree
Hide file tree
Showing 46 changed files with 1,266 additions and 225 deletions.
4 changes: 2 additions & 2 deletions demo/KSYLiveDemo/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.6.0</string>
<string>2.6.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.6.0.0</string>
<string>2.6.1.2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
4 changes: 4 additions & 0 deletions demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@
@property UISegmentedControl * noiseSuppressSeg;
@property (atomic, readonly) KSYAudioNoiseSuppress noiseSuppress;

/// 音频通路数据类型选择
@property UISegmentedControl * audioDataTypeSeg;
@property (atomic, readonly) KSYAudioDataType audioDataType;

@end
8 changes: 7 additions & 1 deletion demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ - (id)init{
_effectType = [self addSegCtrlWithItems:@[@"关闭变声",@"大叔", @"萝莉", @"庄严", @"机器人"]];
_noiseSuppressSeg = [self addSegCtrlWithItems:@[@"关闭去噪",@"", @"", @"", @"很高"]];
_noiseSuppressSeg.selectedSegmentIndex = 3;
_audioDataTypeSeg = [self addSegCtrlWithItems:@[@"CMSampleBufer",@"RawPcm"]];
return self;
}
- (void)layoutUI{
Expand All @@ -66,8 +67,9 @@ - (void)layoutUI{
nu,_lblPlayCapture,_swPlayCapture] ];
[self putRow1:_playCapVol];
[self putRow1:_effectType];
[self putRowFit:@[_lblStereo, _stereoStream]];
[self putRowFit:@[_lblStereo, _stereoStream, _audioDataTypeSeg]];
[self putRow1:_noiseSuppressSeg];

}
- (void) initMicInput {
BOOL bHS = [AVAudioSession isHeadsetInputAvaible];
Expand Down Expand Up @@ -134,4 +136,8 @@ - (KSYAudioEffectType) audioEffect {
- (KSYAudioNoiseSuppress) noiseSuppress {
return _noiseSuppressSeg.selectedSegmentIndex - 1; // off is -1
}
@synthesize audioDataType = _audioDataType;
- (KSYAudioDataType) audioDataType {
return _audioDataTypeSeg.selectedSegmentIndex;
}
@end
13 changes: 2 additions & 11 deletions demo/KSYLiveDemo/KSYDemoUI/KSYBrushStreamerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,10 @@ - (void)onTimer:(NSTimer *)theTimer{
[self updateDrawView];
}

#pragma mark - utils
-(UIImage *)imageFromUIView:(UIView *)v {
CGSize s = v.frame.size;
UIGraphicsBeginImageContextWithOptions(s, NO, 0.0);
[v.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
//刷新画笔view
- (void) updateDrawView{
if(_drawRefresh){
UIImage * img = [self imageFromUIView:_drawView];
[_brushKit addDrawLayer:img];
_brushKit.drawPic = [[GPUImageUIElement alloc] initWithView:_drawView];
}
}

Expand Down
4 changes: 2 additions & 2 deletions demo/KSYLiveDemo/KSYDemoUI/KSYHorScreenStreamerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@interface KSYHorScreenStreamerVC ()
@property UILabel *text;
@property KSYGPUView *preView;
@property UIView *preView;
@end

@implementation KSYHorScreenStreamerVC
Expand All @@ -26,7 +26,7 @@ - (void)setupUI{
_text.hidden = YES;

CGFloat wdt = self.view.frame.size.width;
_preView = [[KSYGPUView alloc] initWithFrame:CGRectMake(0, 75, wdt, wdt * 9 / 16)];
_preView = [[UIView alloc] initWithFrame:CGRectMake(0, 75, wdt, wdt * 9 / 16)];
[self.view addSubview:_preView];
_preView.hidden = YES;
self.profilePicker.hidden = YES;
Expand Down
41 changes: 32 additions & 9 deletions demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
#import "KSYNameSlider.h"
#import "KSYQRCode.h"
#import <YYImage/YYImage.h>

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#import <CallKit/CXCallObserver.h>
#import <CallKit/CallKit.h>
#endif

// 为防止将手机存储写满,限制录像时长为30s
#define REC_MAX_TIME 30 //录制视频的最大时间,单位s

@interface KSYStreamerVC () <UIImagePickerControllerDelegate,UINavigationControllerDelegate, CXCallObserverDelegate>{
@interface KSYStreamerVC () <UIImagePickerControllerDelegate
,UINavigationControllerDelegate
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
,CXCallObserverDelegate
#endif
>{
UISwipeGestureRecognizer *_swipeGest;
NSDateFormatter * _dateFormatter;
int _strSeconds; // 推流持续的时间 , 单位s
Expand All @@ -35,14 +41,16 @@ @interface KSYStreamerVC () <UIImagePickerControllerDelegate,UINavigationControl
UIImageView *_foucsCursor;//对焦框
CGFloat _currentPinchZoomFactor;//当前触摸缩放因子
BOOL _bOutputInfo;//是否输出推流过程中的统计信息
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
CXCallObserver *_callObserver;
#endif
YYImageDecoder * _animateDecoder;
int _animateIdx;
CADisplayLink *_displayLink;
NSTimeInterval _dlTime;
NSLock *_dlLock;
GPUImagePicture *_logoPicure;
UIImageOrientation _logoOrientation;
}
@end

Expand Down Expand Up @@ -202,9 +210,10 @@ - (void) initObservers{
SEL_VALUE(onNetStateEvent:) , KSYNetStateEventNotification,
SEL_VALUE(onBgmPlayerStateChange:) ,KSYAudioStateDidChangeNotification,
nil];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
_callObserver = [[CXCallObserver alloc] init];
[_callObserver setDelegate:self queue:nil];
#endif
}

- (void) addObservers {
Expand All @@ -223,7 +232,9 @@ - (void) addObservers {
- (void) rmObservers {
[super rmObservers];
[[NSNotificationCenter defaultCenter] removeObserver:self];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
_callObserver = nil;
#endif
}

- (void) layoutUI {
Expand Down Expand Up @@ -257,6 +268,8 @@ - (void) setupLogo{
UIImage * logoImg = [UIImage imageNamed:@"ksvc"];
_logoPicure = [[GPUImagePicture alloc] initWithImage:logoImg];
_kit.logoPic = _logoPicure;
_logoOrientation = logoImg.imageOrientation;
[_kit setLogoOrientaion: _logoOrientation];
_kit.logoRect = CGRectMake(0.05, yPos, 0, hgt);
_kit.logoAlpha= 0.5;
yPos += hgt;
Expand All @@ -283,7 +296,8 @@ - (void) updateLogoText {
- (void) setupAnimateLogo:(NSString*)path {
NSData *data = [NSData dataWithContentsOfFile:path];
[_dlLock lock];
_animateDecoder = [YYImageDecoder decoderWithData:data scale:2.0];
_animateDecoder = [YYImageDecoder decoderWithData:data scale: [[UIScreen mainScreen] scale]];
[_kit setLogoOrientaion:UIImageOrientationUp];
[_dlLock unlock];
_animateIdx = 0;
_dlTime = 0;
Expand Down Expand Up @@ -344,6 +358,7 @@ - (void) setCaptureCfg {
_kit.cameraPosition = [self.presetCfgView cameraPos];
_kit.gpuOutputPixelFormat = [self.presetCfgView gpuOutputPixelFmt];
_kit.capturePixelFormat = [self.presetCfgView gpuOutputPixelFmt];
_kit.aCapDev.noiseSuppressionLevel = self.audioView.noiseSuppress;
_kit.videoProcessingCallback = ^(CMSampleBufferRef buf){
// 在此处添加自定义图像处理, 直接修改buf中的图像数据会传递到观众端
// 或复制图像数据之后再做其他处理, 则观众端仍然看到处理前的图像
Expand All @@ -352,6 +367,10 @@ - (void) setCaptureCfg {
// 在此处添加自定义音频处理, 直接修改buf中的pcm数据会传递到观众端
// 或复制音频数据之后再做其他处理, 则观众端仍然听到原始声音
};
_kit.pcmProcessingCallback = ^(uint8_t** pData, int len, const AudioStreamBasicDescription* fmt, CMTime timeInfo){
// 在此处添加自定义音频处理, 直接修改pcm数据会传递到观众端
// 或复制音频数据之后再做其他处理, 则观众端仍然听到原始声音
};
_kit.interruptCallback = ^(BOOL bInterrupt){
// 在此处添加自定义图像采集被打断的处理 (比如接听电话等)
};
Expand Down Expand Up @@ -452,9 +471,11 @@ - (void) onCaptureStateChange:(NSNotification *)notification{
}
if (_kit.captureState == KSYCaptureStateIdle) {
self.ctrlView.btnCapture.backgroundColor = [UIColor darkGrayColor];
self.audioView.audioDataTypeSeg.enabled = YES;
}
else if(_kit.captureState == KSYCaptureStateCapturing) {
self.ctrlView.btnCapture.backgroundColor = [UIColor lightGrayColor];
self.audioView.audioDataTypeSeg.enabled = NO;
}
}

Expand Down Expand Up @@ -728,6 +749,7 @@ - (void) onCameraToggle{ // see kit or block
}
- (void) onCapture{
if (!_kit.vCapDev.isRunning){
_kit.audioDataType = self.audioView.audioDataType;
_kit.videoOrientation = [[UIApplication sharedApplication] statusBarOrientation];
// 重新开启预览是需要重新根据方向setupLogo
[self setupLogo];
Expand Down Expand Up @@ -902,6 +924,7 @@ - (void)onMiscBtns:(id)sender {
[_dlLock lock];
_animateDecoder = nil;
_kit.logoPic = _logoPicure;
[_kit setLogoOrientaion:_logoOrientation];
[_dlLock unlock];
}
}
Expand Down Expand Up @@ -994,12 +1017,10 @@ -(void)imagePickerController:(UIImagePickerController *)picker
_logoPicure = [[GPUImagePicture alloc] initWithImage:image
smoothlyScaleOutput:YES];
_kit.logoPic = _logoPicure;
_logoOrientation = image.imageOrientation;
[_kit setLogoOrientaion: _logoOrientation];
[picker dismissViewControllerAnimated:YES completion:nil];
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
[_kit.vPreviewMixer setPicRotation:kGPUImageRotateRight
ofLayer:_kit.logoPicLayer];
[_kit.vStreamMixer setPicRotation:kGPUImageRotateRight
ofLayer:_kit.logoPicLayer];
[self restartVideoCapSession];
}
}
Expand Down Expand Up @@ -1178,6 +1199,7 @@ - (void)pinchDetected:(UIPinchGestureRecognizer *)recognizer{
[_kit setPinchZoomFactor:zoomFactor];
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
#pragma mark - CXCallObserverDelegate method
- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
//处理来电事件
Expand All @@ -1203,6 +1225,7 @@ - (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call {
if(needSendMsg == YES)
[_kit processMessageData:message];
}
#endif

#pragma mark - Decal 相关
- (void)genDecalViewWithImgName:(NSString *)imgName{
Expand Down
5 changes: 3 additions & 2 deletions demo/KSYLiveDemo/KSYPlayerDemo/KSYRecordVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,14 @@ - (void)setupTimer
{
//调用截图方法
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(captureScreen:)];
if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0"))
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
//如果系统版本大于等于10.0
//设定回调速率
displayLink.preferredFramesPerSecond = 15;
else
#else
//设置间隔多少帧调用一次selector 方法
displayLink.frameInterval = 4;
#endif
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}
}
Expand Down
4 changes: 4 additions & 0 deletions demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
#define SYSTEM_VERSION_GE_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#ifndef __IPHONE_10_0
#define __IPHONE_10_0 100000
#endif

@class KSYUIView;
@interface KSYUIVC : UIViewController

Expand Down
10 changes: 5 additions & 5 deletions demo/KSYLiveDemo_Swift/KSYPlayerDemo_Swift/KSYNetTrackerVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ class KSYNetTrackerVC: UIViewController {
if rtt < 0.00000001 {
displayStr = displayStr?.appending("Request timeout for icmp_seq \(count)")
}else{
let pingRet = tracker?.routerInfo.firstObject as! KSYNetRouterInfo
displayStr = displayStr?.appending(String(format: "ping \(pingRet.ips.firstObject ?? "") icmp_seq \(count) time=%0.3f ms", rtt))
let pingRet = tracker?.routerInfo?.firstObject as! KSYNetRouterInfo
displayStr = displayStr?.appending(String(format: "ping \(pingRet.ips?.firstObject ?? "") icmp_seq \(count) time=%0.3f ms", rtt))
}
}else {
getRouterInfo()
Expand Down Expand Up @@ -279,7 +279,7 @@ class KSYNetTrackerVC: UIViewController {

func getPingRetStr() -> String {
var pingRetStr: String = ""
let pingRet = tracker?.routerInfo[0] as! KSYNetRouterInfo
let pingRet = tracker?.routerInfo?[0] as! KSYNetRouterInfo

pingRetStr = pingRetStr.appending("\n ------ping statics-----\n")
pingRetStr = pingRetStr.appendingFormat("%d packets transmitted, %d packets received, %0.3f packet loss\n", pingRet.number, Int(Float(pingRet.number) * (1 - pingRet.loss)), pingRet.loss)
Expand Down Expand Up @@ -309,13 +309,13 @@ class KSYNetTrackerVC: UIViewController {
return
}

tracker!.routerInfo.enumerateObjects( { (netInfo, idx, _) in
tracker!.routerInfo?.enumerateObjects( { (netInfo, idx, _) in
if let info: KSYNetRouterInfo = (netInfo as! KSYNetRouterInfo) {

if let _ = info.ips {
j = 0;

for ip in info.ips {
for ip in info.ips! {
if let ip: String = (ip as! String) {
if j == 0 {
infoLog = infoLog.appendingFormat("%-3d", i)
Expand Down
2 changes: 1 addition & 1 deletion doc/docset-installed.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Documentation set was installed to Xcode!

Path: /Users/ksyci/Library/Developer/Shared/Documentation/DocSets/com.ksyun.KSYLive_iOS.docset
Time: 2017-08-28 05:49:03 +0000
Time: 2017-09-01 10:01:56 +0000
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ <h1 id="library-title">

<option value="//api/name/outputPts">outputPts</option>

<option value="//api/name/pcmProcessingCallback">pcmProcessingCallback</option>

<option value="//api/name/reverbType">reverbType</option>

</optgroup>
Expand Down Expand Up @@ -540,7 +542,7 @@ <h3 class="method-title"><code><a href="#//api/name/noiseSuppressionLevel">&nbsp


<div class="method-subsection brief-description">
<p>噪声抑制处理的等级(默认为KSYAudioNoiseSuppress_HIGH)</p>
<p>噪声抑制处理的等级(默认为KSYAudioNoiseSuppress_OFF)</p>
</div>


Expand Down Expand Up @@ -837,7 +839,53 @@ <h3 class="method-title"><code><a href="#//api/name/audioProcessingCallback">&nb

<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<p>sampleBuffer 为采集到的音频数据</p>
<p>sampleBuffer 为采集到的音频数据</p><p>与pcmProcessingCallback两者只能二选一, 设置 audioProcessingCallback 会清空<a href="#//api/name/pcmProcessingCallback">pcmProcessingCallback</a></p>
</div>







<div class="method-subsection declared-in-section">
<h4 class="method-subtitle">Declared In</h4>
<p><code class="declared-in-ref">KSYAUAudioCapture.h</code></p>
</div>


</div>
</div>
</div><div class="section-method">
<a name="//api/name/pcmProcessingCallback" title="pcmProcessingCallback"></a>
<h3 class="method-title"><code><a href="#//api/name/pcmProcessingCallback">&nbsp;&nbsp;pcmProcessingCallback</a></code>
</h3>

<div class="method-info">
<div class="pointy-thing"></div>

<div class="method-info-container">


<div class="method-subsection brief-description">
<p>采集数据输出回调函数</p>
</div>



<div class="method-subsection method-declaration"><code>@property (nonatomic, copy) void ( ^ ) ( uint8_t **pData , int len , const AudioStreamBasicDescription *fmt , CMTime timeInfo ) pcmProcessingCallback</code></div>









<div class="method-subsection discussion-section">
<h4 class="method-subtitle">Discussion</h4>
<p>pData 和 len 为采集数据和长度 (目前只支持单声道, 只有pData[0]为有效数据指针 )</p><p>与audioProcessingCallback两者只能二选一, 设置 pcmProcessingCallback 会清空<a href="#//api/name/audioProcessingCallback">audioProcessingCallback</a></p>
</div>


Expand Down
Loading

0 comments on commit 884c1fd

Please sign in to comment.