iOS and Mac

更新时间:
复制 MD 格式

This topic describes how to use screen sharing.

Stream ingest client

  1. Start screen sharing.
    // Configure screen sharing for stream ingest
    int ret = [self.engine startScreenShareWithDesktopId: int:desktopId AliRtcScreenShareConfig * _Nonnull:config];
    .....
  2. After the stream ingest starts, use a callback to confirm that the screen sharing is published.
    void onScreenSharePublishStateChanged(AliRtcEngine.AliRtcPublishState oldState ,
                                                 AliRtcEngine.AliRtcPublishState newState,
                                                 int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous stream ingest state.
    newStateAliRtcPublishStateThe current stream ingest state.
    elapseSinceLastStateintThe time interval since the last state change. Unit: ms.
    channelStringThe current channel ID.
  3. Stop screen sharing.
    // Configure to stop screen sharing
    int ret = [self.engine stopScreenShare:NO];
  4. After screen sharing stops, use a callback to confirm that the screen sharing is unpublished.
    void onScreenSharePublishStateChanged(AliRtcEngine.AliRtcPublishState oldState ,
                                                 AliRtcEngine.AliRtcPublishState newState,
                                                 int elapseSinceLastState, String channel);
    ParameterTypeDescription
    oldStateAliRtcPublishStateThe previous stream ingest state.
    newStateAliRtcPublishStateThe current stream ingest state.
    elapseSinceLastStateintThe time interval since the last state change. Unit: ms.
    channelStringThe current channel ID.

Subscriber client

Subscribers can automatically or manually subscribe to the screen sharing video stream from the stream ingest client and set the corresponding view for display. For more information, see the AliRtcEngine interface.