Updated on 2024-07-30 GMT+08:00

Starting Sharing

StartShare

API Description

This API is used to enable meeting sharing. The UI of the SDK has implemented the sharing function. You can call this API to initiate sharing on a third-party application.

Precautions

  1. If this API is called when you are not in a meeting, a failure message is returned.
  2. This API is an asynchronous API. The return value only indicates whether the API is successfully called. The actual service processing result is returned in the corresponding callback function.

Method Definition

1
HWM_SDK_AGENT_API hwmsdk::HwmErrCode StartShare(HwmStartShareInfo *startShareInfo);

Callback Function

1
virtual void OnStartShareResult(hwmsdk::HwmErrCode ret, const char* reason) {};

Parameter Description

Table 1 HwmStartShareInfo description

Parameter

Mandatory

Type

Description

shareType

Yes

enum

Sharing type.

monitorShareInfo

No

HwmMonitorShareInfo

Desktop sharing details. This parameter is mandatory if the sharing type is desktop sharing.

appShareInfo

No

HwmAppShareInfo

Program sharing details. This parameter is mandatory if the sharing type is program sharing.

operatableUiMonitor

Yes

HwmMonitorShareInfo

Monitor where the toolbar is located during sharing. If monitorMode is set to the primary/secondary monitor mode and the value of monitor is set to 0, you do not need to specify a monitor.

Table 2 Enumerated values of HwmShareType

Enumerated Value

Description

HWM_SHARE_TYPE_MONITOR

Desktop sharing.

HWM_SHARE_TYPE_APP

Program sharing.

Table 3 HwmMonitorShareInfo description

Parameter

Mandatory

Type

Description

monitor

Yes

HwmMonitor

Monitor type. This parameter is valid only when monitorMode is set to the primary/secondary monitor mode.

monitorMode

Yes

HwmMonitorMode

Monitor mode.

monitorIndex

Yes

unsigned int

Monitor index. This parameter is valid only when monitorMode is set to the multi-screen mode.

Table 4 Enumerated values of HwmMonitor

Enumerated Value

Description

HWM_MONITOR_MAIN

Primary monitor.

HWM_MONITOR_SECONDARY

Secondary monitor.

Table 5 Enumerated values of HwmMonitorMode

Enumerated Value

Description

HWM_MONITOR_MODE_PRIMARY_SECONDARY

Primary/Secondary monitor.

HWM_MONITOR_MODE_MULTI_MONITOR

Multi-monitor.

Table 6 HwmAppShareInfo description

Parameter

Mandatory

Type

Description

appHandle

Yes

HWND

Program handle.

Return Values

Table 7 Return values

Type

Description

HwmErrCode

If 0 is returned, the operation is successful. If other values are returned, the operation fails. For details about values returned upon failures, see Common Error Codes.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
/**
* Starts sharing.
*/
int demoStartShareDlg::clickStartShare()
{
    hwmsdkagent::HwmStartShareInfo data;
    memset(&data, 0, sizeof(hwmsdkagent::HwmStartShareInfo));
    // Set the sharing type.
    data.shareType = hwmsdkagent::HwmShareType::HWM_SHARE_TYPE_MONITOR;
    // Set the monitor to share.
    data.monitorShareInfo.monitor = hwmsdkagent::HWM_MONITOR_MAIN;
    // Set the monitor where the toolbar is located.
    data.operatableUiMonitor = hwmsdkagent::HWM_MONITOR_MAIN;
    
    int ret = hwmsdkagent::StartShare(&data);
    return ret;
}