LiteAVSDK
Tencent Cloud TRTC SDK, is a high availability components serving tens of thousands of enterprise customers, which is committed to helping you to minimize your research and development costs.
V2TXLivePusher

Namespaces

 liteav
 

Data Structures

class  V2TXLivePusher
 

create or destroy V2TXLivePusher instance

V2_API liteav::V2TXLivePushercreateV2TXLivePusher (liteav::V2TXLiveMode mode)
 
V2_API void releaseV2TXLivePusher (liteav::V2TXLivePusher *pusher)
 

Detailed Description

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:


Data Structure Documentation

◆ liteav::V2TXLivePusher

class liteav::V2TXLivePusher

Public Member Functions

virtual void setObserver (V2TXLivePusherObserver *observer)=0
 
virtual int32_t setRenderView (void *view)=0
 
virtual int32_t setRenderMirror (V2TXLiveMirrorType mirrorType)=0
 
virtual int32_t setEncoderMirror (bool mirror)=0
 
virtual int32_t setRenderRotation (V2TXLiveRotation rotation)=0
 
virtual int32_t stopCamera ()=0
 
virtual int32_t startMicrophone ()=0
 
virtual int32_t stopMicrophone ()=0
 
virtual int32_t pauseAudio ()=0
 
virtual int32_t resumeAudio ()=0
 
virtual int32_t pauseVideo ()=0
 
virtual int32_t resumeVideo ()=0
 
virtual int32_t startPush (const char *url)=0
 
virtual int32_t stopPush ()=0
 
virtual int32_t isPushing ()=0
 
virtual int32_t setAudioQuality (V2TXLiveAudioQuality quality)=0
 
virtual int32_t setVideoQuality (const V2TXLiveVideoEncoderParam &param)=0
 
virtual ITXAudioEffectManagergetAudioEffectManager ()=0
 
virtual ITXDeviceManagergetDeviceManager ()=0
 
virtual int32_t snapshot ()=0
 
virtual int32_t setWatermark (const char *watermarkPath, float x, float y, float scale)=0
 
virtual int32_t enableVolumeEvaluation (int32_t intervalMs)=0
 
virtual int32_t enableCustomVideoCapture (bool enable)=0
 
virtual int32_t sendCustomVideoFrame (V2TXLiveVideoFrame *videoFrame)=0
 
virtual int32_t sendSeiMessage (int payloadType, const uint8_t *data, uint32_t dataSize)=0
 
virtual void showDebugView (bool isShow)=0
 

Protected Member Functions

virtual ~V2TXLivePusher ()
 

Constructor & Destructor Documentation

◆ ~V2TXLivePusher()

virtual ~V2TXLivePusher ( )
inlineprotectedvirtual

Calls the advanced API of V2TXLivePusher.

Attention
This API is used to call some advanced features.
Parameters
keyKey of the advanced API.
valueParameter 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.

Member Function Documentation

◆ 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
enabletrue: enable custom video capture; false (default): disable custom video capture
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ 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
intervalMsInterval 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
  • V2TXLIVE_OK: successful

◆ getAudioEffectManager()

virtual ITXAudioEffectManager* getAudioEffectManager ( )
pure virtual

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()

virtual ITXDeviceManager* getDeviceManager ( )
pure virtual

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.
  • 1: yes
  • 0: no

◆ pauseAudio()

virtual int32_t pauseAudio ( )
pure virtual

Enables the image streaming.

Parameters
imageimage
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
  • V2TXLIVE_OK: successful

◆ pauseVideo()

virtual int32_t pauseVideo ( )
pure virtual

Pause the video stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ resumeAudio()

virtual int32_t resumeAudio ( )
pure virtual

Resume the audio stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ resumeVideo()

virtual int32_t resumeVideo ( )
pure virtual

Resume the video stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ sendCustomVideoFrame()

virtual int32_t sendCustomVideoFrame ( V2TXLiveVideoFrame videoFrame)
pure virtual

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
videoFrameVideo frames sent to the SDK V2TXLiveVideoFrame
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
enableWhether to enable custom rendering. Default value: false
pixelFormatPixel format of the video called back for custom rendering V2TXLivePixelFormat
bufferTypeData 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
enabletrue: 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
audioFrameAudio frame data sent to SDK V2TXLiveAudioFrame
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
payloadTypePayload type. Valid values: 5, 242, 242 recommended
dataData to be sent
dataSizeData size
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ setAudioQuality()

virtual int32_t setAudioQuality ( V2TXLiveAudioQuality  quality)
pure virtual

Sets the audio quality for pushing.

Parameters
qualityAudio 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
mirrorSpecifies 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
  • V2TXLIVE_OK: successful

◆ setObserver()

virtual void setObserver ( V2TXLivePusherObserver observer)
pure virtual

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
observerCallback target of the pusher. For more information, see V2TXLivePusherObserver

◆ setRenderMirror()

virtual int32_t setRenderMirror ( V2TXLiveMirrorType  mirrorType)
pure virtual

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
mirrorTypeMirror 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
  • V2TXLIVE_OK: successful

◆ setRenderRotation()

virtual int32_t setRenderRotation ( V2TXLiveRotation  rotation)
pure virtual

Sets the rotation angle of the view.

Attention
Only the view is rotated, and images that are pushed are not affected.
Parameters
rotationRotation 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
  • V2TXLIVE_OK: successful

◆ 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
viewLocal camera preview.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ setVideoQuality()

virtual int32_t setVideoQuality ( const V2TXLiveVideoEncoderParam param)
pure virtual

Set the video encoding parameters for pushing.

Parameters
paramvideo encoding parameters V2TXLiveVideoEncoderParam
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ 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
watermarkPathwatermark image path (if nullptr is passed in, the watermark will be removed)
xTop-left offset on the X axis of watermark
yTop-left offset on the Y axis of watermark
scaleRatio of watermark width to image width (the watermark will be scaled according to this parameter)
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful
Attention
watermarkPath
  1. On iOS/macOS, if images are saved in .xcassets, pass in the file name: self.pusher->setWatermark(“imageName”, 0.1, 0.1, 0.2);
  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
isShowSpecifies 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
  • V2TXLIVE_OK: successful

◆ startPush()

virtual int32_t startPush ( const char *  url)
pure virtual

Starts pushing the audio and video data.

Parameters
urlPush 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
  • V2TXLIVE_OK: successful

◆ stopMicrophone()

virtual int32_t stopMicrophone ( )
pure virtual

Disables the microphone.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ stopPush()

virtual int32_t stopPush ( )
pure virtual

Stops pushing the audio and video data.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

Function Documentation

◆ createV2TXLivePusher()

V2_API liteav::V2TXLivePusher* createV2TXLivePusher ( liteav::V2TXLiveMode  mode)

Gets the V2TXLivePusher object pointer during dynamic DLL loading.

Returns
The V2TXLivePusher object pointer is returned. Please call releaseV2TXLivePusher to destruct the object.
Parameters
modeStream publishing protocol. Valid values: RTMP, ROOM
Attention
This API works on Windows, macOS, and iOS.

◆ releaseV2TXLivePusher()

V2_API void releaseV2TXLivePusher ( liteav::V2TXLivePusher pusher)

Destructs the V2TXLivePusher object.

Parameters
pusherPointer to the V2TXLivePusher object