Copyright (c) 2021 Tencent. All rights reserved.
Module: V2TXLivePusherObserver @ TXLiteAVSDK
Function: Tencent Cloud live pusher callback notification
Function
Callback notification for push streaming of Tencent Cloud Live.
Introduce
You can receive some push notifications from the V2TXLivePusher pusher, including the connection status of the pusher, callback of the first frame of audio and video, statistical data, warning and error messages, etc.
V2TXLivePusherObserver
|
| Live pusher error notification, which is called back when the pusher encounters an error |
| Live pusher warning notification |
| Callback notification indicating that collection of the first audio frame is complete |
| Callback notification indicating that collection of the first video frame is complete |
| Microphone-collected volume callback |
| Callback notification of the pusher connection status |
| Live pusher statistics callback |
| Screenshot callback |
| Audio data captured by the local mic, pre-processed by the audio module, effect-processed and BGM-mixed |
| Custom video processing callback |
| Callback of destroying the OpenGL context in the SDK |
| |
| The SDK returns this callback when you call startScreenCapture and other APIs to start screen sharing. |
| The SDK returns this callback when you call stopScreenCapture to stop screen sharing |
| |
| The SDK returns this callback when you call startLocalRecording to start local recording, which means recording task in progress. |
| The SDK returns this callback when you call stopLocalRecording to start local recording. |
| After calling enableVoiceActivityDetection to turn on voice activity detection, you will receive this callback notification when the anchor starts or stops speaking. |
onError:message:extraInfo:
onError:message:extraInfo:
| |
| |
| (NSDictionary *)extraInfo |
Live pusher error notification, which is called back when the pusher encounters an error
|
code | |
extraInfo | Extended information. |
msg | Error message. |
onWarning:message:extraInfo:
onWarning:message:extraInfo:
| |
| |
| (NSDictionary *)extraInfo |
Live pusher warning notification
|
code | |
extraInfo | Extended information. |
msg | Warning message. |
onCaptureFirstAudioFrame
Callback notification indicating that collection of the first audio frame is complete
onCaptureFirstVideoFrame
Callback notification indicating that collection of the first video frame is complete
onMicrophoneVolumeUpdate:
onMicrophoneVolumeUpdate:
- (void)onMicrophoneVolumeUpdate: | |
Microphone-collected volume callback
|
volume | Current volume value for collection. |
onPushStatusUpdate:message:extraInfo:
onPushStatusUpdate:message:extraInfo:
- (void)onPushStatusUpdate: | |
| |
| (NSDictionary *)extraInfo |
Callback notification of the pusher connection status
|
extraInfo | Extended information. |
msg | Connection status message. |
status | |
onStatisticsUpdate:
- (void)onStatisticsUpdate: | |
Live pusher statistics callback
onSnapshotComplete:
- (void)onSnapshotComplete: | (nullable TXImage *)image |
Screenshot callback
|
image | Captured video image. |
Note
This callback notification will be received after calling snapshot . onProcessAudioFrame:
- (void) onProcessAudioFrame: | (V2TXLiveAudioFrame *)frame |
Audio data captured by the local mic, pre-processed by the audio module, effect-processed and BGM-mixed
After you configure the callback of custom audio processing, the SDK will return via this callback the data captured, pre-processed (ANS, AEC, and AGC), effect-processed and BGM-mixed in PCM format, before it is submitted to the network module for encoding.
The audio data returned via this callback is in PCM format and has a fixed frame length (time) of 0.02s.
The formula to convert a frame length in seconds to one in bytes is sample rate * frame length in seconds * number of sound channels * audio bit depth.
Assume that the audio is recorded on a single channel with a sample rate of 48,000 Hz and audio bit depth of 16 bits, which are the default settings of TRTC. The frame length in bytes will be 48000 * 0.02s * 1 * 16 bits = 15360 bits = 1920 bytes.
|
frame | Audio frames in PCM format |
Note
1. Please avoid time-consuming operations in this callback function. The SDK processes an audio frame every 20 ms, so if your operation takes more than 20 ms, it will cause audio exceptions.
2. The audio data returned via this callback can be read and modified, but please keep the duration of your operation short.
onProcessVideoFrame:dstFrame:
onProcessVideoFrame:dstFrame:
- (void)onProcessVideoFrame: | |
| |
Custom video processing callback
|
dstFrame | For images after processing. |
srcFrame | For images before processing. |
Note
to enable custom video processing.
Case 1: The beauty filter component generates new textures.
If the beauty filter component you use generates a new texture frame (for the processed image) during image processing, please set dstFrame.textureId
to a new texture ID in the callback API.
(void) onProcessVideoFrame:(V2TXLiveVideoFrame * _Nonnull)srcFrame dstFrame:(V2TXLiveVideoFrame * _Nonnull)dstFrame
{
GLuint dstTextureId = renderItemWithTexture(srcFrame.textureId, srcFrame.width, srcFrame.height);
dstFrame.textureId = dstTextureId;
return 0;
}
Case 2: The third-party beauty filter component doesn’t generate new textures.
If the third-party beauty filter component you use does not generate new textures and you need to manually set an input texture and an output texture for the component, please consider the following scheme:
(void) onProcessVideoFrame:(V2TXLiveVideoFrame * _Nonnull)srcFrame dstFrame:(V2TXLiveVideoFrame * _Nonnull)dstFrame
{
thirdparty_process(srcFrame.textureId, srcFrame.width, srcFrame.height, dstFrame.textureId);
return 0;
}
onGLContextDestroyed
Callback of destroying the OpenGL context in the SDK
onSetMixTranscodingConfig:message:
onSetMixTranscodingConfig:message:
- (void)onSetMixTranscodingConfig: | |
| |
Callback of setting On-Cloud MixTranscoding parameters, which corresponds to the {@link setMixTranscodingConfig} API
|
code | 0: successful; other values: failed. |
msg | Error message. |
onScreenCaptureStarted
The SDK returns this callback when you call {@link startScreenCapture} and other APIs to start screen sharing.
onScreenCaptureStopped:
- (void)onScreenCaptureStopped: | |
The SDK returns this callback when you call {@link stopScreenCapture} to stop screen sharing
|
Reason | for stop. 0 : Screen capture stopped by user. 1 : On iOS platform means the screen recording is interrupted by the system; Mac, Windows means the screen sharing window is closed. 2 : On windows platform indicates that the display screen status of screen sharing is changed (such as the interface is pulled out, the projection mode is changed, etc.); other platforms do not throw. |
onLocalRecordBegin:storagePath:
onLocalRecordBegin:storagePath:
- (void)onLocalRecordBegin: | |
| |
The SDK returns this callback when you call {@link startLocalRecording} to start local recording.
|
code | status. 0: successful. -1: failed. -2: unsupported format. -6: recording has been started. Stop recording first. -7: recording file already exists and needs to be deleted. -8: recording directory does not have the write permission. Please check the directory permission. |
storagePath | recording filePath. |
onLocalRecording:storagePath:
onLocalRecording:storagePath:
- (void)onLocalRecording: | |
| |
The SDK returns this callback when you call {@link startLocalRecording} to start local recording, which means recording task in progress.
|
durationMs | recording duration. |
storagePath | recording filePath. |
onLocalRecordComplete:storagePath:
onLocalRecordComplete:storagePath:
- (void)onLocalRecordComplete: | |
| |
The SDK returns this callback when you call {@link stopLocalRecording} to start local recording.
|
code | status 0: successful. -1: failed. -2: Switching resolution or horizontal and vertical screen causes the recording to stop. -3: recording duration is too short or no video or audio data is received. Check the recording duration or whether audio or video capture is enabled. |
storagePath | recording filePath. |
onVoiceActivityDetectionUpdate:
onVoiceActivityDetectionUpdate:
- (void)onVoiceActivityDetectionUpdate: | |
After calling {@link enableVoiceActivityDetection} to turn on voice activity detection, you will receive this callback notification when the anchor starts or stops speaking.
|
active | The voice starts or stops. |
Was this page helpful?