# 屏幕采集 (/zh-CN/api-reference/rtc/csharp-windows/video/screencapture)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

<a id="toc_screencapture"></a>

<a id="api_irtcengine_getscreencapturesources"></a>

<a id="ariaid-title2"></a>

## GetScreenCaptureSources [#getscreencapturesources]

获取可共享的屏幕和窗口对象列表。

<a id="api_irtcengine_getscreencapturesources__prototype"></a>

```csharp
public abstract ScreenCaptureSourceInfo[] GetScreenCaptureSources(SIZE thumbSize, SIZE iconSize, bool includeScreen);
```

<a id="api_irtcengine_getscreencapturesources__detailed_desc"></a>

### 详情 [#详情]

屏幕共享或窗口共享前，你可以调用该方法获取可共享的屏幕和窗口的对象列表，方便用户通过列表中的缩略图选择共享某个显示器的屏幕或某个窗口。列表中包含窗口 ID 和屏幕 ID 等重要信息，你可以获取到 ID 后再调用 [StartScreenCaptureByWindowId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebywindowid) 或 [StartScreenCaptureByDisplayId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebydisplayid) 开启共享。

<a id="api_irtcengine_getscreencapturesources__parameters"></a>

### 参数 [#参数]

<ParameterList>
<a id="thumbsize"></a>
<Parameter name="thumbSize">

屏幕或窗口的缩略图的目标尺寸（宽高单位为像素）。SDK 会在保证原图不变形的前提下，缩放原图，使图片最长边和目标尺寸的最长边的长度一致。例如，原图宽高为 400 × 300，thumbSize 为 100 x 100，缩略图实际尺寸为 100 × 75。如果目标尺寸大于原图尺寸，缩略图即为原图，SDK 不进行缩放操作。

</Parameter>
<a id="iconsize"></a>
<Parameter name="iconSize">

程序所对应的图标的目标尺寸（宽高单位为像素）。SDK 会在保证原图不变形的前提下，缩放原图，使图片最长边和目标尺寸的最长边的长度一致。例如，原图宽高为 400 × 300，iconSize 为 100 × 100，图标实际尺寸为 100 × 75。如果目标尺寸大于原图尺寸，图标即为原图，SDK 不进行缩放操作。

</Parameter>
<a id="includescreen"></a>
<Parameter name="includeScreen">

除了窗口信息外，SDK 是否返回屏幕信息：

- `true`：SDK 返回屏幕和窗口信息。
- `false`：SDK 仅返回窗口信息。

</Parameter>
</ParameterList>

<a id="api_irtcengine_getscreencapturesources__return_values"></a>

### 返回值 [#返回值]

[ScreenCaptureSourceInfo](/zh-CN/api-reference/rtc/csharp-windows/class-screencapturesourceinfo) 数组。

<a id="api_irtcengine_queryscreencapturecapability"></a>

<a id="ariaid-title3"></a>

## QueryScreenCaptureCapability [#queryscreencapturecapability]

查询设备在屏幕共享时支持的最高帧率。

<a id="api_irtcengine_queryscreencapturecapability__prototype"></a>

```csharp
public abstract int QueryScreenCaptureCapability();
```

<a id="api_irtcengine_queryscreencapturecapability__detailed_desc"></a>

### 详情 [#详情-1]

<a id="api_irtcengine_queryscreencapturecapability__scenario"></a>

### 适用场景 [#适用场景]

在屏幕共享场景下，如果你想启用高帧率（如 60 fps）、但不确定设备是否支持时，可以先调用该方法查询设备支持的最高帧率。如果设备不支持高帧率，你可以在开启屏幕共享时适当调低屏幕共享流的帧率，以确保共享场景的效果符合预期。

<a id="api_irtcengine_queryscreencapturecapability__return_values"></a>

### 返回值 [#返回值-1]

- 方法调用成功时，返回设备支持的最高帧率。详见 SCREEN_CAPTURE_FRAMERATE_CAPABILITY。
- &lt;0：方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

