Core features
The Video SDK for Windows lets an app share the contents of the device's screen or a single window with the session. You start and manage sharing with IZoomVideoSDKShareHelper, obtained from getShareHelper. To draw over shared content, see Annotation. When more than one user shares at once, see Handle multiple screen shares.
Share a screen
To share an entire display, get the monitor's ID and pass it to startShareScreen. On Windows, enumerate monitors with EnumDisplayMonitors.
// Get available monitors.
std::vector<std::wstring> vecMonitorArray;
EnumDisplayMonitors(NULL, NULL, &MyInfoEnumProc, reinterpret_cast<LPARAM>(&vecMonitorArray));
std::wstring strMonitorId = vecMonitorArray.empty() ? L"" : vecMonitorArray[0];
// Obtain the IZoomVideoSDKShareHelper to perform sharing actions.
IZoomVideoSDKShareHelper* pShareHelper = m_pVideoSDK->getShareHelper();
if (!pShareHelper) return;
ZoomVideoSDKErrors err = pShareHelper->startShareScreen(strMonitorId.c_str());
if (err == ZoomVideoSDKErrors_Success)
{
// Started sharing the screen.
}
Share a window
To share a single window instead of a whole display, call startShareView with the window's HWND.
IZoomVideoSDKShareHelper* pShareHelper = m_pVideoSDK->getShareHelper();
if (!pShareHelper) return;
ZoomVideoSDKErrors err = pShareHelper->startShareView(hWnd);
Share device audio
To include the device's audio with your share, call enableShareDeviceAudio before you start sharing.
pShareHelper->enableShareDeviceAudio(true);
To feed your own frames into a share instead of capturing a screen or window, share an external source. For details, see Send raw data.
Stop, pause, and resume sharing
Call stopShare to end the share. To temporarily stop sending share frames without ending the share, call pauseShare, and resumeShare to continue.
pShareHelper->pauseShare();
pShareHelper->resumeShare();
pShareHelper->stopShare();
Verify your share started
After you start sharing, the SDK calls onUserShareStatusChanged and passes an IZoomVideoSDKShareAction. Read the status from the action object with getShareStatus.
void CExampleListener::onUserShareStatusChanged(IZoomVideoSDKShareHelper* pShareHelper, IZoomVideoSDKUser* pUser, IZoomVideoSDKShareAction* pShareAction)
{
if (pShareAction && pShareAction->getShareStatus() == ZoomVideoSDKShareStatus_Start)
{
// The user has successfully started sharing to the session.
}
}
Render another user's share
To render a share, get the user's share actions with getShareActionList, then subscribe to the IZoomVideoSDKRawDataPipe from the share action you want to display. Each IZoomVideoSDKShareAction represents one share, so this also covers the case where a user has more than one share active.
IVideoSDKVector<IZoomVideoSDKShareAction*>* pShareActions = pUser->getShareActionList();
if (pShareActions && pShareActions->GetCount() > 0)
{
IZoomVideoSDKShareAction* pShareAction = pShareActions->GetItem(0);
IZoomVideoSDKRawDataPipe* pSharePipe = pShareAction->getSharePipe();
// Subscribe to pSharePipe to render the shared content.
}
For the subscription and rendering flow, see Receive raw data. To let viewers pick between simultaneous shares, see Handle multiple screen shares.