User Manual for macOS

FAQ

Where can I download the PortSIP VoIP SDK for testing?

You can download the PortSIP VoIP SDK, along with sample projects, from the PortSIP Website.

What macOS versions are required for development?

Development using the PortSIP VoIP/IMS SDK for macOS requires a Mac running macOS Ventura 13.5 or later and Xcode 15.0 or above.

How can I create a new project with the PortSIP VoIP SDK?

  1. Download the Sample Project: Download the sample project from tthe PortSIP Website and extract it to a desired directory.

  2. Create a New Project: In Xcode, create a new OS X Cocoa Application project.

  3. Add the PortSIPVoIPSDK Framework: Drag and drop the PortSIPVoIPSDK.framework from Finder to your project's Frameworks folder.

  4. Copy Frameworks Files: Under the Build Phases section of your project editor, add a "Copy Files" build phase. Specify the destination as "Frameworks" and add the PortSIPVoIPSDK.framework to be copied.

  5. Import the SDK: In your header file, import the SDK using the following line:

    #import <PortSIPVoIPSDK/PortSIPVoIPSDK.h>

How can I process callback events?

  1. Inherit the PortSIPEventDelegate: Your class should inherit the PortSIPEventDelegate protocol to handle callback events.

  2. Implement Callback Methods: Implement the necessary callback methods (e.g., onRegistrationState, onCallState) to handle specific events.

How do I initialize the SDK?

  1. Create an Instance: Create an instance of the PortSIPSDK class.

  2. Set the Delegate: Set the delegate of the SDK instance to your class that implements the PortSIPEventDelegate protocol.

Is the SDK thread-safe?

Yes, the PortSIP SDK is thread-safe. You can call API functions from multiple threads without worrying about synchronization issues. However, there are exceptions: the onAudioRawCallback, onVideoRawCallback, and onRTPPacketCallback callbacks should not be called directly from other threads.

SDK Callback events

Register events

- (void)onRegisterSuccess: (NSString *)statusText 
              statusCode: (int)statusCode 
              sipMessage: (NSString *)sipMessage

When successfully registered to server, this event will be triggered.

Parameters

- (void)onRegisterFailure: (NSString *)statusText 
              statusCode: (int)statusCode 
              sipMessage: (NSString *)sipMessage

If registration to SIP server fails, this event will be triggered.

Parameters

Call events

- (void)onInviteIncoming: (long)sessionId 
       callerDisplayName: (NSString *)callerDisplayName 
                  caller: (NSString *)caller 
       calleeDisplayName: (NSString *)calleeDisplayName 
                  callee: (NSString *)callee 
             audioCodecs: (NSString *)audioCodecs 
             videoCodecs: (NSString *)videoCodecs 
             existsAudio: (BOOL)existsAudio 
             existsVideo: (BOOL)existsVideo 
              sipMessage: (NSString *)sipMessage

When the call is coming, this event will be triggered.

Parameters

- (void)onInviteTrying: (long)sessionId

If the outgoing call is being processed, this event will be triggered.

Parameters

- (void)onInviteSessionProgress:(long)sessionId
                    audioCodecs:(NSString*)audioCodecs
                    videoCodecs:(NSString*)videoCodecs
               existsEarlyMedia:(BOOL)existsEarlyMedia
                    existsAudio:(BOOL)existsAudio
                    existsVideo:(BOOL)existsVideo
                     sipMessage:(NSString*)sipMessage;

Once the caller received the "183 session in progress" message, this event will be triggered.

Parameters

- (void)onInviteRinging: (long)sessionId 
              statusText: (NSString *)statusText 
              statusCode: (int)statusCode 
              sipMessage: (NSString *)sipMessage 

If the outgoing call is ringing, this event will be triggered.

Parameters

- (void)onInviteAnswered: (long)sessionId 
       callerDisplayName: (NSString *)callerDisplayName 
                  caller: (NSString *)caller 
       calleeDisplayName: (NSString *)calleeDisplayName 
                  callee: (NSString *)callee 
             audioCodecs: (NSString *)audioCodecs 
             videoCodecs: (NSString *)videoCodecs 
             existsAudio: (BOOL)existsAudio 
             existsVideo: (BOOL)existsVideo 
              sipMessage: (NSString *)sipMessage

If the remote party answered the call, this event would be triggered.

Parameters

- (void)onInviteFailure: (long)sessionId 
      callerDisplayName: (NSString *)callerDisplayName 
                 caller: (NSString *)caller 
      calleeDisplayName: (NSString *)calleeDisplayName 
                 callee: (NSString *)callee 
                 reason: (NSString *)reason 
                   code: (int)code 
             sipMessage: (NSString *)sipMessage

If the outgoing/incoming call fails, this event will be triggered.

Parameters

- (void)onInviteUpdated: (long)sessionId 
             audioCodecs: (NSString *)audioCodecs 
             videoCodecs: (NSString *)videoCodecs 
             screenCodecs: (NSString *)screenCodecs 
             existsAudio: (BOOL)existsAudio 
             existsVideo: (BOOL)existsVideo 
             existsScreen: (BOOL)existsScreen 
              sipMessage: (NSString *)sipMessage

This event will be triggered when remote party updates this call.

Parameters

- (void)onInviteConnected: (long)sessionId

This event will be triggered when UAC sent/UAS received ACK (the call is connected). Some functions (hold, updateCall etc...) can be called only after the call is connected, otherwise it will return error.

Parameters

- (void)onInviteBeginingForward: (NSString *)forwardTo

If the enableCallForward method is called and a call is incoming, the call will be forwarded automatically and this event will be triggered.

Parameters

- (void)onInviteClosed: (long)sessionId 
            sipMessage: (NSString *)sipMessage

This event will be triggered once remote side closes the call.

Parameters

