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.
V2TXLivePusher(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 addListener(V2TXLivePusherObserver func)
Parameter | Type | Description |
---|---|---|
observer | V2TXLivePusherObserver | Target object for the publisher’s callbacks. For details, 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.
Future<V2TXLiveCode> setRenderViewID(int viewID)
Parameter | Type | Description |
---|---|---|
viewID | int | The view ID, which is returned by V2TXLiveVideoWidget.onViewCreated(int viewID) . |
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to start publishing audio/video data.
Future<V2TXLiveCode> startPush(String url)
Parameter | Type | Description |
---|---|---|
url | String | The URL to which data is published. Any publishing server is supported. |
V2TXLiveCode:V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_INVALID_PARAMETER
: operation failed because the URL is invalid.V2TXLIVE_ERROR_REFUSED
: you cannot use the same stream ID for publishing and playback on the same device.This API is used to stop publishing audio/video data.
Future<V2TXLiveCode> stopPush()
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to get whether the publisher is publishing streams.
Future<V2TXLiveCode> isPushing()
Whether streams are being played
1
: yes0
: noThis API is used to set the video encoding parameters for publishing.
Future<V2TXLiveCode> setVideoQuality(V2TXLiveVideoEncoderParam param)
Parameter | Type | Description |
---|---|---|
param | V2TXLiveVideoEncoderParam | Video encoding parameters |
This API is used to set the rotation of local camera preview.
Future<V2TXLiveCode> setRenderRotation(V2TXLiveRotation rotation)
Parameter | Type | Description |
---|---|---|
rotation | V2TXLiveRotation | The 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.
Future<V2TXLiveCode> setRenderMirror(V2TXLiveMirrorType mirrorType)
Parameter | Type | Description |
---|---|---|
mirrorType | V2TXLiveMirrorType | The 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:The
startVirtualCamera
,startCamera
, andstartScreenCapture
APIs are mutually exclusive when you use them with the same pusher instance. For example, if you callstartCamera
first and then callstartVirtualCamera
, the SDK will stop publishing camera data and publish an image instead.
Future<V2TXLiveCode> startCamera(bool frontCamera)
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to turn the local camera off.
Future<void> stopCamera()
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to publish an image.
Note:The
startVirtualCamera
,startCamera
, andstartScreenCapture
APIs are mutually exclusive when you use them with the same pusher instance. For example, if you callstartCamera
first and then callstartVirtualCamera
, the SDK will stop publishing camera data and publish an image instead.
Future<V2TXLiveCode> startVirtualCamera(String type, String imageUrl)
V2TXLiveCode:V2TXLIVE_OK
: successful
Parameter | Type | Description |
---|---|---|
type | String | Valid values: network (an image from the internet), file (a local image). |
imageUrl | String | Image URL |
This API is used to stop publishing images.
Future<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.
- The
startVirtualCamera
,startCamera
, andstartScreenCapture
APIs are mutually exclusive when you use them with the same pusher instance. For example, if you callstartCamera
first and then callstartVirtualCamera
, the SDK will stop publishing camera data and publish an image instead.
enableCustomVideoCapture
to enable custom capturing. sendCustomVideoFrame
to send the screen images captured by Broadcast Upload Extension.Future<V2TXLiveCode> startScreenCapture(String appGroup)
Parameter | Type | Description |
---|---|---|
appGroup | String | The App Group ID shared by the host app and Broadcast Upload Extension. You can set it to nil , but for better reliability, we recommend you set it as instructed in our documentation. |
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to stop screen recording.
Future<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
callback.
Future<V2TXLiveCode> snapshot()
V2TXLiveCode:
V2TXLIVE_OK
: successfulV2TXLIVE_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.
Future<V2TXLiveCode> setWatermark(String type, String image, double x,
double y, double scale)
Parameter | Type | Description |
---|---|---|
type | String | Valid values: network (an image from the internet), file (a local image). |
image | String | Image URL |
x | double | Watermark coordinate |
y | double | Watermark coordinate |
scale | double | Percentage by which the image is resized |
This API is used to set the mirror mode of encoded images.
Future<V2TXLiveCode> setEncoderMirror(bool mirror)
Parameter | Type | Description |
---|---|---|
mirror | Boolean | Whether to mirror encoded images. Default value: false . |
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.
Future<V2TXLiveCode> enableCustomVideoCapture(bool enable)
Parameter | Type | Description |
---|---|---|
enable | bool | Whether to enable custom video capturing. Default value: false . |
This API is used to send the captured custom video data to the SDK.
Future<V2TXLiveCode> sendCustomVideoFrame(V2TXLiveVideoFrame videoFrame)
Parameter | Type | Description |
---|---|---|
videoFrame | V2TXLiveVideoFrame | Video frames sent to the SDK |
V2TXLiveCode:
V2TXLIVE_OK
: successfulV2TXLIVE_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.
Future<V2TXLiveCode> enableCustomVideoProcess(bool enable,
V2TXLivePixelFormat pixelFormat, V2TXLiveBufferType bufferType)
Parameter | Type | Description |
---|---|---|
enable | bool | Whether to enable custom video processing. Default value: false . |
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 | Direct buffers. This type is for I420 and other buffers and is used at the native layer. |
v2TXLiveBufferTypeByteArray | Byte arrays. This type is for I420 and other buffers 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 an SEI message. V2TXLivePlayer can receive SEI messages via the onReceiveSeiMessage
callback of V2TXLivePlayerObserver.
Future<V2TXLiveCode> sendSeiMessage(int payloadType, Uint8List data)
Parameter | Type | Description |
---|---|---|
payloadType | int | Data type. Valid values: 5 , 242 (recommended). |
data | Uint8List | Data to be sent |
V2TXLiveCode:
V2TXLIVE_OK
: successful
This API is used to get the beauty filter manager TXBeautyManager.
You can do the following using the beauty filter manger:
TXBeautyManager getBeautyManager()
This API is used to turn the mic on.
Future<V2TXLiveCode> startMicrophone()
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to turn the mic off.
Future<V2TXLiveCode> stopMicrophone()
V2TXLiveCode:V2TXLIVE_OK
: successful
This API is used to set audio quality.
Future<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 call scenarios such as online conferencing and audio calls. |
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
: successfulV2TXLIVE_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 volume measured by the SDK in the
V2TXLivePusherObserver.onMicrophoneVolumeUpdate
callback.
Future<V2TXLiveCode> enableVolumeEvaluation(int intervalMs)
Parameter | Type | Description |
---|---|---|
intervalMs | int | Interval (ms) for volume callbacks. 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 manager TXAudioEffectManager.
You can do the following using TXAudioEffectManager
:
TXAudioEffectManager getAudioEffectManager()
This API is used to get the device manager TXDeviceManager.
You can do the following using TXDeviceManager
:
TXDeviceManager getDeviceManager()
This API is used to call the advanced APIs of V2TXLivePusher
.
Future<V2TXLiveCode> setProperty(String key, String value)
Parameter | Type | Description |
---|---|---|
key | String | Key of the advanced API to call |
value | String | Parameters required by the advanced API |
V2TXLiveCode:
V2TXLIVE_OK
: successfulV2TXLIVE_ERROR_INVALID_PARAMETER
: operation failed because key
is empty.This API is used to set On-Cloud MixTranscoding parameters. If you have enabled relay to CDN on the Function Configuration page of the TRTC console, each anchor will have a default CDN address. There may be multiple anchors in a room, each sending their own video and audio, but the audience needs only one live stream. Therefore, you need to mix multiple audio/video streams into one standard live stream. This is MixTranscoding.
Future<V2TXLiveCode> setMixTranscodingConfig(V2TXLiveTranscodingConfig? config)
Parameter | Type | Description |
---|---|---|
config | V2TXLiveTranscodingConfig | On-Cloud MixTranscoding configuration |
Value | Description |
---|---|
v2TXLiveBufferTypeUnknown | Unknown |
v2TXLiveBufferTypeByteBuffer | Direct buffers. This type is for I420 and other buffers and is used at the native layer. |
v2TXLiveBufferTypeByteArray | Byte arrays. This type is for I420 and other buffers 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.
Future<V2TXLiveCode> showDebugView(bool isShow)
Parameter | Type | Description |
---|---|---|
isShow | bool | Whether to display the dashboard. Default value: false . |
Was this page helpful?