Skip to content

Commit

Permalink
update to v2.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ksvcci authored and Franken Zeng committed Jan 14, 2018
1 parent e371309 commit c91bdb5
Show file tree
Hide file tree
Showing 146 changed files with 20,772 additions and 11,013 deletions.
3 changes: 2 additions & 1 deletion demo/KSYLiveDemo-dy-framework.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OTHER_LDFLAGS = $(inherited) -ObjC -all_load -framework libksygpulive -framework GPUImage -framework Bugly -framework YYImage -lstdc++.6 -lz
OTHER_CFLAGS = -I../framework/
OTHER_LDFLAGS = $(inherited) -ObjC -all_load -framework libksygpulive -framework GPUImage -framework Bugly -framework YYImage -lstdc++.6 -lz -lZipArchive -L../framework/
IPHONEOS_DEPLOYMENT_TARGET = 8.0
FRAMEWORK_SEARCH_PATHS = $(inherited) ../framework/ ../framework/dynamic
3 changes: 2 additions & 1 deletion demo/KSYLiveDemo-framework.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
OTHER_LDFLAGS = $(inherited) -ObjC -all_load -framework libksygpulive -framework GPUImage -framework Bugly -framework YYImage -lstdc++.6 -lz
OTHER_CFLAGS = -I../framework/
OTHER_LDFLAGS = $(inherited) -ObjC -all_load -framework libksygpulive -framework GPUImage -framework Bugly -framework YYImage -lstdc++.6 -lz -lZipArchive -L../framework/
FRAMEWORK_SEARCH_PATHS = $(inherited) ../framework/ ../framework/static
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.9.0</string>
<string>2.9.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.9.0.0</string>
<string>2.9.1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
187 changes: 85 additions & 102 deletions demo/KSYLiveDemo/KSYDemoUI/KSYFilterView.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
#import "KSYFilterView.h"
#import "KSYNameSlider.h"
#import "KSYPresetCfgView.h"
#import "ZipArchive.h"


@interface KSYFilterView() {
UILabel * _lblSeg;
NSInteger _curIdx;
NSArray * _effectNames;
NSInteger _curEffectIdx;
//GPUResource非必备资源名称列表
NSArray *_effectResourceNames;
//GPUResource资源的存储路径
NSString *_downloadGPUResourcePath;
NSString *_gpuResourceDir;
}

@property (nonatomic) UILabel * lbPrevewFlip;
Expand All @@ -37,26 +36,40 @@ @implementation KSYFilterView

