diff --git a/demo/KSYLiveDemo/Images.xcassets/AppIcon.appiconset/Contents.json b/demo/KSYLiveDemo/Images.xcassets/AppIcon.appiconset/Contents.json index 1d060ed..d8db8d6 100644 --- a/demo/KSYLiveDemo/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/demo/KSYLiveDemo/Images.xcassets/AppIcon.appiconset/Contents.json @@ -84,6 +84,11 @@ "idiom" : "ipad", "size" : "83.5x83.5", "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/demo/KSYLiveDemo/Images.xcassets/Image.imageset/Contents.json b/demo/KSYLiveDemo/Images.xcassets/bgp.imageset/Contents.json similarity index 90% rename from demo/KSYLiveDemo/Images.xcassets/Image.imageset/Contents.json rename to demo/KSYLiveDemo/Images.xcassets/bgp.imageset/Contents.json index f8f827e..0d4e94f 100644 --- a/demo/KSYLiveDemo/Images.xcassets/Image.imageset/Contents.json +++ b/demo/KSYLiveDemo/Images.xcassets/bgp.imageset/Contents.json @@ -2,6 +2,7 @@ "images" : [ { "idiom" : "universal", + "filename" : "bgp.png", "scale" : "1x" }, { diff --git a/demo/KSYLiveDemo/Images.xcassets/bgp.imageset/bgp.png b/demo/KSYLiveDemo/Images.xcassets/bgp.imageset/bgp.png new file mode 100644 index 0000000..7425af5 Binary files /dev/null and b/demo/KSYLiveDemo/Images.xcassets/bgp.imageset/bgp.png differ diff --git a/demo/KSYLiveDemo/Images.xcassets/ksvc.imageset/ksvc.png b/demo/KSYLiveDemo/Images.xcassets/ksvc.imageset/ksvc.png index b9fe59a..df15c92 100644 Binary files a/demo/KSYLiveDemo/Images.xcassets/ksvc.imageset/ksvc.png and b/demo/KSYLiveDemo/Images.xcassets/ksvc.imageset/ksvc.png differ diff --git a/demo/KSYLiveDemo/Info.plist b/demo/KSYLiveDemo/Info.plist index 59b69b2..09c6eea 100644 --- a/demo/KSYLiveDemo/Info.plist +++ b/demo/KSYLiveDemo/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.9.3 + 2.9.4 CFBundleSignature ???? CFBundleVersion - 2.9.3.2 + 2.9.4.1 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.m b/demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.m index 2850220..cf2774d 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYAudioCtrlView.m @@ -55,7 +55,9 @@ - (id)init{ - (void)layoutUI{ [super layoutUI]; self.btnH = 30; - + if (self.width > self.height) { + self.btnH = 25; + } [self putRow1:_micVol]; [self putSlider:_bgmVol andSwitch:_bgmMix]; diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.h b/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.h index 76b57f4..17ad4d0 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.h +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.h @@ -8,14 +8,7 @@ #import #import "KSYUIVC.h" -#import +#import "KSYSimplestStreamerVC.h" -@interface KSYBgpStreamerVC : KSYUIVC - -@property KSYGPUBgpStreamerKit *kit; - -- (id)initWithUrl:(NSURL *)rtmpUrl; - -// 重写此方法,调整UI布局 -- (void)setupUI; +@interface KSYBgpStreamerVC : KSYSimplestStreamerVC @end diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.m b/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.m index 9ea7f4e..af4a1fc 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYBgpStreamerVC.m @@ -8,138 +8,47 @@ #import "KSYBgpStreamerVC.h" #import "KSYUIView.h" +#import + @interface KSYBgpStreamerVC (){ UIButton *selectFileBtn;//选择背景图片 - UIButton *captureBtn;//预览按钮 - UIButton *streamBtn;//推流按钮 - UIButton *quitBtn;//返回按钮 - KSYUIView *ctrlView; - BOOL _capFlag; } - -@property NSURL *url; -@property UILabel *streamState;//推流状态 - @end @implementation KSYBgpStreamerVC -- (id)initWithUrl:(NSURL *)rtmpUrl{ - if (self = [super init]) { - _url = rtmpUrl; - [self addObserver]; - } - return self; -} -- (void)addObserver{ - //监听推流状态改变 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(streamStateChanged) name:KSYStreamStateDidChangeNotification object:nil]; -} -- (void)removeObserver{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} -- (void)streamStateChanged{ - //显示当前推流状态 - switch (_kit.streamerBase.streamState) { - case KSYStreamStateIdle: - _streamState.text = @"空闲状态"; - break; - case KSYStreamStateConnecting: - _streamState.text = @"连接中"; - break; - case KSYStreamStateConnected: - _streamState.text = @"已连接"; - break; - case KSYStreamStateDisconnecting: - _streamState.text = @"失去连接"; - break; - case KSYStreamStateError: - _streamState.text = @"连接错误"; - break; - default: - break; +- (id)initWithUrl:(NSURL *)rtmpUrl { + if (self = [super initWithUrl:rtmpUrl]) { + return self; } + return nil; } + - (void)viewDidLoad { [super viewDidLoad]; - _kit = [[KSYGPUBgpStreamerKit alloc] init]; - //推流分辨率 - _kit.streamDimension = CGSizeMake(720, 1280); - //视频编码器 - _kit.streamerBase.videoCodec = KSYVideoCodec_AUTO; - //音频编码器 - _kit.streamerBase.audioCodec = KSYAudioCodec_AT_AAC; - //带宽估计模式(网络自适应) - _kit.streamerBase.bwEstimateMode = KSYBWEstMode_Default; - //视频帧率最小值 - _kit.streamerBase.videoMinFPS = 10; - //视频帧率最大值 - _kit.streamerBase.videoMaxFPS = 25; - //视频的帧率 - _kit.videoFPS = 20; - //视频编码最高码率 - _kit.streamerBase.videoMaxBitrate = 1024; - //视频编码起始码率 - _kit.streamerBase.videoInitBitrate = _kit.streamerBase.videoMaxBitrate*6/10; - //视频编码最低码率 - _kit.streamerBase.videoMinBitrate = 0; - //音频编码码率 - _kit.streamerBase.audiokBPS = 64; - //最大重连次数 - _kit.maxAutoRetry = 3; - _capFlag = 0; - self.view.backgroundColor = [UIColor whiteColor]; - [self setupUI]; } -- (void)setupUI{ - ctrlView = [[KSYUIView alloc] initWithFrame:self.view.bounds]; - @WeakObj(self); - ctrlView.onBtnBlock = ^(id sender){ - [selfWeak onBtn:sender]; - }; - +- (void)setupUI { + [super setupUI]; // top view - selectFileBtn = [ctrlView addButton:@"选择背景图片"]; - quitBtn = [ctrlView addButton:@"退出"]; - _streamState = [ctrlView addLable:@"空闲状态"]; - _streamState.textColor = [UIColor redColor]; - _streamState.textAlignment = NSTextAlignmentCenter; - - // bottom view - captureBtn = [ctrlView addButton:@"开始预览"]; - streamBtn = [ctrlView addButton:@"开始推流"]; - - _streamState.hidden = YES; - captureBtn.hidden = YES; - streamBtn.hidden = YES; - - [self.view addSubview:ctrlView]; - + selectFileBtn = [self.ctrlView addButton:@"选择背景图片"]; [self layoutUI]; } -- (void)layoutUI{ - ctrlView.frame = self.view.frame; - [ctrlView layoutUI]; - [ctrlView putRow:@[selectFileBtn, [UIView new], quitBtn]]; - - ctrlView.yPos = self.view.frame.size.height - 30; - [ctrlView putRow:@[captureBtn, _streamState, streamBtn]]; +- (void)layoutUI { + [super layoutUI]; + self.ctrlView.yPos = CGRectGetMaxY(self.quitBtn.frame) + 4; + UIView * v = [[UIView alloc] init]; + [self.ctrlView putRow3:selectFileBtn and:v and:v]; } -- (void)onBtn:(UIButton *)btn{ +- (void)onBtn:(UIButton *)btn { + [super onBtn:btn]; if (btn == selectFileBtn){ [self onSelectFile]; - }else if (btn == captureBtn) { - [self onCapture]; - }else if (btn == streamBtn){ - [self onStream]; - }else if (btn == quitBtn){ - [self onQuit]; } } -- (void)onSelectFile{ +- (void)onSelectFile { //从相册获取照片 UIImagePickerController *picker = [[UIImagePickerController alloc]init]; picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; @@ -150,35 +59,9 @@ - (void)onSelectFile{ -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { - if(image == nil) { - [picker dismissViewControllerAnimated:YES completion:nil]; - return; - } - _streamState.hidden = NO; - captureBtn.hidden = NO; - streamBtn.hidden = NO; - if (_kit.bgPic){ - [_kit.bgPic removeAllTargets]; - _kit.bgPic = nil; + if(image != nil) { + [self.kit updateBgpImage:image]; } - //设置输出图像的像素格式 - _kit.bgPic = [[GPUImagePicture alloc] initWithImage:image]; - _kit.gpuOutputPixelFormat = kCVPixelFormatType_32BGRA; - //校正图片朝向 - _kit.bgPicRotate = [[_kit class] getRotationMode:image]; - if (image.imageOrientation == UIImageOrientationLeft || image.imageOrientation == UIImageOrientationRight){ - _kit.previewDimension = CGSizeMake(_kit.bgPic.outputImageSize.height, _kit.bgPic.outputImageSize.width); - }else{ - _kit.previewDimension = _kit.bgPic.outputImageSize; - } - //推流过程中切换图片 - if (_capFlag == 0) { - _capFlag = 1; - //开始预览(启动推流前必须开始预览) - [_kit startPreview:self.view]; - } - //开启视频配置和采集 - [_kit startVideoCap]; [picker dismissViewControllerAnimated:YES completion:nil]; } @@ -186,35 +69,32 @@ -(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker { [picker dismissViewControllerAnimated:YES completion:nil]; } -- (void)onCapture{ - if (!_capFlag){ - _capFlag = 1; - [_kit startPreview:self.view]; + +- (void)onCapture { + if ( ! self.kit.bgPic){ + UIImage* img = [UIImage imageNamed:@"bgp"]; + if (img) { + [self.kit updateBgpImage:img]; + } } - else { - _capFlag = 0; - [_kit stopPreview]; - } -} -- (void)onStream{ - if (_kit.streamerBase.streamState == KSYStreamStateIdle || - _kit.streamerBase.streamState == KSYStreamStateError) { - [_kit.streamerBase startStream:_url]; + self.captureBtn.selected = !self.captureBtn.selected; + if (self.captureBtn.selected){ + [self.kit startBgpPreview:self.bgView]; } else { - [_kit.streamerBase stopStream]; + [self.kit stopPreview]; } -} -- (void)onQuit{ - [self removeObserver]; - [_kit stopPreview]; - _kit = nil; - [self dismissViewControllerAnimated:YES completion:nil]; + self.profilePicker.hidden = self.captureBtn.selected; } -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. +- (void)onStream { + if (self.kit.streamerBase.streamState == KSYStreamStateIdle || + self.kit.streamerBase.streamState == KSYStreamStateError) { + [self.kit startBgpStream:self.url]; + } + else { //停止推流 + [self.kit stopBgpStream]; + } } - (BOOL)shouldAutorotate { diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYBrushStreamerVC.m b/demo/KSYLiveDemo/KSYDemoUI/KSYBrushStreamerVC.m index 2dbc58d..8720b3a 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYBrushStreamerVC.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYBrushStreamerVC.m @@ -43,11 +43,17 @@ - (void)layoutUI{ if (self.ctrlView == nil || _drawBtn == nil) { return; } - self.ctrlView.yPos = 55; + self.ctrlView.yPos = CGRectGetMaxY(self.quitBtn.frame) + 4; [self.ctrlView putRow:@[_drawBtn, [UIView new]]]; - int hgt = self.view.frame.size.height; - int wdt = self.view.frame.size.width; - _drawView.frame = CGRectMake(0, 0.15*hgt, wdt, 0.75*hgt); + int hgt = self.ctrlView.frame.size.height; + int wdt = self.ctrlView.frame.size.width; + int offset = self.bgView.frame.origin.y; + _drawView.frame = CGRectMake(0, 0.15*hgt+offset, wdt, 0.75*hgt); + + weakObj(self); // update layer on view update + _drawView.viewUpdateCallback = ^{ + [selfWeak.brushKit.drawPic update]; + }; } - (void)viewWillAppear:(BOOL)animated{ @@ -56,7 +62,7 @@ - (void)viewWillAppear:(BOOL)animated{ _brushKit.videoOrientation = [[UIApplication sharedApplication] statusBarOrientation]; [_brushKit setupFilter:self.curFilter]; //启动预览 - [_brushKit startPreview:self.view]; + [_brushKit startPreview:self.bgView]; } } @@ -66,11 +72,9 @@ - (void)onBtn:(UIButton *)btn{ _drawBtn.selected = !_drawBtn.selected; if (_drawBtn.selected) { // 启动画板 _brushKit.drawPic = [[KSYGPUViewCapture alloc] initWithView:_drawView]; - [_brushKit.drawPic start]; _drawView.hidden = NO; } else { //停止画板 - [_brushKit.drawPic stop]; _brushKit.drawPic = nil; _drawView.hidden = YES; [_drawView clearAllPath]; diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYCollectionView.m b/demo/KSYLiveDemo/KSYDemoUI/KSYCollectionView.m index c96d5e1..250163f 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYCollectionView.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYCollectionView.m @@ -71,5 +71,9 @@ - (void)layoutUI{ [self putRow3:_btn0 and:[UIView new] and:[UIView new]]; + self.btnH = 100; + self.gap = 0; + self.yPos = self.height - self.btnH; + [self putRow1:_collectionView]; } @end diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYHorScreenStreamerVC.m b/demo/KSYLiveDemo/KSYDemoUI/KSYHorScreenStreamerVC.m index 84b21a7..dab3633 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYHorScreenStreamerVC.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYHorScreenStreamerVC.m @@ -24,9 +24,11 @@ - (void)setupUI{ _text.backgroundColor = [UIColor lightGrayColor]; _text.text = @"Comments"; _text.hidden = YES; - + self.bgView.backgroundColor = [UIColor whiteColor]; CGFloat wdt = self.view.frame.size.width; - _preView = [[UIView alloc] initWithFrame:CGRectMake(0, 75, wdt, wdt * 9 / 16)]; + CGFloat offset = CGRectGetMaxY(self.quitBtn.frame) + 4; + offset += self.bgView.frame.origin.y; + _preView = [[UIView alloc] initWithFrame:CGRectMake(0, offset, wdt, wdt * 9.0 / 16)]; [self.view addSubview:_preView]; _preView.hidden = YES; self.profilePicker.hidden = YES; diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYMiscView.m b/demo/KSYLiveDemo/KSYDemoUI/KSYMiscView.m index c279f6c..88d4b1a 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYMiscView.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYMiscView.m @@ -15,6 +15,7 @@ @interface KSYMiscView() { UILabel * _lbrScene; UILabel * _lblPerf; UILabel * _lblRec; + UILabel * _lblLogo; KSYFileSelector *_sel; BOOL _skipBtnTap; // skip btn tap for 0.5 seconds } @@ -25,14 +26,15 @@ @implementation KSYMiscView - (id)init{ self = [super init]; - _btn0 = [self addButton:@"str截图为文件"]; - _btn1 = [self addButton:@"str截图为UIImage"]; + _btn0 = [self addButton:@"截图1"]; + _btn1 = [self addButton:@"截图2"]; _btn2 = [self addButton:@"filter截图"]; - _btn3 = [self addButton:@"选择Logo"]; - _btn4 = [self addButton:@"拍摄Logo"]; - _btn5 = [self addButton:@"清除Logo"]; - _btnAnimate = [self addButton:@"动态Logo"]; + _lblLogo = [self addLable:@"logo"]; + _btn3 = [self addButton:@"选择"]; + _btn4 = [self addButton:@"拍摄"]; + _btn5 = [self addButton:@"清除"]; + _btnAnimate = [self addButton:@"动态图"]; _btnNext = [self addButton:@" 下一张 "]; _lblAnimate = [self addLable:@"动态logo"]; _sel = [[KSYFileSelector alloc] initWithDir:@"/Documents/logo/" @@ -75,6 +77,9 @@ - (id)init{ - (void)layoutUI{ [super layoutUI]; self.btnH = 30; + if (self.width > self.height) { + self.btnH = 25; + } [self putRow3:_btn0 and:_btn1 and:_btn2]; @@ -84,15 +89,12 @@ - (void)layoutUI{ andView:_recSceneSeg]; [self putLable:_lblPerf andView:_vEncPerfSeg]; - [self putRow:@[_btn4,_btn3,_btn5,_btnAnimate]]; + [self putRow:@[_lblLogo,_btn4,_btn3,_btn5,_btnAnimate]]; [self putWide:_lblAnimate andNarrow:_btnNext]; [self putNarrow:_layerSeg andWide:_alphaSl]; [self putRow:@[_lblRec, _swBypassRec, _lblRecDur]]; [self putRow1:_autoReconnect]; - [self putRow1:_buttonPlayUrlAndQR]; - [self putRow3:_buttonAe - and:[UIView new] - and:[UIView new]]; + [self putRow:@[_buttonPlayUrlAndQR, _buttonAe]]; } - (IBAction)onBtn:(id)sender { if (_skipBtnTap) { diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYPresetCfgView.m b/demo/KSYLiveDemo/KSYDemoUI/KSYPresetCfgView.m index d88ce7a..1c5a31f 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYPresetCfgView.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYPresetCfgView.m @@ -19,8 +19,6 @@ @interface KSYPresetCfgView(){ @property UILabel* demoLable; @end -#define FLOAT_EQ( f0, f1 ) ( (f0 - f1 < 0.001)&& (f0 - f1 > -0.001) ) - @implementation KSYPresetCfgView - (id) init { self = [super init]; diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.h b/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.h index 73cf297..e29faaf 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.h +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.h @@ -18,6 +18,14 @@ // profile picker @property UIPickerView *profilePicker; @property (nonatomic, readonly) KSYUIView * ctrlView; +// 适配iphoneX用到的背景视图(在iphoneX上为了保持主播和观众的画面一致, 竖屏时需要上下填一点黑边, 不再全屏预览) +@property (nonatomic, readonly) UIView* bgView; + +@property UIButton *captureBtn;//预览按钮 +@property UIButton *streamBtn;//开始推流 +@property UIButton *cameraBtn;//前后摄像头 +@property UIButton *quitBtn;//返回按钮 +@property NSURL *url; - (id)initWithUrl:(NSURL *)rtmpUrl; // 重写此方法,调整UI布局 diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.m b/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.m index 532aa14..f2b42d9 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYSimplestStreamerVC.m @@ -13,12 +13,7 @@ @interface KSYSimplestStreamerVC () 0) { + _ctrlView.yPos = 0; + } [_ctrlView putRow:@[_quitBtn, _streamState, _cameraBtn]]; _profilePicker.frame = CGRectMake(10, _ctrlView.yPos+_ctrlView.btnH, _ctrlView.width-20, 216); - _ctrlView.yPos = self.view.frame.size.height - 30; + _ctrlView.yPos = previewRect.size.height - 30; [_ctrlView putRow:@[_captureBtn, [UIView new], _streamBtn]]; } @@ -142,7 +145,7 @@ - (void)onCapture{ if (!_kit.vCapDev.isRunning){ _kit.videoOrientation = [[UIApplication sharedApplication] statusBarOrientation]; [_kit setupFilter:_curFilter]; - [_kit startPreview:self.view]; //启动预览 + [_kit startPreview:_bgView]; //启动预览 } else { [_kit stopPreview]; @@ -209,7 +212,9 @@ - (BOOL)shouldAutorotate { } - (void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; - self.kit.preview.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)); + CGFloat x = CGRectGetMidX(self.bgView.bounds); + CGFloat y = CGRectGetMidY(self.bgView.bounds); + self.kit.preview.center = CGPointMake(x,y); } #pragma mark - 旋转预览 iOS > 8.0 diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC+Rotation.m b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC+Rotation.m index a2a36be..59eb567 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC+Rotation.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC+Rotation.m @@ -34,7 +34,9 @@ - (void) onViewRotate { // 重写父类的方法, 参考父类 KSYUIView.m 中 - (void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; - self.kit.preview.center = CGPointMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)); + CGFloat x = CGRectGetMidX(self.bgView.bounds); + CGFloat y = CGRectGetMidY(self.bgView.bounds); + self.kit.preview.center = CGPointMake(x,y); } #pragma mark - 旋转预览 iOS > 8.0 diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.h b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.h index 034430d..213fba8 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.h +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.h @@ -68,6 +68,8 @@ #pragma mark - kit instance @property (nonatomic, retain) KSYGPUStreamerKit * kit; +// 适配iphoneX用到的背景视图(在iphoneX上为了保持主播和观众的画面一致, 竖屏时需要上下填一点黑边, 不再全屏预览) +@property (nonatomic, readonly) UIView* bgView; // 推流地址 完整的URL @property NSURL * hostURL; diff --git a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.m b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.m index c07dba8..c7bfaac 100644 --- a/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.m +++ b/demo/KSYLiveDemo/KSYDemoUI/KSYStreamerVC.m @@ -49,7 +49,7 @@ @interface KSYStreamerVC () *)touches withEvent:(nullable UIEvent *)event { + if(_viewUpdateCallback) { + _viewUpdateCallback(); + } } - (void) clearAllPath { [self.path removeAllPoints]; ((CAShapeLayer *)self.layer).path = nil; + if(_viewUpdateCallback) { + _viewUpdateCallback(); + } } @end diff --git a/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.h b/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.h index 20b4e11..19d4761 100644 --- a/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.h +++ b/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.h @@ -37,6 +37,14 @@ // 重写本函数进行UI重新布局 - (void) layoutUI; +/** + 计算预览区域的工具函数 + + @param ratio 预览区域的宽高比 + @return 居中放置的预览区域的位置和大小 + */ +- (CGRect) calcPreviewRect:(CGFloat) ratio; + // 重写该方法来响应屏幕旋转 - (void) onViewRotate; diff --git a/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.m b/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.m index cd7396e..0b1f650 100644 --- a/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.m +++ b/demo/KSYLiveDemo/KSYUIUtils/KSYUIVC.m @@ -103,6 +103,25 @@ - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } +- (CGRect) calcPreviewRect:(CGFloat) ratio { + CGRect previewRect = self.view.frame; + CGSize sz = previewRect.size; + CGSize screenSz = [[UIScreen mainScreen] bounds].size; + CGFloat hgt = MAX(screenSz.height, screenSz.width); + if (!FLOAT_EQ(hgt, 812)){ + return previewRect; // not iphoneX + } + if (sz.width < sz.height ) { // 竖屏 + previewRect.size.height = sz.width*ratio; + previewRect.origin.y += (sz.height -previewRect.size.height)/2; + } + else { // 横屏 + previewRect.size.width = sz.height*ratio; + previewRect.origin.x += (sz.width -previewRect.size.width)/2; + } + return previewRect; +} + - (void) layoutUI { if(_layoutView){ _layoutView.frame = self.view.frame; diff --git a/demo/KSYLiveDemo/KSYUIUtils/KSYUIView.h b/demo/KSYLiveDemo/KSYUIUtils/KSYUIView.h index 19c3147..2120b89 100644 --- a/demo/KSYLiveDemo/KSYUIUtils/KSYUIView.h +++ b/demo/KSYLiveDemo/KSYUIUtils/KSYUIView.h @@ -113,3 +113,6 @@ #define WeakObj(o) try{}@finally{} __weak typeof(o) o##Weak = o; #define weakObj(o) __weak typeof(o) o##Weak = o; + +#define FLOAT_EQ( f0, f1 ) ( (f0 - f1 < 0.001)&& (f0 - f1 > -0.001) ) + diff --git a/demo/KSYLiveDemo_Swift/KSYDemoUI_Swift/KSYStreamerVC.swift b/demo/KSYLiveDemo_Swift/KSYDemoUI_Swift/KSYStreamerVC.swift index 35aa674..adb9da2 100644 --- a/demo/KSYLiveDemo_Swift/KSYDemoUI_Swift/KSYStreamerVC.swift +++ b/demo/KSYLiveDemo_Swift/KSYDemoUI_Swift/KSYStreamerVC.swift @@ -241,7 +241,7 @@ class KSYStreamerVC: KSYUIVC, UIImagePickerControllerDelegate, UINavigationContr let logoFile = NSHomeDirectory().appending("/Documents/ksvc.png") if FileManager.default.fileExists(atPath: logoFile) { let url = NSURL.init(fileURLWithPath: logoFile) - kit?.logoPic = GPUImagePicture.init(url: url as URL!) + kit?.logoPic = KSYGPUPicture.init(url: url as URL!) kit?.logoRect = CGRect.init(x: 0.05, y: yPos, width: 0, height: hgt) kit?.logoAlpha = 0.5 yPos += hgt @@ -810,7 +810,7 @@ class KSYStreamerVC: KSYUIVC, UIImagePickerControllerDelegate, UINavigationContr //显示的图片 if let image = info[UIImagePickerControllerOriginalImage] { - kit?.logoPic = GPUImagePicture.init(image: image as! UIImage, smoothlyScaleOutput: true) + kit?.logoPic = KSYGPUPicture.init(image: image as! UIImage, smoothlyScaleOutput: true) picker.dismiss(animated: true, completion: nil) } diff --git a/doc/docset-installed.txt b/doc/docset-installed.txt index 50cf1bd..2458ae4 100644 --- a/doc/docset-installed.txt +++ b/doc/docset-installed.txt @@ -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-11-21 02:44:19 +0000 \ No newline at end of file +Time: 2017-12-08 02:07:55 +0000 \ No newline at end of file diff --git a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUBgpStreamerKit.html b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUBgpStreamerKit.html deleted file mode 100644 index ede2541..0000000 --- a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUBgpStreamerKit.html +++ /dev/null @@ -1,1787 +0,0 @@ - - - - - - KSYGPUBgpStreamerKit Class Reference - - - - - - -
-
- -

