Publishing Multiple Streams Simultaneously
Function Introduction
Publishing multiple streams means the SDK provides the capability to publish multiple streams simultaneously (currently the SDK supports publishing a second stream).
When the following situations occur in a developer's business, it is recommended to use the SDK's multiple stream publishing functionality:
- Game streaming host publishes main stream with camera footage, and publishes a second stream with screen capture footage.
- External hosts publish main stream with front camera, and publish a second stream with rear camera.
Example Source Code Download
Please refer to Download Example Source Code to obtain the source code.
For related source code, please check files in the "/ZegoExpressExample/src/AuxStream" directory.
Prerequisites
Before implementing the multiple stream publishing functionality, please ensure:
- The ZEGO Express SDK has been integrated in your project and basic real-time voice functionality has been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementing Flow.
- A project has been created in the ZEGOCLOUD Console and a valid AppID and AppSign have been obtained.
Usage Steps
- Call getVideoDeviceList to obtain the list of available video devices.
- Call useVideoDevice to specify the main stream's video device, and call startPublishingStream to publish the main stream.
- Call useVideoDevice to specify the second stream's video device, and call startPublishingStream to publish the second stream.
// Obtain available video devices
auto videoDeviceList = engine->getVideoDeviceList();
// Specify video device for main stream and then start publishing main stream
engine->useVideoDevice(videoDeviceList[0].deviceID, ZEGO_PUBLISH_CHANNEL_MAIN);
engine->startPublishingStream("stream1", ZEGO_PUBLISH_CHANNEL_MAIN);
// Specify video device for second stream and then start publishing second stream
engine->useVideoDevice(videoDeviceList[1].deviceID, ZEGO_PUBLISH_CHANNEL_AUX);
engine->startPublishingStream("stream2", ZEGO_PUBLISH_CHANNEL_AUX);API Reference List
| Method | Description |
|---|---|
| startPublishingStream | Start publishing |
| stopPublishingStream | Stop publishing |
| getVideoDeviceList | Get video device list |
| useVideoDevice | Specify video device |