- (void)onDialogStateUpdated: (NSString *)BLFMonitoredUri 
              BLFDialogState: (NSString *)BLFDialogState 
                BLFDialogId: (NSString *)BLFDialogId 
          BLFDialogDirection: (NSString *)BLFDialogDirection

If a user subscribed and his dialog status monitored, when the monitored user is holding a call or being rang, this event will be triggered.

Parameters

- (void)onRemoteHold: (long)sessionId

If the remote side has placed the call on hold, this event will be triggered.

Parameters

- (void)onRemoteUnHold: (long)sessionId 
            audioCodecs: (NSString *)audioCodecs 
            videoCodecs: (NSString *)videoCodecs 
            existsAudio: (BOOL)existsAudio 
            existsVideo: (BOOL)existsVideo

If the remote side un-holds the call, this event will be triggered.

Parameters

Refer events

- (void)onReceivedRefer:(long)sessionId
                referId:(long)referId
                     to:(NSString*)to
                   from:(NSString*)from
        referSipMessage:(NSString*)referSipMessage;

This event will be triggered once receiving a REFER message.

Parameters

- (void)onReferAccepted:(long)sessionId;

This callback will be triggered once remote side calls "acceptRefer" to accept the REFER.

Parameters

- (void)onReferRejected:(long)sessionId 
                 reason:(NSString*)reason
                   code:(int)code;

This callback will be triggered once remote side calls "rejectRefer" to reject the REFER.

Parameters

- (void)onTransferTrying:(long)sessionId;

When the refer call is being processed, this event will be trigged.

Parameters

- (void)onTransferRinging:(long)sessionId;

When the refer call rings, this event will be triggered.

Parameters

- (void)onACTVTransferSuccess:(long)sessionId;

When the refer call succeeds, this event will be triggered. ACTV means Active. For example: A starts the call with B, and A transfers B to C. When C accepts the refered call, A will receive this event.

Parameters

- (void)onACTVTransferFailure:(long)sessionId 
                       reason:(NSString*)reason
                         code:(int)code;

When the refer call fails, this event will be triggered. ACTV means Active. For example: A starts the call with B, and A transfers B to C. When C rejects the refered call, A will receive this event.

Parameters

Signaling events

- (void)onReceivedSignaling:(long)sessionId 
                    message:(NSString*)message; 

This event will be triggered when receiving an SIP message. This event is disabled by default. To enable, use enableCallbackSignaling.

Parameters

- (void)onSendingSignaling:(long)sessionId 
                   message:(NSString*)message; 

This event will be triggered when a SIP message is sent. This event is disabled by default. To enable, use enableCallbackSignaling.

Parameters

MWI events

- (void)onWaitingVoiceMessage:(NSString*)messageAccount
        urgentNewMessageCount:(int)urgentNewMessageCount
        urgentOldMessageCount:(int)urgentOldMessageCount
              newMessageCount:(int)newMessageCount
              oldMessageCount:(int)oldMessageCount;

If there are any waiting voice messages (MWI), this event will be triggered.

Parameters

- (void)onWaitingFaxMessage:(NSString*)messageAccount
      urgentNewMessageCount:(int)urgentNewMessageCount
      urgentOldMessageCount:(int)urgentOldMessageCount
            newMessageCount:(int)newMessageCount
            oldMessageCount:(int)oldMessageCount;

If there are any waiting fax messages (MWI), this event will be triggered.

Parameters

DTMF events

- (void)onRecvDtmfTone:(long)sessionId 
                  tone:(int)tone;

This event will be triggered when receiving a DTMF tone from remote side.

Parameters

INFO/OPTIONS message events

- (void)onRecvOptions:(NSString*)optionsMessage;

This event will be triggered when receiving the OPTIONS message.

Parameters

- (void)onRecvInfo:(NSString*)infoMessage;

This event will be triggered when receiving the INFO message.

Parameters

- (void)onRecvNotifyOfSubscription:(long)subscribeId
                     notifyMessage:(NSString*)notifyMessage
                       messageData:(unsigned char*)messageData
                 messageDataLength:(int)messageDataLength;

This event will be triggered when receiving a NOTIFY message of the subscription.

Parameters

Presence events

- (void)onPresenceRecvSubscribe:(long)subscribeId
                fromDisplayName:(NSString*)fromDisplayName
                           from:(NSString*)from
                        subject:(NSString*)subject; 

This event will be triggered when receiving the SUBSCRIBE request from a contact.

Parameters

- (void)onPresenceOnline:(NSString*)fromDisplayName
                    from:(NSString*)from
               stateText:(NSString*)stateText;

This event will be triggered when the contact is online or changes presence status.

Parameters

- (void)onPresenceOffline:(NSString*)fromDisplayName from:(NSString*)from;

When the contact status is changed to offline, this event will be triggered. Parameters

MESSAGE message events

- (void)onRecvMessage:(long)sessionId
             mimeType:(NSString*)mimeType
          subMimeType:(NSString*)subMimeType
          messageData:(unsigned char*)messageData
    messageDataLength:(int)messageDataLength;

This event will be triggered when receiving a MESSAGE message in dialog.

Parameters

- (void)onRecvOutOfDialogMessage:(NSString*)fromDisplayName
                            from:(NSString*)from
                   toDisplayName:(NSString*)toDisplayName
                              to:(NSString*)to
                        mimeType:(NSString*)mimeType
                     subMimeType:(NSString*)subMimeType
                     messageData:(unsigned char*)messageData
               messageDataLength:(int)messageDataLength
                      sipMessage:(NSString*)sipMessage;

This event will be triggered when receiving a MESSAGE message out of dialog. For example: pager message.

Parameters

- (void)onSendMessageSuccess:(long)sessionId
                   messageId:(long)messageId
                  sipMessage:(NSString*)sipMessage;

This event will be triggered when the message is sent successfully in dialog.

Parameters