- KSYLive_iOS -

- -

- Kingsoft -

- -
-
- - - -
-
-
-
-

KSYGPUBgpStreamerKit Class Reference

- - -
- - - - - - - -
Inherits fromNSObject
Declared inKSYGPUBgpStreamerKit.h
- - - - - - -
- - - - - - -
-
- -

– initWithDefaultCfg -

- -
-
- -
- - -
-

初始化方法

-
- - - -
- (instancetype)initWithDefaultCfg
- - - - - - - - - -
-

Discussion

-

创建带有默认参数的 kit,不会打断其他后台的音乐播放

Warning: kit只支持单实例推流,构造多个实例会出现异常

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– initWithInterruptCfg -

- -
-
- -
- - -
-

初始化方法

-
- - - -
- (instancetype)initWithInterruptCfg
- - - - - - - - - -
-

Discussion

-

创建带有默认参数的 kit,会打断其他后台的音乐播放

Warning: kit只支持单实例推流,构造多个实例会出现异常

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getKSYVersion -

- -
-
- -
- - -
-

获取SDK版本号

-
- - - -
- (NSString *)getKSYVersion
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  filter -

- -
-
- -
- - -
-

获取当前使用的滤镜

-
- - - -
@property (nonatomic, readonly) GPUImageOutput<GPUImageInput> *filter
- - - - - - - - - -
-