<a id="api_irtcengine_setscreencapturecontenthint"></a>

<a id="ariaid-title4"></a>

## SetScreenCaptureContentHint [#setscreencapturecontenthint]

设置屏幕共享内容类型。

<a id="api_irtcengine_setscreencapturecontenthint__prototype"></a>

```csharp
public abstract int SetScreenCaptureContentHint(VIDEO_CONTENT_HINT contentHint);
```

<a id="api_irtcengine_setscreencapturecontenthint__detailed_desc"></a>

### 详情 [#详情-2]

<a id="api_irtcengine_setscreencapturecontenthint__desc"></a>

SDK 会根据不同的内容类型，使用不同的算法对共享效果进行优化。如果不调用该方法，SDK 会将屏幕共享的内容默认为 CONTENT_HINT_NONE，即无指定的内容类型。

<a id="api_irtcengine_setscreencapturecontenthint__note"></a>

:::caution
注意： 该方法在开始屏幕共享前后都能调用。
:::

<a id="api_irtcengine_setscreencapturecontenthint__parameters"></a>

### 参数 [#参数-1]

<ParameterList>
<a id="contenthint"></a>
<Parameter name="contentHint">

屏幕共享的内容类型。详见 [VIDEO_CONTENT_HINT](/zh-CN/api-reference/rtc/csharp-windows/enum-videocontenthint)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_setscreencapturecontenthint__return_values"></a>

### 返回值 [#返回值-2]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

### 所属接口类 [#所属接口类]

- [IRtcEngine](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengine)

<a id="api_irtcengine_setscreencapturescenario"></a>

<a id="ariaid-title5"></a>

## SetScreenCaptureScenario [#setscreencapturescenario]

设置屏幕共享的场景。

<a id="api_irtcengine_setscreencapturescenario__prototype"></a>

```csharp
public abstract int SetScreenCaptureScenario(SCREEN_SCENARIO_TYPE screenScenario);
```

<a id="api_irtcengine_setscreencapturescenario__detailed_desc"></a>

### 详情 [#详情-3]

开启屏幕共享或窗口共享时，你可以调用该方法设置屏幕共享的场景，SDK 会根据你设置的场景调整共享画面的画质。

:::note
注： 声网建议你在加入频道前调用该方法。
:::

<a id="api_irtcengine_setscreencapturescenario__parameters"></a>

### 参数 [#参数-2]

<ParameterList>
<a id="screenscenario"></a>
<Parameter name="screenScenario">

屏幕共享的场景，详见 [SCREEN_SCENARIO_TYPE](/zh-CN/api-reference/rtc/csharp-windows/enum-screenscenariotype)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_setscreencapturescenario__return_values"></a>

### 返回值 [#返回值-3]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

### 所属接口类 [#所属接口类-1]

- [IRtcEngine](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengine)

<a id="api_irtcengine_startscreencapture2"></a>

<a id="ariaid-title6"></a>

## StartScreenCapture [2/2] [#startscreencapture-22]

开始屏幕采集并指定视频源。

<a id="api_irtcengine_startscreencapture2__prototype"></a>

```csharp
public abstract int StartScreenCapture(VIDEO_SOURCE_TYPE sourceType, ScreenCaptureConfiguration config);
```

<a id="api_irtcengine_startscreencapture2__detailed_desc"></a>

:::caution
注意： 该方法仅适用于 macOS 和 Windows 平台。
:::

<a id="api_irtcengine_startscreencapture2__scenario"></a>

### 适用场景 [#适用场景-1]

在屏幕共享场景下，你需要调用该方法开始采集屏幕视频流。

SDK 支持一系列开启屏幕采集的方法，它们之间存在以下区别，请根据实际场景选用：