- (void)onSendMessageFailure:(long)sessionId
                   messageId:(long)messageId
                      reason:(NSString*)reason
                        code:(int)code
                  sipMessage:(NSString*)sipMessage;

This event will be triggered when the message fails to be sent out of dialog.

Parameters

- (void)onSendOutOfDialogMessageSuccess:(long)messageId
                        fromDisplayName:(NSString*)fromDisplayName
                                   from:(NSString*)from
                          toDisplayName:(NSString*)toDisplayName
                                     to:(NSString*)to
                             sipMessage:(NSString*)sipMessage; 

This event will be triggered when the message is sent successfully out of dialog.

Parameters

- (void)onSendOutOfDialogMessageFailure:(long)messageId
                        fromDisplayName:(NSString*)fromDisplayName
                                   from:(NSString*)from
                          toDisplayName:(NSString*)toDisplayName
                                     to:(NSString*)to
                                 reason:(NSString*)reason
                                   code:(int)code
                             sipMessage:(NSString*)sipMessage;

This event will be triggered when the message fails to be sent out of dialog.

Parameters

- (void)onSubscriptionFailure:(long)subscribeId
                   statusCode:(int)statusCode;

This event will be triggered on sending SUBSCRIBE failure.

Parameters

- (void)onSubscriptionTerminated:(long)subscribeId;

This event will be triggered when a SUBSCRIPTION is terminated or expired.

Parameters

Play audio and video file finished events

- (void)onPlayFileFinished:(long)sessionId fileName:(NSString*)fileName; 

If startPlayingFileToRemote function is called with no loop mode, this event will be triggered once the file play finished.

Parameters

- (void)onStatistics:(long)sessionId stat:(NSString*)stat;

If getStatistics function is called, this event will be triggered once receiving a RTP statistics .

Parameters

RTP callback events

- (void)onRTPPacketCallback:(long)sessionId
                  mediaType:(int)mediaType
                  direction:(DIRECTION_MODE) direction
                  RTPPacket:(unsigned char *)RTPPacket
                 packetSize:(int)packetSize;

If enableRtpCallback function is called to enable the RTP callback, this event will be triggered once a RTP packet received.

Parameters

Parameters

Note

Don't call any SDK API functions in this event directly. If you want to call the API functions or other code, which is time-consuming, you should post a message to another thread and execute SDK API functions or other code in another thread.

Audio and video stream callback events

- (void)onAudioRawCallback:(long)sessionId
         audioCallbackMode:(int)audioCallbackMode
                      data:(unsigned char *)data
                dataLength:(int)dataLength
            samplingFreqHz:(int)samplingFreqHz;

This event will be triggered once receiving the audio packets when enableAudioStreamCallback function is called.

Parameters

Note

Don't call any SDK API functions in this event directly. If you want to call the API functions or other code, which is time-consuming, you should post a message to another thread and execute SDK API functions or other code in another thread.

- (int)onVideoRawCallback:(long)sessionId
        videoCallbackMode:(int)videoCallbackMode
                    width:(int)width
                   height:(int)height
                     data:(unsigned char *)data
               dataLength:(int)dataLength;

This event will be triggered once received the video packets if called enableVideoStreamCallback function.

Parameters

Returns

If you changed the sent video data, dataLength should be returned, otherwise 0.

Note

Don't call any SDK API functions in this event directly. If you want to call the API functions or other code, which is time-consuming, you should post a message to another thread and execute SDK API functions or other code in another thread.

SDK functions

Initialize and register functions

- (int) initialize:(TRANSPORT_TYPE)transport
           localIP:(NSString*)localIP
      localSIPPort:(int)localSIPPort
          loglevel:(PORTSIP_LOG_LEVEL)logLevel
           logPath:(NSString*)logFilePath
           maxLine:(int)maxCallLines
             agent:(NSString*)sipAgent
  audioDeviceLayer:(int)audioDeviceLayer
  videoDeviceLayer:(int)videoDeviceLayer
TLSCertificatesRootPath:(NSString*)TLSCertificatesRootPath
     TLSCipherList:(NSString*)TLSCipherList
verifyTLSCertificate:(BOOL)verifyTLSCertificate
        dnsServers:(NSString*)dnsServers;

Initialize the SDK.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setInstanceId:(NSString*)instanceId;

Set the instance Id, the outbound instanceId((RFC5626) ) used in contact headers.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void) unInitialize;

Un-initialize the SDK and release resources.

- (int) setUser:(NSString*)userName
    displayName:(NSString*)displayName
       authName:(NSString*)authName
       password:(NSString*)password
     userDomain:(NSString*)userDomain
      SIPServer:(NSString*)sipServer
  SIPServerPort:(int)sipServerPort
     STUNServer:(NSString*)stunServer
 STUNServerPort:(int)stunServerPort
 outboundServer:(NSString*)outboundServer
outboundServerPort:(int)outboundServerPort;

Set user account info.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setDisplayName:(NSString*)displayName;

Set the display name of user.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void) removeUser;

Remove user account info.

- (int)registerServer:(int)expires
           retryTimes:(int)retryTimes;

Register to SIP proxy server (login to server)

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code. If registration to server succeeds, onRegisterSuccess will be triggered, otherwise onRegisterFailure triggered.

- (int)refreshRegistration:(int)expires;

Refresh the registration manually after successfully registered.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code. If registration to server succeeds, onRegisterSuccess will be triggered, otherwise onRegisterFailure triggered.

- (int)unRegisterServer:(int)waitMS; 

Un-register from the SIP proxy server.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setLicenseKey:(NSString*)key;

Set the license key. It must be called before setUser function.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Parameters

NIC and local IP functions

- (int)getNICNums;

Get the Network Interface Card numbers. Returns

If the function succeeds, it will return NIC numbers, which are greater than or equal to 0. If the function fails, it will return a specific error code.

- (NSString*)getLocalIpAddress:(int)index;

Get the local IP address by Network Interface Card index.

Parameters