Discussion

-

通过此指针可以对滤镜参数进行设置 -@waning 请确保外部保留了filter的真实类型的指针, 否则会出现奔溃

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  preview -

- -
-
- -
- - -
-

预览视图

-
- - - -
@property (nonatomic, readonly) KSYGPUView *preview
- - - - - - - - - -
-

Discussion

-

通过此指针可以对预览视图进行操作

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  gpuToStr -

- -
-
- -
- - -
-

获取渲染的图像

-
- - - -
@property (nonatomic, readonly) KSYGPUPicOutput *gpuToStr
- - - - - - - - - -
-

Discussion

-

用于衔接GPU和streamer

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  aCapDev -

- -
-
- -
- - -
-

音频采集设备 Audio Unit 音频采集

-
- - - -
@property (nonatomic, readonly) KSYAUAudioCapture *aCapDev
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  aMixer -

- -
-
- -
- - -
-

音频混合器

-
- - - -
@property (nonatomic, readonly) KSYAudioMixer *aMixer
- - - - - - - - - -
-

Discussion

-

用于将多路音频进行混合,将混合后的音频送入streamerBase

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  msgStreamer -

- -
-
- -
- - -
-

消息通道

-
- - - -
@property (nonatomic, readonly) KSYMessage *msgStreamer
- - - - - - - - - -
-

