Commit a273c54ce989f8bd9758402299f681747d46fca6

Authored by zhangxiaowen
1 parent 74bb97df

no message

CNLivePlayer/Classes/Streamer/CNLiveBgmPlayer.h
... ... @@ -6,6 +6,10 @@
6 6 // Copyright © 2019 153993236@qq.com. All rights reserved.
7 7 //
8 8  
  9 +/**
  10 + * 背景音乐播放器
  11 + */
  12 +
9 13 #import <Foundation/Foundation.h>
10 14 #import <AVFoundation/AVFoundation.h>
11 15 #import "CNLivePlayerDefines.h"
... ...
CNLivePlayer/Classes/Streamer/CNLiveBgmPlayer.m
... ... @@ -18,7 +18,7 @@ NSString * const CNLiveBgmAudioStateDidChangeNotification = @&quot;CNLiveBgmAudioStat
18 18 - (instancetype)init {
19 19 self = [super init];
20 20 if (self) {
21   - [self addBgmObservers];
  21 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioStateDidChange) name:KSYAudioStateDidChangeNotification object:nil];
22 22  
23 23 STREAMER_Manager_BgmPlayer.audioDataBlock = ^ BOOL(uint8_t** pData, int len, const AudioStreamBasicDescription* fmt, CMTime pts){
24 24 [STREAMER_Manager.aMixer processAudioData:pData nbSample:len withFormat:fmt timeinfo:pts of:STREAMER_Manager.bgmTrack];
... ... @@ -35,23 +35,16 @@ NSString * const CNLiveBgmAudioStateDidChangeNotification = @&quot;CNLiveBgmAudioStat
35 35 return self;
36 36 }
37 37  
38   -- (void)addBgmObservers {
39   - [[NSNotificationCenter defaultCenter] addObserver:self
40   - selector:@selector(audioStateDidChange)
41   - name:KSYAudioStateDidChangeNotification
42   - object:nil];
43   -}
44   -
45 38 - (CNLiveBgmPlayerState)audioStateDidChange {
46 39 return (CNLiveBgmPlayerState)STREAMER_Manager_BgmPlayer.bgmPlayerState;
47 40 }
48 41  
49 42 - (void)dealloc {
50   - [[NSNotificationCenter defaultCenter] removeObserver:self
51   - name:KSYAudioStateDidChangeNotification
52   - object:nil];
  43 + [[NSNotificationCenter defaultCenter] removeObserver:self];
  44 +
53 45 }
54 46  
  47 +#pragma mark - methods
55 48 - (BOOL)startPlayBgm:(NSString *)path isLoop:(BOOL)loop {
56 49 return [STREAMER_Manager_BgmPlayer startPlayBgm:path isLoop:loop];
57 50 }
... ...
CNLivePlayer/Classes/Streamer/CNLiveStreamerKit.m
... ... @@ -213,14 +213,15 @@ NSString * const CNLiveServiceConnectBreakNotification = @&quot;CNLiveServiceConnectB
213 213 else {
214 214 //设置初始美颜
215 215 _filter = [[KSYGPUBeautifyExtFilter alloc] init];
216   - [(KSYGPUBeautifyExtFilter *)_filter setBeautylevel: 0.5];
  216 + [(KSYGPUBeautifyExtFilter *)_filter setBeautylevel:0.5];
217 217 [_manager.kit setupFilter:_filter];
218 218  
219 219 //摄像头位置
220 220 _manager.kit.cameraPosition = AVCaptureDevicePositionFront;
221 221 }
222 222  
223   - _manager.kit.streamerBase.shouldEnableKSYStatModule = NO; //收集网络相关状态的日志(不收集)
  223 + _manager.kit.streamerBase.shouldEnableKSYStatModule = NO;
  224 + //收集网络相关状态的日志(不收集)
