PortSIP VoIP SDK Manual for iOS  16.2
PortSIP features our newest, supported, quality-assured VoIP SDK used by Several hundred companies around the world for easy VoIP application develop and quality-assured code.
PortSIPSDK.h
1 #import <Foundation/Foundation.h>
2 #import "PortSIPEventDelegate.h"
3 #import "PortSIPVideoRenderView.h"
4 #import "PortSIPTypes.hxx"
5 #import "PortSIPErrors.hxx"
6 
16 @interface PortSIPSDK : NSObject
17 
18 @property (nonatomic, weak) id<PortSIPEventDelegate> delegate;
19 
51 - (int) initialize:(TRANSPORT_TYPE)transport
52  localIP:(NSString*)localIP
53  localSIPPort:(int)localSIPPort
54  loglevel:(PORTSIP_LOG_LEVEL)logLevel
55  logPath:(NSString*)logFilePath
56  maxLine:(int)maxCallLines
57  agent:(NSString*)sipAgent
58  audioDeviceLayer:(int)audioDeviceLayer
59  videoDeviceLayer:(int)videoDeviceLayer
60 TLSCertificatesRootPath:(NSString*)TLSCertificatesRootPath
61  TLSCipherList:(NSString*)TLSCipherList
62 verifyTLSCertificate:(BOOL)verifyTLSCertificate;
63 
74 - (int)setInstanceId:(NSString*)instanceId;
75 
79 - (void) unInitialize;
80 
98 - (int) setUser:(NSString*)userName
99  displayName:(NSString*)displayName
100  authName:(NSString*)authName
101  password:(NSString*)password
102  userDomain:(NSString*)userDomain
103  SIPServer:(NSString*)sipServer
104  SIPServerPort:(int)sipServerPort
105  STUNServer:(NSString*)stunServer
106  STUNServerPort:(int)stunServerPort
107  outboundServer:(NSString*)outboundServer
108 outboundServerPort:(int)outboundServerPort;
109 
114 - (void)removeUser;
115 
125 - (int)registerServer:(int)expires
126  retryTimes:(int)retryTimes;
127 
128 
137 - (int)refreshRegistration:(int)expires;
138 
139 
145 - (int)unRegisterServer;
146 
154 - (int)setLicenseKey:(NSString*)key;
155  // end of group1
157 
167 - (int)getNICNums;
168 
176 - (NSString*)getLocalIpAddress:(int)index;
177  // end of group2
179 
191 - (int)addAudioCodec:(AUDIOCODEC_TYPE)codecType;
192 
200 - (int)addVideoCodec:(VIDEOCODEC_TYPE)codecType;
201 
207 - (BOOL)isAudioCodecEmpty;
208 
214 - (BOOL)isVideoCodecEmpty;
215 
224 - (int)setAudioCodecPayloadType:(AUDIOCODEC_TYPE)codecType
225  payloadType:(int) payloadType;
226 
235 - (int)setVideoCodecPayloadType:(VIDEOCODEC_TYPE)codecType
236  payloadType:(int) payloadType;
237 
241 - (void)clearAudioCodec;
242 
246 - (void)clearVideoCodec;
247 
258 - (int)setAudioCodecParameter:(AUDIOCODEC_TYPE)codecType
259  parameter:(NSString*)parameter;
260 
271 - (int)setVideoCodecParameter:(VIDEOCODEC_TYPE) codecType
272  parameter:(NSString*)parameter;
273  // end of group3
275 
285 - (NSString*)getVersion;
286 
294 - (int)enableRport:(BOOL)enable;
295 
303 - (int)enableEarlyMedia:(BOOL)enable;
304 
312 - (int)enableReliableProvisional:(BOOL)enable;
313 
321 - (int)enable3GppTags:(BOOL)enable;
322 
328 - (void)enableCallbackSendingSignaling:(BOOL)enable;
329 
337 - (int)setSrtpPolicy:(SRTP_POLICY)srtpPolicy;
338 
351 - (int)setRtpPortRange:(int) minimumRtpAudioPort
352  maximumRtpAudioPort:(int) maximumRtpAudioPort
353  minimumRtpVideoPort:(int) minimumRtpVideoPort
354  maximumRtpVideoPort:(int) maximumRtpVideoPort;
355 
368 - (int)setRtcpPortRange:(int) minimumRtcpAudioPort
369  maximumRtcpAudioPort:(int) maximumRtcpAudioPort
370  minimumRtcpVideoPort:(int) minimumRtcpVideoPort
371  maximumRtcpVideoPort:(int) maximumRtcpVideoPort;
372 
381 - (int)enableCallForward:(BOOL)forBusyOnly forwardTo:(NSString*) forwardTo;
382 
388 - (int)disableCallForward;
389 
402 - (int)enableSessionTimer:(int) timerSeconds refreshMode:(SESSION_REFRESH_MODE)refreshMode;
403 
409 - (int)disableSessionTimer;
410 
416 - (void)setDoNotDisturb:(BOOL)state;
417 
423 - (void)enableAutoCheckMwi:(BOOL)state;
424 
425 
435 - (int)setRtpKeepAlive:(BOOL)state
436  keepAlivePayloadType:(int)keepAlivePayloadType
437  deltaTransmitTimeMS:(int)deltaTransmitTimeMS;
438 
446 - (int)setKeepAliveTime:(int) keepAliveTime;
456 - (int)setAudioSamples:(int) ptime
457  maxPtime:(int) maxPtime;
458 
490 - (int)addSupportedMimeType:(NSString*) methodName
491  mimeType:(NSString*) mimeType
492  subMimeType:(NSString*) subMimeType;
493  // end of group4
495 
513 -(NSString*)getSipMessageHeaderValue:(NSString*)sipMessage
514  headerName:(NSString*) headerName;
515 
531 - (long)addSipMessageHeader:(long) sessionId
532  methodName:(NSString*) methodName
533  msgType:(int) msgType
534  headerName:(NSString*) headerName
535  headerValue:(NSString*) headerValue;
536 
544 - (int)removeAddedSipMessageHeader:(long) addedSipMessageId;
545 
546 
558 
574 - (long)modifySipMessageHeader:(long) sessionId
575  methodName:(NSString*) methodName
576  msgType:(int) msgType
577  headerName:(NSString*) headerName
578  headerValue:(NSString*) headerValue;
579 
587 - (int)removeModifiedSipMessageHeader:(long) modifiedSipMessageId;
588 
589 
601  // end of group5
603 
615 - (int)setVideoDeviceId:(int) deviceId;
616 
626 - (int)setVideoResolution:(int)width
627  height:(int)height;
637 - (int)setAudioBitrate:(long) sessionId
638  codecType:(AUDIOCODEC_TYPE)codecType
639  bitrateKbps:(int)bitrateKbps;
640 
649 - (int)setVideoBitrate:(long) sessionId bitrateKbps:(int) bitrateKbps;
650 
660 - (int)setVideoFrameRate:(long) sessionId frameRate:(int) frameRate;
669 - (int)sendVideo:(long)sessionId
670  sendState:(BOOL)sendState;
671 
672 
678 - (void)setLocalVideoWindow:(PortSIPVideoRenderView*)localVideoWindow;
679 
688 - (int)setRemoteVideoWindow:(long) sessionId
689  remoteVideoWindow:(PortSIPVideoRenderView*) remoteVideoWindow;
690 
698 - (int)displayLocalVideo:(BOOL) state;
699 
707 - (int)setVideoNackStatus:(BOOL) state;
708 
717 - (int)setLoudspeakerStatus:(BOOL)enable;
718 
730 - (int)setChannelOutputVolumeScaling:(long) sessionId
731  scaling:(int) scaling;
732  // end of group6
734 
748 - (long)call:(NSString*) callee
749  sendSdp:(BOOL)sendSdp
750  videoCall:(BOOL)videoCall;
751 
760 - (int)rejectCall:(long)sessionId code:(int)code;
761 
769 - (int)hangUp:(long)sessionId;
770 
779 - (int)answerCall:(long)sessionId videoCall:(BOOL)videoCall;
780 
803 - (int)updateCall:(long)sessionId
804  enableAudio:(BOOL)enableAudio
805  enableVideo:(BOOL)enableVideo;
806 
814 - (int)hold:(long)sessionId;
815 
823 - (int)unHold:(long)sessionId;
824 
836 - (int)muteSession:(long)sessionId
837  muteIncomingAudio:(BOOL)muteIncomingAudio
838  muteOutgoingAudio:(BOOL)muteOutgoingAudio
839  muteIncomingVideo:(BOOL)muteIncomingVideo
840  muteOutgoingVideo:(BOOL)muteOutgoingVideo;
841 
850 - (int)forwardCall:(long)sessionId forwardTo:(NSString*) forwardTo;
851 
866 - (long)pickupBLFCall:(const char * )replaceDialogId videoCall:(BOOL)videoCall;
887 - (int)sendDtmf:(long) sessionId
888  dtmfMethod:(DTMF_METHOD) dtmfMethod
889  code:(int) code
890  dtmfDration:(int) dtmfDuration
891  playDtmfTone:(BOOL) playDtmfTone;
892  // end of group7
894 
911 - (int)refer:(long)sessionId referTo:(NSString*)referTo;
912 
925 - (int)attendedRefer:(long)sessionId
926  replaceSessionId:(long)replaceSessionId
927  referTo:(NSString*) referTo;
928 
943 - (int)attendedRefer2:(long)sessionId
944  replaceSessionId:(long)replaceSessionId
945  replaceMethod:(NSString*)replaceMethod
946  target:(NSString*)target
947  referTo:(NSString*)referTo;
948 
949 
960 - (int)outOfDialogRefer:(long)replaceSessionId
961  replaceMethod:(NSString*)replaceMethod
962  target:(NSString*)target
963  referTo:(NSString*)referTo;
972 - (long)acceptRefer:(long)referId referSignaling:(NSString*) referSignaling;
973 
981 - (int)rejectRefer:(long)referId;
982  // end of group8
984 
999 - (int)enableSendPcmStreamToRemote:(long)sessionId state:(BOOL)state streamSamplesPerSec:(int)streamSamplesPerSec;
1000 
1014 - (int)sendPcmStreamToRemote:(long)sessionId data:(NSData*) data;
1015 
1024 - (int)enableSendVideoStreamToRemote:(long)sessionId state:(BOOL)state;
1025 
1043 - (int)sendVideoStreamToRemote:(long)sessionId data:(NSData*) data width:(int)width height:(int)height;
1044  // end of group9
1046 
1058 - (int)setRtpCallback:(BOOL)enable;
1059 
1076 - (int)enableAudioStreamCallback:(long) sessionId enable:(BOOL)enable callbackMode:(AUDIOSTREAM_CALLBACK_MODE)callbackMode;
1077 
1094 - (int)enableVideoStreamCallback:(long) sessionId callbackMode:(VIDEOSTREAM_CALLBACK_MODE) callbackMode;
1095  // end of group10
1097 
1116 - (int)startRecord:(long)sessionId
1117  recordFilePath:(NSString*) recordFilePath
1118  recordFileName:(NSString*) recordFileName
1119  appendTimeStamp:(BOOL)appendTimeStamp
1120  audioFileFormat:(AUDIO_FILE_FORMAT) audioFileFormat
1121  audioRecordMode:(RECORD_MODE) audioRecordMode
1122  aviFileCodecType:(VIDEOCODEC_TYPE) aviFileCodecType
1123  videoRecordMode:(RECORD_MODE) videoRecordMode;
1124 
1132 - (int)stopRecord:(long)sessionId;
1133  // end of group11
1135 
1151 - (int) playVideoFileToRemote:(long)sessionId aviFile:(NSString*) aviFile loop:(BOOL)loop playAudio:(BOOL)playAudio;
1152 
1160 - (int)stopPlayVideoFileToRemote:(long)sessionId;
1161 
1172 - (int)playAudioFileToRemote:(long)sessionId
1173  filename:(NSString*) filename // Support .wav, .amr and .pcm formats
1174  fileSamplesPerSec:(int) fileSamplesPerSec // fileSamplesPerSec MUST be sent for playing .pcm file
1175  loop:(BOOL)loop;
1176 
1184 - (int)stopPlayAudioFileToRemote:(long)sessionId;
1185 
1195 - (int)playAudioFileToRemoteAsBackground:(long)sessionId filename:(NSString*)filename fileSamplesPerSec:(int)fileSamplesPerSec;
1196 
1204 - (int)stopPlayAudioFileToRemoteAsBackground:(long)sessionId;
1205 
1211 - (void)audioPlayLoopbackTest:(BOOL)enable;
1212  // end of group12
1214 
1224 - (int)createAudioConference;
1225 
1236 - (int)createVideoConference:(PortSIPVideoRenderView*) conferenceVideoWindow
1237  videoWidth:(int) videoWidth
1238  videoHeight:(int) videoHeight
1239  displayLocalVideo:(BOOL)displayLocalVideoInConference;
1240 
1244 - (void)destroyConference;
1245 
1253 - (int)setConferenceVideoWindow:(PortSIPVideoRenderView*) conferenceVideoWindow;
1254 
1262 - (int)joinToConference:(long)sessionId;
1263 
1271 - (int)removeFromConference:(long)sessionId;
1272  // end of group13
1274 
1289 - (int)setAudioRtcpBandwidth:(long)sessionId
1290  BitsRR:(int)BitsRR
1291  BitsRS:(int)BitsRS
1292  KBitsAS:(int)KBitsAS;
1293 
1304 - (int)setVideoRtcpBandwidth:(long)sessionId
1305  BitsRR:(int)BitsRR
1306  BitsRS:(int)BitsRS
1307  KBitsAS:(int)KBitsAS;
1308 
1316 - (int)enableAudioQos:(BOOL)state;
1317 
1325 - (int)enableVideoQos:(BOOL)state;
1326 
1334 - (int)setVideoMTU:(int)mtu;
1335  // end of group14
1337 
1364 - (int)getAudioStatistics:(long)sessionId
1365  sendBytes:(int*)sendBytes
1366  sendPackets:(int*)sendPackets
1367  sendPacketsLost:(int*)sendPacketsLost
1368  sendFractionLost:(int*)sendFractionLost
1369  sendRttMS:(int*)sendRttMS
1370  sendCodecType:(int*)sendCodecType
1371  sendJitterMS:(int*)sendJitterMS
1372  sendAudioLevel:(int*)sendAudioLevel
1373  recvBytes:(int*)recvBytes
1374  recvPackets:(int*)recvPackets
1375  recvPacketsLost:(int*)recvPacketsLost
1376  recvFractionLost:(int*)recvFractionLost
1377  recvCodecType:(int*)recvCodecType
1378  recvJitterMS:(int*)recvJitterMS
1379  recvAudioLevel:(int*)recvAudioLevel;
1380 
1407 - (int)getVideoStatistics:(long)sessionId
1408  sendBytes:(int*)sendBytes
1409  sendPackets:(int*)sendPackets
1410  sendPacketsLost:(int*)sendPacketsLost
1411  sendFractionLost:(int*)sendFractionLost
1412  sendRttMS:(int*)sendRttMS
1413  sendCodecType:(int*)sendCodecType
1414  sendFrameWidth:(int*)sendFrameWidth
1415  sendFrameHeight:(int*)sendFrameHeight
1416  sendBitrateBPS:(int*)sendBitrateBPS
1417  sendFramerate:(int*)sendFramerate
1418  recvBytes:(int*)recvBytes
1419  recvPackets:(int*)recvPackets
1420  recvPacketsLost:(int*)recvPacketsLost
1421  recvFractionLost:(int*)recvFractionLost
1422  recvCodecType:(int*)recvCodecType
1423  recvFrameWidth:(int*)recvFrameWidth
1424  recvFrameHeight:(int*)recvFrameHeight
1425  recvBitrateBPS:(int*)recvBitrateBPS
1426  recvFramerate:(int*)recvFramerate;
1427  // end of group15
1429 
1439 - (void)enableVAD:(BOOL)state;
1440 
1446 - (void)enableCNG:(BOOL)state;
1447  // end of group16
1449 
1462 - (int)sendOptions:(NSString*)to sdp:(NSString*) sdp;
1463 
1474 - (int)sendInfo:(long)sessionId
1475  mimeType:(NSString*) mimeType
1476  subMimeType:(NSString*) subMimeType
1477  infoContents:(NSString*) infoContents;
1478 
1502 - (long)sendMessage:(long)sessionId
1503  mimeType:(NSString*) mimeType
1504  subMimeType:(NSString*)subMimeType
1505  message:(NSData*) message
1506  messageLength:(int)messageLength;
1507 
1529 - (long)sendOutOfDialogMessage:(NSString*) to
1530  mimeType:(NSString*) mimeType
1531  subMimeType:(NSString*)subMimeType
1532  isSMS:(BOOL)isSMS
1533  message:(NSData*) message
1534  messageLength:(int)messageLength;
1535  // end of group17
1537 
1552 - (int)setPresenceMode:(int) mode;
1553 
1560 - (int)setDefaultSubscriptionTime:(int) secs;
1561 
1568 - (int)setDefaultPublicationTime:(int) secs;
1569 
1570 
1580 - (long)presenceSubscribe:(NSString*) contact
1581  subject:(NSString*) subject;
1582 
1583 
1590 - (int)presenceTerminateSubscribe:(long) subscribeId;
1591 
1602 - (int)presenceAcceptSubscribe:(long)subscribeId;
1603 
1614 - (int)presenceRejectSubscribe:(long)subscribeId;
1615 
1624 - (int)setPresenceStatus:(long)subscribeId
1625  statusText:(NSString*) statusText;
1626 
1627 
1644 - (long)sendSubscription:(NSString*) to
1645  eventName:(NSString*) eventName;
1646 
1658 - (int)terminateSubscription:(long)subscribeId; // end of group18
1660 
1672 - (BOOL) startKeepAwake;//call in applicationDidEnterBackground
1673 
1680 - (BOOL) stopKeepAwake;//call in applicatEionWillEnterForeground
1681  // end of group19
1683 
1695 - (BOOL) startAudio;
1696 
1703 - (BOOL) stopAudio;
1704 
1711 - (int) enableCallKit:(BOOL)state;
1712  // end of group20 // end of groupSDK
1715 
1716 @end
NSString * getVersion()
Get the current version number of the SDK.
BOOL stopKeepAwake()
Keep VoIP awake in the background. Call this function in applicationWillEnterForeground once your ap...
int createAudioConference()
Create an audio conference.
PortSIP VoIP SDK functions class.
Definition: PortSIPSDK.h:16
BOOL isAudioCodecEmpty()
Detect if the enabled audio codecs is empty.
void removeUser()
Remove user account info.
int disableCallForward()
Disable the call forwarding. The SDK is not forwarding any incoming calls once this function is calle...
void clearVideoCodec()
Remove all enabled video codecs.
int disableSessionTimer()
Disable the session timer.
void clearAddedSipMessageHeaders()
Clear the added extension headers (custom headers)
BOOL stopAudio()
Stop Audio Device. Call it as AVAudioSessionInterruptionTypeBegan.
BOOL startKeepAwake()
Keep VoIP awake in the background. If you want your application to be able to receive the incoming c...
void unInitialize()
Un-initialize the SDK and release resources.
void clearAudioCodec()
Remove all enabled audio codecs.
BOOL startAudio()
Start Audio Device. Call it as AVAudioSessionInterruptionTypeEnded.
int unRegisterServer()
Un-register from the SIP proxy server.
PortSIP VoIP SDK Video Render View class.
Definition: PortSIPVideoRenderView.h:13
void destroyConference()
Destroy the existent conference.
void clearModifiedSipMessageHeaders()
Clear the modified headers value, and do not modify every outgoing SIP message header values any long...
int getNICNums()
Get the Network Interface Card numbers.
BOOL isVideoCodecEmpty()
Detect if enabled video codecs is empty or not.