Discussion

-

用于采集消息,并将数据送入streamerBase

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  streamerBase -

- -
-
- -
- - -
-

获取初始化时创建的底层推流工具

-
- - - -
@property (nonatomic, readonly) KSYStreamerBase *streamerBase
- - - - - - - - - -
-

Discussion

-
    -
  1. 通过它来设置推流参数
  2. -
-
    -
  1. 通过它来启动,停止推流
  2. -
- -
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  maxAutoRetry -

- -
-
- -
- - -
-

自动重连次数 关闭(0), 开启(>0), 默认为0

-
- - - -
@property (nonatomic, assign) int maxAutoRetry
- - - - - - - - - -
-

Discussion

-

当内部发现推流错误后, 会在一段时间后尝试重连 -自动重连不会重新获取推流地址, 仍然使用上次推流的地址

Warning: 如果在推流地址有过期时间, 请勿开启

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  autoRetryDelay -

- -
-
- -
- - -
-

自动重连延时, 发现连接错误后, 重试的延时

-
- - - -
@property (nonatomic, assign) double autoRetryDelay
- - - - - - - - - -
-

Discussion

-

单位为秒, 默认为2s, 最小值为0.1s

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  cameraLayer -

- -
-
- -
- - -
-

摄像头图层

-
- - - -
@property (nonatomic, readonly) NSInteger cameraLayer
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  micTrack -

