LFLiveKit详解

感谢原作者:点击打开链接


    首先LFLiveKit支持rtmp,flv两种流类型,LFLiveSession是整个库文件的入口,包含有那么几个属性

@property (nullable,nonatomic, weak) delegate;//代理方法 稍后介绍

@property (nonatomic, assign) BOOL running;//控制直播是开还是关的状态

@property (nonatomic, strong,null_resettable) UIView *preView;//视频图层

@property (nonatomic, assign) AVCaptureDevicePosition captureDevicePosition;//摄像头方向

@property (nonatomic, assign) BOOL beautyFace;//美颜开关

@property (nonatomic,assign) BOOL muted;//静音开关

@property (nullable,nonatomic, strong,readonly) LFLiveStreamInfo * streamInfo;//控制直播流的信息

@property (nonatomic,assign,readonly) LFLiveState state;//直播流上传的状态

@property (nonatomic,assign) BOOL showDebugInfo;//

@property (nonatomic,assign) NSUInteger reconnectInterval;//重连间隔 

    @property (nonatomic,assign) NSUInteger reconnectCount;//重连次数

代理方法

- (void)liveSession:(nullable LFLiveSession *)session liveStateDidChange:(LFLiveState)state; //监听直播的状态

- (void)liveSession:(nullable LFLiveSession *)session debugInfo:(nullable LFLiveDebug*)debugInfo;

- (void)liveSession:(nullable LFLiveSession*)session errorCode:(LFLiveSocketErrorCode)errorCode;

初始化方法

- (nullable instancetype)initWithAudioConfiguration:(nullable LFLiveAudioConfiguration*)audioConfiguration videoConfiguration:(nullable LFLiveVideoConfiguration*)videoConfiguration liveType:(LFLiveType)liveType //初始化session的方法 三个参数分别是 视频 音频 和 流类型设置

- (void)startLive:(nonnull LFLiveStreamInfo*)streamInfo;//开始直播

- (void)stopLive;//停止直播

demo

//初始化preView

-(UIView *)livingPreView{

         if (!_livingPreView) {

                  UIView *livingPreView = [[UIView alloc]initWithFrame:self.view.bounds];

                  livingPreView.backgroundColor = [UIColor clearColor];

                  livingPreView.autoresizingMask = UIViewAutoresizingFlexibleWidth|                              UIViewAutoresizingFlexibleHeight;

                [self.view insertSubview:livingPreView atIndex:0];

                _livingPreView = livingPreView;

                                 }

       return _livingPreView;

}

//初始化session

-(LFLiveSession *)session{

              if (!_session) {

              //采用默认的音视频质量 LFLiveAudioConfiguration(音频设置)                  LFLiveVideoConfiguration(视频质量)

              _session = [[LFLiveSession alloc]initWithAudioConfiguration:    [LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfigurationForQuality:LFLiveVideoQuality_Medium2] liveType:LFLiveRTMP];

             //设置代理

               _session.delegate = self;

             _session.running = YES;

             _session.preView = self.livingPreView;

                             }

            return _session;

}

- (void)viewDidLoad {

            [super viewDidLoad];

            LFLiveStreamInfo *stream = [[LFLiveStreamInfo alloc]init];

           stream.url = @"rtmp://10.130.28.4410.130.28.44"

           self.session.beautyFace = yes;

           [self.session startLive:stream];

           [self setup];

}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值