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

    setObserver:
    - (void)setObserver:
    (id<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:
    - (V2TXLiveCode)setRenderView:
    (TXView *)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:
    - (V2TXLiveCode)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:
    - (V2TXLiveCode)setEncoderMirror:
    (BOOL)mirror

    Sets the video encoder mirror

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

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    setRenderRotation:

    setRenderRotation:
    - (V2TXLiveCode)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:
    - (V2TXLiveCode)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:
    - (V2TXLiveCode)startCamera:
    (BOOL)frontCamera

    Enables the local camera

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

    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:
    - (V2TXLiveCode)startVirtualCamera:
    (TXImage *)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:
    - (V2TXLiveCode)startScreenCapture:
    (NSString *)appGroup

    Enables video capturing

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

    Return code for V2TXLiveCode.
    V2TXLIVE_ERROR_NOT_SUPPORTED: this feature is not supported.

    stopScreenCapture

    stopScreenCapture

    Disables video capture

    Return Desc:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    pauseAudio

    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:

    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:
    - (V2TXLiveCode)startPush:
    (NSString *)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:
    - (V2TXLiveCode)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:
    - (V2TXLiveCode)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:x:y:scale:

    setWatermark:x:y:scale:
    - (V2TXLiveCode)setWatermark:
    (TXImage *)image
    x:
    (float)x
    y:
    (float)y
    scale:
    (float)scale

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

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

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    enableVolumeEvaluation:

    enableVolumeEvaluation:
    - (V2TXLiveCode)enableVolumeEvaluation:
    (NSUInteger)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:pixelFormat:bufferType:

    enableCustomVideoProcess:pixelFormat:bufferType:
    - (V2TXLiveCode)enableCustomVideoProcess:
    (BOOL)enable
    pixelFormat:
    (V2TXLivePixelFormat)pixelFormat
    bufferType:
    (V2TXLiveBufferType)bufferType

    Enables or disables custom video processing

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

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

    enableCustomVideoCapture:

    enableCustomVideoCapture:
    - (V2TXLiveCode)enableCustomVideoCapture:
    (BOOL)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
    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:

    Return code for V2TXLiveCode.
    V2TXLIVE_OK: successful.

    enableCustomAudioCapture:

    enableCustomAudioCapture:
    - (V2TXLiveCode)enableCustomAudioCapture:
    (BOOL)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 YES: Open custom capture; NO: Close custom capture. Default value : NO .
    @return Return code for V2TXLiveCode.
    V2TXLIVE_OK : successful.

    sendCustomVideoFrame:

    sendCustomVideoFrame:
    - (V2TXLiveCode)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:
    - (V2TXLiveCode)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:format:

    enableAudioProcessObserver:format:
    - (V2TXLiveCode)enableAudioProcessObserver:
    (BOOL)enable
    format:

    Enables/Disables audio process callback

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

    sendSeiMessage:data:

    sendSeiMessage:data:
    - (V2TXLiveCode)sendSeiMessage:
    (int)payloadType
    data:
    (NSData *)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.

    showDebugView:

    showDebugView:
    - (void)showDebugView:
    (BOOL)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 : NO.

    setProperty:value:

    setProperty:value:
    - (V2TXLiveCode)setProperty:
    (NSString *)key
    value:
    (NSObject *)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:
    - (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 ====> /
    
    
    
    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:
    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:
    - (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:

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