- -
-
- -
- - -
-

麦克风通道

-
- - - -
@property (nonatomic, readonly) int micTrack
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  captureState -

- -
-
- -
- - -
-

当前采集设备状况

-
- - - -
@property (nonatomic, readonly) KSYCaptureState captureState
- - - - - - - - - -
-

Discussion

-

可以通过该属性获取采集设备的工作状况

通知: -* KSYCaptureStateDidChangeNotification 当采集设备工作状态发生变化时提供通知 -* 收到通知后,通过本属性查询新的状态,并作出相应的动作

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getCaptureStateName: -

- -
-
- -
- - -
-

获取采集状态对应的字符串

-
- - - -
- (NSString *)getCaptureStateName:(KSYCaptureState)stat
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getCurCaptureStateName -

- -
-
- -
- - -
-

获取当前采集状态对应的字符串

-
- - - -
- (NSString *)getCurCaptureStateName
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startPreview: -

- -
-
- -
- - -
-

启动预览

-
- - - -
- (void)startPreview:(UIView *)view
- - - -
-

Parameters

- - - - - - - -
view

预览画面作为subview,插入到 view 的最底层

-
- - - - - - - -
-

Discussion

-

设置完成采集参数之后,按照设置值启动预览,启动后对采集参数修改不会生效

需要访问摄像头和麦克风的权限,若授权失败,其他API都会拒绝服务

- -

@warning: 开始推流前必须先启动预览

-
- - - - - -
-

See Also

- -
- - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startVideoCap -

- -
-
- -
- - -
-

开启视频配置和采集

-
- - - -
- (BOOL)startVideoCap
- - - - - - - - - -
-

Discussion

-

设置完成视频采集参数之后,按照设置值启动视频预览,启动后对视频采集参数修改不会生效

需要访问摄像头的权限,若授权失败,其他API都会拒绝服务

视频采集成功返回YES,不成功返回NO

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startAudioCap -

- -
-
- -
- - -
-

开始音频配置和采集

-
- - - -
- (BOOL)startAudioCap
- - - - - - - - - -
-

Discussion

-

设置完成音频采集参数之后,按照设置值启动音频预览,启动后对音频采集参数修改不会生效

需要访问麦克风的权限,若授权失败,其他API都会拒绝服务

音频采集成功返回YES,不成功返回NO

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– stopPreview -

- -
-
- -
- - -
-

停止预览,停止采集设备,并清理会话

-
- - - -
- (void)stopPreview
- - - - - - - - - -
-

Discussion

-

若推流未结束,则先停止推流

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– appEnterBackground -

- -
-
- -
- - -
-

进入后台: 暂停图像采集

-
- - - -
- (void)appEnterBackground
- - - - - - - - - -
-

Discussion

-

暂停图像采集和预览, 中断旁路录制

如果需要释放mic资源请直接调用停止采集

kit内部在收到UIApplicationDidEnterBackgroundNotification 或采集被打断等事件时,会主动调用本接口

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– appBecomeActive -

- -
-
- -
- - -
-

回到前台: 恢复采集

-
- - - -
- (void)appBecomeActive
- - - - - - - - - -
-

Discussion

-

恢复图像采集和预览

恢复音频采集

kit内部在收到UIApplicationDidBecomeActiveNotification等事件时,会主动调用本接口

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  previewDimension -

- -
-
- -
- - -
-

预览分辨率 (仅在开始采集前设置有效)

-
- - - -
@property (nonatomic, assign) CGSize previewDimension
- - - - - - - - - -
-

Discussion

-

内部始终将较大的值作为宽度 (若需要竖屏,请设置 videoOrientation)

宽高都会向上取整为4的整数倍

有效范围: 宽度[160, 1920] 高度[ 90, 1080], 超出范围会取边界有效值

当预览分辨率与采集分辨率不一致时: -若宽高比不同, 先进行裁剪, 再进行缩放 -若宽高比相同, 直接进行缩放

默认值为(640, 360)

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  streamDimension -

- -
-
- -
- - -
-

用户定义的视频 推流 分辨率

-
- - - -
@property (nonatomic, assign) CGSize streamDimension
- - - - - - - - - -
-

Discussion

-

有效范围: 宽度[160, 1280] 高度[ 90, 720], 超出范围会取边界有效值

其他与previewDimension限定一致,

当与previewDimension不一致时, 同样先裁剪到相同宽高比, 再进行缩放

默认值为(640, 360)

-
- - - - - -
-

See Also

- -
- - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  gpuOutputPixelFormat -

- -
-
- -
- - -
-

gpu output pixel format (默认:kCVPixelFormatType_32BGRA)

-
- - - -
@property (nonatomic, assign) OSType gpuOutputPixelFormat
- - - - - - - - - -
-

Discussion

-

目前支持 BGRA , NV12 和 I420

仅在开始推流前设置有效

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  videoFPS -

- -
-
- -
- - -
-

采集及编码视频帧率 (开始采集前设置有效)

-
- - - -
@property (nonatomic, assign) int videoFPS
- - - - - - - - - -
-

