Tencent Cloud live pusher.
The live pusher encodes the local audio and video data and pushes the encoded data to a specified push URL.
The pusher has the following capabilities:
- Customized video collection, which allows you to customize your audio and video data sources based on the project requirements.
- Beauty filters, filters, and stickers. The pusher contains multiple sets of beauty retouch algorithms (natural & smooth) and multiple color space filters (supporting custom filters).
- QoS traffic throttling technology and uplink network adaptation capability. The pusher can adjust the audio and video data volumes in real time based on the actual network conditions on the host side.
- Face feature adjustment and animated widgets. The pusher supports fine-tuning of facial features, such as big eyes, thin face, and nose effects, based on YouTu AI face recognition technology and animated widget effects. You only need to purchase the YouTu license to easily implement a wide range of livestreaming effects.
◆ liteav::V2TXLivePusher
class liteav::V2TXLivePusher |
◆ ~V2TXLivePusher()
Calls the advanced API of V2TXLivePusher.
- Attention
- This API is used to call some advanced features.
- Parameters
-
key | Key of the advanced API. |
value | Parameter needed to call the advanced API corresponding to the key. |
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The key cannot be nullptr.
◆ enableCustomVideoCapture()
virtual int32_t enableCustomVideoCapture |
( |
bool |
enable | ) |
|
|
pure virtual |
Enables or disables custom video capture.
In the custom video capture mode, the SDK no longer captures images from cameras. Only the encoding and sending capabilities are retained.
- Attention
- This API takes effect only when it is called before startPush .
- Parameters
-
enable | true : enable custom video capture; false (default): disable custom video capture |
- Returns
- Return code for V2TXLiveCode
◆ enableVolumeEvaluation()
virtual int32_t enableVolumeEvaluation |
( |
int32_t |
intervalMs | ) |
|
|
pure virtual |
Enables volume update.
After this feature is enabled, you can obtain the volume evaluation through the V2TXLivePusherObserver#onMicrophoneVolumeUpdate(int) callback.
- Parameters
-
intervalMs | Interval for triggering the volume callback. The unit is ms. The minimum interval is 100 ms. If the value is equal to or smaller than 0, the callback is disabled. We recommend that you set this parameter to 300 ms. [Default]: 0. |
- Returns
- Return code for V2TXLiveCode
◆ getAudioEffectManager()
Obtains the audio effect manager TXAudioEffectManager.
With the audio effect manager, you can use the following features:
- Adjust the volume of human voice collected by the microphone.
- Set the reverb and voice changing effects.
- Start the headphone monitor, and set the volume of the headphone monitor.
- Add the BGM, and adjust the playback effect of BGM.
◆ getDeviceManager()
Obtains the video device manager TXDeviceManager.
With the device manager, you can use the following features:
- Switch between the front and rear cameras.
- Set the auto focus.
- Adjust the camera magnification.
- Turn the flash on or off.
- Switch between the earphone and speaker.
- Modify the volume type (media volume or conversation volume).
◆ isPushing()
virtual int32_t isPushing |
( |
| ) |
|
|
pure virtual |
Indicates whether the pusher is currently pushing streams.
- Returns
- Indicates whether the pusher is pushing streams.
◆ pauseAudio()
virtual int32_t pauseAudio |
( |
| ) |
|
|
pure virtual |
Enables the image streaming.
- Parameters
-
- Attention
- startVirtualCamera, startCamera, startScreenCapture, if use the same Pusher instance, only one can publish. To switch between different capture sources, first stop the previous capture source, and then start the next capture source to ensure that start and stop of the same capture source are called in pairs. eg: when the capture source is switched from Camera to VirtualCamera, the call sequence is startCamera -> stopCamera -> startVirtualCamera.
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: successful Disables the image streaming.
-
Return code for V2TXLiveCode
- V2TXLIVE_OK: successful Pause the audio stream of the pusher.
-
Return code for V2TXLiveCode
◆ pauseVideo()
virtual int32_t pauseVideo |
( |
| ) |
|
|
pure virtual |
Pause the video stream of the pusher.
- Returns
- Return code for V2TXLiveCode
◆ resumeAudio()
virtual int32_t resumeAudio |
( |
| ) |
|
|
pure virtual |
Resume the audio stream of the pusher.
- Returns
- Return code for V2TXLiveCode
◆ resumeVideo()
virtual int32_t resumeVideo |
( |
| ) |
|
|
pure virtual |
Resume the video stream of the pusher.
- Returns
- Return code for V2TXLiveCode
◆ sendCustomVideoFrame()
Sends the collected video data to the SDK in the custom video capture mode.
In the custom video capture mode, the SDK no longer captures images from cameras. Only the encoding and sending capabilities are retained. You can pack collected SampleBuffer packets into V2TXLiveVideoFrame and periodically send them through this API.
- Attention
- You must call V2TXLivePusher#enableCustomVideoCapture(boolean) to enable custom video capture before V2TXLivePusher#startPush(String) .
- Parameters
-
- Returns
- Return code for V2TXLiveCode
◆ sendSeiMessage()
virtual int32_t sendSeiMessage |
( |
int |
payloadType, |
|
|
const uint8_t * |
data, |
|
|
uint32_t |
dataSize |
|
) |
| |
|
pure virtual |
Turn on/off custom audio capture.
In the custom audio capture mode, the SDK no longer collects sound from the microphone, and only retains the encoding and sending capabilities.
Sets the callback of local video for custom rendering.
You can use this API to obtain each frame of decoded video and render them by yourself.
- Parameters
-
enable | Whether to enable custom rendering. Default value: false |
pixelFormat | Pixel format of the video called back for custom rendering V2TXLivePixelFormat |
bufferType | Data format of the video called back for custom rendering V2TXLiveBufferType |
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: successful Turn on/off custom audio capture.
- Attention
- It needs to be called before startPush to take effect.
- Parameters
-
enable | true: Open custom capture; false: Close custom capture.**Default value**: false |
- Returns
- Return code for V2TXLiveCode
V2TXLIVE_OK
: successful In the custom audio collection mode, send the collected audio data to the SDK
In the custom audio collection mode, the collected audio data is sent to the SDK. The SDK no longer collects microphone data, and only retains the encoding and sending functions.
- Attention
- You need to call V2TXLivePusher#enableCustomAudioCapture(boolean) before startPush to enable custom capture.
- Parameters
-
- Returns
- Return code for V2TXLiveCode
V2TXLIVE_OK
: successful
V2TXLIVE_ERROR_REFUSED
: Sending failed, you must first call enableCustomAudioCapture to start custom audio capture Use SEI channel to send custom message
The player end V2TXLivePlayer can receive the message via onReceiveSeiMessage
callback in V2TXLivePlayerObserver.
- Parameters
-
payloadType | Payload type. Valid values: 5 , 242 , 242 recommended |
data | Data to be sent |
dataSize | Data size |
- Returns
- Return code for V2TXLiveCode
◆ setAudioQuality()
Sets the audio quality for pushing.
- Parameters
-
quality | Audio quality V2TXLiveAudioQuality
- V2TXLiveAudioQualityDefault [Default]: universal
- V2TXLiveAudioQualitySpeech: speech
- V2TXLiveAudioQualityMusic: music
|
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_REFUSED: the audio quality cannot be adjusted in the pushing process.
◆ setEncoderMirror()
virtual int32_t setEncoderMirror |
( |
bool |
mirror | ) |
|
|
pure virtual |
Sets the video encoder mirror.
- Attention
- The encoder mirror only influences video effects on the audience side.
- Parameters
-
mirror | Specifies whether the mirrored images are viewed.
- false [Default]: non-mirrored images are viewed on the player side.
- true: mirrored images are viewed on the player side.
|
- Returns
- Return code for V2TXLiveCode
◆ setObserver()
Sets the pusher callback.
By setting the callback, you can listen to some callback events of V2TXLivePusher, including the pusher status, volume callback, statistics, warnings, and error messages.
- Parameters
-
◆ setRenderMirror()
Sets the view mirror of the local camera.
Local cameras are divided into the front camera and the rear camera. By default, images from the front camera are mirrored, and images from the rear camera are not mirrored. Here, you can modify the default mirror type of the front or rear camera.
- Parameters
-
mirrorType | Mirror type of the camera V2TXLiveMirrorType
- V2TXLiveMirrorTypeAuto [Default]: default mirror type. In this case, images from the front camera are mirrored, and images from the rear camera are not mirrored.
- V2TXLiveMirrorTypeEnable: both the front camera and rear camera are switched to mirror mode.
- V2TXLiveMirrorTypeDisable: both the front camera and rear camera are switched to non-mirror mode.
|
- Returns
- Return code for V2TXLiveCode
◆ setRenderRotation()
Sets the rotation angle of the view.
- Attention
- Only the view is rotated, and images that are pushed are not affected.
- Parameters
-
rotation | Rotation angle of the view V2TXLiveRotation
- V2TXLiveRotation0 [Default]: 0 degrees, which means the view is not rotated.
- V2TXLiveRotation90: rotate 90 degrees clockwise.
- V2TXLiveRotation180: rotate 180 degrees clockwise.
- V2TXLiveRotation270: rotate 270 degrees clockwise.
|
- Returns
- Return code for V2TXLiveCode
◆ setRenderView()
virtual int32_t setRenderView |
( |
void * |
view | ) |
|
|
pure virtual |
Sets the local camera preview.
Images collected by the local camera will be eventually displayed on the view that is passed in after it is overlaid by multiple effects, such as beauty filters, facial feature adjustments, and filters.
- Parameters
-
view | Local camera preview. |
- Returns
- Return code for V2TXLiveCode
◆ setVideoQuality()
Set the video encoding parameters for pushing.
- Parameters
-
- Returns
- Return code for V2TXLiveCode
◆ setWatermark()
virtual int32_t setWatermark |
( |
const char * |
watermarkPath, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
scale |
|
) |
| |
|
pure virtual |
Sets the pusher watermark image. By default, the watermark is disabled.
The watermark position is determined by the x
, y
, and scale
parameters.
x
: X coordinate of watermark, which is a floating-point number between 0 and 1.
y
: Y coordinate of watermark, which is a floating-point number between 0 and 1.
scale
: watermark dimensions ratio, which is a floating-point number between 0 and 1.
- Parameters
-
watermarkPath | watermark image path (if nullptr is passed in, the watermark will be removed) |
x | Top-left offset on the X axis of watermark |
y | Top-left offset on the Y axis of watermark |
scale | Ratio of watermark width to image width (the watermark will be scaled according to this parameter) |
- Returns
- Return code for V2TXLiveCode
- Attention
- watermarkPath
- On iOS/macOS, if images are saved in
.xcassets
, pass in the file name: self.pusher->setWatermark(“imageName”, 0.1, 0.1, 0.2);
- On Android, if images are saved in the
assets
directory, pass in the file name or path: self.pusher->setWatermark(“imageName.png”, 0.1, 0.1, 0.2); In other cases, get the file path as required by the platform and pass it in.
◆ showDebugView()
virtual void showDebugView |
( |
bool |
isShow | ) |
|
|
pure virtual |
Indicates whether the debug view of the pusher video status information is displayed.
- Parameters
-
isShow | Specifies whether to display the debug view. [Default]: false |
◆ snapshot()
virtual int32_t snapshot |
( |
| ) |
|
|
pure virtual |
Captures the local view in the pushing process.
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: successful
- V2TXLIVE_ERROR_REFUSED: pushing is stopped, and the snapshot operation cannot be called.
◆ startMicrophone()
virtual int32_t startMicrophone |
( |
| ) |
|
|
pure virtual |
Enables the local microphone.
- Returns
- Return code for V2TXLiveCode
◆ startPush()
virtual int32_t startPush |
( |
const char * |
url | ) |
|
|
pure virtual |
Starts pushing the audio and video data.
- Parameters
-
url | Push URL, which can be any push server. |
- Returns
- Return code for V2TXLiveCode
- V2TXLIVE_OK: operation succeeded. The pusher starts connecting to the target push URL.
- V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The URL is invalid.
- V2TXLIVE_ERROR_INVALID_LICENSE: operation failed. The license is invalid and authentication failed.
- V2TXLIVE_ERROR_REFUSED: operation failed. Duplicate streamId, please ensure that no other player or pusher is using this streamId now.
◆ stopCamera()
virtual int32_t stopCamera |
( |
| ) |
|
|
pure virtual |
Disables the local camera.
- Returns
- Return code for V2TXLiveCode
◆ stopMicrophone()
virtual int32_t stopMicrophone |
( |
| ) |
|
|
pure virtual |
Disables the microphone.
- Returns
- Return code for V2TXLiveCode
◆ stopPush()
virtual int32_t stopPush |
( |
| ) |
|
|
pure virtual |
Stops pushing the audio and video data.
- Returns
- Return code for V2TXLiveCode
◆ createV2TXLivePusher()
Gets the V2TXLivePusher
object pointer during dynamic DLL loading.
- Returns
- The
V2TXLivePusher
object pointer is returned. Please call releaseV2TXLivePusher
to destruct the object.
- Parameters
-
mode | Stream publishing protocol. Valid values: RTMP , ROOM |
- Attention
- This API works on Windows, macOS, and iOS.
◆ releaseV2TXLivePusher()
Destructs the V2TXLivePusher
object.
- Parameters
-
pusher | Pointer to the V2TXLivePusher object |