Copyright (c) 2021 Tencent. All rights reserved.
Module: V2TXLivePusher @ TXLiteAVSDK
Function: Tencent Cloud live pusher
Function
Tencent Cloud Live Pusher
Introduce
It is mainly responsible for encoding the local audio and video images and pushing them to the specified streaming address, supporting any streaming server.
Flowmakers include the following capabilities:
Customized video capture, allowing you to customize your own audio and video data sources according to project needs.
Beautification, filters, stickers, including multiple sets of beautification and microdermabrasion algorithms (natural & smooth) and a variety of color space filters (support custom filters).
Qos flow control technology, with uplink network adaptive capability, can adjust the amount of audio and video data in real time according to the specific conditions of the host network.
Face shape adjustment, animation pendants, support face shape fine-tuning and animation pendant effects based on Youtu AI face recognition technology such as big eyes, thin face, nose augmentation, etc. You only need to purchase Youtu License to easily achieve rich live broadcast effects.
V2TXLivePusher
|
| Sets the pusher callback |
| Sets the local camera preview |
| Sets the view mirror of the local camera |
| Sets the video encoder mirror |
| Sets the rotation angle of the view |
| Sets the fill mode of the local video image |
| Enables the local camera |
| Disables the local camera |
| Enables the local microphone |
| Disables the microphone |
| Enables the image streaming |
| Disables the image streaming |
| Enables video capturing |
| Disables video capture |
| Mute local audio |
| Resume the audio stream of the pusher |
| Pause the video stream of the pusher |
| Resume the video stream of the pusher |
| Starts pushing the audio and video data |
| Stops pushing the audio and video data |
| Indicates whether the pusher is currently pushing streams |
| Sets the audio quality for pushing |
| Set the video encoding parameters for pushing |
| Obtains the beauty manager |
| Obtains the audio effect manager |
| Obtains the video device manager |
| Captures the local view in the pushing process |
| Sets the pusher watermark image. By default, the watermark is disabled |
| Enables volume update |
| Enables or disables custom video processing |
| Enables or disables custom video capture |
| Turn on/off custom audio capture |
| Sends the collected video data to the SDK in the custom video capture mode |
| In the custom audio collection mode, send the collected audio data to the SDK |
| Enables/Disables audio process callback |
| Use SEI channel to send custom message |
| Indicates whether the debug view of the pusher video status information is displayed |
| Calls the advanced API of V2TXLivePusher |
| Sets On-Cloud MixTranscoding parameters |
| Start recording audio and video stream |
| Stop recording audio and video stream |
| Enable voice activity detection |
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.
setRenderView:
- (V2TXLiveCode)setRenderView: | |
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.
|
view | Local camera preview. |
Return Desc:
V2TXLIVE_OK: successful.
setRenderMirror:
- (V2TXLiveCode)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.
|
mirrorType | 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. |
Return Desc:
V2TXLIVE_OK: successful.
setEncoderMirror:
- (V2TXLiveCode)setEncoderMirror: | |
Sets the video encoder mirror
|
mirror | Specifies whether the mirrored images are viewed. NO Default : non-mirrored images are viewed on the player side. YES: mirrored images are viewed on the player side. |
Note
The encoder mirror only influences video effects on the audience side.
Return Desc:
V2TXLIVE_OK: successful.
setRenderRotation:
- (V2TXLiveCode)setRenderRotation: | |
Sets the rotation angle of the view
|
rotation | 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. |
Note
Only the view is rotated, and images that are pushed are not affected.
Return Desc:
V2TXLIVE_OK: successful.
setRenderFillMode:
- (V2TXLiveCode)setRenderFillMode: | |
Sets the fill mode of the local video image
|
mode | V2TXLiveFillModeFill: Default: fill the screen with the image without leaving any black edges. If the aspect ratio of the view is different from that of the screen, part of the view will be cropped. V2TXLiveFillModeFit make the view fit the screen without cropping. If the aspect ratio of the view is different from that of the screen, black edges will appear. V2TXLiveFillModeScaleFill fill the screen with the stretched image, thus the length and width may not change proportionally. |
Return Desc:
V2TXLIVE_OK: successful
startCamera:
- (V2TXLiveCode)startCamera: | |
Enables the local camera
|
frontCamera | Specifies whether to switch to the front camera. YES Default : switch to the front camera. NO: switch to the rear camera. |
Note
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.
Return Desc:
V2TXLIVE_OK: successful.
stopCamera
Disables the local camera
Return Desc:
V2TXLIVE_OK: successful.
startMicrophone
Enables the local microphone
Return Desc:
V2TXLIVE_OK: successful.
stopMicrophone
Disables the microphone
Return Desc:
V2TXLIVE_OK: successful.
startVirtualCamera:
- (V2TXLiveCode)startVirtualCamera: | |
Enables the image streaming
Note
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.
Return Desc:
V2TXLIVE_OK: successful.
stopVirtualCamera
Disables the image streaming
Return Desc:
V2TXLIVE_OK: successful.
startScreenCapture:
- (V2TXLiveCode)startScreenCapture: | |
Enables video capturing
|
appGroup | The Application Group Identifier shared by the main App and Broadcast can be specified as nil. It is worth noting that the function will be more reliable according to the document guidelines. |
Note
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 ScreenCapture, the call sequence is startCamera -> stopCamera -> startScreenCapture.
Return Desc:
V2TXLIVE_ERROR_NOT_SUPPORTED: this feature is not supported.
stopScreenCapture
Disables video capture
Return Desc:
V2TXLIVE_OK: successful.
pauseAudio
Mute local audio
After muting the local audio, the SDK will not continue to collect the microphone sound,
The difference from stopMicrophone is pauseAudio does not stop sending audio data, instead continue to send silent packets with a very low bit rate.
Due to video file formats such as MP4, the continuity of the audio is very demanding. Using stopMicrophone will cause the recorded MP4 to be difficult to play.
Therefore, in scenes that require high recording quality, it is recommended to choose pauseAudio to record MP4 files with better compatibility.
Return Desc:
V2TXLIVE_OK: successful.
resumeAudio
Resume the audio stream of the pusher
Return Desc:
V2TXLIVE_OK: successful.
pauseVideo
Pause the video stream of the pusher
Return Desc:
V2TXLIVE_OK: successful.
resumeVideo
Resume the video stream of the pusher
Return Desc:
V2TXLIVE_OK: successful.
startPush:
- (V2TXLiveCode)startPush: | |
Starts pushing the audio and video data
|
url | Push URL, which can be any push server. |
Return Desc:
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.
stopPush
Stops pushing the audio and video data
Return Desc:
V2TXLIVE_OK: successful.
isPushing
Indicates whether the pusher is currently pushing streams
Return Desc:
Indicates whether the pusher is pushing streams.
1: yes.
0: no.
setAudioQuality:
- (V2TXLiveCode)setAudioQuality: | |
Sets the audio quality for pushing
|
quality | V2TXLiveAudioQualityDefault Default : universal. V2TXLiveAudioQualitySpeech: speech. V2TXLiveAudioQualityMusic: music. |
Return Desc:
V2TXLIVE_OK: successful.
V2TXLIVE_ERROR_REFUSED: the audio quality cannot be adjusted in the pushing process.
setVideoQuality:
- (V2TXLiveCode)setVideoQuality: | |
Set the video encoding parameters for pushing
Return Desc:
V2TXLIVE_OK: successful.
getBeautyManager
Obtains the beauty manager
With the beauty manager, you can use the following features:
Set the following cosmetic effects: beauty style, whitening, ruddy, big eyes, slim face, V-shape face, chin, short face, small nose, bright eyes, white teeth, remove eye bags, remove wrinkles, remove laugh lines.
Adjust the hairline, eye spacing, eye corners, mouth shape, nose wings, nose position, lip thickness, and face shape.
Set animated effects such as face widgets (materials).
Add makeup effects.
Recognize gestures.
getAudioEffectManager
Obtains the audio effect manager
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
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).
snapshot
Captures the local view in the pushing process
Return Desc:
V2TXLIVE_OK: successful.
V2TXLIVE_ERROR_REFUSED: pushing is stopped, and the snapshot operation cannot be called.
setWatermark:x:y:scale:
- (V2TXLiveCode)setWatermark: | |
| |
| |
| |
Sets the pusher watermark image. By default, the watermark is disabled
|
image | Watermark image. If the value is nil, it is equivalent to disabling the watermark. |
scale | Scaling ratio of the watermark. Valid range: 0 - 1. |
x | Display position of the watermark. Valid range: 0 - 1. |
y | Display position of the watermark. Valid range: 0 - 1. |
Return Desc:
V2TXLIVE_OK: successful.
enableVolumeEvaluation:
- (V2TXLiveCode)enableVolumeEvaluation: | |
Enables volume update
|
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. |
Return Desc:
V2TXLIVE_OK: successful.
enableCustomVideoProcess:pixelFormat:bufferType:
enableCustomVideoProcess:pixelFormat:bufferType:
- (V2TXLiveCode)enableCustomVideoProcess: | |
| |
| |
Enables or disables custom video processing
|
bufferType | Data format of callbacks. |
enable | YES : enable; NO : disable (default).
|
pixelFormat | Pixel format of callbacks. |
Note
Supported format combinations:
V2TXLivePixelFormatTexture2D+V2TXLiveBufferTypeTexture
V2TXLivePixelFormatNV12+V2TXLiveBufferTypePixelBuffer
V2TXLivePixelFormatBGRA32+V2TXLiveBufferTypePixelBuffer
Return Desc:
V2TXLIVE_OK
: successful.
V2TXLIVE_ERROR_NOT_SUPPORTED
: unsupported format.
enableCustomVideoCapture:
enableCustomVideoCapture:
- (V2TXLiveCode)enableCustomVideoCapture: | |
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.
|
enable | YES : enable custom video capture; NO (default): disable custom video capture.
|
Note
This API takes effect only when it is called before startPush. Return Desc:
V2TXLIVE_OK: successful.
enableCustomAudioCapture:
enableCustomAudioCapture:
- (V2TXLiveCode)enableCustomAudioCapture: | |
Turn on/off custom audio capture
@brief 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.
@note It needs to be called before startPush to take effect.
@param enable YES: Open custom capture; NO: Close custom capture. Default value
: NO
.
V2TXLIVE_OK
: successful.
sendCustomVideoFrame:
- (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.
Return Desc:
V2TXLIVE_OK: successful.
V2TXLIVE_ERROR_INVALID_PARAMETER: The video frames fail to be sent because they are invalid.
sendCustomAudioFrame:
- (V2TXLiveCode)sendCustomAudioFrame: | (V2TXLiveAudioFrame *)audioFrame |
In the custom audio collection mode, send the collected audio data to the SDK
Note
You need to call enableCustomAudioCapture(boolean) before startPush to enable custom capture. Return Desc:
V2TXLIVE_OK
: successful.
V2TXLIVE_ERROR_INVALID_PARAMETER
: The audio frames fail to be sent because they are invalid.
enableAudioProcessObserver:format:
enableAudioProcessObserver:format:
- (V2TXLiveCode)enableAudioProcessObserver: | |
| |
Enables/Disables audio process callback
|
enable | YES : enable; NO (default): disable.
|
format | audio frame format. |
Note
This API works only if you call it before startPush. sendSeiMessage:data:
- (V2TXLiveCode)sendSeiMessage: | |
| |
Use SEI channel to send custom message
|
data | Data to be sent. |
payloadType | Payload type. Valid values: 5 , 242 , 242 recommended. |
Return Desc:
V2TXLIVE_OK: successful.
showDebugView:
Indicates whether the debug view of the pusher video status information is displayed
|
isShow | Specifies whether to display the debug view. Default : NO. |
setProperty:value:
- (V2TXLiveCode)setProperty: | |
| |
Calls the advanced API of V2TXLivePusher
|
key | Key of the advanced API, please see V2TXLiveProperty. |
value | Parameter needed to call the advanced API corresponding to the key. |
Note
This API is used to call some advanced features.
Return Desc:
V2TXLIVE_OK: successful.
V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The key cannot be nil.
setMixTranscodingConfig:
- (V2TXLiveCode)setMixTranscodingConfig: | |
Sets On-Cloud MixTranscoding parameters
If you have enabled relayed push on the "Function Configuration" page of the TRTC console, then each stream in a room will have a default CDN address.
There may be multiple anchors 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 mixing and transcoding.
When you call the setMixTranscodingConfig()
API, the SDK will send a command to the Tencent Cloud transcoding server to combine multiple audio/video streams in the room into one stream.
You can use the mixUsers
parameter to set the position of each channel of image and specify whether to mix only audio. You can also set the encoding parameters of the mixed stream, including videoWidth
, videoHeight
, and videoBitrate
.
Image 1 => decoding ====> \\
\\
Image 2=> decoding => image mixing => encoding => mixed image
/
Image 3 => decoding ====> /
Audio 1 => decoding ====> \\
\\
Audio 2 => decoding => audio mixing => encoding => mixed audio
/
Audio 3 => decoding ====> /
|
config | Please see the description of V2TXLiveTranscodingConfig in V2TXLiveDef.h . Passing in nil will cancel On-Cloud MixTranscoding. |
Note
Notes:
On-Cloud MixTranscoding will increase the delay of CDN live streaming by about 1-2 seconds.
If you call this API, the streams of co-anchors will be mixed into your stream or the streamId
specified in config
.
If you are still in the room but do not need to mix streams anymore, make sure that you pass in nil
to cancel On-Cloud MixTranscoding. The On-Cloud MixTranscoding module starts working the moment you enable On-Cloud MixTranscoding. You may incur additional costs if you do not cancel it in a timely manner.
When you leave the room, mixing will be canceled automatically.
Return Desc:
V2TXLIVE_OK
: successful.
V2TXLIVE_ERROR_REFUSED
: failed to set On-Cloud MixTranscoding parameters as stream pushing has not started.
startLocalRecording:
- (V2TXLiveCode)startLocalRecording: | |
Start recording audio and video stream
Note
The recording can only be started after the push stream is started, and it is invalid to start the recording in the non-push state.
Do not dynamically switch the resolution and soft/hard editing during the recording process, as there is a high probability that the generated video will be abnormal.
Return Desc:
V2TXLIVE_OK
: successful.
V2TXLIVE_ERROR_INVALID_PARAMETER
: The parameter is invalid, such as filePath is empty.
V2TXLIVE_ERROR_REFUSED
: API refuse, you must first call startPush to start publishing streaming.
stopLocalRecording
Stop recording audio and video stream
Note
When the push stream is stopped, if the video is still being recorded, the SDK will automatically end the recording.
enableVoiceActivityDetection:
enableVoiceActivityDetection:
- (void)enableVoiceActivityDetection: | |
Enable voice activity detection
Note
After turning on, you can get the start and stop of voice activities in the OnVoiceActivityDetectionUpdate callback
Was this page helpful?