Updated on 2023-03-23 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 or call, a failure message is returned.
  2. If this API is called during a call, the call is converted into a meeting.
  3. 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 parameters

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

HwmMonitor

Monitor where the toolbar is located during sharing. If the value is 0, no monitor is specified.

Table 2 Enumerated values of HwmShareType

Enumerated Value

Description

HWM_SHARE_TYPE_MONITOR

Desktop sharing.

HWM_SHARE_TYPE_APP

Program sharing.

Table 3 HwmMonitorShareInfo parameters

Parameter

Mandatory

Type

Description

monitor

Yes

HwmMonitor

Monitor type.

Table 4 Enumerated values of HwmMonitor

Enumerated Value

Description

HWM_MONITOR_MAIN

Primary monitor.

HWM_MONITOR_SECONDARY

Secondary monitor.

Table 5 HwmAppShareInfo parameters

Parameter

Mandatory

Type

Description

appHandle

Yes

HWND

Program handle.

Return Values

Table 6 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;
}