logo
Video Call
Other Features
On this page

Multi-Source Capture

2024-09-20

Feature Overview

Multi-source capture is used to manage audio/video source configurations for each channel. Through this capability, you can flexibly and quickly implement real-time interaction of different audio/video content, such as screen sharing, audio mixing, etc.

The main capabilities and limitations of multi-source capture are as follows:

  • Publishing channels support setting multiple audio/video sources, but the same audio/video source can only be occupied by one channel.
  • The main channel's audio/video sources support dynamic switching and also support audio mixing capabilities. Auxiliary channels only support specifying capture sources before publishing and do not support mixing.
  • When capturing screen, only iOS and Android platforms support capturing video and audio simultaneously; other platforms only support capturing video. If audio capture is needed, developers need to implement related logic themselves.

Example Source Code

Please refer to Download Example Source Code to get the source code.

For related source code, please check files in the "/ZegoExpressExample/Examples/Others/MultiVideoSource" directory.

Prerequisites

Before using multi-source capture functionality, please ensure:

Implementation Flow

Warning

Real-time audio products only support setting audio capture sources.

1 Create ZegoExpressEngine Engine

For the process of creating ZegoExpressEngine engine, please refer to Create Engine in implementing video call.

ZegoEngineProfile profile;
// AppID and AppSign are assigned to each App by ZEGO; for security reasons, it is recommended to store AppSign in the App's business backend and obtain it from the backend when needed
profile.appID = appID;
profile.appSign = appSign;
// Specify using live streaming scenario (please fill in the scenario suitable for your business according to the actual situation)
profile.scenario = ZegoScenario::ZEGO_SCENARIO_BROADCAST;
// Create engine instance
auto engine = ZegoExpressSDK::createEngine(profile, nullptr);

2 Set Audio/Video Capture Source

  1. Call the setVideoSource interface to set the video capture source.
/** Use camera as video capture source */
engine->setVideoSource(ZEGO_VIDEO_SOURCE_TYPE_CAMERA);
Note
  1. Call the setAudioSource interface to set the audio capture source.
/** Use microphone as audio capture source */
engine->setAudioSource(ZEGO_AUDIO_SOURCE_TYPE_MICROPHONE);
Note

3 Login Room and Publish Stream

For the process of logging in to room and publishing stream, please refer to Login Room and Publish Stream in implementing video call.

4 (Optional) Switch Audio/Video Capture Source

  1. Call the setVideoSource interface to switch video capture source.
/** Use screen sharing as video capture source */
engine->setVideoSource(ZEGO_VIDEO_SOURCE_TYPE_SCREEN_CAPTURE);
  1. Call the setAudioSource interface to switch audio capture source.
/** Use media player as audio capture source */
engine->setAudioSource(ZEGO_AUDIO_SOURCE_TYPE_MEDIA_PLAYER);

5 Stop Publishing Stream

For the process of stopping publishing stream, please refer to Stop Publishing/Playing Stream in implementing video call.

// Stop publishing stream
engine->stopPublishingStream();

FAQ

Yes, but note that the same player instance can only be occupied by one channel.

The limitations for combining video sources and audio sources are as follows:

  1. The main channel cannot use media player's video or audio source.
  2. When an auxiliary channel uses media player as audio/video source, the main channel needs to use and start the microphone device (enableMicrophone). If you don't need microphone sound on the main channel, you can disable audio publishing through mutePublishStreamAudio to keep the microphone started.
  3. Only when the main channel uses camera video source or microphone audio source, can the auxiliary channel copying main channel video source or audio source take effect.
  4. The main channel's audio source cannot be set to None, otherwise audio cannot be rendered.

Previous

Network Speed Test

Next

Supplemental Enhancement Information (SEI)

On this page

Back to top