Overview
Tencent Cloud’s live stream publisher
Features
V2TXLivePusher
encodes local audio/video and publishes the encoded data to a specified URL. It supports any publishing server.
It has the following capabilities:
V2TXLivePusher
integrates multiple retouching algorithms (natural & smooth) and color space filters (custom filters are supported).V2TXLivePusher
can adapt automatically to different upstream network conditions by controlling audio/video traffic in real time based on the network conditions of hosts.V2TXLivePusher
supports animated widgets and fine-tuning of facial features, such as eye enlarging, face slimming, and nose reshaping. You need to purchase a YouTu license to use these live streaming effects.This API is used to initialize the publisher.
- (instancetype)initWithLiveMode:(V2TXLiveMode)liveMode
Parameter | Type | Description |
---|---|---|
liveMode | V2TXLiveMode | Publishing protocol: RTMP (default) or ROOM |
This API is used to set the callbacks of the publisher. After the setting, you can listen for callback events of V2TXLivePusher
, including publisher status, volume, statistics, warning and error messages, etc.
- (void)setObserver:(id<V2TXLivePusherObserver>)observer
Parameter | Type | Description |
---|---|---|
observer | V2TXLivePusherObserver | Target object for the publisher’s callbacks. For more information, please see V2TXLivePusherObserver. |
This API is used to set the view for local camera preview. Images captured by the local camera are displayed on the view passed in after retouching, facial feature adjustments, and filter application.
- (V2TXLiveCode)setRenderView:(TXView *)view
Parameter | Type | Description |
---|---|---|
view | TXView * | View for local camera preview |
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to start publishing audio/video data.
- (V2TXLiveCode)startPush:(NSString *)url
Parameter | Type | Description |
---|---|---|
url | NSString * | Publishing URL. Any publishing server is supported. |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_INVALID_PARAMETER
: operation failed because the URL is invalid.V2TXLIVE_ERROR_REFUSED
: RTC does not support using the same stream ID for publishing and playback on the same device.This API is used to stop publishing audio/video data.
- (V2TXLiveCode)stopPush
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to get whether the publisher is publishing streams.
- (int)isPushing
Whether streams are being played
1
: yes0
: no// Set video encoding parameters for publishing
- (V2TXLiveCode)setVideoQuality:(V2TXLiveVideoEncoderParam *)param;
Parameter | Type | Description |
---|---|---|
param | V2TXLiveVideoEncoderParam | Video encoding parameters |
This API is used to set the rotation of local camera preview.
- (V2TXLiveCode)setRenderRotation:(V2TXLiveRotation)rotation
Parameter | Type | Description |
---|---|---|
rotation | V2TXLiveRotation | Degrees by which the image is rotated. Default value: V2TXLiveRotation0 |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLiveRotation
enumerated valuesValue | Description |
---|---|
V2TXLiveRotation0 | No rotation |
V2TXLiveRotation90 | Rotate 90 degrees clockwise |
V2TXLiveRotation180 | Rotate 180 degrees clockwise |
V2TXLiveRotation270 | Rotate 270 degrees clockwise |
This API is used to set the mirror mode of local camera preview.
- (V2TXLiveCode)setRenderMirror:(V2TXLiveMirrorType)mirrorType
Parameter | Type | Description |
---|---|---|
mirrorType | V2TXLiveMirrorType | Mirror mode of the camera. Default value: V2TXLiveMirrorTypeAuto |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLiveMirrorType
enumerated valuesValue | Description |
---|---|
V2TXLiveMirrorTypeAuto | The default value. In this mode, the front camera is mirrored, but the rear camera is not. |
V2TXLiveMirrorTypeEnable | Both the front and rear cameras are mirrored. |
V2TXLiveMirrorTypeDisable | Neither the front nor rear camera is mirrored. |
This API is used to turn the local camera on.
Note:Among
startVirtualCamera
,startCamera
, andstartScreenCapture
, only one can be used to publish data under the same pusher instance. If, for example,startCamera
is called first and thenstartVirtualCamera
, the SDK will pause the publishing of camera data and start image publishing.
- (V2TXLiveCode)startCamera:(BOOL)frontCamera
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to turn the local camera off.
- (V2TXLiveCode)stopCamera
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to start image publishing.
Note:Among
startVirtualCamera
,startCamera
, andstartScreenCapture
, only one can be used to publish data under the same pusher instance. If, for example,startCamera
is called first and thenstartVirtualCamera
, the SDK will pause the publishing of camera data and start image publishing.
- (V2TXLiveCode)startVirtualCamera:(TXImage *)image
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to stop image publishing.
- (V2TXLiveCode)stopVirtualCamera
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to start screen recording.
Note:
- To start screen recording on iOS, instead of using this API, you need to do the following.
- Among
startVirtualCamera
,startCamera
, andstartScreenCapture
, only one can be used to publish data under the same pusher instance. If, for example,startCamera
is called first and thenstartVirtualCamera
, the SDK will pause the publishing of camera data and start image publishing.
enableCustomVideoCapture
to enable custom capturing. sendCustomVideoFrame
to send the screen images captured by Broadcast Upload Extension.- (V2TXLiveCode)startScreenCapture:(NSString *)appGroup
Parameter | Type | Description |
---|---|---|
appGroup | NSString * | The App Group ID shared by the host app and Broadcast Upload Extension. It can be set to nil , but setting it as instructed in our documentation will make the feature more reliable. |
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to stop screen recording.
- (V2TXLiveCode)stopScreenCapture
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to take a screenshot of the local video while it is being published.
Note:After
V2TXLIVE_OK
is returned, you can get the screenshot taken in theV2TXLivePusherObserver#onSnapshotComplete:(TXImage *)image
callback.
- (V2TXLiveCode)snapshot
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_REFUSED
: failed to take a screenshot because publishing has stopped.This API is used to set a watermark for the publisher. Watermarking is disabled by default.
- (V2TXLiveCode)setWatermark:(TXImage *)image x:(float)x y:(float)y scale:(float)scale
Parameter | Type | Description |
---|---|---|
image | TXImage * | Watermark image. If this parameter is null , it means watermarking is disabled. |
x | float | Horizontal coordinate of the watermark |
y | float | Vertical coordinate of the watermark |
scale | float | Scale ratio of the watermark image |
This API is used to set the mirror mode of encoded images.
- (V2TXLiveCode)setEncoderMirror:(BOOL)mirror
Parameter | Type | Description |
---|---|---|
mirror | BOOL | Whether to mirror encoded images. Default value: NO |
This API is used to enable/disable custom video capturing. In the custom video capturing mode, the SDK stops capturing images from the camera, but continues to encode and send images.
- (V2TXLiveCode)enableCustomVideoCapture:(BOOL)enable
Parameter | Type | Description |
---|---|---|
enable | BOOL | Whether to enable custom capturing. Default value: NO |
This API is used to send the custom video data captured to the SDK.
- (V2TXLiveCode)sendCustomVideoFrame:(V2TXLiveVideoFrame *)videoFrame
Parameter | Type | Description |
---|---|---|
videoFrame | V2TXLiveVideoFrame * | Video frames sent to the SDK |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_INVALID_PARAMETER
: operation failed because the video data is invalid.V2TXLIVE_ERROR_REFUSED
: failed. You must call enableCustomVideoCapture
to enable custom video capturing first.This API is used to enable/disable custom video processing.
- (V2TXLiveCode)enableCustomVideoProcess:(BOOL)enable pixelFormat:(V2TXLivePixelFormat)pixelFormat bufferType:(V2TXLiveBufferType)bufferType
Parameter | Type | Description |
---|---|---|
enable | BOOL | Whether to enable custom video processing. Default value: NO |
pixelFormat | V2TXLivePixelFormat | Pixel format of video frames |
bufferType | V2TXLiveBufferType | Buffer type of video data |
V2TXLivePixelFormat
enumerated valuesValue | Description |
---|---|
V2TXLivePixelFormatUnknown | Unknown |
V2TXLivePixelFormatI420 | YUV420P (I420) |
V2TXLivePixelFormatTexture2D | OpenGL 2D texture |
V2TXLiveBufferType
enumerated valuesValue | Description |
---|---|
V2TXLiveBufferTypeUnknown | Unknown |
V2TXLiveBufferTypeByteBuffer | DirectBuffer , which carries buffers in the format of I420 and others and is used at the native layer. |
V2TXLiveBufferTypeByteArray | byte[] , which carries buffers in the format of I420 and others and is used at the Java layer. |
V2TXLiveBufferTypeTexture | Texture ID, which allows direct operation. It delivers the best performance and has the smallest impact on video quality. |
This API is used to send SEI messages. The player V2TXLivePlayer can receive SEI messages via the onReceiveSeiMessage
callback in V2TXLivePlayerObserver.
- (V2TXLiveCode)sendSeiMessage:(int)payloadType data:(NSData *)data;
Parameter | Type | Description |
---|---|---|
payloadType | int | Data type. Valid values: 5 , 242 (recommended) |
data | NSData * | Data to send |
V2TXLiveCode:
V2TXLIVE_OK
: successful
This API is used to get the beauty filter management object TXBeautyManager.
You can do the following using TXBeautyManager
:
- (TXBeautyManager *)getBeautyManager
This API is used to turn the mic on.
- (V2TXLiveCode)startMicrophone
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to turn the mic off.
- (V2TXLiveCode)stopMicrophone
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to set audio quality.
- (V2TXLiveCode)setAudioQuality:(V2TXLiveAudioQuality)quality
Parameter | Type | Description |
---|---|---|
quality | V2TXLiveAudioQuality | Audio quality |
V2TXLiveAudioQuality
enumerated valuesValue | Description |
---|---|
V2TXLiveAudioQualitySpeech | Speech. Audio sample rate: 16 kHz; sound channel: mono; bitrate: 16 Kbps This is designed for speech-based call scenarios such as online conferencing and audio call. |
V2TXLiveAudioQualityDefault | Default. Audio sample rate: 48 kHz; sound channel: mono; bitrate: 50 Kbps This is the default audio quality of the SDK and is recommended. |
V2TXLiveAudioQualityMusic | Music. Audio sample rate: 48 kHz; sound channel: dual; bitrate: 128 Kbps This is designed for music-oriented scenarios with hi-fi requirements, such as karaoke and live music streaming. |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_REFUSED
: you cannot change audio quality settings when streams are being published.This API is used to enable the volume reminder for audio capturing.
Note:After enabling the volume reminder, you can get the SDK’s volume evaluation through the
V2TXLivePusherObserver#onMicrophoneVolumeUpdate:(NSInteger)volume
callback.
- (V2TXLiveCode)enableVolumeEvaluation:(NSInteger)intervalMs;
Parameter | Type | Description |
---|---|---|
intervalMs | NSInteger | Interval (ms) for triggering the onMicrophoneVolumeUpdate callback. The minimum interval allowed is 100 ms. If the value is 0 (default) or smaller, the callback is disabled. 300 is recommended. |
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to get the audio effect management object TXAudioEffectManager.
You can do the following using TXAudioEffectManager
:
- (TXAudioEffectManager *)getAudioEffectManager
This API is used to get the device management object TXDeviceManager.
You can do the following using TXDeviceManager
:
- (TXDeviceManager *)getDeviceManager;
This API is used to call the advanced APIs of V2TXLivePusher
.
- (V2TXLiveCode)setProperty:(NSString *)key value:(NSObject *)value
Parameter | Type | Description |
---|---|---|
key | NSString * | Key of the advanced API to call |
value | NSObject * | Parameters required by the advanced API |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_INVALID_PARAMETER
: operation failed because key
is empty.This API is used to set On-Cloud MixTranscoding parameters. If you have enabled relayed push on the Function Configuration page of the TRTC console, then each channel of image will have a default CDN live streaming address. There may be multiple hosts in a room, each sending their own video and audio, but CDN audience needs only one live stream. Therefore, you need to mix multiple audio/video streams into one standard live stream, which requires MixTranscoding.
- (V2TXLiveCode)setMixTranscodingConfig:(V2TXLiveTranscodingConfig *)config
Parameter | Type | Description |
---|---|---|
config | V2TXLiveTranscodingConfig * | On-Cloud MixTranscoding configuration |
Value | Description |
---|---|
V2TXLiveBufferTypeUnknown | Unknown |
V2TXLiveBufferTypeByteBuffer | DirectBuffer , which carries buffers in the format of I420 and others and is used at the native layer. |
V2TXLiveBufferTypeByteArray | byte[] , which carries buffers in the format of I420 and others and is used at the Java layer. |
V2TXLiveBufferTypeTexture | Texture ID, which allows direct operation. It delivers the best performance and has the smallest impact on video quality. |
This API is used to set whether to display the dashboard.
- (void)showDebugView:(BOOL)isShow
Parameter | Type | Description |
---|---|---|
isShow | BOOL | Whether to show the debug view. Default value: NO |
Was this page helpful?