Public APIs

更新时间:
复制 MD 格式

This topic describes the APIs for integrating the audio and video calling SDK for iOS.

API type

API

Description

Channel-related APIs

createRoom

Creates a video call channel.

joinRoom

Joins a video call channel.

leaveRoom

Leaves a video call channel.

Invitation and response APIs

inviteWith

Notifies a user to join the channel.

replyWith

Responds to an invitation.

Publish and subscribe APIs

publish

Publishes a stream.

unpublish

Unpublishes a stream.

subscribe

Subscribes to a stream.

unsubscribe

Unsubscribes from a stream.

Camera Interface

startCameraPreviewUsingBackCamera

Starts the camera.

stopCameraPreview

Stops the camera.

switchCamera

Switches between the front and rear cameras.

The Mute API

muteMicrophone

Mutes the microphone.

muteRemoteAudio

Mutes the audio of a single remote user.

muteAllRemoteAudios

Mutes the audio of all remote users.

muteRemoteVideo

Mutes the video of a single remote user.

muteAllRemoteVideos

Mutes the video of all remote users.

Snapshot API

snapshotForFeed

Screenshot

Speaker/Earpiece interface

currentAudioPlayMode

The current audio playback mode.

switchAudioPlayModeTo

Switches between the earpiece and speaker modes.

IM APIs

sendMessage

Sends an IM message to a single user.

sendMessage

Sends an IM message to multiple users.

Custom stream ingest APIs

createCustomVideoCapturer

Creates a custom stream ingest class.

destroyCustomVideoCapturer

Destroys a custom stream ingest class.

Screen sharing APIs

isScreenCaptureSupported

Checks whether screen capture is supported.

isScreenCaptureStarted

Checks whether screen capture is started.

startScreenCaptureWithParams

Starts screen capture.

stopScreenCapture

Stops screen capture.

createRoom

  • Declaration: (void)createRoom:(ARTVCCreateRoomParams*) params

  • Description: Creates a video call channel.

  • Parameters:

    Parameter

    Type

    Description

    Optional

    uid

    NSString*

    The user UID.

    NO

    bizName

    NSString*

    The primary business name.

    NO

    signature

    NSString*

    The signature.

    NO

    extraInfo

    NSDictionary*

    The extension parameters.

    YES

  • Return value: None.

joinRoom

  • Declaration: (void)joinRoom:(ARTVCJoinRoomParams*) params;

  • Description: Joins a video call channel.

  • Parameters:

    Parameter

    Type

    Description

    Can be empty?

    uid

    NSString*

    The user UID.

    NO

    bizName

    NSString*

    The primary business name.

    NO

    signature

    NSString*

    The signature.

    NO

    roomId

    NSString*

    The channel ID.

    NO

    rtoken

    NSString*

    The channel token.

    NO

    extraInfo

    NSDictionary*

    The extension parameters.

    YES

  • Return value: None.

leaveRoom

  • Declaration: (void)leaveRoom;

  • Description: Leaves a video call channel.

  • Parameters: None.

  • Return value: None.

inviteWith

  • Declaration: (void)inviteWith:(ARTVCInviteParams*)params complete:(ARTVCInviteCallback)complete;

  • Description: After creating a video call channel, call this API to invite a user to join the channel. In C2B mode, you can invite a web agent. This API is not supported in C2C mode.

  • Parameters:

    • ARTVCInviteParams

      Parameter

      Type

      Description

      Optional.

      Default value

      inviteId

      NSString

      The invitation ID. This ID identifies the invitation.

      No.

      None

      inviteeUid

      NSString

      The UID of the remote user.

      No

      None

      inviteType

      ARTVCInviteType

      Only `ARTVCInviteTypeWebsocket` is supported. The invitee must be a web client.

      No.

      None

      audioEnable

      BOOL

      Invites the remote user to enable audio.

      No

      Yes

      videoEnable

      BOOL

      Invites the remote user to enable video.

      Yes

      Yes.

      timeout

      int

      The timeout period.

      No

      60

      extraInfo

      NSDictionary*

      The extension parameters.

      Yes

      None

    • ARTVCInviteCallback

      // If error is nil, the operation is successful. For more information about error codes, see ARTVCInviteError.
      typedef void (^ARTVCInviteCallback)(NSError*_Nullable error);
    • Error code definitions

      typedef NS_ENUM(int,ARTVCInviteError){
      ARTVCInviteErrorBadParameters                  = 1,
      ARTVCInviteErrorNotHaveValidRoom               = 2,
      ARTVCInviteErrorPreviousInviteUnderProcessing  = 3,
      ARTVCInviteErrorRequestFailed                  = 4,
      ARTVCInviteErrorTimeout                        = 5,
      ARTVCInviteErrorCanceledWhenLeaveRoom          = 6,
      };
  • Return value: None.