Returns

The buffer for receiving the IP.

Audio and video codecs functions

- (int)addAudioCodec:(AUDIOCODEC_TYPE)codecType;

Enable an audio codec. It will appear in SDP.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)addVideoCodec:(VIDEOCODEC_TYPE)codecType;

Enable a video codec. It will appear in SDP.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (BOOL)isAudioCodecEmpty;

Detect if the enabled audio codecs is empty.

Returns

If no audio codec is enabled, it will return value true, otherwise false.

- (BOOL)isVideoCodecEmpty;

Detect if enabled video codecs is empty or not.

Returns

If no video codec is enabled, it will return value true, otherwise false.

- (int)setAudioCodecPayloadType:(AUDIOCODEC_TYPE)codecType
                    payloadType:(int) payloadType;

Set the RTP payload type for dynamic audio codec.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoCodecPayloadType:(VIDEOCODEC_TYPE)codecType
                    payloadType:(int) payloadType;

Set the RTP payload type for dynamic Video codec.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setAudioCodecParameter:(AUDIOCODEC_TYPE)codecType
                     parameter:(NSString*)parameter;
 

Set the codec parameter for audio codec.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Example:

[myVoIPsdk setAudioCodecParameter:AUDIOCODEC\_AMR parameter:"mode-set=0; octet-align=1; robust-sorting=0"];

- (int)setVideoCodecParameter:(VIDEOCODEC_TYPE) codecType
                     parameter:(NSString*)parameter;

Set the codec parameter for video codec.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return value a specific error code.

Remarks

Example:

[myVoIPsdk setVideoCodecParameter:VIDEOCODEC\_H264 parameter:"profile-level-id=420033; packetization-mode=0"];

- (void) clearAudioCodec;

Remove all enabled audio codecs.

- (void) clearVideoCodec;

Remove all enabled video codecs.

Additional settings functions

- (NSString*)getVersion;

Get the current version number of the SDK.

Returns

Return a current version number MAJOR.MINOR.PATCH of the SDK.

- (int)enableRport:(BOOL)enable;

Enable/disable rport(RFC3581).

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enableEarlyMedia:(BOOL)enable;

Enable/disable Early Media.

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enablePriorityIPv6Domain:(BOOL)enable;

Enable/disable which allows specifying the preferred protocol when a domain supports both IPV4 and IPV6 simultaneously.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setUriUserEncoding:(NSString*)character enable:(BOOL)enable;

Modifies the default URI user character needs to be escaped.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

-(int)setReliableProvisional:(int)mode;

Enable/disable PRACK.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enable3GppTags:(BOOL)enable;

Enable/disable the 3Gpp tags, including "ims.icsi.mmtel" and "g.3gpp.smsip".

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)enableCallbackSignaling:(BOOL)enableSending
                 enableReceived:(BOOL)enableReceived;

Enable/disable to callback the SIP messages.

Parameters

- (int)setSrtpPolicy:(SRTP_POLICY)srtpPolicy;

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setRtpPortRange:(int) minimumRtpPort
        maximumRtpPort:(int) maximumRtpPort;

Set the RTP ports range for audio and video streaming.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

The port range ((max - min) / maxCallLines) should be greater than 4.

- (int)enableCallForward:(BOOL)forBusyOnly forwardTo:(NSString*) forwardTo;

Enable call forwarding.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)disableCallForward;

Disable the call forwarding. The SDK is not forwarding any incoming calls once this function is called.

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enableSessionTimer:(int) timerSeconds refreshMode:(SESSION_REFRESH_MODE)refreshMode;

Allows to periodically refresh Session Initiation Protocol (SIP) sessions by sending INVITE requests repeatedly.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

The INVITE requests, or re-INVITEs, are sent repeatedly during an active call log to allow user agents (UA) or proxies to determine the status of a SIP session. Without this keep-alive mechanism, proxies for remembering incoming and outgoing requests (stateful proxies) may continue to retain call state needlessly. If a UA fails to send a BYE message at the end of a session or if the BYE message is lost because of network problems, a stateful proxy does not know that the session has ended. The re-INVITEs ensure that active sessions stay active and completed sessions are terminated.

- (int)disableSessionTimer;

Disable the session timer.

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)setDoNotDisturb:(BOOL)state;

Enable the "Do not disturb" to enable/disable.

Parameters

- (void)enableAutoCheckMwi:(BOOL)state;

Enable the CheckMwi to enable/disable.

Parameters

- (int)setRtpKeepAlive:(BOOL)state
  keepAlivePayloadType:(int)keepAlivePayloadType
   deltaTransmitTimeMS:(int)deltaTransmitTimeMS;

Enable or disable to send RTP keep-alive packet when the call is established.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setKeepAliveTime:(int) keepAliveTime;

Enable or disable to send SIP keep-alive packet.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setAudioSamples:(int) ptime
              maxPtime:(int) maxPtime;

Set the audio capturing sample.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

It will appear in the SDP of INVITE and 200 OK message as "ptime and "maxptime" attribute.

- (int)addSupportedMimeType:(NSString*) methodName
                   mimeType:(NSString*) mimeType
                subMimeType:(NSString*) subMimeType;

Set the SDK to receive the SIP message that includes special mime type.

Parameters

|*mimeType *| The mime type of SIP message. |

|subMimeType| The sub mime type of SIP message. |

Returns If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

By default, PortSIP VoIP SDK supports the media types (mime types) listed in the below incoming SIP messages:

"message/sipfrag" in NOTIFY message. application/simple-message-summary" in NOTIFY message. "text/plain" in MESSAGE message. "application/dtmf-relay" in INFO message. "application/media_control+xml" in INFO message.

The SDK allows to receive SIP messages that include above mime types. Now if remote side sends an INFO SIP message with its "Content-Type" header value "text/plain", SDK will reject this INFO message, for "text/plain" of INFO message is not included in the default supported list. How should we enable the SDK to receive the SIP INFO messages that include "text/plain" mime type? The answer is to use addSupportedMimyType:

