LFLiveKit is a opensource RTMP streaming SDK for iOS.
上面这句话是LFLiveKit在github上的介绍。它提供以下功能:
后台录制、美颜功能、支持h264、AAC硬编码,动态改变速率,RTMP传输等
该SDK同时支持swift。
集成方法:
通过cocoapods集成,Podfile内容如下:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target “your app target” do
pod 'LFLiveKit'
end
注意,这里ios平台的版本是8.0。
该SDK中最主要的类是LFLiveSession,通过下面的代码进行初始化
LFLiveSession*session=[[LFLiveSession alloc] initWithAudioConfiguration:[LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfiguration]];//音视频默认配置
session.preView=self.view//指定视图
session.delete=self;//指定代理
下面是开始推流的代码
LFLiveStreamInfo *streamInfo = [LFLiveStreamInfo new];
streamInfo.url = @"your server rtmp url";//指定推流地址
[session startLive:streamInfo];//开始推流
[session stopLive];//停止推流
主要的代理方法
- (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;//推流错误的回调函数
是不是很简单???