Discussion

-

video frame per seconds 有效范围[1~30], 超出范围会取边界有效值

默认值为15

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  videoProcessingCallback -

- -
-
- -
- - -
-

视频处理回调接口

-
- - - -
@property (nonatomic, copy) void ( ^ ) ( CMSampleBufferRef sampleBuffer ) videoProcessingCallback
- - - -
-

Parameters

- - - - - - - -
sampleBuffer

原始采集到的视频数据

-
- - - - - - - -
-

Discussion

-

对sampleBuffer内的图像数据的修改将传递到观众端

请注意本函数的执行时间,如果太长可能导致不可预知的问题

请参考 CMSampleBufferRef

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  audioProcessingCallback -

- -
-
- -
- - -
-

音频处理回调接口

-
- - - -
@property (nonatomic, copy) void ( ^ ) ( CMSampleBufferRef sampleBuffer ) audioProcessingCallback
- - - - - - - - - -
-

Discussion

-

sampleBuffer 原始采集到的音频数据

对sampleBuffer内的pcm数据的修改将传递到观众端

请注意本函数的执行时间,如果太长可能导致不可预知的问题

请参考 CMSampleBufferRef

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– setupFilter: -

- -
-
- -
- - -
-

设置当前使用的滤镜

-
- - - -
- (void)setupFilter:(GPUImageOutput<GPUImageInput> *)filter
- - - - - - - - - -
-

Discussion

-

filter 为nil, 则关闭滤镜

filter 为GPUImageFilter的实例,则使用该滤镜做处理

filter 也可以是GPUImageFilterGroup的实例,可以将多个滤镜组合

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– processMessageData: -

- -
-
- -
- - -
-

用户待发送的消息 -@param messageData待发送的消息

-
- - - -
- (BOOL)processMessageData:(NSDictionary *)messageData
- - - - - -
-

Return Value

-

YES / NO

-
- - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  bgPic -

- -
-
- -
- - -
-

背景图片,用于背景图片推流

-
- - - -
@property (nonatomic, readwrite) GPUImagePicture *bgPic
- - - - - - - - - -
-

Discussion

-

设置为nil为清除背景图片

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  bgPicRotate -

- -
-
- -
- - -
-

背景图片朝向

-
- - - -
@property (nonatomic, readwrite) GPUImageRotationMode bgPicRotate
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

+ getRotationMode: -

- -
-
- -
- - -
-

读取图像的朝向

-
- - - -
+ (GPUImageRotationMode)getRotationMode:(UIImage *)img
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
-
- -
- - - - - - -
- - -
-
-
- - - - diff --git a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUPicture.html b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUPicture.html index 3ed6a6d..4cfc2df 100644 --- a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUPicture.html +++ b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUPicture.html @@ -60,6 +60,8 @@

+ + @@ -130,10 +132,115 @@

–&
+ +
+

通过指定图片名称载入图片

+
+ +
- (id)initWithImageName:(NSString *)name
+ +
+

Parameters

+ + + + + + + +
name

图片的名称

+
+ + + +
+

Return Value

+

载入图片后的实例

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUPicture.h

+
+ + +
+ +
+ +

– initWithImage:andOutputSize: +

+ +
+
+ +
+ + +
+

指定载入图片后输出的尺寸

+
+ + + +
- (id)initWithImage:(UIImage *)img andOutputSize:(CGSize)size
+ + + +
+

Parameters

+ + + + + + + + + + + + +
img

图片

size

尺寸

+
+ + + +
+

Return Value

+

构造的实例

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUPicture.h

+
+ +
diff --git a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUStreamerKit.html b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUStreamerKit.html index 93cd0ea..a5a7d05 100644 --- a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUStreamerKit.html +++ b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUStreamerKit.html @@ -74,6 +74,8 @@

+ + @@ -198,22 +200,34 @@

+ + + + + + + + + + + + @@ -277,7 +291,7 @@

Overview

- +

Other Methods

+
+ +

– setOrientaion:ofLayer: +

+ +
+
+ +
+ + +
+

设置指定图层的朝向

+
+ + + +
- (void)setOrientaion:(UIImageOrientation)orien ofLayer:(NSInteger)idx
+ + + +
+

Parameters

+ + + + + + + + + + + + +
orien

目标朝向

idx

图层的index

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit.h

+
+ + +
+
+
+ + + + + + +

bgp Methods

+ +
+
+ +

  bgPic +

+ +
+
+ +
+ + +
@property (nonatomic, retain) KSYGPUPicture *bgPic
+ + +
+
+
+ +

– updateBgpImage: +

+ +
+
+ +
+ + +
+

更新背景图片

+
+ + + +
- (void)updateBgpImage:(UIImage *)img
+ + + +
+

Parameters

+ + + + + + + +
img

新的背景图片

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– startBgpPreview: +

+ +
+
+ +
+ + +
+

开始背景图预览

+
+ + + +
- (BOOL)startBgpPreview:(UIView *)bgView
+ + + +
+

Parameters

+ + + + + + + +
bgView

预览视图的背景图, 预览视图会填满背景视图 +结束预览仍然使用之前的 stopPreview

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– startBgpStream: +

+ +
+
+ +
+ + +
+

开始背景图推流

+
+ + + +
- (BOOL)startBgpStream:(NSURL *)url
+ + + +
+

Parameters

+ + + + + + + +
url

推流地址

+
+ + + +
+

Return Value

+

当前状态是否能开始推流

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– stopBgpStream +

+ +
+
+ +
+ + +
+

停止背景图推流

+
+ + + +
- (void)stopBgpStream
+ + + + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ +
diff --git a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUTwoInputFiter.html b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUTwoInputFiter.html index e179405..e2da4e3 100644 --- a/doc/docset/Contents/Resources/Documents/Classes/KSYGPUTwoInputFiter.html +++ b/doc/docset/Contents/Resources/Documents/Classes/KSYGPUTwoInputFiter.html @@ -43,6 +43,8 @@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - -
-
-
-
-

KSYGPUBgpStreamerKit Class Reference

- - -
- - - - - - - -
Inherits fromNSObject
Declared inKSYGPUBgpStreamerKit.h
- - - - - - -
- - - - - - -
-
- -

– initWithDefaultCfg -

- -
-
- -
- - -
-

初始化方法

-
- - - -
- (instancetype)initWithDefaultCfg
- - - - - - - - - -
-

Discussion

-

创建带有默认参数的 kit,不会打断其他后台的音乐播放

Warning: kit只支持单实例推流,构造多个实例会出现异常

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– initWithInterruptCfg -

- -
-
- -
- - -
-

初始化方法

-
- - - -
- (instancetype)initWithInterruptCfg
- - - - - - - - - -
-

Discussion

-

创建带有默认参数的 kit,会打断其他后台的音乐播放

Warning: kit只支持单实例推流,构造多个实例会出现异常

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getKSYVersion -

- -
-
- -
- - -
-

获取SDK版本号

-
- - - -
- (NSString *)getKSYVersion
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  filter -

- -
-
- -
- - -
-

获取当前使用的滤镜