[myVoIPSdk addSupportedMimeType:@"INFO" mimeType:@"text" subMimeType:@"plain"];

To receive the NOTIFY message with "application/media_control+xml":

[myVoIPSdk addSupportedMimeType:@"NOTIFY" mimeType:@"application" ]subMimeType:@"media\_control+xml"];

For more details about the mime type, please visit: http://www.iana.org/assignments/media-types/

Access SIP message header functions

-(NSString*)getSipMessageHeaderValue:(NSString*)sipMessage
                    headerName:(NSString*) headerName;

Access the SIP header of SIP message.

Parameters

Returns

If the function succeeds, it will return value headerValue. If the function fails, it will return value null.

Remarks

When receiving an SIP message in the onReceivedSignaling callback event, and user wishes to get SIP message header value, use getExtensionHeaderValue:

NSString* headerValue = [myVoIPSdk getSipMessageHeaderValue:message headerName:name];

- (long)addSipMessageHeader:(long) sessionId
                methodName:(NSString*) methodName
                   msgType:(int) msgType
                headerName:(NSString*) headerName
               headerValue:(NSString*) headerValue;

Add the SIP Message header into the specified outgoing SIP message.

Parameters

Returns

If the function succeeds, it will return addedSipMessageId, which is greater than 0. If the function fails, it will return a specific error code.

- (int)removeAddedSipMessageHeader:(long) addedSipMessageId;

Remove the headers (custom header) added by addSipMessageHeader.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)clearAddedSipMessageHeaders;  

Clear the added extension headers (custom headers).

Remarks

For example, we have added two custom headers into every outgoing SIP message and wish to remove them.

  [myVoIPSdk addedSipMessageId:-1  methodName:@"ALL"  msgType:3 headerName:@"Blling" headerValue:@"usd100.00"]; 

  [myVoIPSdk addedSipMessageId:-1  methodName:@"ALL"  msgType:3 headerName:@"ServiceId" headerValue:@"8873456"]; 

  [myVoIPSdk clearAddedSipMessageHeaders]; 
- (long)modifySipMessageHeader:(long) sessionId
                methodName:(NSString*) methodName
                   msgType:(int) msgType
                headerName:(NSString*) headerName
               headerValue:(NSString*) headerValue;

Modify the special SIP header value for every outgoing SIP message.

Parameters

Returns

If the function succeeds, it will return modifiedSipMessageId, which is greater than 0. If the function fails, it will return a specific error code.

- (int)removeModifiedSipMessageHeader:(long) modifiedSipMessageId;

Remove the extension header (custom header) from every outgoing SIP message.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)clearModifiedSipMessageHeaders;

Clear the modified headers value, and do not modify every outgoing SIP message header values any longer.

Remarks

For example, to modify two headers' value for every outging SIP message and wish to clear it:

  [myVoIPSdk removeModifiedSipMessageHeader:-1  methodName:@"ALL"  msgType:3 headerName:@"Expires" headerValue:@"1000"]; 

  [myVoIPSdk removeModifiedSipMessageHeader:-1  methodName:@"ALL"  msgType:3 headerName:@"User-Agent" headerValue:@"MyTest Softphone 1.0"]; 

  [myVoIPSdk clearModifiedSipMessageHeaders]; 

Audio and video functions

- (void)clearModifiedSipMessageHeaders;

Set the video device that will be used for video call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoOrientation:(int) rotation;

Set the video Device Orientation.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoResolution:(int)width
                   height:(int)height;

Set the video capturing resolution.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setAudioBitrate:(long) sessionId
             codecType:(AUDIOCODEC_TYPE)codecType
           bitrateKbps:(int)bitrateKbps;

Set the audio bit rate.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoBitrate:(long) sessionId bitrateKbps:(int) bitrateKbps;

Set the video bitrate.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoFrameRate:(long) sessionId frameRate:(int) frameRate;

Set the video frame rate.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Usually you do not need to call this function to set the frame rate, as the SDK uses default frame rate.

- (int)sendVideo:(long)sessionId
       sendState:(BOOL)sendState; 

Send the video to remote side.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setRemoteVideoWindow:(long) sessionId
          remoteVideoWindow:(PortSIPVideoRenderView*) remoteVideoWindow;

Set the window for a session to display the received remote video image.

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setRemoteScreenWindow:(long) sessionId
          remoteScreenWindow:(PortSIPVideoRenderView*) remoteScreenWindow;

Set the window for a session to display the received remote screen image.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)displayLocalVideo:(BOOL) state
                  mirror:(BOOL)mirror
        localVideoWindow:(PortSIPVideoRenderView*)localVideoWindow;

Start/stop displaying the local video image.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoNackStatus:(BOOL) state;

Enable/disable the NACK feature (RFC4585) to help to improve the video quality.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)muteMicrophone:(BOOL) mute;

Mute the device microphone. It's unavailable for Android and iOS.

- (void)muteSpeaker:(BOOL) mute;

Mute the device speaker. It's unavailable for Android and iOS.

Parameters

- (int)setAudioDeviceId:(int)inputDeviceId outputDeviceId:(int)outputDeviceId

Set the audio device that will be used for audio call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Allow to switch between earphone and loudspeaker only.

- (int)setChannelOutputVolumeScaling:(long) sessionId
                              scaling:(int) scaling;

Set a volume |scaling| to be applied to the outgoing signal of a specific audio channel.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setChannelInputVolumeScaling:(long) sessionId
                             scaling:(int) scaling; 

Set a volume |scaling| to be applied to the microphone signal of a specific audio channel.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Call functions

- (long)call:(NSString*) callee
     sendSdp:(BOOL)sendSdp
   videoCall:(BOOL)videoCall;

Make a call.

Parameters

Returns