replyWith

  • Declaration: -(void)replyWith:(ARTVCReplyParams*)params complete:(ARTVCReplyCallback)complete;

  • Note: This interface is for acknowledgements.

  • Parameters:

    • ARTVCReplyParams

      Parameter

      Type

      Description

      Nullable

      Default value

      uid

      NSString

      The user UID.

      No

      None

      inviterUid

      NSString

      The inviter UID.

      No

      None

      bizName

      NSString

      The primary business name.

      No

      None

      roomId

      NSString

      The channel ID.

      No

      None

      replyType

      ARTVCReplyType

      The acknowledgement type.

      No

      None

      audioEnable

      BOOL

      Specifies whether to enable audio.

      No

      YES

      videoEnable

      BOOL

      Specifies whether to enable video.

      No

      YES

      timeout

      int

      The timeout settings.

      No

      60

      extraInfo

      NSDictionary*

      The extension parameters.

      Yes

      None

    • ARTVCReplyCallback

      // If error is nil, the operation is successful. For more information about error codes, see ARTVCReplyError.
      typedef void (^ARTVCReplyCallback)(NSError*_Nullable error);
    • Error code definitions

      typedef NS_ENUM(int,ARTVCReplyError){
      ARTVCReplyErrorBadParameters                     = 1,
      ARTVCReplyErrorPreviousReplyUnderProcessing      = 3,
      ARTVCReplyErrorRequestFailed                     = 4,
      ARTVCReplyErrorTimeout                           = 5,
      ARTVCReplyErrorCanceledWhenLeaveRoom             = 6,
      };
  • Return value: None.

publish

  • Declaration: (void)publish:(ARTVCPublishConfig*)config

  • Description: Publishes a stream.

  • Parameters: ARTVCPublishConfig

    Parameter

    Type

    Description

    Default value

    videoEnable

    BOOL

    Specifies whether to publish a video stream.

    Yes.

    audioEnable

    BOOL

    Specifies whether to publish an audio stream.

    true

    videoSource

    ARTVCVideoSourceType

    The video source type.

    ARTVCVideoSourceType_Camera

    videoProfile

    ARTVCVideoProfileType

    The resolution and frames per second (FPS) for video encoding.

    ARTVCVideoProfileType640x36015Fps

    videoCustomWidth

    int

    The custom video width. This parameter is valid only when `videoProfile` is set to `ARTVCVideoProfileType_Custom`. We do not recommend using this parameter.

    None

    videoCustomHeight

    int

    The custom video height. This parameter is valid only when `videoProfile` is set to `ARTVCVideoProfileType_Custom`. We do not recommend using this parameter.

    None

    videoCustomFps

    int

    The custom FPS. This parameter is valid only when `videoProfile` is set to `ARTVCVideoProfileType_Custom`. We do not recommend using this parameter.

    None

    videoCustomBitrate

    int

    The custom bitrate. This parameter is valid only when `videoProfile` is set to `ARTVCVideoProfileType_Custom`. We do not recommend using this parameter.

    None

    timeout

    int

    The timeout period.

    60

    tag

    NSString

    The custom stream tag.

    VIDEO_SOURCE_CAMERA / VIDEO_SOURCE_SCREEN

  • Return value: None.

unpublish

  • Declaration: -(void)unpublish:(ARTVCUnpublishConfig*)config

  • Description: Unpublishes a stream.

  • Parameters:

    • ARTVCUnpublishConfig

      Parameter

      Type

      Description

      feed

      ARTVCFeed*

      The feed to unpublish.

    • ARTVCFeed

      Parameter

      Type

      Description

      Nullable

      uid

      NSString*

      The UID of the user who owns the feed.

      No

      userType

      ARTVCParticipantType

      The user type. The default value is regular user. `ARTVCParticipantTypeVirtualVod` indicates a virtual user for the video-on-demand service.

      No

      feedId

      NSString*

      The feed ID.

      No

      tag

      NSString*

      The tag type of the feed.

      Yes

  • Return value: None.

