TXLivePush Class Reference
Inherits from | NSObject |
---|---|
Declared in | TXLivePush.h |
config
推流参数配置
@property (nonatomic, copy) TXLivePushConfig *config
See Also
Declared In
TXLivePush.h
delegate
推流回调
@property (nonatomic, weak) id<TXLivePushListener> delegate
See Also
Declared In
TXLivePush.h
videoProcessDelegate
视频自定义处理回调
@property (nonatomic, weak) id<TXVideoCustomProcessDelegate> videoProcessDelegate
See Also
Declared In
TXLivePush.h
audioProcessDelegate
音频自定义处理回调
@property (nonatomic, weak) id<TXAudioCustomProcessDelegate> audioProcessDelegate
See Also
Declared In
TXLivePush.h
recordDelegate
推流端录制回调
@property (nonatomic, weak) id<TXLiveRecordListener> recordDelegate
See Also
Declared In
TXLivePush.h
– initWithConfig:
初始化推流器
- (id)initWithConfig:(TXLivePushConfig *)config
Parameters
config |
推流参数配置 |
---|
Declared In
TXLivePush.h
– startPush:
启动到指定URL地址推流
- (int)startPush:(NSString *)rtmpURL
Parameters
rtmpURL |
推流地址 |
---|
Return Value
0:启动成功 -1:出错
Declared In
TXLivePush.h
– pausePush
后台推送默认数据,在切后台或打断场合需要调用 当从前台切到后台的时候,调用pausePush会推配置里设置的图片(TXLivePushConfig.pauseImg)
- (void)pausePush
Discussion
pauseImg 设置后台推流的默认图片,不设置为默认黑色背景 pauseFps 设置后台推流帧率,最小值为5,最大值为20,默认10 pauseTime 设置后台推流持续时长,单位秒,默认300秒 具体使用方式请参考demo里面的示例
Note: 暂停推流,后台视频发送TXLivePushConfig里面设置的图像,音频会继续录制声音发送, 如果不需要录制声音,需要再调下setMute接口
Declared In
TXLivePush.h
– resumePush
恢复推流, 当从后台回到前台的时候,调用resumePush恢复推送camera采集的数据
- (void)resumePush
Declared In
TXLivePush.h
– startRecord:
视频录制 开始录制短视频,开始推流后才能启动录制
- (int)startRecord:(NSString *)videoPath
Parameters
videoPath |
视频录制后存储路径 @return 返回值 | 涵义 ——|—— 0 | 成功 -1 | videoPath 为nil -2 | 上次录制未结束,请先stopRecord -3 | 推流未开始 |
---|
Discussion
Note: 1,录制过程中请勿动态切换分辨率和软硬编,可能导致生成的视频异常 2,目前仅支持 企业版 和 Professional SDK版本,其他版本调用无效
Declared In
TXLivePush.h
– stopRecord
结束录制短视频,停止推流后,如果视频还在录制中,SDK内部会自动结束录制
- (int)stopRecord
Return Value
0: 成功 -1:不存在录制任务;
Declared In
TXLivePush.h
– startPreview:
开始推流画面的预览
- (int)startPreview:(UIView *)view
Parameters
view |
预览控件所在的父控件 |
---|
Return Value
0 (异步处理,返回总是0)
Declared In
TXLivePush.h
– setMirror:
设置镜像
- (void)setMirror:(BOOL)isMirror
Parameters
isMirror |
YES:播放端看到的是镜像画面 NO:播放端看到的是非镜像画面 |
---|
Discussion
Note: 推流端前置摄像头默认看到的是镜像画面,后置摄像头默认看到的是非镜像画面
Declared In
TXLivePush.h
– setBeautyStyle:beautyLevel:whitenessLevel:ruddinessLevel:
设置美颜 和 美白 效果级别
- (void)setBeautyStyle:(TX_Enum_Type_BeautyStyle)beautyStyle beautyLevel:(float)beautyLevel whitenessLevel:(float)whitenessLevel ruddinessLevel:(float)ruddinessLevel
Parameters
beautyStyle |
TX_Enum_Type_BeautyStyle |
---|---|
beautyLevel |
: 美颜级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
whitenessLevel |
: 美白级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
ruddinessLevel |
: 红润级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
See Also
Declared In
TXLivePush.h
– setEyeScaleLevel:
设置大眼级别(企业版有效,其它版本设置此参数无效)
- (void)setEyeScaleLevel:(float)eyeScaleLevel
Parameters
eyeScaleLevel |
大眼级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXLivePush.h
– setFaceScaleLevel:
设置瘦脸级别(企业版有效,其它版本设置此参数无效)
- (void)setFaceScaleLevel:(float)faceScaleLevel
Parameters
faceScaleLevel |
瘦脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXLivePush.h
– setFilter:
设置指定素材滤镜特效
- (void)setFilter:(UIImage *)image
Parameters
image |
指定素材,即颜色查找表图片。 |
---|
Discussion
Note: 一定要用png格式!!!demo用到的滤镜查找表图片位于TXLiteAVDemo/Resource/Beauty/filter/FilterResource.bundle中
Declared In
TXLivePush.h
– setSpecialRatio:
设置滤镜效果程度 @prarm specialValue 从0到1,越大滤镜效果越明显,默认取值0.5
- (void)setSpecialRatio:(float)specialValue
Declared In
TXLivePush.h
– setFaceVLevel:
设置V脸(企业版有效,其它版本设置此参数无效)
- (void)setFaceVLevel:(float)faceVLevel
Parameters
faceVLevel |
V脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXLivePush.h
– setChinLevel:
设置下巴拉伸或收缩(企业版有效,其它版本设置此参数无效)
- (void)setChinLevel:(float)chinLevel
Parameters
chinLevel |
下巴拉伸或收缩级别取值范围 -9 ~ 9; 0 表示关闭 -9收缩 ~ 9拉伸。 |
---|
Declared In
TXLivePush.h
– setFaceShortLevel:
设置短脸(企业版有效,其它版本设置此参数无效)
- (void)setFaceShortLevel:(float)faceShortlevel
Parameters
faceShortlevel |
短脸级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXLivePush.h
– setNoseSlimLevel:
设置瘦鼻(企业版有效,其它版本设置此参数无效)
- (void)setNoseSlimLevel:(float)noseSlimLevel
Parameters
noseSlimLevel |
瘦鼻级别取值范围 0 ~ 9; 0 表示关闭 1 ~ 9值越大 效果越明显。 |
---|
Declared In
TXLivePush.h
– toggleTorch:
打开闪关灯。
- (BOOL)toggleTorch:(BOOL)bEnable
Parameters
bEnable |
YES: 打开 NO: 关闭 |
---|
Return Value
YES: 打开成功 NO: 打开失败
Declared In
TXLivePush.h
– setRenderRotation:
设置本地视频方向
- (void)setRenderRotation:(int)rotation
Parameters
rotation |
取值为 0 , 90, 180, 270(其他值无效) 表示推流端本地视频向右旋转的角度 |
---|
Discussion
Note: 横竖屏推流,activty旋转可能会改变本地视频流方向,可以设置此参数让本地视频回到正方向,具体请参考demo设置,如果demo里面的设置满足不了您的业务需求,请自行setRenderRotation到自己想要的方向(tips:推流端setRenderRotation不会改变观众端的视频方向)
Declared In
TXLivePush.h
– setMute:
设置静音
- (void)setMute:(BOOL)bEnable
Parameters
bEnable |
YES: 静音 NO:关闭静音 |
---|
Declared In
TXLivePush.h
– sendCustomPCMData:len:
发送客户自定义的音频PCM数据
- (void)sendCustomPCMData:(unsigned char *)data len:(unsigned int)len
Parameters
data |
要发送的PCM数据 |
---|---|
len |
数据长度 |
Discussion
Note: 目前SDK只支持16位采样的PCM编码;如果是单声道,请保证传入的PCM长度为2048;如果是双声道,请保证传入的PCM长度为4096
Declared In
TXLivePush.h
– sendVideoSampleBuffer:
发送自定义的SampleBuffer,内部有简单的帧率控制,发太快会自动丢帧;超时则会重发最后一帧
- (void)sendVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer
Parameters
sampleBuffer |
要发送的视频sampleBuffer |
---|
Discussion
Note: autoSampleBufferSize优先级高于sampleBufferSize @see TXLivePushConfig @property sampleBufferSize,设置输出分辨率,如果此分辨率不等于sampleBuffer中数据分辨率则会对视频数据做缩放 @property autoSampleBufferSize,输出分辨率等于输入分辨率,即sampleBuffer中数据的实际分辨率
Declared In
TXLivePush.h
– sendAudioSampleBuffer:withType:
Replaykit发送自定义音频包 @prama sampleBuffer 声音sampleBuffer @prama sampleBufferType RPSampleBufferTypeAudioApp or RPSampleBufferTypeAudioMic,
- (void)sendAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer withType:(RPSampleBufferType)sampleBufferType
Discussion
Note: 当两种声音都发送时,内部做混音;否则只发送一路声音
Declared In
TXLivePush.h
– setSendAudioSampleBufferMuted:
Replaykit发送静音包,在InApp类型录制切后台场合时需要调用。系统屏幕录制不需要
- (void)setSendAudioSampleBufferMuted:(BOOL)muted
Parameters
muted |
YES: 静音 NO:关闭静音 |
---|
Declared In
TXLivePush.h
– setFocusPosition:
调用手动对焦功能
- (void)setFocusPosition:(CGPoint)touchPoint
Parameters
touchPoint |
为传入的对焦点位置 |
---|
Discussion
Note: 早期SDK版本手动对焦功能是由SDK内部触发,现在把手动对焦的接口开放出来,客户可以根据自己需求触发 ,如果客户调用这个接口,SDK内部触发对焦的逻辑将会停止,避免重复触发对焦逻辑
Declared In
TXLivePush.h
– setZoom:
调整焦距
- (void)setZoom:(CGFloat)distance
Parameters
distance |
焦距大小, 取值范围 1~5 |
---|
Discussion
Note: 当为1的时候为最远视角(正常镜头),当为5的时候为最近视角(放大镜头),这里最大值推荐为5,超过5后视频数据会变得模糊不清
Declared In
TXLivePush.h
– playBGM:
播放背景音乐, 用于混音处理,背景音与Mic采集到的人声混合
- (BOOL)playBGM:(NSString *)path
Parameters
path |
本地音乐文件路径 |
---|
Return Value
YES:成功 NO:失败
Declared In
TXLivePush.h
– playBGM:withBeginNotify:withProgressNotify:andCompleteNotify:
播放背景音乐
- (BOOL)playBGM:(NSString *)path withBeginNotify:(void ( ^ ) ( NSInteger errCode ))beginNotify withProgressNotify:(void ( ^ ) ( NSInteger progressMS , NSInteger durationMS ))progressNotify andCompleteNotify:(void ( ^ ) ( NSInteger errCode ))completeNotify
Parameters
path |
本地音乐文件路径 |
---|---|
beginNotify |
音乐播放开始的回调通知 |
progressNotify |
音乐播放的进度通知,单位毫秒 |
completeNotify |
音乐播放结束的回调通知 |
Return Value
YES:成功 NO:失败
Declared In
TXLivePush.h
– getMusicDuration:
获取音乐文件总时长,单位毫秒
- (int)getMusicDuration:(NSString *)path
Parameters
path |
音乐文件路径,如果path为空,那么返回当前正在播放的music时长 |
---|
Declared In
TXLivePush.h
– setMicVolume:
设置麦克风的音量大小,播放背景音乐混音时使用,用来控制麦克风音量大小
- (BOOL)setMicVolume:(float)volume
Parameters
volume |
音量大小,1为正常音量,建议值为0~2,如果需要调大音量可以设置更大的值 |
---|
Return Value
YES:成功 NO:失败
Declared In
TXLivePush.h
– setBGMVolume:
设置背景音乐的音量大小,播放背景音乐混音时使用,用来控制背景音音量大小
- (BOOL)setBGMVolume:(float)volume
Parameters
volume |
音量大小,1为正常音量,建议值为0~2,如果需要调大背景音量可以设置更大的值 |
---|
Return Value
YES:成功 NO:失败
Declared In
TXLivePush.h
– setBgmPitch:
设置背景音的变声类型
- (BOOL)setBgmPitch:(float)pitch
Parameters
pitch |
音调, 默认值是0.f;范围是 [-1,1]; |
---|
Return Value
YES:成功 NO:失败
Declared In
TXLivePush.h
– setVideoQuality:adjustBitrate:adjustResolution:
设置视频质量
- (void)setVideoQuality:(TX_Enum_Type_VideoQuality)quality adjustBitrate:(BOOL)adjustBitrate adjustResolution:(BOOL)adjustResolution
Parameters
quality |
画质类型(标清,高清,超高清) |
---|---|
adjustBitrate |
动态码率开关 |
adjustResolution |
动态切分辨率开关 |
Declared In
TXLivePush.h
– setReverbType:
设置混响效果
- (BOOL)setReverbType:(TXReverbType)reverbType
Parameters
reverbType |
:混响类型 ,详见 TXReverbType |
---|
Return Value
YES:成功 NO:失败
See Also
Declared In
TXLivePush.h
– setVoiceChangerType:
设置变声类型
- (BOOL)setVoiceChangerType:(TXVoiceChangerType)voiceChangerType
Parameters
voiceChangerType |
变声类型, 详见 TXVoiceChangerType |
---|
Return Value
YES:成功 NO:失败
See Also
Declared In
TXLivePush.h
– setGreenScreenFile:
设置绿幕文件。仅企业版有效
- (void)setGreenScreenFile:(NSURL *)file
Parameters
file |
绿幕文件路径。支持mp4; nil 关闭绿幕 |
---|
Declared In
TXLivePush.h
– selectMotionTmpl:inDir:
选择动效。仅企业版有效
- (void)selectMotionTmpl:(NSString *)tmplName inDir:(NSString *)tmplDir
Parameters
tmplName |
动效名称 |
---|---|
tmplDir |
动效所在目录 |
Declared In
TXLivePush.h
– setMotionMute:
设置动效静音 (企业版有效,其它版本设置此参数无效)
- (void)setMotionMute:(BOOL)motionMute
Parameters
motionMute |
YES 静音, NO 不静音 |
---|
Declared In
TXLivePush.h
– setLogViewMargin:
设置状态浮层view在渲染view上的边距
- (void)setLogViewMargin:(UIEdgeInsets)margin
Parameters
margin |
logView在渲染view上的边距 |
---|
Declared In
TXLivePush.h
– showVideoDebugLog:
是否显示播放状态统计及事件消息浮层view
- (void)showVideoDebugLog:(BOOL)isShow
Parameters
isShow |
YES:显示 NO:隐藏 |
---|
Declared In
TXLivePush.h
– snapshot:
推流截图 @params snapshotCompletionBlock 截图完成回调
- (void)snapshot:(void ( ^ ) ( UIImage *))snapshotCompletionBlock
Declared In
TXLivePush.h
– sendMessage:
发送消息,播放端通过 onPlayEvent(PLAY_EVT_GET_MESSAGE)接收
- (void)sendMessage:(NSData *)data
Parameters
data |
要发送的消息数据 |
---|
Discussion
Note: 1. 若您使用过该接口,切换到sendMessageEx接口时会有兼容性问题: sendMessageEx发送消息给旧版本的SDK(5.0及5.0以下)时,消息会无法正确解析,但播放不受影响。
Note: 2. 若您未使用过该接口,请直接使用sendMessageEx
Declared In
TXLivePush.h
– sendMessageEx:
发送消息,播放端通过 onPlayEvent(PLAY_EVT_GET_MESSAGE)接收
- (BOOL)sendMessageEx:(NSData *)data
Parameters
data |
要发送的消息数据 |
---|
Discussion
Note: 1. 消息大小不允许超过2K
Note: 2. 该接口发送消息,能够解决旧的sendMessage接口会导致在iOS上无法播放对应的HLS流的问题
Declared In
TXLivePush.h