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

Data Structures

protocol  <V2TXLivePusher>
 

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

◆ V2TXLivePusher-p

protocol V2TXLivePusher-p
+ Inheritance diagram for <V2TXLivePusher>:

Instance Methods

(void) - setObserver:
 
(V2TXLiveCode- setRenderView:
 
(V2TXLiveCode- setRenderMirror:
 
(V2TXLiveCode- setEncoderMirror:
 
(V2TXLiveCode- setRenderRotation:
 
(V2TXLiveCode- startCamera:
 
(V2TXLiveCode- startCamera:
 
(V2TXLiveCode- stopCamera
 
(V2TXLiveCode- startMicrophone
 
(V2TXLiveCode- stopMicrophone
 
(V2TXLiveCode- startVirtualCamera:
 
(V2TXLiveCode- stopVirtualCamera
 
(V2TXLiveCode- startScreenCapture:
 
(V2TXLiveCode- stopScreenCapture
 
(V2TXLiveCode- pauseAudio
 
(V2TXLiveCode- resumeAudio
 
(V2TXLiveCode- pauseVideo
 
(V2TXLiveCode- resumeVideo
 
(V2TXLiveCode- startPush:
 
(V2TXLiveCode- stopPush
 
(int) - isPushing
 
(V2TXLiveCode- setAudioQuality:
 
(V2TXLiveCode- setVideoQuality:
 
(TXBeautyManager *) - getBeautyManager
 
(TXAudioEffectManager *) - getAudioEffectManager
 
(TXDeviceManager *) - getDeviceManager
 
(V2TXLiveCode- snapshot
 
(V2TXLiveCode- setWatermark:x:y:scale:
 
(V2TXLiveCode- enableVolumeEvaluation:
 
(V2TXLiveCode- enableCustomVideoProcess:pixelFormat:bufferType:
 
(V2TXLiveCode- enableCustomVideoCapture:
 
(V2TXLiveCode- sendCustomVideoFrame:
 
(V2TXLiveCode- enableCustomAudioCapture:
 
(V2TXLiveCode- sendCustomAudioFrame:
 
(V2TXLiveCode- sendSeiMessage:data:
 
(void) - showDebugView:
 
(V2TXLiveCode- setProperty:value:
 
(V2TXLiveCode- setMixTranscodingConfig:
 

Method Documentation

◆ enableCustomAudioCapture:()

- (V2TXLiveCode) enableCustomAudioCapture: (BOOL)  enable

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.

Turn on/off custom audio capture.

Attention
It needs to be called before startPush to take effect.
Parameters
enableYES: Open custom capture; NO: Close custom capture.**Default value**: NO
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ 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.

Attention
This API takes effect only when it is called before startPush .
Parameters
enableYES: enable custom video capture; NO (default): disable custom video capture
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ enableCustomVideoProcess:pixelFormat:bufferType:()

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

Enables or disables custom video processing.

Attention
RTMP supports only callbacks in the format of OpenGL textures.
Parameters
enableYES: enable; NO: disable (default)
pixelFormatPixel format of callbacks. Note: only V2TXLivePixelFormatTexture2D is supported by RTMP.
bufferTypeData format of callbacks. Note: only V2TXLiveBufferTypeTexture is supported by RTMP.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful
  • V2TXLIVE_ERROR_NOT_SUPPORTED: unsupported format

◆ enableVolumeEvaluation:()

- (V2TXLiveCode) enableVolumeEvaluation: (NSUInteger)  intervalMs

Enables volume update.

After this feature is enabled, you can obtain the volume evaluation through the onMicrophoneVolumeUpdate 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()

- (TXAudioEffectManager *) 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.

◆ getBeautyManager()

- (TXBeautyManager *) getBeautyManager

Obtains the beauty manager TXBeautyManager

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.

◆ getDeviceManager()

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

- (int) isPushing

Indicates whether the pusher is currently pushing streams.

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

◆ pauseAudio()

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

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ pauseVideo()

- (V2TXLiveCode) pauseVideo

Pause the video stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ resumeAudio()

- (V2TXLiveCode) resumeAudio

Resume the audio stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ resumeVideo()

- (V2TXLiveCode) resumeVideo

Resume the video stream of the pusher.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ sendCustomAudioFrame:()

- (V2TXLiveCode) sendCustomAudioFrame: (V2TXLiveAudioFrame *)  audioFrame

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.

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

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

◆ 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.

Attention
You must call enableCustomVideoCapture to enable custom video capture before startPush .
Parameters
videoFrameVideo frames sent to the SDK V2TXLiveVideoFrame
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful
  • V2TXLIVE_ERROR_INVALID_PARAMETER: The video frames fail to be sent because they are invalid.
  • V2TXLIVE_ERROR_REFUSED: You must call enableCustomVideoCapture to enable custom video capture before startPush .

◆ 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.

Parameters
payloadTypePayload type. Valid values: 5, 242, 242 recommended
dataData to be sent
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ setAudioQuality:()

- (V2TXLiveCode) setAudioQuality: (V2TXLiveAudioQuality quality

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

- (V2TXLiveCode) setEncoderMirror: (BOOL)  mirror

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.
  • NO [Default]: non-mirrored images are viewed on the player side.
  • YES: mirrored images are viewed on the player side.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ setMixTranscodingConfig:()

- (V2TXLiveCode) setMixTranscodingConfig: (V2TXLiveTranscodingConfig *)  config

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.

Attention
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.
Parameters
configPlease see the description of V2TXLiveTranscodingConfig in V2TXLiveDef.h. Passing in nil will cancel On-Cloud MixTranscoding.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful
  • V2TXLIVE_ERROR_REFUSED: failed to set On-Cloud MixTranscoding parameters as stream pushing has not started

◆ 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.

Parameters
observerCallback target of the pusher. For more information, see V2TXLivePusherObserver

◆ setProperty:value:()

- (V2TXLiveCode) setProperty: (NSString *)  key
value: (NSObject *)  value 

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 nil.

◆ 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.

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

- (V2TXLiveCode) setRenderRotation: (V2TXLiveRotation rotation

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

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

Parameters
viewLocal camera preview.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ setVideoQuality:()

- (V2TXLiveCode) setVideoQuality: (V2TXLiveVideoEncoderParam *)  param

Set the video encoding parameters for pushing.

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

◆ 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.

Parameters
imageWatermark image. If the value is nil, it is equivalent to disabling the watermark.
xDisplay position of the watermark. Valid range: 0 - 1.
yDisplay position of the watermark. Valid range: 0 - 1.
scaleScaling ratio of the watermark. Valid range: 0 - 1.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ showDebugView:()

- (void) showDebugView: (BOOL)  isShow

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

Parameters
isShowSpecifies whether to display the debug view. [Default]: NO

◆ snapshot()

- (V2TXLiveCode) snapshot

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.

◆ startCamera:() [1/2]

- (V2TXLiveCode) startCamera: (BOOL)  frontCamera

Enables the local camera.

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.
Parameters
frontCameraSpecifies whether to switch to the front camera.
  • YES [Default]: switch to the front camera.
  • NO: switch to the rear camera.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ startCamera:() [2/2]

- (V2TXLiveCode) startCamera: (NSString *)  cameraId

Enables the local camera.

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.
Parameters
cameraIdcamera id
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ startMicrophone()

- (V2TXLiveCode) startMicrophone

Enables the local microphone.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ startPush:()

- (V2TXLiveCode) startPush: (NSString *)  url

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.

◆ startScreenCapture:()

- (V2TXLiveCode) startScreenCapture: (NSString *)  appGroup

Enables video capturing.

Attention
The iOS system currently does not support the use of this API to enable video capture.
iOS Broadcast Upload Extension must be used to enable video capture. Then, enableCustomVideoCapture is called to enable custom video capture. Finally, sendCustomVideoFrame is called to send video data collected in Broadcast Upload Extension.
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.
Parameters
appGroupThe 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.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_ERROR_NOT_SUPPORTED: this feature is not supported.

◆ startVirtualCamera:()

- (V2TXLiveCode) startVirtualCamera: (TXImage *)  image

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

◆ stopCamera()

- (V2TXLiveCode) stopCamera

Disables the local camera.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ stopMicrophone()

- (V2TXLiveCode) stopMicrophone

Disables the microphone.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ stopPush()

- (V2TXLiveCode) stopPush

Stops pushing the audio and video data.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful

◆ stopScreenCapture()

- (V2TXLiveCode) stopScreenCapture

Disables video capture.

Attention
The iOS system currently does not support the use of this API to disable video capture.
You can directly disable video capture on the video recording screen of the iOS system. Alternatively, you can call enableCustomVideoCapture to disable video capture.
Returns
Return code for V2TXLiveCode
  • V2TXLIVE_ERROR_NOT_SUPPORTED: this feature is not supported.

◆ stopVirtualCamera()

- (V2TXLiveCode) stopVirtualCamera

Disables the image streaming.

Returns
Return code for V2TXLiveCode
  • V2TXLIVE_OK: successful