logo
On this page

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:

Usage Steps

  1. Call getVideoDeviceList to obtain the list of available video devices.
  2. Call useVideoDevice to specify the main stream's video device, and call startPublishingStream to publish the main stream.
  3. 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

MethodDescription
startPublishingStreamStart publishing
stopPublishingStreamStop publishing
getVideoDeviceListGet video device list
useVideoDeviceSpecify video device

Previous

Multi-source Capture

Next

Supplemental Enhancement Information (SEI)

On this page

Back to top