- [StartScreenCaptureByDisplayId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebydisplayid)/[StartScreenCaptureByWindowId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebywindowid)：仅支持采集单个屏幕或窗口，适合仅共享单个屏幕的场景。
- [StartScreenCapture [2/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapture2)：支持指定多个视频源，以采集多路屏幕共享流，用于本地合图或者多频道发布场景。

<a id="api_irtcengine_startscreencapture2__timing"></a>

### 调用时机 [#调用时机]

该方法在加入频道前后均可调用，区别如下：

- 如果在加入频道前调用该方法，然后调用 [JoinChannel [2/2]](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_joinchannel2) 加入频道，并设置 publishScreenCaptureVideo 为 `true`，即可开始屏幕共享。
- 如果在加入频道后调用该方法，然后调用 [UpdateChannelMediaOptions](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_updatechannelmediaoptions) 更新频道媒体选项，并设置 publishScreenCaptureVideo 为 `true`，即可开始屏幕共享。

<a id="api_irtcengine_startscreencapture2__restriction"></a>

### 调用限制 [#调用限制]

- 如果调用该方法开始屏幕采集，则停止屏幕采集时需要调用 [StopScreenCapture [2/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture2)。
- 在 Windows 平台上，最多支持 4 路屏幕采集的视频流。

<a id="api_irtcengine_startscreencapture2__parameters"></a>

### 参数 [#参数-3]

<ParameterList>
<a id="sourcetype"></a>
<Parameter name="sourceType">

视频源的类型，详见 [VIDEO_SOURCE_TYPE](/zh-CN/api-reference/rtc/csharp-windows/enum-videosourcetype)。

</Parameter>
<a id="config"></a>
<Parameter name="config">

屏幕采集配置。详见 [ScreenCaptureConfiguration](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureconfiguration)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_startscreencapture2__return_values"></a>

### 返回值 [#返回值-4]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

<a id="api_irtcengine_startscreencapturebydisplayid"></a>

<a id="ariaid-title7"></a>

## StartScreenCaptureByDisplayId [#startscreencapturebydisplayid]

开始采集指定屏幕的视频流。

<a id="api_irtcengine_startscreencapturebydisplayid__prototype"></a>

```csharp
public abstract int StartScreenCaptureByDisplayId(uint displayId, Rectangle regionRect, ScreenCaptureParameters captureParams);
```

<a id="api_irtcengine_startscreencapturebydisplayid__detailed_desc"></a>

采集一个屏幕或该屏幕部分区域的视频流。

<a id="api_irtcengine_startscreencapturebydisplayid__scenario"></a>

### 适用场景 [#适用场景-2]

在屏幕共享场景下，你需要调用该方法开始采集屏幕视频流。有关屏幕共享的实现方法，详见[屏幕共享](/zh-CN/realtime-media/rtc/build/video/screen-share)。

<a id="api_irtcengine_startscreencapturebydisplayid__timing"></a>

### 调用时机 [#调用时机-1]

<a id="api_irtcengine_startscreencapturebydisplayid__apisequence"></a>

该方法在加入频道前后均可调用，区别如下：

- 如果在加入频道前调用该方法，然后调用 [JoinChannel [2/2]](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_joinchannel2) 加入频道，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。
- 如果在加入频道后调用该方法，然后调用 [UpdateChannelMediaOptions](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_updatechannelmediaoptions) 更新频道媒体选项，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。

<a id="api_irtcengine_startscreencapturebydisplayid__restriction"></a>

### 调用限制 [#调用限制-1]

无。

<a id="api_irtcengine_startscreencapturebydisplayid__parameters"></a>

### 参数 [#参数-4]

<ParameterList>
<a id="displayid"></a>
<Parameter name="displayId">

指定待共享的屏幕 ID。

</Parameter>
<a id="regionrect"></a>
<Parameter name="regionRect">

（可选）指定待共享区域相对于整个屏幕的位置。如需共享整个屏幕，则填 `nil`。详见 [Rectangle](/zh-CN/api-reference/rtc/csharp-windows/class-rectangle)。

如果设置的共享区域超出了屏幕的边界，则只共享屏幕内的内容；如果宽或高设为 0，则共享整个屏幕。

</Parameter>
<a id="captureparams"></a>
<Parameter name="captureParams">

屏幕共享的参数配置。默认的视频编码分辨率为 1920 × 1080，即 2073600 像素。该像素值为计费标准。详见 [ScreenCaptureParameters](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureparameters)。

:::caution
注意： 屏幕共享流的视频属性只需通过该参数设置，与 [SetVideoEncoderConfiguration](/zh-CN/api-reference/rtc/csharp-windows/video/video-basic#api_irtcengine_setvideoencoderconfiguration) 无关。
:::

</Parameter>
</ParameterList>

<a id="api_irtcengine_startscreencapturebydisplayid__return_values"></a>

### 返回值 [#返回值-5]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

<a id="api_irtcengine_startscreencapturebyscreenrect"></a>

<a id="ariaid-title8"></a>

## StartScreenCaptureByScreenRect [#startscreencapturebyscreenrect]

开始采集指定屏幕区域的视频流。

<a id="api_irtcengine_startscreencapturebyscreenrect__prototype"></a>

```csharp
public abstract int StartScreenCaptureByScreenRect(Rectangle screenRect, Rectangle regionRect,
            ScreenCaptureParameters captureParams);
```

<a id="api_irtcengine_startscreencapturebyscreenrect__detailed_desc"></a>

### 详情 [#详情-4]

<a id="弃用"></a>

:::error[弃用：]
该方法已废弃。请改用 [StartScreenCaptureByDisplayId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebydisplayid)。如果你需要在设备外接其他显示屏的情况下开启屏幕共享，强烈建议你使用 StartScreenCaptureByDisplayId。
:::

<a id="api_irtcengine_startscreencapturebyscreenrect__desc"></a>

共享一个屏幕或该屏幕的部分区域。你需要在该方法中指定想要共享的屏幕区域。

该方法在加入频道前后均可调用，区别如下：

- 如果在加入频道前调用该方法，然后调用 [JoinChannel [2/2]](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_joinchannel2) 加入频道，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。
- 如果在加入频道后调用该方法，然后调用 [UpdateChannelMediaOptions](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_updatechannelmediaoptions) 更新频道媒体选项，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。

<a id="api_irtcengine_startscreencapturebyscreenrect__parameters"></a>

### 参数 [#参数-5]

<ParameterList>
<a id="screenrect"></a>
<Parameter name="screenRect">

指定待共享的屏幕相对于虚拟屏的位置。

</Parameter>
<a id="regionrect-1"></a>
<Parameter name="regionRect">

（可选）指定待共享区域相对于整个屏幕的位置。如不填，则表示共享整个屏幕。详见 [Rectangle](/zh-CN/api-reference/rtc/csharp-windows/class-rectangle)。如果设置的共享区域超出了屏幕的边界，则只共享屏幕内的内容；如果将 width 或 height 设为 0 ，则共享整个屏幕。

</Parameter>
<a id="captureparams-1"></a>
<Parameter name="captureParams">

屏幕共享的编码参数配置。默认的分辨率为 1920 x 1080，即 2073600 像素。该像素值为计费标准。详见 [ScreenCaptureParameters](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureparameters)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_startscreencapturebyscreenrect__return_values"></a>

### 返回值 [#返回值-6]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

<a id="api_irtcengine_startscreencapturebywindowid"></a>

<a id="ariaid-title9"></a>

## StartScreenCaptureByWindowId [#startscreencapturebywindowid]

开始采集指定窗口的视频流。

<a id="api_irtcengine_startscreencapturebywindowid__prototype"></a>

```csharp
public abstract int StartScreenCaptureByWindowId(long windowId, Rectangle regionRect, ScreenCaptureParameters captureParams);
```

<a id="api_irtcengine_startscreencapturebywindowid__detailed_desc"></a>

<a id="api_irtcengine_startscreencapturebywindowid__desc"></a>

共享一个窗口或该窗口的部分区域。用户需要在该方法中指定想要共享的窗口 ID。

<a id="api_irtcengine_startscreencapturebywindowid__note"></a>

:::caution
注意： 该方法仅适用于 macOS 和 Windows 平台。
:::

该方法支持共享通用 Windows 平台（UWP）应用窗口。声网使用最新版 SDK 对主流的 UWP 应用进行了测试，结果如下：

<a id="api_irtcengine_startscreencapturebywindowid__table_lvk_tfs_r4b"></a>

<DocsTable>
<thead>
<tr>
<th scope="col">**系统版本**</th>
<th scope="col">**软件**</th>
<th scope="col">**软件版本**</th>
<th scope="col">**是否支持**</th>
</tr>
</thead>
<tbody>
<tr>
<td rowSpan={8}>win10</td>
<td>Chrome</td>
<td>76.0.3809.100</td>
<td>否</td>
</tr>
<tr>
<td>Office Word</td>
<td rowSpan={3}>18.1903.1152.0</td>
<td>是</td>
</tr>
<tr>
<td>Office Excel</td>
<td>否</td>
</tr>
<tr>
<td>Office PPT</td>
<td>是</td>
</tr>
<tr>
<td>WPS Word</td>
<td rowSpan={3}>11.1.0.9145</td>
<td rowSpan={3}>是</td>
</tr>
<tr>
<td>WPS Excel</td>
</tr>
<tr>
<td>WPS PPT</td>
</tr>
<tr>
<td>Media Player（系统自带）</td>
<td>全部</td>
<td>是</td>
</tr>
<tr>
<td rowSpan={8}>win8</td>
<td>Chrome</td>
<td>全部</td>
<td>是</td>
</tr>
<tr>
<td>Office Word</td>
<td rowSpan={3}>全部</td>
<td rowSpan={3}>是</td>
</tr>
<tr>
<td>Office Excel</td>
</tr>
<tr>
<td>Office PPT</td>
</tr>
<tr>
<td>WPS Word</td>
<td rowSpan={3}>11.1.0.9098</td>
<td rowSpan={3}>是</td>
</tr>
<tr>
<td>WPS Excel</td>
</tr>
<tr>
<td>WPS PPT</td>
</tr>
<tr>
<td>Media Player（系统自带）</td>
<td>全部</td>
<td>是</td>
</tr>
<tr>
<td rowSpan={8}>win7</td>
<td>Chrome</td>
<td>73.0.3683.103</td>
<td>否</td>
</tr>
<tr>
<td>Office Word</td>
<td rowSpan={3}>全部</td>
<td rowSpan={3}>是</td>
</tr>
<tr>
<td>Office Excel</td>
</tr>
<tr>
<td>Office PPT</td>
</tr>
<tr>
<td>WPS Word</td>
<td rowSpan={2}>11.1.0.9098</td>
<td rowSpan={2}>否</td>
</tr>
<tr>
<td>WPS Excel</td>
</tr>
<tr>
<td>WPS PPT</td>
<td>11.1.0.9098</td>
<td>是</td>
</tr>
<tr>
<td>Media Player（系统自带）</td>
<td>全部</td>
<td>否</td>
</tr>
</tbody>
</DocsTable>

<a id="api_irtcengine_startscreencapturebywindowid__scenario"></a>

### 适用场景 [#适用场景-3]

在屏幕共享场景下，你需要调用该方法开始采集屏幕视频流。有关屏幕共享的实现方法，详见[屏幕共享](/zh-CN/realtime-media/rtc/build/video/screen-share)。

<a id="api_irtcengine_startscreencapturebywindowid__timing"></a>

### 调用时机 [#调用时机-2]

该方法在加入频道前后均可调用，区别如下：

- 如果在加入频道前调用该方法，然后调用 [JoinChannel [2/2]](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_joinchannel2) 加入频道，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。
- 如果在加入频道后调用该方法，然后调用 [UpdateChannelMediaOptions](/zh-CN/api-reference/rtc/csharp-windows/channel#api_irtcengine_updatechannelmediaoptions) 更新频道媒体选项，并设置 publishScreenTrack 或 publishSecondaryScreenTrack 为 `true`，即可开始屏幕共享。

<a id="api_irtcengine_startscreencapturebywindowid__restriction"></a>

### 调用限制 [#调用限制-2]

SDK 的窗口共享功能依赖于 WGC（Windows Graphics Capture）或 GDI（Graphics Device Interface）采集，WGC 在早于 Windows 10 2004 的系统上无法设置关闭鼠标采集，因此，当你在搭载早于 Windows 10 2004 系统的设备上进行窗口共享时，可能出现 `captureMouseCursor(false)` 不生效的现象。详见 [ScreenCaptureParameters](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureparameters)。

<a id="api_irtcengine_startscreencapturebywindowid__parameters"></a>

### 参数 [#参数-6]

<ParameterList>
<a id="windowid"></a>
<Parameter name="windowId">

指定待共享的窗口 ID。

</Parameter>
<a id="regionrect-2"></a>
<Parameter name="regionRect">

（可选）指定待共享区域相对于整个屏幕的位置。如不填，则表示共享整个屏幕。详见 [Rectangle](/zh-CN/api-reference/rtc/csharp-windows/class-rectangle)。如果设置的共享区域超出了窗口的边界，则只共享窗口内的内容；如果宽或高为 0，则共享整个窗口。

</Parameter>
<a id="captureparams-2"></a>
<Parameter name="captureParams">

屏幕共享的参数配置。默认的分辨率为 1920 x 1080，即 2073600 像素。该像素值为计费标准。详见 [ScreenCaptureParameters](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureparameters)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_startscreencapturebywindowid__return_values"></a>

### 返回值 [#返回值-7]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

<a id="api_irtcengine_stopscreencapture"></a>

<a id="ariaid-title10"></a>

## StopScreenCapture [1/2] [#stopscreencapture-12]

停止屏幕采集。

<a id="api_irtcengine_stopscreencapture__prototype"></a>

```csharp
public abstract int StopScreenCapture();
```

<a id="api_irtcengine_stopscreencapture__detailed_desc"></a>

<a id="api_irtcengine_stopscreencapture__scenario"></a>

### 适用场景 [#适用场景-4]

如果你调用了 [StartScreenCaptureByWindowId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebywindowid) 或 [StartScreenCaptureByDisplayId](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapturebydisplayid) 开启屏幕采集，则停止屏幕采集时需要调用该方法。

<a id="api_irtcengine_stopscreencapture__timing"></a>

### 调用时机 [#调用时机-3]

该方法在加入频道前后均可调用。

<a id="api_irtcengine_stopscreencapture__restriction"></a>

### 调用限制 [#调用限制-3]

无。

<a id="api_irtcengine_stopscreencapture__return_values"></a>

### 返回值 [#返回值-8]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

### 所属接口类 [#所属接口类-2]

- [IRtcEngine](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengine)

<a id="api_irtcengine_stopscreencapture2"></a>

<a id="ariaid-title11"></a>

## StopScreenCapture [2/2] [#stopscreencapture-22]

停止对指定的视频源进行屏幕采集。

<a id="api_irtcengine_stopscreencapture2__prototype"></a>

```csharp
public abstract int StopScreenCapture(VIDEO_SOURCE_TYPE sourceType);
```

<a id="api_irtcengine_stopscreencapture2__detailed_desc"></a>

<a id="api_irtcengine_stopscreencapture2__scenario"></a>

### 适用场景 [#适用场景-5]

如果你调用了 [StartScreenCapture [2/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_startscreencapture2) 开启一路或多路屏幕采集，则停止屏幕采集时需要调用该方法，并通过 sourceType 参数指定屏幕。

<a id="api_irtcengine_stopscreencapture2__timing"></a>

### 调用时机 [#调用时机-4]

该方法在加入频道前后均可调用。

<a id="api_irtcengine_stopscreencapture2__restriction"></a>

### 调用限制 [#调用限制-4]

无。

<a id="api_irtcengine_stopscreencapture2__parameters"></a>

### 参数 [#参数-7]

<ParameterList>
<a id="sourcetype-1"></a>
<Parameter name="sourceType">

视频源的类型，详见 [VIDEO_SOURCE_TYPE](/zh-CN/api-reference/rtc/csharp-windows/enum-videosourcetype)。

</Parameter>
</ParameterList>

<a id="api_irtcengine_stopscreencapture2__return_values"></a>

### 返回值 [#返回值-9]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

<a id="api_irtcengine_updatescreencaptureparameters"></a>

<a id="ariaid-title12"></a>

## UpdateScreenCaptureParameters [#updatescreencaptureparameters]

更新屏幕采集的参数配置。

<a id="api_irtcengine_updatescreencaptureparameters__prototype"></a>

```csharp
public abstract int UpdateScreenCaptureParameters(ScreenCaptureParameters captureParams);
```

<a id="api_irtcengine_updatescreencaptureparameters__detailed_desc"></a>

### 详情 [#详情-5]

:::caution
注意：

- 请在开启屏幕共享或窗口共享后调用该方法。
:::

<a id="api_irtcengine_updatescreencaptureparameters__parameters"></a>

### 参数 [#参数-8]

<ParameterList>
<a id="captureparams-3"></a>
<Parameter name="captureParams">

屏幕共享的编码参数配置。详见 [ScreenCaptureParameters](/zh-CN/api-reference/rtc/csharp-windows/class-screencaptureparameters)。

:::caution
注意： 屏幕共享流的视频属性只需通过该参数设置，与 [SetVideoEncoderConfiguration](/zh-CN/api-reference/rtc/csharp-windows/video/video-basic#api_irtcengine_setvideoencoderconfiguration) 无关。
:::

</Parameter>
</ParameterList>

<a id="api_irtcengine_updatescreencaptureparameters__return_values"></a>

### 返回值 [#返回值-10]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

### 所属接口类 [#所属接口类-3]

- [IRtcEngine](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengine)

<a id="api_irtcengine_updatescreencaptureregion"></a>

<a id="ariaid-title13"></a>

## UpdateScreenCaptureRegion [#updatescreencaptureregion]

更新屏幕采集的区域。

<a id="api_irtcengine_updatescreencaptureregion__prototype"></a>

```csharp
public abstract int UpdateScreenCaptureRegion(Rectangle regionRect);
```

<a id="api_irtcengine_updatescreencaptureregion__detailed_desc"></a>

### 详情 [#详情-6]

:::caution
注意： 请在开启屏幕共享或窗口共享后调用该方法。
:::

<a id="api_irtcengine_updatescreencaptureregion__parameters"></a>

### 参数 [#参数-9]

<ParameterList>
<a id="regionrect-3"></a>
<Parameter name="regionRect">

待共享区域相对于整个屏幕或窗口的位置，如不填，则表示共享整个屏幕或窗口。详见 [Rectangle](/zh-CN/api-reference/rtc/csharp-windows/class-rectangle)。如果设置的共享区域超出了屏幕或窗口的边界，则只共享屏幕或窗口内的内容；如果将 width 或 height 设为 0，则共享整个屏幕或窗口。

</Parameter>
</ParameterList>

<a id="api_irtcengine_updatescreencaptureregion__return_values"></a>

### 返回值 [#返回值-11]

- 0: 方法调用成功。
- &lt; 0: 方法调用失败。详见[错误码](/zh-CN/api-reference/rtc/error-code)了解详情和解决建议。

  - -2：传入的参数无效。
  - -8：屏幕共享状态无效。可能因为你已经共享了其他屏幕或窗口。尝试调用 [StopScreenCapture [1/2]](/zh-CN/api-reference/rtc/csharp-windows/video/screencapture#api_irtcengine_stopscreencapture) 停止当前共享，再重新开始共享屏幕。

### 所属接口类 [#所属接口类-4]

- [IRtcEngine](/zh-CN/api-reference/rtc/csharp-windows/rtc-interface-class#class_irtcengine)