- (id)init{
self = [super init];
_effectNames = [NSArray arrayWithObjects: @"0 原图", @"1 小清新", @"2 靓丽",
@"3 甜美可人", @"4 怀旧", @"5 蓝调", @"6 老照片" ,
@"7 樱花", @"8 樱花(光线较暗)", @"9 红润(光线较暗)",
@"10 阳光(光线较暗)", @"11 红润", @"12 阳光", @"13 自然", nil];
_effectResourceNames = [NSArray arrayWithObjects:
@"null",
@"1_xiaoqingxin.png",
@"2_liangli.png",
@"3_tianmeikeren.png",
@"4_huaijiu.png",
@"5_landiao.png",
@"6_laozhaop.png",
@"7_yinghua.png",
@"8_yinghua_night.png",
@"9_hongrun_night.png",
@"10_yangguang_night.png",
@"11_hongrun.png",
@"12_yangguang.png",
@"13_ziran.png",nil];
[self creatGPUResourceFile];
_effectNames = [NSArray arrayWithObjects:
@"0 原图关闭特效",
@"1 小清新",
@"2 靓丽",
@"3 甜美可人",
@"4 怀旧",
@"5 蓝调",
@"6 老照片",
@"7 樱花",
@"8 樱花(适用于光线较暗的环境)",
@"9 红润(适用于光线较暗的环境)",
@"10 阳光(适用于光线较暗的环境)",
@"11 红润",
@"12 阳光",
@"13 自然",
@"14 恋人",
@"15 高雅",
@"16 红粉佳人 ",
@"17 优格 ",
@"18 流年 ",
@"19 柔光 ",
@"20 经典 ",
@"21 初夏 ",
@"22 黑白 ",
@"23 纽约 ",
@"24 上野 ",
@"25 碧波 ",
@"26 日系 ",
@"27 清凉 ",
@"28 移轴 ",
@"29 梦幻 ",
@"30 恬淡 ",
@"31 候鸟 ",
@"32 淡雅 ", nil];
[self downloadGPUResource];
_curEffectIdx = 1;
// 修改美颜参数
Expand Down Expand Up @@ -211,7 +224,17 @@ - (void) selectFilter:(NSInteger)idx {
_filterParam1.hidden = NO;
_filterParam2.hidden = NO;
_filterParam3.hidden = NO;
UIImage *rubbyMat = [self getGPUResourceImageAt:_effectResourceNames[3]];
NSString *imgPath=[_gpuResourceDir stringByAppendingString:@"3_tianmeikeren.png"];
UIImage *rubbyMat=[[UIImage alloc]initWithContentsOfFile:imgPath];
if (rubbyMat == nil) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
message:@"特效资源正在下载,请稍后重试"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"确定", nil];
alert.alertViewStyle = UIAlertViewStyleDefault;
[alert show];
}
KSYBeautifyFaceFilter *bf = [[KSYBeautifyFaceFilter alloc] initWithRubbyMaterial:rubbyMat];
bf.grindRatio = _filterParam1.normalValue;
bf.whitenRatio = _filterParam2.normalValue;
Expand All @@ -233,24 +256,18 @@ - (void) selectFilter:(NSInteger)idx {
bf.whitenRatio = _filterParam2.normalValue;
bf.ruddyRatio = 0.5;

UIImage *downloadImage = [self getGPUResourceImageAt:_effectResourceNames[_curEffectIdx]];
if(downloadImage == nil) {
_curFilter = bf;
}
else {
KSYBuildInSpecialEffects * sf = [[KSYBuildInSpecialEffects alloc] initWithUIImage:downloadImage];
sf.intensity = _filterParam3.normalValue;
[bf addTarget:sf];

// 用滤镜组 将 滤镜 串联成整体
GPUImageFilterGroup * fg = [[GPUImageFilterGroup alloc] init];
[fg addFilter:bf];
[fg addFilter:sf];

[fg setInitialFilters:[NSArray arrayWithObject:bf]];
[fg setTerminalFilter:sf];
_curFilter = fg;
}
KSYBuildInSpecialEffects * sf = [[KSYBuildInSpecialEffects alloc] initWithIdx:_curEffectIdx];
sf.intensity = _filterParam3.normalValue;
[bf addTarget:sf];

// 用滤镜组 将 滤镜 串联成整体
GPUImageFilterGroup * fg = [[GPUImageFilterGroup alloc] init];
[fg addFilter:bf];
[fg addFilter:sf];

[fg setInitialFilters:[NSArray arrayWithObject:bf]];
[fg setTerminalFilter:sf];
_curFilter = fg;
}
else {
_curFilter = nil;
Expand Down Expand Up @@ -326,74 +343,40 @@ - (void)pickerView:(UIPickerView *)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component {
_curEffectIdx = row;
if ( [_curFilter isMemberOfClass:[GPUImageFilterGroup class]]){
GPUImageFilterGroup * fg = (GPUImageFilterGroup *)_curFilter;
KSYBuildInSpecialEffects * sf = (KSYBuildInSpecialEffects *)[fg filterAtIndex:1];
UIImage *downloadImage = [self getGPUResourceImageAt:_effectResourceNames[_curEffectIdx]];
[sf setSpecialEffectsUIImage:downloadImage];
}
}

-(UIImage *)getGPUResourceImageAt:(NSString *)effectName{
if ([effectName isEqualToString:@"null"]){
return nil;
}
NSString * path = [[NSBundle mainBundle] pathForResource:@"KSYGPUResource" ofType:@"bundle"];
path = [path stringByAppendingPathComponent:effectName];
if ([UIImage imageWithContentsOfFile:path]) {
return [UIImage imageWithContentsOfFile:path];
if (! [_curFilter isMemberOfClass:[GPUImageFilterGroup class]]){
return;
}
UIImage *dwnloadImage = [self getDocumentImageName:effectName];
if (!dwnloadImage) {
//当前选中的资源还没有下载好
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"特效资源正在下载,请稍后重试" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
alert.alertViewStyle = UIAlertViewStyleDefault;
[alert show];
return nil;
GPUImageFilterGroup * fg = (GPUImageFilterGroup *)_curFilter;
if (![fg.terminalFilter isMemberOfClass:[KSYBuildInSpecialEffects class]]) {
return;
}
return dwnloadImage;
}

-(UIImage *)getDocumentImageName:(NSString *)name{
// 读取沙盒路径图片
NSString *pathDocuments = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *downloadGPUResourcePath = [NSString stringWithFormat:@"%@/GPUResource", pathDocuments];
NSString *aPath3=[downloadGPUResourcePath stringByAppendingFormat:@"/%@",name];
// 拿到沙盒路径图片
UIImage *imgFromUrl3=[[UIImage alloc]initWithContentsOfFile:aPath3];
return imgFromUrl3;
KSYBuildInSpecialEffects * sf = (KSYBuildInSpecialEffects *)fg.terminalFilter;
[sf setSpecialEffectsIdx:_curEffectIdx];
}

-(void)creatGPUResourceFile{
-(void)downloadGPUResource{ // 下载资源文件
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *pathDocuments = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
_downloadGPUResourcePath = [NSString stringWithFormat:@"%@/GPUResource", pathDocuments];
_gpuResourceDir=[NSHomeDirectory() stringByAppendingString:@"/Documents/GPUResource/"];
// 判断文件夹是否存在,如果不存在,则创建
if (![[NSFileManager defaultManager] fileExistsAtPath:_downloadGPUResourcePath]) {
[fileManager createDirectoryAtPath:_downloadGPUResourcePath withIntermediateDirectories:YES attributes:nil error:nil];
if (![[NSFileManager defaultManager] fileExistsAtPath:_gpuResourceDir]) {
[fileManager createDirectoryAtPath:_gpuResourceDir
withIntermediateDirectories:YES
attributes:nil
error:nil];
}
}

-(void)downloadGPUResource{
//下载没有下载好的图片
NSString *strPre = @"https://ks3-cn-beijing.ksyun.com/ksy.vcloud.sdk/Ios/KSYLive_iOS_Resource/";
//当前图片不存在,需要下载
NSString *zipPath = [_gpuResourceDir stringByAppendingString:@"KSYGPUResource.zip"];
if ([[NSFileManager defaultManager] fileExistsAtPath:zipPath]) {
return; // already downloaded
}
NSString *zipUrl = @"https://ks3-cn-beijing.ksyun.com/ksy.vcloud.sdk/Ios/KSYLive_iOS_Resource/KSYGPUResource.zip";
dispatch_async(dispatch_get_global_queue(0, 0), ^{
for(int i = 1; i < _effectResourceNames.count - 1; i++){
NSString *GPUResourceFilePath = [_downloadGPUResourcePath stringByAppendingFormat:@"/%@",_effectResourceNames[i]];
UIImage *savedImage = [[UIImage alloc] initWithContentsOfFile:GPUResourceFilePath];
if(!savedImage){
//当前图片不存在,需要下载
NSString *strUrl = [strPre stringByAppendingFormat:@"%@",_effectResourceNames[i]];
NSURL *url =[NSURL URLWithString:strUrl];
NSData *data =[NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
//设置一个图片的存储路径
NSString *imagePath = [_downloadGPUResourcePath stringByAppendingFormat:@"/%@",_effectResourceNames[i]];
//把图片直接保存到指定的路径
[UIImagePNGRepresentation(image) writeToFile:imagePath atomically:YES];
}
}
NSURL *url =[NSURL URLWithString:zipUrl];
NSData *data =[NSData dataWithContentsOfURL:url];
[data writeToFile:zipPath atomically:YES];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:zipPath ];
[zipArchive UnzipFileTo:_gpuResourceDir overWrite:YES];
[zipArchive UnzipCloseFile];
});
}

Expand Down
3 changes: 2 additions & 1 deletion demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC+Rotation.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ - (void) onViewRotate { // 重写父类的方法, 参考父类 KSYUIView.m 中
if (self.kit == nil || !self.ksyFilterView.swUiRotate.on) {
return;
}
UIInterfaceOrientation orie = [[UIApplication sharedApplication] statusBarOrientation];
[self.kit rotatePreviewTo:orie];
if (self.ksyFilterView.swStrRotate.on) {
// 1. 旋转推流方向
UIInterfaceOrientation orie = [[UIApplication sharedApplication] statusBarOrientation];
[self.kit rotateStreamTo:orie];

// 2. 旋转水印方向,并调整大小和位置(保持水印大小和位置不变)
Expand Down
2 changes: 1 addition & 1 deletion demo/KSYLiveDemo/KSYPlayerDemo/KSYPlayerVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ - (void)printfMeta{
for(NSDictionary *stream in streams) {
NSString *streamType = [stream objectForKey:kKSYPLYStreamType];
NSString *codecName = [stream objectForKey:kKSYPLYCodecName];
NSInteger streamIndex = [[stream objectForKey:kKSYPLYStreamIndex] integerValue];
long streamIndex = [[stream objectForKey:kKSYPLYStreamIndex] integerValue];
if([streamType isEqualToString:@"video"]) {
NSInteger width = [[stream objectForKey:kKSYPLYVideoWidth] integerValue];
NSInteger height = [[stream objectForKey:kKSYPLYVideoHeight] integerValue];
Expand Down
3 changes: 2 additions & 1 deletion demo/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ target 'KSYLiveDemo' do
# YYImage 仅demo中用于导入gif和apng的格式的图片用到了
# 不需要支持这些格式的话,不需要添加YYImage的依赖
pod 'YYImage'

# ZipArchive 仅demo中用于解压资源文件,不是必须依赖
pod 'ZipArchive', '~> 1.4'

pod 'GPUImage'
pod 'libksygpulive/KSYGPUResource', :path => '../'
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/ksvc/Library/Developer/Shared/Documentation/DocSets/com.ksyun.KSYLive_iOS.docset
Time: 2017-10-20 08:49:57 +0000
Time: 2017-10-27 12:03:08 +0000
Loading

0 comments on commit c91bdb5

Please sign in to comment.