224 225 _manager.kit.videoProcessingCallback = ^(CMSampleBufferRef sampleBuffer){
225 226  
226 227 };
... ... @@ -410,22 +411,7 @@ NSString * const CNLiveServiceConnectBreakNotification = @&quot;CNLiveServiceConnectB
410 411  
411 412  
412 413 - (void)quitStreaming {
413   - [[NSNotificationCenter defaultCenter] removeObserver:self
414   - name:KSYCaptureStateDidChangeNotification
415   - object:nil];
416   -
417   - [[NSNotificationCenter defaultCenter] removeObserver:self
418   - name:KSYStreamStateDidChangeNotification
419   - object:nil];
420   -
421   - [[NSNotificationCenter defaultCenter] removeObserver:self
422   - name:UIApplicationWillResignActiveNotification
423   - object:nil];
424   -
425   - [[NSNotificationCenter defaultCenter] removeObserver:self
426   - name:UIApplicationDidBecomeActiveNotification
427   - object:nil];
428   -
  414 + [[NSNotificationCenter defaultCenter] removeObserver:self];
429 415  
430 416 [self.heartTimer invalidate];
431 417 self.heartTimer = nil;
... ...
CNLivePlayer/Classes/Streamer/CNLiveStreamerTools.h
... ... @@ -11,9 +11,10 @@
11 11 NS_ASSUME_NONNULL_BEGIN
12 12  
13 13 @interface CNLiveStreamerTools : NSObject
14   -//SHA加密
  14 +//签名
15 15 + (NSMutableDictionary *)encryptionSignWithParameter:(NSMutableDictionary *)parameter;
16 16  
  17 +//SHA加密
17 18 + (NSString*)sha1:(NSString *)string;
18 19  
19 20 + (NSString *)signvalue:(NSDictionary*)parameter;
... ...
CNLivePlayer/Classes/Streamer/CNLiveWatermark.h
... ... @@ -20,7 +20,6 @@ NS_ASSUME_NONNULL_BEGIN
20 20 @abstract 水印logo的图片
21 21 @discussion 设置为nil为清除水印图片
22 22 @discussion 请注意背景图片的尺寸, 太大的图片会导致内存占用过高
23   - @see
24 23 */
25 24 @property (nonatomic, readwrite) GPUImagePicture *logoPic;
26 25  
... ...
Example/CNLivePlayer.xcodeproj/project.pbxproj
... ... @@ -16,7 +16,7 @@
16 16 08740E52230E7DFB00B5D28D /* CNLiveStreamerDetailController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E40230E7DFA00B5D28D /* CNLiveStreamerDetailController.m */; };
17 17 08740E53230E7DFB00B5D28D /* FilterFunctionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */; };
18 18 08740E54230E7DFB00B5D28D /* SliderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E44230E7DFA00B5D28D /* SliderView.m */; };
19   - 08740E55230E7DFB00B5D28D /* FloatingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E45230E7DFA00B5D28D /* FloatingViewController.m */; };
  19 + 08740E55230E7DFB00B5D28D /* CNLiveFloatingController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E45230E7DFA00B5D28D /* CNLiveFloatingController.m */; };
20 20 08740E56230E7DFB00B5D28D /* AudioStreamingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */; };
21 21 08740E59230E7DFB00B5D28D /* BgmPlayerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 08740E4D230E7DFA00B5D28D /* BgmPlayerView.m */; };
22 22 08740E5E230E8A0700B5D28D /* house.gif in Resources */ = {isa = PBXBuildFile; fileRef = 08740E5D230E8A0700B5D28D /* house.gif */; };
... ... @@ -64,14 +64,14 @@
64 64 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FilterFunctionView.m; sourceTree = "<group>"; };
65 65 08740E43230E7DFA00B5D28D /* BgmPlayerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BgmPlayerView.h; sourceTree = "<group>"; };
66 66 08740E44230E7DFA00B5D28D /* SliderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SliderView.m; sourceTree = "<group>"; };
67   - 08740E45230E7DFA00B5D28D /* FloatingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FloatingViewController.m; sourceTree = "<group>"; };
  67 + 08740E45230E7DFA00B5D28D /* CNLiveFloatingController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLiveFloatingController.m; sourceTree = "<group>"; };
68 68 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioStreamingViewController.m; sourceTree = "<group>"; };
69 69 08740E49230E7DFA00B5D28D /* FilterFunctionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilterFunctionView.h; sourceTree = "<group>"; };
70 70 08740E4A230E7DFA00B5D28D /* CNLiveStreamerDetailController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveStreamerDetailController.h; sourceTree = "<group>"; };
71 71 08740E4B230E7DFA00B5D28D /* CNLiveStreamerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveStreamerController.h; sourceTree = "<group>"; };
72 72 08740E4C230E7DFA00B5D28D /* SliderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SliderView.h; sourceTree = "<group>"; };
73 73 08740E4D230E7DFA00B5D28D /* BgmPlayerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BgmPlayerView.m; sourceTree = "<group>"; };
74   - 08740E4E230E7DFA00B5D28D /* FloatingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatingViewController.h; sourceTree = "<group>"; };
  74 + 08740E4E230E7DFA00B5D28D /* CNLiveFloatingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNLiveFloatingController.h; sourceTree = "<group>"; };
75 75 08740E50230E7DFA00B5D28D /* AudioStreamingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioStreamingViewController.h; sourceTree = "<group>"; };
76 76 08740E5D230E8A0700B5D28D /* house.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = house.gif; sourceTree = "<group>"; };
77 77 08740E60230E8C6500B5D28D /* CNLivePlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CNLivePlayerController.m; sourceTree = "<group>"; };
... ... @@ -168,8 +168,8 @@
168 168 08740E40230E7DFA00B5D28D /* CNLiveStreamerDetailController.m */,
169 169 08740E50230E7DFA00B5D28D /* AudioStreamingViewController.h */,
170 170 08740E46230E7DFA00B5D28D /* AudioStreamingViewController.m */,
171   - 08740E4E230E7DFA00B5D28D /* FloatingViewController.h */,
172   - 08740E45230E7DFA00B5D28D /* FloatingViewController.m */,
  171 + 08740E4E230E7DFA00B5D28D /* CNLiveFloatingController.h */,
  172 + 08740E45230E7DFA00B5D28D /* CNLiveFloatingController.m */,
