API | Description |
Static function is used to check browser compatibility. | |
Set the local video preview container. | |
Set Push Video Quality. | |
Set Push Audio Quality. | |
Invoke Advanced API Interface. | |
Open Camera Device. | |
Close Camera Device. | |
Open Microphone Device. | |
Close Microphone Device. | |
Enable Screen Capture. | |
Disable Screen Capture. | |
Start Capturing Local Media File Stream. | |
Stop Capturing Local Media File Stream. | |
Use Custom Audio and Video Stream. | |
Close Custom Audio and Video Stream. | |
Start Pushing Stream. | |
Stop Pushing Stream. | |
Check if Currently Pushing Stream. | |
Get Audio and Video Stream by Stream ID. | |
Get Device Manager Object. | |
Get Video Effect Manager Object. | |
Get Audio Effect Manager Object. | |
Set whether to disable video stream. | |
Set whether to disable audio stream. | |
Disable video stream. | |
Disable audio stream. | |
Restore video stream. | |
Restore audio stream. | |
Set video content hint to improve encoding quality in different content scenarios. | |
Set push stream event callback notification. | |
When leaving the page or exiting, clean up the SDK instance. |
API | Description |
Get Device List. | |
Get device information of the current stream. | |
Switch the currently used device. | |
Switch camera device. | |
Switch microphone device. |
API | Description |
Set the volume level of the audio stream. |
API | Description |
Enable local video screen mixing feature. | |
Set mixing parameters. | |
Get the final adopted mixing parameters. | |
Set Picture-in-Picture layout parameters for the video stream. | |
Get Picture-in-Picture layout parameters for the specified stream. | |
Set mirror effect for the video stream. | |
Set general filter effect for the video stream. | |
Set watermark. | |
Set text. |
const livePusher = new TXLivePusher();
static checkSupport(): Promise<TXSupportResult>;
setRenderView(container: string | HTMLDivElement): void;
Field | Type | Description |
container | string | HTMLDivElement | Container ID or DOM node. |
setVideoQuality(quality: string): void;
Field | Type | Description |
quality | string | Predefined video quality template names. |
Template Name | Resolution (Width x Height) | Frame Rate (fps) | Bitrate (kbps) |
120p | 160 x 120 | 15 | 200 |
180p | 320 x 180 | 15 | 350 |
240p | 320 x 240 | 15 | 400 |
360p | 640 x 360 | 15 | 800 |
480p | 640 x 480 | 15 | 900 |
720p | 1280 x 720 | 15 | 1500 |
1080p | 1920 x 1080 | 15 | 2000 |
2K | 2560 x 1440 | 30 | 4860 |
4K | 3840 x 2160 | 30 | 9000 |
setVideoQuality('720p')
.setAudioQuality(quality: string): void;
Field | Type | Description |
quality | string | The pre-defined name of the audio quality template. |
Template Name | Sample rate | Bitrate (Kbps) |
standard | 48000 | 40 |
high | 48000 | 128 |
setAudioQuality('standard')
.setProperty(key: string, value: any): void;
Field | Type | Description |
key | string | Key corresponding to the advanced API. |
value | * | Parameters needed when invoking the key corresponding to the advanced API. |
Key | Value | Description | Sample code |
setVideoResolution | { width: number; height:number; } | Establish the video resolution | setProperty('setVideoResolution', { width: 1920, height: 1080 }) |
setVideoFPS | number | Configure the video frame rate | setProperty('setVideoFPS', 25) |
setVideoBitrate | number | Set the video bitrate | setProperty('setVideoBitrate', 2000) |
setAudioSampleRate | number | Configure the audio sample rate | setProperty('setAudioSampleRate', 44100) |
setAudioBitrate | number | Establish the audio bitrate | setProperty('setAudioBitrate', 200) |
setConnectRetryCount | number | Set the retry count for connections, default is: 3; range: 0 - 10. When the SDK unexpectedly disconnects with the server, it will attempt to reconnect. | setProperty('setConnectRetryCount', 5) |
setConnectRetryDelay | number | Set the connection retry delay, the default value is: 1, in seconds; within the range: 0 - 10. When the SDK is anomalously disconnected from the server, it endeavors to reconnect. | setProperty('setConnectRetryDelay', 2) |
enableAudioAEC | boolean | Enable echo cancellation | setProperty('enableAudioAEC', true) |
enableAudioAGC | boolean | Enable automatic gain | setProperty('enableAudioAGC', true) |
enableAudioANS | boolean | Enable noise suppression | setProperty('enableAudioANS', true) |
enableLog | boolean | Should logs be printed in the console | setProperty('enableLog', true) |
startCamera(deviceId?: string): Promise<string>;
Field | Type | Description |
deviceId | string | Camera device ID, an optional parameter, determines the camera device to open. The device ID can be obtained using the method getDevicesList in TXDeviceManager . On mobile devices, the front and rear cameras can be specified by entering 'user' and 'environment'. |
stopCamera(streamId?: string): void;
Field | Type | Description |
streamId | string | Stream ID, an optional parameter, signifies the specific camera stream to be deactivated. After the local stream mix is enabled, if multiple camera streams have been collected, you can turn off the specified camera stream through the stream ID; otherwise, it will close all camera streams. |
startMicrophone(deviceId?: string): Promise<string>;
Field | Type | Description |
deviceId | string | Microphone Device ID, an optional parameter designating the specific microphone equipment to be activated. The Device ID can be retrieved through the method getDevicesList() found in TXDeviceManager . |
livePusher.videoView.muted = true;
stopMicrophone(streamId?: string): void;
Field | Type | Description |
streamId | string | Stream ID is an optional parameter that indicates the specification of a microphone stream to be discontinued. Once local mix streaming has been activated, a specific microphone stream can be silenced by using Stream ID, if multiple microphone streams have been captured, otherwise, all microphone streams will be muted. |
startScreenCapture(audio?: boolean): Promise<string>;
Field | Type | Description |
audio | boolean | Determines whether to collect system sound or Tag page sound: true - collection of sound, false - no sound collection, default is set to false. |
stopScreenCapture(streamId?: string): void;
Field | Type | Description |
streamId | string | Stream ID, optional parameter, designates the shared screen stream to be closed. Once local stream mix is activated, if multiple screen share streams have been collected, a particular screen share stream can be turned off via the stream ID. If not specified, all screen share streams will be shut down. |
startVirtualCamera(file: File): Promise<string>;
Field | Type | Description |
file | File | Local media files are compulsory. The file format must be any of the following: mp4, mp3, jpg, png, bmp. |
<input type="file">
to guide users in local file selection.stopVirtualCamera(streamId?: string): void;
Field | Type | Description |
streamId | string | Stream ID is an optional parameter used to specify the media file stream that needs to be shut off. After enabling local merged streaming, if multiple media file streams have been collected, you can close a specified media file stream through Stream ID, otherwise all media file streams will be shut off. |
startCustomCapture(stream: MediaStream): Promise<string>;
Field | Type | Description |
stream | MediaStream | User-defined stream. |
stopCustomCapture(streamId?: string): void;
Field | Type | Description |
streamId | string | Stream ID, an optional parameter, refers to the custom stream that needs to be removed. After activating local mixed flow, if multiple custom streams are added, you can remove the specific custom stream through the stream ID, otherwise all custom streams will be purged. |
startPush(pushUrl: string): Promise<void>;
Field | Type | Description |
pushUrl | string | WebRTC push address. |
stopPush(): void;
isPushing(): boolean;
getMediaStream(streamId: string): MediaStream;
Field | Type | Description |
streamId | string | Stream ID is returned after the successful invocation of interfaces such as startCamera(), startMicrophone(), startScreenCapture(), etc. |
getDeviceManager(): TXDeviceManager;
getVideoEffectManager(): TXVideoEffectManager;
getAudioEffectManager(): TXAudioEffectManager;
setVideoMute(mute: boolean): void;
Field | Type | Description |
mute | boolean | true - disabled, false - enabled. |
setAudioMute(mute: boolean): void;
Field | Type | Description |
mute | boolean | true - disabled, false - enabled. |
setVideoMute(true)
.pauseVideo(): void;
setAudioMute(true)
.pauseAudio(): void;
setVideoMute(false)
.resumeVideo(): void;
setAudioMute(false)
.resumeAudio(): void;
setVideoContentHint(contentHint: string): void;
Field | Type | Description |
contentHint | string |
Fetching Value | Description |
'' | By default, the browser will automatically evaluate the video content and choose the appropriate prompt configuration for encoding. |
'motion' | This manifests as a preference for smoothness, applicable when the video content is obtained from camera captures, films, videos, or games. |
'detail' | Manifests as clarity precedence, suitable for video content that includes mixed images and text. When screen sharing, it's advisable to use this prompt. |
'text' | Manifests as clarity prioritized, applicable when the video content only contains copious amount of text. |
setObserver(observer: TXLivePusherObserver): void;
Field | Type | Description |
observer | The callback target object for the stream push. |
onError
, onWarning
, onCaptureFirstAudioFrame
, onCaptureFirstVideoFrame
can also be obtained through the Promise object returned by the corresponding interface. Users can opt for the method to receive the respective event notifications based on their usage preferences. For instance:
startCamera().then()
is equivalent to onCaptureFirstVideoFrame()
, the status of successful acquisition of the first frame of video can also be achieved.startCamera().catch()
is equivalent to onWarning()
, also it helps in obtaining the error when failing to turn on the camera.destroy(): void;
const deviceManager = livePusher.getDeviceManager();
getDevicesList(type?: string): Promise<TXMediaDeviceInfo[]>;
Field | Type | Description |
type | string | Taking value video or audio, optional parameter. If not transmitted, return all device list, transmit video for camera device list, transmit audio for microphone device list. |
getCurrentDevice(type: string, streamId?: string): Promise<TXMediaDeviceInfo>;
Field | Type | Description |
type | string | Device type: video - camera device, audio - microphone device. |
streamId | string | Stream ID refers to the stream from which device information is to be fetched. This is a mandatory variable after enabling local stream mixing, corresponding to the stream collected by the camera or microphone devices. |
switchDevice(type: string, deviceId: string, streamId?: string): Promise<void>;
Field | Type | Description |
type | string | Device type: video - camera device, audio - microphone device. |
deviceId | string | |
streamId | string | Stream ID, designates the stream of the device to be switched, it is required when local mix stream is enabled. The corresponding stream must be a stream collected by a camera or a microphone device. |
switchDevice('video', deviceId, streamId)
.switchCamera(deviceId: string, streamId?: string): Promise<void>;
Field | Type | Description |
deviceId | string | The device ID can be acquired by invoking getDevicesList(). On mobile devices, switching between the front and rear cameras can be facilitated by entering 'user' and 'environment'. |
streamId | string | The stream ID specifies the stream of the camera device to be switched. Once local stream mix is activated, it's a mandatory field. The corresponding stream must be the one collected by the camera device. |
switchDevice('audio', deviceId, streamId)
.switchMicrophone(deviceId: string, streamId?: string): Promise<void>;
Field | Type | Description |
deviceId | string | |
streamId | string | Stream ID, identifies the stream for which the microphone device will be changed, and must be supplied after enabling local mixed-flow. The corresponding stream must be a stream collected from the microphone device. |
const audioEffectManager = livePusher.getAudioEffectManager();
setVolume(volume: number, streamId?: string): void;
Field | Type | Description |
volume | number | The volume level, which ranges from 0 to 100, with the default value being 100. |
streamId | string | Stream ID, designates the stream to be set, and must be transmitted after enabling local stream blending. |
const videoEffectManager = livePusher.getVideoEffectManager();
enableMixing(enabled: boolean): void;
Field | Type | Description |
enabled | boolean | Whether to activate local stream mix feature; it is deactivated by default. |
TXVideoEffectManager
before deploying other methods.startCamera
to capture two disparate camera visuals, or initially executing startCamera
to capture the camera visual, followed by startScreenCapture
to capture screen visual. The multi-stream captures, both visual and audio, appear in the final merged output.TXLivePusher
in setVideoQuality() and setProperty().setMixingConfig(config: TXMixingConfig): void;
Field | Type | Description |
config | Configuration of mix streaming parameters. |
TXLivePusher
methods in setVideoQuality() and setProperty().getMixingConfig(): TXMixingConfig;
setLayout(config: TXLayoutConfig | TXLayoutConfig[]): void;
Field | Type | Description |
config | The configuration of the PiP layout supports the passage of an object or an array of objects. |
getLayout(streamId: string): TXLayoutConfig | null;
Field | Type | Description |
streamId | string | Stream ID, signifies the stream from which you wish to acquire the Picture-in-Picture layout parameters. |
setMirror(config: TXMirrorConfig | TXMirrorConfig[]): void;
Field | Type | Description |
config | Configuration for the mirror effect permits both individual and batch setting via object or object array. |
setNormalFilter(config: TXNormalFilterConfig | TXNormalFilterConfig[]): void;
Field | Type | Description |
config | The configuration for the general filter effect supports object or object array transmission. |
setWatermark(config: TXWatermarkConfig | TXWatermarkConfig[] | null): void;
Field | Type | Description |
config | Watermark configuration parameters allow for the transmission of objects, object arrays, or null. |
setText(config: TXTextConfig | TXTextConfig[] | null): void;
Field | Type | Description |
config | Text configuration parameters, supporting object passage, object arrays, or null. |
Field | Type | Description |
isWebRTCSupported | boolean | Whether WebRTC is supported |
isH264EncodeSupported | boolean | Is H.264 encoding supported? |
isH264DecodeSupported | boolean | Is H.264 decoding supported? |
isMediaDevicesSupported | boolean | Is acquisition of media devices and media streams supported? |
isScreenCaptureSupported | boolean | Is screen capture supported? |
isMediaFileSupported | boolean | Is retrieval of local media file streams supported? |
Field | Type | Description |
onError | Notification of streaming errors. | |
onWarning | Stream warning notification. | |
onCaptureFirstAudioFrame | Callback notification completed for initial audio frame capture. | |
onCaptureFirstVideoFrame | Callback notification upon completion of the first frame video collection. | |
onPushStatusUpdate | Live stream connection status callback notification. | |
onStatisticsUpdate | Callback notification of live stream statistical data. |
onError(code: number, message: string, extraInfo: object): void;
Field | Type | Description |
code | number | Error Codes. |
message | string | Error message. |
extraInfo | object | Extension information. |
Enumeration | Numerical Value | Description |
TXLIVE_ERROR_WEBRTC_FAILED | -1 | Failed to call the `WebRTC` API. |
TXLIVE_ERROR_REQUEST_FAILED | -2 | Server stream request interface returned with an error. |
onWarning(code: number, message: string, extraInfo: object): void;
Field | Type | Description |
code | number | Error Codes. |
message | string | Error message. |
extraInfo | object | Extension information. |
Enumeration | Numerical Value | Description |
TXLIVE_WARNING_CAMERA_START_FAILED | -1001 | Camera activation failure. |
TXLIVE_WARNING_MICROPHONE_START_FAILED | -1002 | Failed to activate the microphone. |
TXLIVE_WARNING_SCREEN_CAPTURE_START_FAILED | -1003 | Failed to initiate screen sharing. |
TXLIVE_WARNING_VIRTUAL_CAMERA_START_FAILED | -1004 | Failed to open the local media file. |
TXLIVE_WARNING_CAMERA_INTERRUPTED | -1005 | Camera was interrupted (device was detached or permission was revoked by user). |
TXLIVE_WARNING_MICROPHONE_INTERRUPTED | -1006 | Microphone was interrupted (device was unplugged or permission was annulled by user). |
TXLIVE_WARNING_SCREEN_CAPTURE_INTERRUPTED | -1007 | Screen sharing has been interrupted (clicking the stop sharing button in Chrome browser). |
onCaptureFirstAudioFrame(): void;
onCaptureFirstVideoFrame(): void;
onPushStatusUpdate(status: number, message: string, extraInfo: object): void;
Field | Type | Description |
status | number | Connection status code. |
message | string | Connection status information. |
extraInfo | object | Extension information. |
Enumeration | Numerical Value | Description |
TXLIVE_PUSH_STATUS_DISCONNECTED | 0 | Disconnect from server |
TXLIVE_PUSH_STATUS_CONNECTING | 1 | Establishing server connection |
TXLIVE_PUSH_STATUS_CONNECTED | 2 | Server connection established successfully |
TXLIVE_PUSH_STATUS_RECONNECTING | 3 | Reconnecting to the server |
onStatisticsUpdate(statistics: object): void;
Field | Type | Description |
statistics | object | Push stream statistics. |
statistics.timestamp | number | The time for data sampling, counted as milliseconds elapsed since January 1, 1970 (UTC). |
statistics.video | object | Data pertinent to the video stream. |
statistics.video.bitrate | number | Video bitrate, unit: bit/s. |
statistics.video.framesPerSecond | number | Video frame rate. |
statistics.video.frameWidth | number | Video width. |
statistics.video.frameHeight | number | Video height. |
statistics.video.framesEncoded | number | Encoded frame count. |
statistics.video.framesSent | number | Transmitted Frame Count. |
statistics.video.packetsSent | number | Number of packets sent. |
statistics.video.nackCount | number | NACK (Negative Acknowledgement) count. |
statistics.video.firCount | number | FIR (Full Intra Request), the number of keyframe retransmission requests. |
statistics.video.pliCount | number | PLI(Picture Loss Indication), the number of times video frames are retransmitted due to loss. |
statistics.video.frameEncodeAvgTime | number | Average Encoding Time, measured in: ms. |
statistics.video.packetSendDelay | number | Average duration of local caching prior to data packet transmission, unit: ms . |
statistics.audio | object | Data related to the audio stream. |
statistics.audio.bitrate | number | Audio bitrate, expressed in: bit/s . |
statistics.audio.packetsSent | number | Number of packets sent. |
Field | Type | Description |
type | string | Device type, video - camera, audio - microphone. |
deviceId | string | Device ID. |
deviceName | string | Device Name. |
Field | Type | Description |
videoWidth | number | The final width of the mixed video stream. |
videoHeight | number | The ultimate height of the mixed video stream. |
videoFramerate | number | Frame rate of the video after final mixing. |
backgroundColor | number | The background color of the mixed screen, in hexadecimal format, defaults to black, i.e., 0x000000. |
Field | Type | Description |
streamId | string | Stream ID, denotes the stream to be configured. |
x | number | Layout of the x-coordinate. |
y | number | Layout y-axis. |
width | number | Layout Width. |
height | number | Layout Height. |
zOrder | number | Layout Hierarchy. |
Field | Type | Description |
streamId | string | Stream ID, denotes the stream to be configured. |
mirrorType | number | Mirror Type: 0 - No mirror effect, 1 - Horizontal mirror, 2 - Vertical mirror, 3 - Horizontal + Vertical mirror. |
Field | Type | Description |
streamId | string | Stream ID, denotes the stream to be configured. |
contrast | number | Contrast, value range [-100, 100], 0 denotes no processing. |
brightness | number | Brightness, the value range [-100, 100], 0 indicates no processing. |
saturation | number | Saturation, the value ranges from [-100, 100]. 0 indicates no processing. |
Field | Type | Description |
image | HTMLImageElement | Watermark image object. |
x | number | Watermark's x-coordinate. |
y | number | Watermark Y coordinate. |
width | number | Watermark width. |
height | number | Watermark height. |
zOrder | number | Watermark hierarchy. |
Field | Type | Description |
text | string | Text content cannot be an empty string. |
style | object | Refer to the corresponding CSS style settings for text styles. |
style.font | string | Font Name. |
style.font_size | number | Font size. |
style.font_color | string | Font color represented in hexadecimal, such as #000000. |
style.font_alpha | number | Font transparency, range [0, 100], default 100 (opaque). |
style.bold | number | Text bolding, 0 - No bold, 1 - Bold, default 0 . |
style.italic | number | Font slant, 0 - normal, 1 - italic, default 0. |
style.shadow_color | string | Text shadow color, represented in hexadecimal, for instance #000000 . |
style.shadow_alpha | number | Text shadow opacity, ranging from [0, 100], effective when shadow_color is present, default is 100 (opaque). |
style.stroke_color | string | Text outline color, represented in hexadecimal, such as #000000 . |
style.stroke_thickness | number | Stroke thickness of the text, default value is 0, that is, no stroke. |
style.background_color | string | Background color, represented in hexadecimal form, such as #000000 . |
style.background_alpha | number | Background transparency, ranging [0, 100]. It is effective when background_color exists, default value is 100 (Opaque). |
x | number | Text x coordinate. |
y | number | Text Y-Axes. |
zOrder | number | Textual Hierarchy. |
Was this page helpful?