subscribe

  • Declaration: (void)subscribe:(ARTVCSubscribeConfig*)config

  • Description: Subscribes to a stream.

  • Parameters:

    • ARTVCSubscribeConfig

      Parameter

      Type

      Description

      Nullable

      feed

      ARTVCFeed*

      The feed to subscribe to.

      NO

      options

      ARTVCSubscribeOptions*

      Subscription parameters.

      NO

    • ARTVCSubscribeOptions

      Parameter

      Type

      Description

      This is optional.

      receiveAudio

      BOOL

      Specifies whether to subscribe to the audio stream.

      Yes

      receiveVideo

      BOOL

      Specifies whether to subscribe to the video stream.

      Yes.

      timeout

      int

      Timeout settings

      60

  • Return value: None.

unsubscribe

  • Declaration: (void)unsubscribe:(ARTVCUnsubscribeConfig*)config

  • Description: Unsubscribes from a stream.

  • Parameters: ARTVCUnsubscribeConfig

    Parameter

    Type

    Description

    feed

    ARTVCFeed*

    The feed to unsubscribe from.

  • Return value: None.

startCameraPreviewUsingBackCamera

  • Declaration: (void)startCameraPreviewUsingBackCamera:(BOOL)usingBackCamera

  • Description: Starts the camera.

  • Parameters: If `usingBackCamera` is set to `true`, the rear camera is used. Otherwise, the front camera is used.

  • Return value: None.

stopCameraPreview

  • Declaration: (void)stopCameraPreview

  • Description: Stops the camera.

  • Parameters: None.

  • Return value: None.

switchCamera

  • Declaration: (void)switchCamera

  • Description: Switches between the front and rear cameras.

  • Parameters: None.

  • Return value: None.

muteMicrophone

  • Declaration: (void)muteMicrophone:(BOOL)muted

  • Description: Mutes the microphone.

  • Parameters: If `muted` is set to `true`, the microphone is muted. Otherwise, the microphone is unmuted.

  • Return value: None.

muteRemoteAudio

  • Declaration: (void)muteRemoteAudio:(BOOL)muted forFeed:(ARTVCFeed*)feed

  • Description: Mutes the audio of a single remote user.

  • Parameters: If `muted` is set to `true`, the audio stream in the specified feed is muted. Otherwise, the audio stream is unmuted. The `feed` parameter cannot be empty.

  • Return value: None.

muteAllRemoteAudios

  • Declaration: (void)muteAllRemoteAudios:(BOOL)muted

  • Description: Mutes the audio of all remote users.

  • Parameters: If `muted` is set to `true`, the audio streams in all subscribed feeds are muted. Otherwise, the audio streams are unmuted.

  • Return value: None.

muteRemoteVideo

  • Declaration: (void)muteRemoteVideo:(BOOL)muted forFeed:(ARTVCFeed*)feed

  • Description: Mutes the video of a single remote user.

  • Parameters: If `muted` is set to `true`, the video stream in the specified feed is muted. Otherwise, the video stream is unmuted. The `feed` parameter cannot be empty.

  • Return value: None.

muteAllRemoteVideos

  • Declaration: (void)muteAllRemoteVideos:(BOOL)muted

  • Description: Mutes the video of all remote users.

  • Parameters: If `muted` is set to `true`, the video streams in all subscribed feeds are muted. Otherwise, the video streams are unmuted.

  • Return value: None.

snapshotForFeed

  • Declaration: (void)snapshotForFeed:(ARTVCFeed*)feed complete:(void(^)(UIImage* image))complete

  • Description: Captures a video frame from a local or remote feed and returns it as a UIImage in `.jpg` format.

  • Parameters:

    • ARTVCFeed

      Parameter

      Type

      Description

      This can be left empty.

      uid

      NSString*

      The UID of the user who owns the feed.

      No.

      userType

      ARTVCParticipantType

      The user type. The default value is regular user. `ARTVCParticipantTypeVirtualVod` indicates a virtual user for the video-on-demand service.

      No.

      feedId

      NSString*

      The feed ID.

      No

      tag

      NSString*

      The tag type of the feed.

      Yes

    • complete

      Parameter

      Type

      Description

      Can be empty

      complete

      ARTVCIMCallback

      The screenshot callback. An empty value indicates that the screenshot failed.

      YES

  • Return value: None.

currentAudioPlayMode

  • Declaration: (ARTVCAudioPlayMode)currentAudioPlayMode

  • Note: Specifies the playback mode of the current audio.

  • Parameters: None.

  • Return value: None.