173 173 08740E49230E7DFA00B5D28D /* FilterFunctionView.h */,
174 174 08740E41230E7DFA00B5D28D /* FilterFunctionView.m */,
175 175 08740E43230E7DFA00B5D28D /* BgmPlayerView.h */,
... ... @@ -511,7 +511,7 @@
511 511 isa = PBXSourcesBuildPhase;
512 512 buildActionMask = 2147483647;
513 513 files = (
514   - 08740E55230E7DFB00B5D28D /* FloatingViewController.m in Sources */,
  514 + 08740E55230E7DFB00B5D28D /* CNLiveFloatingController.m in Sources */,
515 515 08740E69230E989000B5D28D /* CNLiveMoreFunctionsView.m in Sources */,
516 516 6003F59E195388D20070C39A /* CNLiveAppDelegate.m in Sources */,
517 517 08740E52230E7DFB00B5D28D /* CNLiveStreamerDetailController.m in Sources */,
... ...
Example/CNLivePlayer/CNLiveViewController.m
... ... @@ -17,8 +17,7 @@
17 17  
18 18 @implementation CNLiveViewController
19 19  
20   -- (void)viewDidLoad
21   -{
  20 +- (void)viewDidLoad {
22 21 [super viewDidLoad];
23 22 // Do any additional setup after loading the view, typically from a nib.
24 23  
... ... @@ -45,7 +44,6 @@
45 44 label.font = [UIFont systemFontOfSize:16];
46 45 label.textAlignment = NSTextAlignmentCenter;
47 46 [self.view addSubview:label];
48   -
49 47  
50 48 }
51 49 - (void)btnDidClicked1{
... ... @@ -57,10 +55,4 @@
57 55  
58 56 }
59 57  
60   -- (void)didReceiveMemoryWarning
61   -{
62   - [super didReceiveMemoryWarning];
63   - // Dispose of any resources that can be recreated.
64   -}
65   -
66 58 @end
... ...
Example/CNLivePlayer/Streamer/FloatingViewController.h renamed to Example/CNLivePlayer/Streamer/CNLiveFloatingController.h
1 1 //
2   -// FloatingViewController.h
3   -// CNLivePlayerSDKDemo
  2 +// CNLiveFloatingController.h
  3 +// CNLivePlayer_Example
4 4 //
5   -// Created by iOS on 2017/9/20.
6   -// Copyright © 2017年 雷浩杰. All rights reserved.
  5 +// Created by CNLive-zxw on 2019/8/17.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
7 7 //
8 8  
9 9 #import <UIKit/UIKit.h>
10 10 #import "CNLiveStreamerKit.h"
11 11  
12   -@interface FloatingViewController : UIViewController
  12 +@interface CNLiveFloatingController : UIViewController
13 13  
14 14 @property (nonatomic, strong) CNLiveStreamerKit *kit;
15 15  
... ...
Example/CNLivePlayer/Streamer/FloatingViewController.m renamed to Example/CNLivePlayer/Streamer/CNLiveFloatingController.m
1 1 //
2   -// FloatingViewController.m
3   -// CNLivePlayerSDKDemo
  2 +// CNLiveFloatingController.m
  3 +// CNLivePlayer_Example
4 4 //
5   -// Created by iOS on 2017/9/20.
6   -// Copyright © 2017年 雷浩杰. All rights reserved.
  5 +// Created by CNLive-zxw on 2019/8/17.
  6 +// Copyright © 2019 153993236@qq.com. All rights reserved.
7 7 //
8 8  
9   -#import "FloatingViewController.h"
  9 +#import "CNLiveFloatingController.h"
10 10  
11 11 #define Width [UIScreen mainScreen].bounds.size.width
12 12 #define Height [UIScreen mainScreen].bounds.size.height
13 13  
14   -@interface FloatingViewController ()
  14 +@interface CNLiveFloatingController ()
15 15  
16 16 @property (nonatomic, strong) UIView *preView;
17 17 @property CGPoint loc_in;
18 18  
19 19 @end
20 20  
21   -@implementation FloatingViewController
  21 +@implementation CNLiveFloatingController
22 22  
23 23 - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
24 24  
... ... @@ -52,6 +52,7 @@
52 52  
53 53 - (void)backAction {
54 54 [self dismissViewControllerAnimated:YES completion:NULL];
  55 +
55 56 }
56 57  
57 58 - (void)pan:(UIPanGestureRecognizer *)ges{
... ... @@ -81,9 +82,9 @@
81 82 [UIView animateWithDuration:0 animations:^{
82 83 _preView.center = CGPointMake(x, y);
83 84 }];
  85 +
84 86 }
85 87  
86   -
87 88 - (void)didReceiveMemoryWarning {
88 89 [super didReceiveMemoryWarning];
89 90 // Dispose of any resources that can be recreated.
... ...
Example/CNLivePlayer/Streamer/CNLiveStreamerDetailController.m
... ... @@ -13,7 +13,7 @@
13 13  
14 14 #import <GPUImage/GPUImage.h>
15 15 #import <YYImage/YYImage.h>
16   -#import "FloatingViewController.h"
  16 +#import "CNLiveFloatingController.h"
17 17 #import "CNLiveStreamerKit.h"
18 18  
19 19 #import "CNLiveLoadingView.h"
... ... @@ -40,8 +40,7 @@
40 40 UIButton *_flashBtn; //打开闪光灯
41 41 UIButton *_filterBtn; //滤镜
42 42 UIButton *_voiceBtn; //声音
43   - UIButton *_moreBtn; //更多
44   -
  43 + UIButton *_moreBtn; //更多
45 44  
46 45 CGFloat _currentPinchZoomFactor; //当前触摸缩放因子
47 46  
... ... @@ -68,7 +67,7 @@
68 67  
69 68 @property (nonatomic, strong) NSLock *dlLock;
70 69 @property (nonatomic, strong) GPUImagePicture *logoPicure;
71   -@property (nonatomic, strong) CADisplayLink *displayLink;
  70 +@property (nonatomic, strong) CADisplayLink *displayLink;
72 71  
73 72 @end
74 73  
... ... @@ -96,11 +95,12 @@
96 95 UIDeviceOrientation toDeviceOrientation = [UIDevice currentDevice].orientation;
97 96  
98 97 if (toDeviceOrientation == UIDeviceOrientationPortrait) {
  98 + //竖屏
99 99 newTransform = CGAffineTransformIdentity;
100 100 newFrame = CGRectMake(0, 0, minLength, maxLength);
101 101 }
102 102 else {
103   -
  103 + //横屏
104 104 if (currentInterfaceOrientation == UIInterfaceOrientationPortrait) {
105 105 newTransform = CGAffineTransformMakeRotation(M_PI_2*(toDeviceOrientation == UIDeviceOrientationLandscapeRight ? 1 : -1));
106 106 }
... ... @@ -142,7 +142,8 @@
142 142 }
143 143 _previewBtn.frame = CGRectMake(20, Screen_Height-60, 90, 30);
144 144 _startLiveBtn.frame = CGRectMake(Screen_Width-90-20, Screen_Height-60, 90, 30);
145   -
  145 + _stateLabel.frame = newFrame;
  146 +
146 147 }];
147 148 }
148 149  
... ... @@ -562,7 +563,7 @@
562 563 }
563 564  
564 565 - (void)floatingWindowBtnClicked {
565   - FloatingViewController *vc = [[FloatingViewController alloc] init];
  566 + CNLiveFloatingController *vc = [[CNLiveFloatingController alloc] init];
566 567 vc.kit = _kitCN;
567 568 [self presentViewController:vc animated:YES completion:NULL];
568 569 }
... ...