-
- - - -
@property (nonatomic, readonly) GPUImageOutput<GPUImageInput> *filter
- - - - - - - - - -
-

Discussion

-

通过此指针可以对滤镜参数进行设置 -@waning 请确保外部保留了filter的真实类型的指针, 否则会出现奔溃

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  preview -

- -
-
- -
- - -
-

预览视图

-
- - - -
@property (nonatomic, readonly) KSYGPUView *preview
- - - - - - - - - -
-

Discussion

-

通过此指针可以对预览视图进行操作

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  gpuToStr -

- -
-
- -
- - -
-

获取渲染的图像

-
- - - -
@property (nonatomic, readonly) KSYGPUPicOutput *gpuToStr
- - - - - - - - - -
-

Discussion

-

用于衔接GPU和streamer

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  aCapDev -

- -
-
- -
- - -
-

音频采集设备 Audio Unit 音频采集

-
- - - -
@property (nonatomic, readonly) KSYAUAudioCapture *aCapDev
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  aMixer -

- -
-
- -
- - -
-

音频混合器

-
- - - -
@property (nonatomic, readonly) KSYAudioMixer *aMixer
- - - - - - - - - -
-

Discussion

-

用于将多路音频进行混合,将混合后的音频送入streamerBase

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  msgStreamer -

- -
-
- -
- - -
-

消息通道

-
- - - -
@property (nonatomic, readonly) KSYMessage *msgStreamer
- - - - - - - - - -
-

Discussion

-

用于采集消息,并将数据送入streamerBase

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  streamerBase -

- -
-
- -
- - -
-

获取初始化时创建的底层推流工具

-
- - - -
@property (nonatomic, readonly) KSYStreamerBase *streamerBase
- - - - - - - - - -
-

Discussion

-
    -
  1. 通过它来设置推流参数
  2. -
-
    -
  1. 通过它来启动,停止推流
  2. -
- -
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  maxAutoRetry -

- -
-
- -
- - -
-

自动重连次数 关闭(0), 开启(>0), 默认为0

-
- - - -
@property (nonatomic, assign) int maxAutoRetry
- - - - - - - - - -
-

Discussion

-

当内部发现推流错误后, 会在一段时间后尝试重连 -自动重连不会重新获取推流地址, 仍然使用上次推流的地址

Warning: 如果在推流地址有过期时间, 请勿开启

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  autoRetryDelay -

- -
-
- -
- - -
-

自动重连延时, 发现连接错误后, 重试的延时

-
- - - -
@property (nonatomic, assign) double autoRetryDelay
- - - - - - - - - -
-

Discussion

-

单位为秒, 默认为2s, 最小值为0.1s

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  cameraLayer -

- -
-
- -
- - -
-

摄像头图层

-
- - - -
@property (nonatomic, readonly) NSInteger cameraLayer
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  micTrack -

- -
-
- -
- - -
-

麦克风通道

-
- - - -
@property (nonatomic, readonly) int micTrack
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  captureState -

- -
-
- -
- - -
-

当前采集设备状况

-
- - - -
@property (nonatomic, readonly) KSYCaptureState captureState
- - - - - - - - - -
-

Discussion

-

可以通过该属性获取采集设备的工作状况

通知: -* KSYCaptureStateDidChangeNotification 当采集设备工作状态发生变化时提供通知 -* 收到通知后,通过本属性查询新的状态,并作出相应的动作

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getCaptureStateName: -

- -
-
- -
- - -
-

获取采集状态对应的字符串

-
- - - -
- (NSString *)getCaptureStateName:(KSYCaptureState)stat
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– getCurCaptureStateName -

- -
-
- -
- - -
-

获取当前采集状态对应的字符串

-
- - - -
- (NSString *)getCurCaptureStateName
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startPreview: -

- -
-
- -
- - -
-

启动预览

-
- - - -
- (void)startPreview:(UIView *)view
- - - -
-

Parameters

- - - - - - - -
view

预览画面作为subview,插入到 view 的最底层

-
- - - - - - - -
-

Discussion

-

设置完成采集参数之后,按照设置值启动预览,启动后对采集参数修改不会生效

需要访问摄像头和麦克风的权限,若授权失败,其他API都会拒绝服务

- -

@warning: 开始推流前必须先启动预览

-
- - - - - -
-

See Also

- -
- - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startVideoCap -

- -
-
- -
- - -
-

开启视频配置和采集

-
- - - -
- (BOOL)startVideoCap
- - - - - - - - - -
-

Discussion

-

设置完成视频采集参数之后,按照设置值启动视频预览,启动后对视频采集参数修改不会生效

需要访问摄像头的权限,若授权失败,其他API都会拒绝服务

视频采集成功返回YES,不成功返回NO

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– startAudioCap -

- -
-
- -
- - -
-

开始音频配置和采集

-
- - - -
- (BOOL)startAudioCap
- - - - - - - - - -
-

Discussion

-

设置完成音频采集参数之后,按照设置值启动音频预览,启动后对音频采集参数修改不会生效

需要访问麦克风的权限,若授权失败,其他API都会拒绝服务

音频采集成功返回YES,不成功返回NO

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– stopPreview -

- -
-
- -
- - -
-

停止预览,停止采集设备,并清理会话

-
- - - -
- (void)stopPreview
- - - - - - - - - -
-

Discussion

-

若推流未结束,则先停止推流

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– appEnterBackground -

- -
-
- -
- - -
-

进入后台: 暂停图像采集

-
- - - -
- (void)appEnterBackground
- - - - - - - - - -
-

Discussion

-

暂停图像采集和预览, 中断旁路录制

如果需要释放mic资源请直接调用停止采集

kit内部在收到UIApplicationDidEnterBackgroundNotification 或采集被打断等事件时,会主动调用本接口

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– appBecomeActive -

- -
-
- -
- - -
-

回到前台: 恢复采集

-
- - - -
- (void)appBecomeActive
- - - - - - - - - -
-

Discussion

-

恢复图像采集和预览

恢复音频采集

kit内部在收到UIApplicationDidBecomeActiveNotification等事件时,会主动调用本接口

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  previewDimension -

- -
-
- -
- - -
-

预览分辨率 (仅在开始采集前设置有效)

-
- - - -
@property (nonatomic, assign) CGSize previewDimension
- - - - - - - - - -
-

Discussion

-

内部始终将较大的值作为宽度 (若需要竖屏,请设置 videoOrientation)

宽高都会向上取整为4的整数倍

有效范围: 宽度[160, 1920] 高度[ 90, 1080], 超出范围会取边界有效值

当预览分辨率与采集分辨率不一致时: -若宽高比不同, 先进行裁剪, 再进行缩放 -若宽高比相同, 直接进行缩放

默认值为(640, 360)

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  streamDimension -

- -
-
- -
- - -
-

用户定义的视频 推流 分辨率

-
- - - -
@property (nonatomic, assign) CGSize streamDimension
- - - - - - - - - -
-

Discussion

-

有效范围: 宽度[160, 1280] 高度[ 90, 720], 超出范围会取边界有效值

其他与previewDimension限定一致,

当与previewDimension不一致时, 同样先裁剪到相同宽高比, 再进行缩放

默认值为(640, 360)

