tencent cloud

Feedback

V2TXLivePusher

Last updated: 2024-11-28 17:46:19
    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

    V2TXLivePusher

    FuncList
    DESC
    Release V2TXLivePusher resources
    Sets the pusher callback
    Sets the local camera preview
    Sets the local camera preview
    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 screen capture
    Disables video capture
    Pause the audio stream of the pusher
    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
    Enable system audio capturing
    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

    release

    release

    Release `V2TXLivePusher` resources

    setObserver

    setObserver
    void setObserver
    (V2TXLivePusherObserver observer)

    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.
    Param
    DESC
    observer
    Callback target of the pusher. For more information, see V2TXLivePusherObserver.

    setRenderView

    setRenderView
    int setRenderView
    (TXCloudVideoView view)

    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.
    Param
    DESC
    view
    Local camera preview.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderView

    setRenderView
    int setRenderView
    (TextureView view)

    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.
    Param
    DESC
    view
    Local camera preview.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderView

    setRenderView
    int setRenderView
    (SurfaceView view)

    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.
    Param
    DESC
    view
    Local camera preview.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderMirror

    setRenderMirror
    int setRenderMirror
    (V2TXLiveMirrorType mirrorType)

    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.
    Param
    DESC
    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.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setEncoderMirror

    setEncoderMirror
    int setEncoderMirror
    (boolean mirror)

    Sets the video encoder mirror

    Param
    DESC
    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.
    Note
    The encoder mirror only influences video effects on the audience side.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderRotation

    setRenderRotation
    int setRenderRotation
    (V2TXLiveRotation rotation)

    Sets the rotation angle of the view

    Param
    DESC
    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.
    Note
    Only the view is rotated, and images that are pushed are not affected.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderFillMode

    setRenderFillMode
    int setRenderFillMode
    (V2TXLiveFillMode mode)

    Sets the fill mode of the local video image

    Param
    DESC
    mode
    Fill mode of the view V2TXLiveFillMode.
    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:

    Return code V2TXLiveCode
    V2TXLIVE_OK: successful

    startCamera

    startCamera
    int startCamera
    (boolean frontCamera)

    Enables the local camera

    Param
    DESC
    frontCamera
    Specifies whether to switch to the front camera.
    true Default : switch to the front camera.
    false: 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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    stopCamera

    stopCamera

    Disables the local camera

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    startMicrophone

    startMicrophone

    Enables the local microphone

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    stopMicrophone

    stopMicrophone

    Disables the microphone

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    startVirtualCamera

    startVirtualCamera
    int startVirtualCamera
    (Bitmap image)

    Enables the image streaming

    Param
    DESC
    image
    image.
    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    stopVirtualCamera

    stopVirtualCamera

    Disables the image streaming

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    startScreenCapture

    startScreenCapture

    Enables video screen capture

    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    stopScreenCapture

    stopScreenCapture

    Disables video capture

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    pauseAudio

    pauseAudio

    Pause the audio stream of the pusher

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    resumeAudio

    resumeAudio

    Resume the audio stream of the pusher

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    pauseVideo

    pauseVideo

    Pause the video stream of the pusher

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    resumeVideo

    resumeVideo

    Resume the video stream of the pusher

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    startPush

    startPush
    int startPush
    (String url)

    Starts pushing the audio and video data

    Param
    DESC
    url
    Push URL, which can be any push server.

    Return Desc:

    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.

    stopPush

    stopPush

    Stops pushing the audio and video data

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    isPushing

    isPushing

    Indicates whether the pusher is currently pushing streams

    Return Desc:

    Indicates whether the pusher is pushing streams.
    1: yes.
    0: no.

    setAudioQuality

    setAudioQuality
    int setAudioQuality
    (V2TXLiveAudioQuality quality)

    Sets the audio quality for pushing

    Param
    DESC
    quality
    Audio quality V2TXLiveAudioQuality.
    V2TXLiveAudioQualityDefault Default : universal.
    V2TXLiveAudioQualitySpeech: speech.
    V2TXLiveAudioQualityMusic: music.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.
    V2TXLIVE_ERROR_REFUSED: the audio quality cannot be adjusted in the pushing process.

    setVideoQuality

    setVideoQuality
    int setVideoQuality

    Set the video encoding parameters for pushing

    Param
    DESC
    param
    video encoding parameters V2TXLiveVideoEncoderParam.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    getBeautyManager

    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.
    
    please see TXBeautyManager

    getAudioEffectManager

    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.
    
    please see TXAudioEffectManager

    getDeviceManager

    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).
    
    please see TXDeviceManager

    snapshot

    snapshot

    Captures the local view in the pushing process

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.
    V2TXLIVE_ERROR_REFUSED: pushing is stopped, and the snapshot operation cannot be called.

    setWatermark

    setWatermark
    int setWatermark
    (Bitmap image
    
    float x
    
    float y
    
    float scale)

    Sets the pusher watermark image. By default, the watermark is disabled

    Param
    DESC
    image
    Watermark image. If the value is null, 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:

    Return code for V2TXLiveCode
    V2TXLIVE_OK: successful

    enableVolumeEvaluation

    enableVolumeEvaluation
    int enableVolumeEvaluation
    (int intervalMs)

    Enables volume update

    After this feature is enabled, you can obtain the volume evaluation through the onMicrophoneVolumeUpdate callback.
    Param
    DESC
    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    enableCustomVideoProcess

    enableCustomVideoProcess
    int enableCustomVideoProcess
    (boolean enable
    
    V2TXLivePixelFormat pixelFormat
    
    V2TXLiveBufferType bufferType)

    Enables or disables custom video processing

    Param
    DESC
    enable
    true : enable; false : disable (default).
    Note
    Supported format combinations:
    V2TXLivePixelFormatTexture2D+V2TXLiveBufferTypeTexture
    V2TXLivePixelFormatI420+V2TXLiveBufferTypeByteBuffer

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK : successful.
    V2TXLIVE_ERROR_NOT_SUPPORTED : unsupported format.

    enableCustomVideoCapture

    enableCustomVideoCapture
    int enableCustomVideoCapture
    (boolean enable)

    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.
    Param
    DESC
    enable
    true : enable custom video capture; false (default): disable custom video capture.
    Note
    This API takes effect only when it is called before startPush.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    enableCustomAudioCapture

    enableCustomAudioCapture
    int enableCustomAudioCapture
    (boolean enable)

    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 true: Open custom capture; false: Close custom capture. Default value : false .
    @return Return code for V2TXLiveCode.
    V2TXLIVE_OK : successful.

    sendCustomVideoFrame

    sendCustomVideoFrame
    int sendCustomVideoFrame
    (V2TXLiveVideoFrame videoFrame)

    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.
    Param
    DESC
    videoFrame
    Video frames sent to the SDK V2TXLiveVideoFrame.
    Note
    You must call enableCustomVideoCapture to enable custom video capture before startPush .

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.
    V2TXLIVE_ERROR_INVALID_PARAMETER: The video frames fail to be sent because they are invalid.

    sendCustomAudioFrame

    sendCustomAudioFrame
    int sendCustomAudioFrame
    (V2TXLiveAudioFrame audioFrame)

    In the custom audio collection mode, send the collected audio data to the SDK

    Param
    DESC
    audioFrame
    Audio frame data sent to SDK V2TXLiveAudioFrame.
    Note
    You need to call enableCustomAudioCapture(boolean) before startPush to enable custom capture.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK : successful.
    V2TXLIVE_ERROR_INVALID_PARAMETER : The audio frames fail to be sent because they are invalid.

    enableAudioProcessObserver

    enableAudioProcessObserver
    int enableAudioProcessObserver
    (boolean enable
    
    V2TXLiveDef.V2TXLiveAudioFrameObserverFormat format)

    Enables/Disables audio process callback

    Param
    DESC
    enable
    true : enable; false (default): disable.
    format
    audio frame format.
    Note
    This API works only if you call it before startPush.

    sendSeiMessage

    sendSeiMessage
    int sendSeiMessage
    (int payloadType
    
    byte[] data)

    Use SEI channel to send custom message

    
    The player end V2TXLivePlayer can receive the message via onReceiveSeiMessage callback in V2TXLivePlayerObserver.
    Param
    DESC
    data
    Data to be sent.
    payloadType
    Payload type. Valid values: 5 , 242 , 242 recommended.

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    startSystemAudioLoopback

    startSystemAudioLoopback

    Enable system audio capturing

    Captures the audio of the entire OS.
    The audio is then mixed into the audio captured by the mic before being published to the cloud.
    Note
    1. This interface only works on Android API 29 and above.
    2. You need to use this interface to enable system sound capture first, and it will take effect only when you call startScreenCapture to enable screen sharing.
    3. You need to add a foreground service to ensure that the system sound capture is not silenced, and set android:foregroundServiceType="mediaProjection".
    4. The SDK only capture audio of applications that satisfies the capture strategy and audio usage. Currently, the audio usage captured by the SDK includes USAGE_MEDIA, USAGE_GAME。

    showDebugView

    showDebugView
    void showDebugView
    (boolean isShow)

    Indicates whether the debug view of the pusher video status information is displayed

    Param
    DESC
    isShow
    Specifies whether to display the debug view. Default : false.

    setProperty

    setProperty
    int setProperty
    (String key
    
    Object value)

    Calls the advanced API of V2TXLivePusher

    Param
    DESC
    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.
    V2TXLIVE_ERROR_INVALID_PARAMETER: operation failed. The key cannot be nil.

    setMixTranscodingConfig

    setMixTranscodingConfig
    int 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 mixStreams 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 ====> /
    
    
    
    For more information, please see On-Cloud MixTranscoding.
    Param
    DESC
    config
    Please see the description of V2TXLiveTranscodingConfig in V2TXLiveDef.h . Passing in nil will cancel On-Cloud MixTranscoding.
    Note
    Notes:
    Only supported RTC mode.
    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK : successful.
    V2TXLIVE_ERROR_REFUSED : failed to set On-Cloud MixTranscoding parameters as stream pushing has not started.

    startLocalRecording

    startLocalRecording
    int 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:

    Return code for V2TXLiveCode.
    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

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

    Enable voice activity detection

    Note
    After turning on, you can get the start and stop of voice activities in the OnVoiceActivityDetectionUpdate callback
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support