If the function succeeds, it will return the session ID of the call, which is greater than 0. If the function fails, it will return a specific error code. Note: the function success just means the outgoing call is being processed, and you need to detect the final state of calling in onInviteTrying, onInviteRinging, onInviteFailure callback events.

- (int)rejectCall:(long)sessionId code:(int)code;  

rejectCall Reject the incoming call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)hangUp:(long)sessionId;

hangUp Hang up the call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)answerCall:(long)sessionId videoCall:(BOOL)videoCall;

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)updateCall:(long)sessionId
      enableAudio:(BOOL)enableAudio
      enableVideo:(BOOL)enableVideo;

Use the re-INVITE to update the established call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Example usage:

Example 1: A called B with the audio only, and B answered A, then there would be an audio conversation between A and B. Now if A wants to see B visually, A could use these functions to fulfill it.

  [myVoIPSdk clearVideoCodec]; 
  [myVoIPSdk addVideoCodec:VIDEOCODEC\_H264]; 
  [myVoIPSdk updateCall:sessionId enableAudio:true enableVideo:true]; 

Example 2: Remove video stream from current conversation.

  [myVoIPSdk updateCall:sessionId enableAudio:true enableVideo:false]; 
- (int)hold:(long)sessionId;

Place a call on hold.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)unHold:(long)sessionId;

Take off hold.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)muteSession:(long)sessionId
 muteIncomingAudio:(BOOL)muteIncomingAudio
 muteOutgoingAudio:(BOOL)muteOutgoingAudio
 muteIncomingVideo:(BOOL)muteIncomingVideo
 muteOutgoingVideo:(BOOL)muteOutgoingVideo;

Mute the specified session audio or video.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)forwardCall:(long)sessionId forwardTo:(NSString*) forwardTo;

Forward the call to another user once received an incoming call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (long)pickupBLFCall:(const char * )replaceDialogId videoCall:(BOOL)videoCall;

This function will be used for picking up a call based on the BLF (Busy Lamp Field) status.

Parameters

Returns

If the function succeeds, it will return a session ID that is greater than 0 to the new call, otherwise returns a specific error code that is less than 0.

Remarks

The scenario is:

  1. User 101 subscribed the user 100's call status: sendSubscription("100", "dialog");

  2. When 100 hold a call or 100 is ringing, onDialogStateUpdated callback will be triggered, and 101 will receive this callback. Now 101 can use pickupBLFCall function to pick the call rather than 100 to talk with caller.

- (int)sendDtmf:(long) sessionId
     dtmfMethod:(DTMF_METHOD) dtmfMethod
           code:(int) code
    dtmfDration:(int) dtmfDuration
   playDtmfTone:(BOOL) playDtmfTone;

Send DTMF tone.

Parameters

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Refer functions

- (int)refer:(long)sessionId referTo:(NSString*)referTo;

Refer the current call to another one.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

[myVoIPSdk refer:sessionId referTo:@"sip:testuser12@sip.portsip.com"];

You can watch the video on YouTube at https://www.youtube.com/watch?v=_2w9EGgr3FY. It will demonstrate the transfer.

- (int)attendedRefer:(long)sessionId
    replaceSessionId:(long)replaceSessionId
             referTo:(NSString*)  referTo;

Make an attended refer.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Please read the sample project source code for more details, or you can watch the video on YouTube at https://www.youtube.com/watch?v=NezhIZW4lV4, which will demonstrate the transfer.

- (int)attendedRefer2:(long)sessionId
     replaceSessionId:(long)replaceSessionId
        replaceMethod:(NSString*)replaceMethod
              target:(NSString*)target
        referTo:(NSString*)referTo;

Make an attended refer with specified request line and specified method embedded into the "Refer-To" header.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Please read the sample project source code for more details, or you can watch the video on YouTube at https://www.youtube.com/watch?v=NezhIZW4lV4, which will demonstrate the transfer.

- (int)outOfDialogRefer:(long)replaceSessionId
          replaceMethod:(NSString*)replaceMethod
                 target:(NSString*)target
                referTo:(NSString*)referTo;

Send an out of dialog REFER to replace the specified call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (long)acceptRefer:(long)referId referSignaling:(NSString*) referSignaling;

Once the REFER request accepted, a new call will be made if called this function. The function is usually called after onReceivedRefer callback event.

Parameters

Returns

If the function succeeds, it will return a session ID that is greater than 0 to the new call for REFER, otherwise returns a specific error code that is less than 0.

- (int)rejectRefer:(long)referId;

Reject the REFER request.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Send audio and video stream functions

- (int)enableSendPcmStreamToRemote:(long)sessionId state:(BOOL)state streamSamplesPerSec:(int)streamSamplesPerSec;

Enable the SDK to send PCM stream data to remote side from another source instead of microphone.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

To send the PCM stream data to another side, this function MUST be called first.

- (int)sendPcmStreamToRemote:(long)sessionId data:(NSData*) data;

Send the audio stream in PCM format from another source instead of audio device capturing (microphone).

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Usually we should use it like below:

  [myVoIPSdk enableSendPcmStreamToRemote:sessionId state:YES streamSamplesPerSec:16000]; 
  [myVoIPSdk sendPcmStreamToRemote:sessionId data:data]; 

You can't have too much audio data at one time as we have 100ms audio buffer only. Once you put too much, data will be lost. It is recommended to send 20ms audio data every 20ms.

- (int)enableSendVideoStreamToRemote:(long)sessionId state:(BOOL)state;

Enable the SDK to send video stream data to remote side from another source instead of camera.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)sendVideoStreamToRemote:(long)sessionId data:(NSData*) data width:(int)width height:(int)height;

Send the video stream to remote side.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Send the video stream in i420 from another source instead of video device capturing (camera).