-
- - - - - -
-

See Also

- -
- - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  gpuOutputPixelFormat -

- -
-
- -
- - -
-

gpu output pixel format (默认:kCVPixelFormatType_32BGRA)

-
- - - -
@property (nonatomic, assign) OSType gpuOutputPixelFormat
- - - - - - - - - -
-

Discussion

-

目前支持 BGRA , NV12 和 I420

仅在开始推流前设置有效

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  videoFPS -

- -
-
- -
- - -
-

采集及编码视频帧率 (开始采集前设置有效)

-
- - - -
@property (nonatomic, assign) int videoFPS
- - - - - - - - - -
-

Discussion

-

video frame per seconds 有效范围[1~30], 超出范围会取边界有效值

默认值为15

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  videoProcessingCallback -

- -
-
- -
- - -
-

视频处理回调接口

-
- - - -
@property (nonatomic, copy) void ( ^ ) ( CMSampleBufferRef sampleBuffer ) videoProcessingCallback
- - - -
-

Parameters

- - - - - - - -
sampleBuffer

原始采集到的视频数据

-
- - - - - - - -
-

Discussion

-

对sampleBuffer内的图像数据的修改将传递到观众端

请注意本函数的执行时间,如果太长可能导致不可预知的问题

请参考 CMSampleBufferRef

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  audioProcessingCallback -

- -
-
- -
- - -
-

音频处理回调接口

-
- - - -
@property (nonatomic, copy) void ( ^ ) ( CMSampleBufferRef sampleBuffer ) audioProcessingCallback
- - - - - - - - - -
-

Discussion

-

sampleBuffer 原始采集到的音频数据

对sampleBuffer内的pcm数据的修改将传递到观众端

请注意本函数的执行时间,如果太长可能导致不可预知的问题

请参考 CMSampleBufferRef

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– setupFilter: -

- -
-
- -
- - -
-

设置当前使用的滤镜

-
- - - -
- (void)setupFilter:(GPUImageOutput<GPUImageInput> *)filter
- - - - - - - - - -
-

Discussion

-

filter 为nil, 则关闭滤镜

filter 为GPUImageFilter的实例,则使用该滤镜做处理

filter 也可以是GPUImageFilterGroup的实例,可以将多个滤镜组合

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

– processMessageData: -

- -
-
- -
- - -
-

用户待发送的消息 -@param messageData待发送的消息

-
- - - -
- (BOOL)processMessageData:(NSDictionary *)messageData
- - - - - -
-

Return Value

-

YES / NO

-
- - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  bgPic -

- -
-
- -
- - -
-

背景图片,用于背景图片推流

-
- - - -
@property (nonatomic, readwrite) GPUImagePicture *bgPic
- - - - - - - - - -
-

Discussion

-

设置为nil为清除背景图片

-
- - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

  bgPicRotate -

- -
-
- -
- - -
-

背景图片朝向

-
- - - -
@property (nonatomic, readwrite) GPUImageRotationMode bgPicRotate
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
- -

+ getRotationMode: -

- -
-
- -
- - -
-

读取图像的朝向

-
- - - -
+ (GPUImageRotationMode)getRotationMode:(UIImage *)img
- - - - - - - - - - - - - - - -
-

Declared In

-

KSYGPUBgpStreamerKit.h

-
- - -
-
-
-
- -
- - - - - - -
- - -
-
-
- - - - diff --git a/doc/html/Classes/KSYGPUPicture.html b/doc/html/Classes/KSYGPUPicture.html index 3ed6a6d..4cfc2df 100644 --- a/doc/html/Classes/KSYGPUPicture.html +++ b/doc/html/Classes/KSYGPUPicture.html @@ -60,6 +60,8 @@

+ + @@ -130,10 +132,115 @@

–&
+ +
+

通过指定图片名称载入图片

+
+ +
- (id)initWithImageName:(NSString *)name
+ +
+

Parameters

+ + + + + + + +
name

图片的名称

+
+ + + +
+

Return Value

+

载入图片后的实例

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUPicture.h

+
+ + +
+ +
+ +

– initWithImage:andOutputSize: +

+ +
+
+ +
+ + +
+

指定载入图片后输出的尺寸

+
+ + + +
- (id)initWithImage:(UIImage *)img andOutputSize:(CGSize)size
+ + + +
+

Parameters

+ + + + + + + + + + + + +
img

图片

size

尺寸

+
+ + + +
+

Return Value

+

构造的实例

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUPicture.h

+
+ +
diff --git a/doc/html/Classes/KSYGPUStreamerKit.html b/doc/html/Classes/KSYGPUStreamerKit.html index 93cd0ea..a5a7d05 100644 --- a/doc/html/Classes/KSYGPUStreamerKit.html +++ b/doc/html/Classes/KSYGPUStreamerKit.html @@ -74,6 +74,8 @@

+ + @@ -198,22 +200,34 @@

+ + + + + + + + + + + + @@ -277,7 +291,7 @@

Overview

- +

Other Methods

+
+ +

– setOrientaion:ofLayer: +

+ +
+
+ +
+ + +
+

设置指定图层的朝向

+
+ + + +
- (void)setOrientaion:(UIImageOrientation)orien ofLayer:(NSInteger)idx
+ + + +
+

Parameters

+ + + + + + + + + + + + +
orien

目标朝向

idx

图层的index

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit.h

+
+ + +
+
+
+ + + + + + +

bgp Methods

+ +
+
+ +

  bgPic +

+ +
+
+ +
+ + +
@property (nonatomic, retain) KSYGPUPicture *bgPic
+ + +
+
+
+ +

– updateBgpImage: +

+ +
+
+ +
+ + +
+

更新背景图片

+
+ + + +
- (void)updateBgpImage:(UIImage *)img
+ + + +
+

Parameters

+ + + + + + + +
img

新的背景图片

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– startBgpPreview: +

+ +
+
+ +
+ + +
+

开始背景图预览

+
+ + + +
- (BOOL)startBgpPreview:(UIView *)bgView
+ + + +
+

Parameters

+ + + + + + + +
bgView

预览视图的背景图, 预览视图会填满背景视图 +结束预览仍然使用之前的 stopPreview

+
+ + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– startBgpStream: +

+ +
+
+ +
+ + +
+

开始背景图推流

+
+ + + +
- (BOOL)startBgpStream:(NSURL *)url
+ + + +
+

Parameters

+ + + + + + + +
url

推流地址

+
+ + + +
+

Return Value

+

当前状态是否能开始推流

+
+ + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ + +
+
+
+ +

– stopBgpStream +

+ +
+
+ +
+ + +
+

停止背景图推流

+
+ + + +
- (void)stopBgpStream
+ + + + + + + + + + + + + + + +
+

Declared In

+

KSYGPUStreamerKit+bgp.h

+
+ +
diff --git a/doc/html/Classes/KSYGPUTwoInputFiter.html b/doc/html/Classes/KSYGPUTwoInputFiter.html index e179405..e2da4e3 100644 --- a/doc/html/Classes/KSYGPUTwoInputFiter.html +++ b/doc/html/Classes/KSYGPUTwoInputFiter.html @@ -43,6 +43,8 @@