快直播 LEB (超低延迟直播) IOS SDK https://cloud.tencent.com/product/leb
下载Demo体验请前点击 IOS demo下载地址
使用Cocoapods的方式来进行集成。在您的podfile中加入需要集成的库即可
LiveEB_IOS 封装了webrtc接口
最新版本参考: https://github.com/tencentyun/leb-ios-sdk/blob/master/DEMO/LiveEB_Demo/Podfile
pod 'TWebRTC', :git=>'https://github.com/tencentyun/TWebRTC-IOS-SDK.git' , :tag => '1.0.0'
pod 'LiveEB_IOS', :git=>'https://github.com/tencentyun/leb-ios-sdk.git' , :tag => '1.0.1'
说明:
https://github.com/tencentyun/TWebRTC-IOS-SDK.git 是ios TWebRTC的源码编译后pod私有仓库
https://github.com/tencentyun/leb-ios-sdk.git 是封装webrtc接口的封装层。包括源码和私有仓库。
1> cd LiveEB_Demo
2> pod install
SDK支持IOS 9.0以上系统
xcode10及以上环境
#import <LiveEB_IOS/LiveEB_IOS.h>
__weak typeof(self) weakSelf = self; [[LiveEBManager sharedManager] initSDK:weakSelf];
_remoteVideoView = [LiveEBVideoView new];
[self addSubview:_remoteVideoView];
_remoteVideoView2.liveEBURL = liveEBURL;
eg: liveEBURL= @"webrtc://6721.liveplay.myqcloud.com/live/6721_d71956d9cc93e4a467b11e06fdaf039a";
_controlDelegate = _remoteVideoView;
-(void)start; //开始播放
-(void)stop; //结束播放
-(void)finitSDK;
@protocol LiveEBVideoViewDelegate
@required
- (void)videoView:(LiveEBVideoView *)videoView didError:(NSError *)error;
- (void)videoView:(LiveEBVideoView *)videoView didChangeVideoSize:(CGSize)size;
@optional
- (void)onPrepared:(LiveEBVideoView*)videoView;
- (void)onCompletion:(LiveEBVideoView*)videoView;
- (void)onFirstFrameRender:(LiveEBVideoView*)videoView;
- (void)showStats:(LiveEBVideoView )videoView statReport:(LEBStatReport)statReport;
@end
/默认内部设置,可以提供给view层接口查询信息/ @property(nonatomic, readonly, strong) LiveEBMediaEngine *mediaEngine;
typedef NS_ENUM(NSInteger, LiveEBStreamState) { kLiveEBStreamStateConnecting,
kLiveEBStreamStateConnected,
kLiveEBStreamStateClosed,
kLiveEBStreamStateDisconnected, };
@interface LiveEBConfiguration : NSObject
@property (nonatomic, copy) NSString *sessionid;
@property (nonatomic, copy) NSString *rtcHost;
@property (nonatomic, copy) NSString *startStream;
@property (nonatomic, copy) NSString *stopStream;
@property (nonatomic, assign) BOOL switchStatOn;
@property (nonatomic, assign) BOOL isPullStream;
@end
@class LiveEBMediaEngine; @protocol LiveEBMediaEnginDelegate
- (void)mediaEngin:(LiveEBMediaEngine *)mediaEngin didChangeState:(LiveEBStreamState)state;
- (void)mediaEngin:(LiveEBMediaEngine *)mediaEngin didCreateLocalSource:(LiveEBCaptureSource *)localSource;
- (void)mediaEngin:(LiveEBMediaEngine )mediaEngin didGetStats:(LEBStatReport)stats;
- (void)mediaEngin:(LiveEBMediaEngine *)mediaEngin didError:(NSError *)error; @end
@interface LiveEBPullStreamConfigure : NSObject
@property (nonatomic, copy) NSString *streamURL;
@property (nonatomic, copy) NSString *streamIDSDPStream;
@end
@protocol LiveEBPullStreamDelegate
- (void)onPrepared;
- (void)onCompletion;
- (void)onFirstFrameRender;
@end
@interface LiveEBPullStreamContext : NSObject
@property(nonatomic, strong) LiveEBPullStreamConfigure *pullConfig;
@property(weak, nonatomic) id videoRender;
@property(weak, nonatomic) id streamDelegate;
@property(nonatomic, copy) NSString* remoteSDP;
-
(BOOL)isPlaying;
-
(void)start;
-
(void)stop;
-
(void)resume;
-
(void)pause;
-
(void)background;
-
(void)setAudioMute:(BOOL)mute;
-
(void)setVideoPaused:(BOOL)paused;
-
(CGFloat)setVolume:(CGFloat)volume;
-
(CGFloat)getVolume; @end
@interface LiveEBPushStreamConfigure : NSObject
@property (nonatomic, copy) NSString *pushURL;
@property (nonatomic, copy) NSString *streamIDSDPStream;
@end
@interface LiveEBPushStreamContext : NSObject
@property(nonatomic, strong) LiveEBPushStreamConfigure *pushConfig;
/*
- capture作为source, mediaengine作为sink,
- 定制的capture可以使用这个delegate输出数据
- implemention by LiveEBCaptureSource */ @property(weak, nonatomic) id captureSinkDelegate;
-
(void)start;
-
(void)stop;
@end
@interface LiveEBMediaEngine : NSObject
@property(readonly, nonatomic) LiveEBStreamState connState;
/*
- pullStreamCtx 拉流模块上下文 */ @property(readonly, nonatomic) LiveEBPullStreamContext *pullStreamCtx;
/*
- pullStreamCtx 推流模块上下文 */ @property(readonly, nonatomic) LiveEBPushStreamContext *pushStreamCtx;
/* 创建针对拉流的mediaengin pullConfig为拉流配置 */
- (instancetype)createPullEngine:(LiveEBPullStreamConfigure*) pullConfig;
/* 创建针对推流的mediaengin pushConfig推流配置 */
- (instancetype)createPushEngine:(LiveEBPushStreamConfigure*) pushConfig;
/* 设置media engin 的配置 */
-
(void)setEnginConfig:(LiveEBConfiguration * _Nonnull)enginConfig;
-
(void)setMediaEnginDelegate:(id)delegate;
/TO-DO/
- (void)setAudioSessionConfiguration:(LiveEBAudioSessionConfiguration *)configuration;
/**
- 设置video录制源即推流video源 */
- (void)setCaptureSource:(LiveEBCaptureSource *)captureSource;
/***
- 设置渲染器 可以自定义 */
- (void)setVideoRender:(LiveEBVideoRenderAdapter *)videoRender;
/*
- 是stream media engin 配置生效 */
- (void)configure; @end
需要自定义渲染器注册给LiveEBMediaEngine。目前LiveEBVideoView内部已实现利用 LiveEBMediaEngine使用sdk。后续将会开源渲染器定义代码,提供类似LiveEBVideoView的代码方便用户从LiveEBMediaEngine接入sdk。