Before calling this function, you MUST call the enableSendVideoStreamToRemote function. Usually we should use it like below:

  [myVoIPSdk enableSendVideoStreamToRemote:sessionId state:YES]; 
  [myVoIPSdk sendVideoStreamToRemote:sessionId data:data width:352 height:288];

RTP packets, audio stream and video stream callback functions

- (int)enableRtpCallback:(long) sessionId
               mediaType:(int)mediaType
                    mode:(DIRECTION_MODE)mode;

Set the RTP callbacks to allow to access the sent and received RTP packets.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enableAudioStreamCallback:(long) sessionId  enable:(BOOL)enable callbackMode:(DIRECTION_MODE)callbackMode;

Enable/disable the audio stream callback.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

onAudioRawCallback event will be triggered if the callback is enabled.

- (int)enableVideoStreamCallback:(long) sessionId callbackMode:(DIRECTION_MODE) callbackMode;

Enable/disable the video stream callback.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

The onVideoRawCallback event will be triggered if the callback is enabled.

Record functions

- (int)startRecord:(long)sessionId
    recordFilePath:(NSString*) recordFilePath
    recordFileName:(NSString*) recordFileName
   appendTimeStamp:(BOOL)appendTimeStamp
          channels:(int)channels
        fileFormat:(FILE_FORMAT) recordFileFormat
   audioRecordMode:(RECORD_MODE) audioRecordMode
   videoRecordMode:(RECORD_MODE) videoRecordMode;

Start recording the call.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)stopRecord:(long)sessionId;

Stop recording.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Play audio and video files to remote party

- (int) startPlayingFileToRemote:(long)sessionId fileUrl:(NSString*) fileUrl loop:(BOOL)loop playAudio:(int)playAudio;

Play a file to remote party.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)stopPlayingFileToRemote:(long)sessionId;

Stop playing file to remote party.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int) startPlayingFileLocally:(NSString*) fileUrl
                           loop:(BOOL)loop
                playVideoWindow:(PortSIPVideoRenderView*) playVideoWindow;

Play a file to locally.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)stopPlayingFileLocally;

Stop playing file to locally. Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)audioPlayLoopbackTest:(BOOL)enable;

Used for the loop back testing against audio device.

Parameters

Conference functions

- (int)createAudioConference;

Create an audio conference.

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)createVideoConference:(PortSIPVideoRenderView*) conferenceVideoWindow
                  videoWidth:(int) videoWidth
                 videoHeight:(int) videoHeight
                      layout:(int) layout;

Create a video conference.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (void)destroyConference;

Destroy the existent conference.

- (int)setConferenceVideoWindow:(PortSIPVideoRenderView*) conferenceVideoWindow;

Set the window for a conference that is used to display the received remote video image.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)joinToConference:(long)sessionId;

Join a session into existent conference. If the call is in hold, please un-hold first.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)removeFromConference:(long)sessionId;

Remove a session from an existent conference.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

RTP and RTCP QOS functions

- (int)setAudioRtcpBandwidth:(long)sessionId
                      BitsRR:(int)BitsRR
                      BitsRS:(int)BitsRS
                     KBitsAS:(int)KBitsAS;

Set the audio RTCP bandwidth parameters as the RFC3556.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoRtcpBandwidth:(long)sessionId
                      BitsRR:(int)BitsRR
                      BitsRS:(int)BitsRS
                     KBitsAS:(int)KBitsAS;

Set the video RTCP bandwidth parameters as the RFC3556.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enableAudioQos:(BOOL)state;

Set the DSCP (differentiated services code point) value of QoS (Quality of Service) for audio channel.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)enableVideoQos:(BOOL)state;

Set the DSCP (differentiated services code point) value of QoS (Quality of Service) for video channel.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setVideoMTU:(int)mtu;

Set the MTU size for video RTP packet.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Media statistics functions

- (int)getStatistics:(long)sessionId;

Obtain the statistics of channel. the event onStatistics will be triggered.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Audio effect functions

- (void)enableVAD:(BOOL)state;

Enable/disable Voice Activity Detection (VAD).

Parameters

- (void)enableCNG:(BOOL)state;

Enable/disable Comfort Noise Generator (CNG).

Parameters

Send OPTIONS/INFO/MESSAGE functions

- (int)sendOptions:(NSString*)to sdp:(NSString*) sdp;

Send OPTIONS message.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)sendInfo:(long)sessionId
       mimeType:(NSString*) mimeType
    subMimeType:(NSString*) subMimeType
   infoContents:(NSString*) infoContents; 

Send an INFO message to remote side in dialog.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (long)sendMessage:(long)sessionId
           mimeType:(NSString*) mimeType
        subMimeType:(NSString*)subMimeType
            message:(NSData*) message
      messageLength:(int)messageLength;

Send a MESSAGE message to remote side in dialog.

Parameters

Returns

If the function succeeds, it will return a message ID that allows to track the message sending state in onSendMessageSuccess and onSendMessageFailure. If the function fails, it will return a specific error code less than 0.

Remarks

Example 1: Send a plain text message. Note: to send other languages text, please use the UTF-8 to encode the message before sending.

[myVoIPsdk sendMessage:sessionId mimeType:@"text" subMimeType:@"plain" message:data messageLength:dataLen];

Example 2: Send a binary message.

[myVoIPsdk sendMessage:sessionId mimeType:@"application" subMimeType:@"vnd.3gpp.sms" message:data messageLength:dataLen];

- (long)sendOutOfDialogMessage:(NSString*) to
                      mimeType:(NSString*) mimeType
                   subMimeType:(NSString*)subMimeType
                         isSMS:(BOOL)isSMS
                       message:(NSData*) message
                 messageLength:(int)messageLength;

Send an out of dialog MESSAGE message to remote side.

Parameters

Returns

If the function succeeds, it will return a message ID that allows to track the message sending state in onSendOutOfMessageSuccess and onSendOutOfMessageFailure. If the function fails, it will return a specific error code less than 0.

Remarks