switchAudioPlayModeTo

  • Declaration: (void)switchAudioPlayModeTo:(ARTVCAudioPlayMode)audioPlayMode complete:(void (^_Nullable)(NSError*_Nullable error))callback

  • Description: Switches between the earpiece and speaker modes. This operation is ignored in headphone mode.

  • Parameters:

    • ARTVCAudioPlayMode

      /**
      * Audio playback mode
      */
      typedef NS_ENUM(NSUInteger,ARTVCAudioPlayMode) {
      ARTVCAudioPlayModeInit = 0,  // Initial state
      ARTVCAudioPlayModeReceiver,  // Earpiece
      ARTVCAudioPlayModeSpeaker,   // Speaker
      ARTVCAudioPlayModeHeadphone, // Headphone
      ARTVCAudioPlayModeBluetooth // Bluetooth device
      };
    • Explanation of the `callback`: If `error` is null, the operation was successful. Otherwise, the operation failed.

  • Return value: None.

sendMessage

  • Declaration: (void)sendMessage:(ARTVCIMMessage*)message toPariticipant:(NSString*)pariticipant complete:(ARTVCIMCallback)complete

  • Description: Sends an IM message to a single user.

  • Parameters:

    Parameter

    Type

    Description

    Can be empty

    message

    ARTVCIMMessage*

    IM message

    No

    pariticipant

    NSString*

    User UID

    No

    complete

    ARTVCIMCallback

    Callback for the message sending result

    Yes

    • ARTVCIMMessage

      Parameter

      Type

      Description

      Nullable

      msg

      NSString*

      The content of the message.

      NO

      msgId

      NSUInteger

      The ID of the message.

      YES

      timestamp

      NSTimeInterval

      The timestamp of the message.

      YES

    • ARTVCIMCallback

      // If error is nil, the operation is successful.
      typedef void (^ARTVCIMCallback)(NSError* error);
  • Return value: None.

sendMessage

  • Declaration: (void)sendMessage:(ARTVCIMMessage*)message toPariticipants:(NSArray<NSString*>*)pariticipants complete:(ARTVCIMCallback)complete

  • Description: Sends an IM message to multiple users.

  • Parameters:

    Parameter

    Type

    Description

    Nullable

    message

    ARTVCIMMessage *

    The IM message.

    No

    participants

    NSArray<NSString>

    An array of user UIDs.

    No

    complete

    ARTVCIMCallback

    The callback for the message sending result.

    Yes

  • Return value: None.

createCustomVideoCapturer

  • Declaration: -(ARTVCCustomVideoCapturer*)createCustomVideoCapturer:(ARTVCCreateCustomVideoCaputurerParams*)params;

  • Description: Creates a custom stream ingest class.

  • Parameters:

    Parameter

    Type

    Description

    Nullable

    params

    ARTVCCreateCustomVideoCaputurerParams*

    Parameters for the custom stream ingest class.

    No

    ARTVCCreateCustomVideoCaputurerParams is defined as follows:

    Parameter

    Type

    Description

    This parameter is optional.

    provideRenderView

    BOOL

    Specifies whether to provide a rendering view.

    No

  • Return value: None.

destroyCustomVideoCapturer

  • Declaration: -(void)destroyCustomVideoCapturer;

  • Description: Destroys the custom stream ingest class.

  • Parameters: None.

  • Return value: None.

isScreenCaptureSupported

  • Declaration: -(BOOL)isScreenCaptureSupported;

  • Description: Checks whether screen capture is supported. Note that screen capture is supported only on iOS 11 and later.

  • Parameters: None.

  • Return value: Returns `true` if screen capture is supported, or `false` otherwise.

isScreenCaptureStarted

  • Declaration: -(BOOL)isScreenCaptureStarted;

  • Description: Checks whether screen capture is started.

  • Parameters: None.

  • Return value: None.

startScreenCaptureWithParams

  • Declaration: -(void)startScreenCaptureWithParams:(ARTVCCreateScreenCaputurerParams*)params complete:(ARTVCErrorCallback)callback;

  • Description: Starts screen capture.

  • Parameters:

    Parameter

    Type

    Description

    Nullable

    params

    ARTVCCreateCustomVideoCaputurerParams*

    The parameters for starting screen capture.

    No.

    callback

    ARTVCErrorCallback

    The callback for the result of starting screen capture.

    No

    ARTVCCreateScreenCaputurerParams is defined as follows:

    Parameter

    Type

    Description

    This field is optional.

    provideRenderView

    BOOL

    Specifies whether to provide a rendering view.

    No

  • Return value: None.

stopScreenCapture

  • Declaration: -(void)stopScreenCapture;

  • Description: Stops screen capture.

  • Parameters: None.

  • Return value: None.