Example 1: Send a plain text message. Note: to send text in other languages, please use UTF-8 to encode the message before sending.

[myVoIPsdk sendOutOfDialogMessage:@"sip:user1@sip.portsip.com" mimeType:@"text" subMimeType:@"plain" message:data messageLength:dataLen];

Example 2: Send a binary message.

[myVoIPsdk sendOutOfDialogMessage:@"sip:user1@sip.portsip.com" mimeType:@"application" subMimeType:@"vnd.3gpp.sms" isSMS:NO message:data messageLength:dataLen];

Presence functions

- (int)setPresenceMode:(PRESENCE_MODES) mode;

Indicate that SDK uses the P2P mode for presence or presence agent mode.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Since presence agent mode requires the PBX/Server support the PUBLISH, please ensure you have your server and PortSIP PBX support this feature. For more details please visit: https://www.portsip.com/portsip-pbx

 (int)setDefaultSubscriptionTime:(int) secs;

Set the default expiration time to be used when creating a subscription.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)setDefaultPublicationTime:(int) secs;

Set the default expiration time to be used when creating a publication.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (long)presenceSubscribe:(NSString*) contact
                  subject:(NSString*) subject;

Send a SUBSCRIBE message for subscribing the contact's presence status.

Parameters

Returns

If the function succeeds, it will return subscribeId. If the function fails, it will return a specific error code.

- (int)presenceTerminateSubscribe:(long) subscribeId;

Terminate the given presence subscription.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)presenceAcceptSubscribe:(long)subscribeId;

Accept the presence SUBSCRIBE request which is received from contact.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

If the P2P presence mode is enabled, when someone subscribes your presence status, you will receive the subscription request in the callback, and you can use this function to reject it.

- (int)presenceRejectSubscribe:(long)subscribeId;

Reject a presence SUBSCRIBE request which is received from contact.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

If the P2P presence mode is enabled, when someone subscribe your presence status, you will receive the subscribe request in the callback, and you can use this function to accept it.

- (int)setPresenceStatus:(long)subscribeId
              statusText:(NSString*) statusText;

Send a NOTIFY message to contact to notify that presence status is online/offline/changed.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return value a specific error code.

- (long)sendSubscription:(NSString*) to
               eventName:(NSString*) eventName;

Send a SUBSCRIBE message to remote side.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

Example 1, to subscribe the MWI (Message Waiting notifications), You can use this code: long mwiSubId = sendSubscription("sip:101@test.com", "message-summary");

Example 2, to monitor a user/extension call status, You can use code: sendSubscription("100", "dialog"); Extension 100 is the one to be monitored. Once being monitored, when extension 100 hold a call or is ringing, the onDialogStateUpdated callback will be triggered.

- (int)terminateSubscription:(long)subscribeId;

Terminate the given subscription.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

Remarks

For example, if you want stop check the MWI, use below code:

'terminateSubscription(mwiSubId); '

Device Manage functions.

- (int)getNumOfVideoCaptureDevices;

Gets the number of available capturing devices. Returns

The return value is the count of video capturing devices. If fails, it will return a specific error code less than 0.

- (int)getVideoCaptureDeviceName:(int) index
                        uniqueId:(NSString**)uniqueIdUTF8
                      deviceName:(NSString**) deviceNameUTF8;

Gets the name of a specific video capturing device given by an index. Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)getNumOfRecordingDevices;

Gets the number of audio devices available for audio recording. Returns

The return value is the count of recording devices. If the function fails, it will return a specific error code less than 0.

- (int)getNumOfPlayoutDevices;

Gets the number of audio devices available for audio playout.

Returns

The return value is the count of playout devices. If the function fails, it will return a specific error code less than 0.

- (NSString*)getRecordingDeviceName:(int) index;

Get the name of a specific recording device given by an index. Parameters

Returns

A NSString to which the device name will be copied as a null-terminated string in UTF-8 format.

- (NSString*)getPlayoutDeviceName:(int) index;

Get the name of a specific playout device given by an index.

Parameters

Returns

A NSString to which the device name will be copied as a null-terminated string in UTF8 format.

- (int)setSpeakerVolume:(int) volume;

Set the speaker volume level.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)getSpeakerVolume;

Gets the speaker volume.

Returns

If the function succeeds, it will return the value of speaker volume that ranges 0 - 255. If the function fails, it will return a specific error code.

- (int)setMicVolume:(int) volume;

Sets the microphone volume level.

Parameters

Returns

If the function succeeds, it will return value 0. If the function fails, it will return a specific error code.

- (int)getMicVolume;

Retrieves the current microphone volume.

Returns

If the function succeeds, it will return the value of microphone volume. If the function fails, it will return a specific error code.

- (int)getScreenSourceCount;

Retrieves the current number of screen.

Returns

If the function succeeds, it will return the screen number. If the function fails, it will return a specific error code.

- (NSString*)getScreenSourceTitle:(int) index;

Retrieves the current screen title .

Parameters

Returns

If the function succeeds, return value 0. If the function fails, it will return a specific error code.

- (int)selectScreenSource:(int) index;

Sets the Screen to share .

Parameters

Returns

If the function succeeds, return value 0. If the function fails, it will return a specific error code.

- (int)setScreenFrameRate:(int) frameRate;

Sets the Screen video framerate .

Parameters

Returns

If the function succeeds, return value 0. If the function fails, it will return a specific error code.

PortSIPVideoRenderView

- (void) updateVideoRenderFrame: (CGRect)  frameRect

Change the Video Render size.

Remarks

Example:

NSRect rect = videoRenderView.frame; 
rect.size.width += 20; 
rect.size.height += 20;

videoRenderView.frame = rect; 
[videoRenderView setNeedsDisplay:YES]; 

NSRect renderRect = [videoRenderView bounds]; 
[videoRenderView updateVideoRenderFrame:renderRect]; 

Last updated