Changeset 4608
- Timestamp:
- Oct 1, 2013 9:41:01 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i
r4600 r4608 26 26 %template(IntVector) std::vector<int>; 27 27 %template(AuthCredInfoVector) std::vector<AuthCredInfo>; 28 %template(SipMultipartPartVector) std::vector<SipMultipartPart>; 29 %template(SipHeaderVector) std::vector<SipHeader>; 28 30 } 29 31 -
pjproject/branches/projects/pjsua2/pjsip/build/Makefile
r4598 r4608 90 90 export PJSUA2_LIB_SRCDIR = ../src/pjsua2 91 91 export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 92 endpoint.o types.o92 account.o endpoint.o types.o 93 93 export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 94 94 export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS) -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/account.hpp
r4597 r4608 25 25 */ 26 26 #include <pjsua-lib/pjsua.h> 27 #include <pjsua2/types.hpp> 27 28 28 29 /** … … 37 38 */ 38 39 40 /** PJSUA2 API is inside pj namespace */ 41 namespace pj 42 { 43 using std::string; 44 using std::vector; 45 39 46 /** 40 47 * Account registration config. This will be specified in AccountConfig. … … 49 56 * value is empty, no account registration will be performed. 50 57 */ 51 String registrarUri;58 string registrarUri; 52 59 53 60 /** … … 64 71 * request. 65 72 */ 66 S tringVector headers;73 SipHeaderVector headers; 67 74 68 75 /** … … 102 109 * Default: PJSIP_REGISTER_CLIENT_DELAY_BEFORE_REFRESH, 5 seconds 103 110 */ 104 unsigned delayBeforeRefresh ;111 unsigned delayBeforeRefreshSec; 105 112 106 113 /** … … 122 129 123 130 /** 124 * Specify whether REGISTER requests will use the proxy settings 125 * of this account. If zero, the REGISTER request will not have any 126 * Route headers. 127 * 128 * Default: 1 (use account proxy) 131 * Specify how the registration uses the outbound and account proxy 132 * settings. This controls if and what Route headers will appear in 133 * the REGISTER request of this account. The value is bitmask combination 134 * of PJSUA_REG_USE_OUTBOUND_PROXY and PJSUA_REG_USE_ACC_PROXY bits. 135 * If the value is set to 0, the REGISTER request will not use any proxy 136 * (i.e. it will not have any Route headers). 137 * 138 * Default: 3 (PJSUA_REG_USE_OUTBOUND_PROXY | PJSUA_REG_USE_ACC_PROXY) 129 139 */ 130 140 unsigned proxyUse; … … 241 251 */ 242 252 pjsua_sip_timer_use timerUse; 253 254 /** 255 * Specify minimum Session Timer expiration period, in seconds. 256 * Must not be lower than 90. Default is 90. 257 */ 258 unsigned timerMinSESec; 259 260 /** 261 * Specify Session Timer expiration period, in seconds. 262 * Must not be lower than timerMinSE. Default is 1800. 263 */ 264 unsigned timerSessExpiresSec; 265 243 266 }; 244 267 … … 252 275 * subscription request. 253 276 */ 254 S tringVector subHeaders;277 SipHeaderVector headers; 255 278 256 279 /** … … 390 413 */ 391 414 bool iceNoRtcp; 415 416 /** 417 * Always send re-INVITE/UPDATE after ICE negotiation regardless of whether 418 * the default ICE transport address is changed or not. When this is set 419 * to False, re-INVITE/UPDATE will be sent only when the default ICE 420 * transport address is changed. 421 * 422 * Default: yes 423 */ 424 bool iceAlwaysUpdate; 392 425 393 426 /** … … 440 473 * Default: TRUE 441 474 */ 442 bool contactRewriteEnabled;475 int contactRewriteUse; 443 476 444 477 /** 445 478 * Specify how Contact update will be done with the registration, if 446 * contactRewriteEnabled is enabled. 447 * 448 * If set to 1, the Contact update will be done by sending unregistration 449 * to the currently registered Contact, while simultaneously sending new 450 * registration (with different Call-ID) for the updated Contact. 451 * 452 * If set to 2, the Contact update will be done in a single, current 453 * registration session, by removing the current binding (by setting its 454 * Contact's expires parameter to zero) and adding a new Contact binding, 455 * all done in a single request. 456 * 457 * Value 1 is the legacy behavior. 458 * 459 * Default value: PJSUA_CONTACT_REWRITE_METHOD (2) 479 * \a contactRewriteEnabled is enabled. The value is bitmask combination of 480 * \a pjsua_contact_rewrite_method. See also pjsua_contact_rewrite_method. 481 * 482 * Value PJSUA_CONTACT_REWRITE_UNREGISTER(1) is the legacy behavior. 483 * 484 * Default value: PJSUA_CONTACT_REWRITE_METHOD 485 * (PJSUA_CONTACT_REWRITE_NO_UNREG | PJSUA_CONTACT_REWRITE_ALWAYS_UPDATE) 460 486 */ 461 487 int contactRewriteMethod; … … 469 495 * Default: TRUE 470 496 */ 471 bool viaRewriteEnabled; 497 int viaRewriteUse; 498 499 /** 500 * This option controls whether the IP address in SDP should be replaced 501 * with the IP address found in Via header of the REGISTER response, ONLY 502 * when STUN and ICE are not used. If the value is FALSE (the original 503 * behavior), then the local IP address will be used. If TRUE, and when 504 * STUN and ICE are disabled, then the IP address found in registration 505 * response will be used. 506 * 507 * Default: PJ_FALSE (no) 508 */ 509 int sdpNatRewriteUse; 472 510 473 511 /** … … 484 522 * Default: TRUE 485 523 */ 486 bool sipOutboundEnabled;524 int sipOutboundUse; 487 525 488 526 /** … … 531 569 { 532 570 /** 533 * Media transport configuration.571 * Media transport (RTP) configuration. 534 572 */ 535 573 TransportConfig transportConfig; … … 574 612 */ 575 613 int srtpSecureSignaling; 576 }; 577 578 /** 579 * Video stream rate control config. This will be specified in 580 * AccountVideoConfig. 581 */ 582 struct VidRateControlConfig 583 { 584 /** 585 * Rate control method. 586 * 587 * Default: PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING. 588 */ 589 pjmedia_vid_stream_rc_method method; 590 591 /** 592 * Upstream/outgoing bandwidth. If this is set to zero, the video stream 593 * will use codec maximum bitrate setting. 594 * 595 * Default: 0 (follow codec maximum bitrate). 596 */ 597 unsigned bandwidth; 598 599 /** Default constructor */ 600 VidRateControlConfig(); 601 602 /** Convert to pj */ 603 pjmedia_vid_stream_rc_config toPj() const; 604 605 /** Convert from pj */ 606 void fromPj(const pjmedia_vid_stream_rc_config &prm); 614 615 /** 616 * Specify whether IPv6 should be used on media. Default is not used. 617 */ 618 pjsua_ipv6_use ipv6Use; 607 619 }; 608 620 … … 626 638 * Default: False 627 639 */ 628 bool autoShowIncoming;640 bool autoShowIncoming; 629 641 630 642 /** … … 641 653 * Default: False 642 654 */ 643 bool autoTransmitOutgoing;655 bool autoTransmitOutgoing; 644 656 645 657 /** … … 649 661 * Default: 0 650 662 */ 651 unsigned windowFlags;663 unsigned windowFlags; 652 664 653 665 /** … … 658 670 * Default: PJMEDIA_VID_DEFAULT_CAPTURE_DEV 659 671 */ 660 pjmedia_vid_dev_index defaultCaptureDevice;672 pjmedia_vid_dev_index defaultCaptureDevice; 661 673 662 674 /** … … 665 677 * Default: PJMEDIA_VID_DEFAULT_RENDER_DEV 666 678 */ 667 pjmedia_vid_dev_index defaultRenderDevice; 668 669 /** 670 * Specify the send rate control for video stream. 671 */ 672 VidRateControlConfig rateControlConfig; 679 pjmedia_vid_dev_index defaultRenderDevice; 680 681 /** 682 * Rate control method. 683 * 684 * Default: PJMEDIA_VID_STREAM_RC_SIMPLE_BLOCKING. 685 */ 686 pjmedia_vid_stream_rc_method rateControlMethod; 687 688 /** 689 * Upstream/outgoing bandwidth. If this is set to zero, the video stream 690 * will use codec maximum bitrate setting. 691 * 692 * Default: 0 (follow codec maximum bitrate). 693 */ 694 unsigned rateControlBandwidth; 673 695 }; 674 696 … … 692 714 * This field is mandatory. 693 715 */ 694 String uri;716 string idUri; 695 717 696 718 /** … … 734 756 AccountVideoConfig videoConfig; 735 757 758 public: 736 759 /** 737 760 * Default constructor will initialize with default values. … … 740 763 741 764 /** 742 * Convert to pjsip. 765 * This will return a temporary pjsua_acc_config instance, which contents 766 * are only valid as long as this AccountConfig structure remains valid 767 * AND no modifications are done to it AND no further toPj() function call 768 * is made. Any call to toPj() function will invalidate the content of 769 * temporary pjsua_acc_config that was returned by the previous call. 743 770 */ 744 771 pjsua_acc_config toPj() const; … … 747 774 * Initialize from pjsip. 748 775 */ 749 void fromPj(const pjsua_acc_config &prm); 776 void fromPj(const pjsua_acc_config &prm, const pjsua_media_config *mcfg); 777 778 }; 779 780 /** 781 * This describes account presence status. 782 */ 783 struct AccountPresenceStatus 784 { 785 /** Basic status. */ 786 bool isOnline; 787 788 /** Activity type. */ 789 pjrpid_activity activity; 790 791 /** Optional text describing the person/element. */ 792 string note; 793 794 /** Optional RPID ID string. */ 795 string rpidId; 796 797 public: 798 AccountPresenceStatus(); 750 799 }; 751 800 … … 821 870 822 871 /** 823 * This structure contains parameters for onIncomingCall() callback. 824 */ 825 struct IncomingCallParam 826 { 827 // rdata 828 }; 829 830 /** 831 * This structure contains parameters for onRegState() callback. 832 */ 833 struct RegStateParam 834 { 835 // reginfo 872 * This structure contains parameters for onIncomingCall() account callback. 873 */ 874 struct OnIncomingCallParam 875 { 876 /** 877 * The library call index allocated for the new call. 878 */ 879 int callIndex; 880 881 /** 882 * The incoming INVITE request. 883 */ 884 SipRxData rdata; 885 }; 886 887 /** 888 * This structure contains parameters for onRegStarted() account callback. 889 */ 890 struct OnRegStartedParam 891 { 892 /** 893 * True for registration and False for unregistration. 894 */ 895 bool renew; 896 }; 897 898 /** 899 * This structure contains parameters for onRegState() account callback. 900 */ 901 struct OnRegStateParam 902 { 903 /** 904 * Registration operation status. 905 */ 906 pj_status_t status; 907 908 /** 909 * SIP status code received. 910 */ 911 int code; 912 913 /** 914 * SIP reason phrase received. 915 */ 916 pj_str_t reason; 917 918 /** 919 * The incoming message. 920 */ 921 SipRxData rdata; 922 923 /** 924 * Next expiration interval. 925 */ 926 int expiration; 836 927 }; 837 928 … … 839 930 * This structure contains parameters for onIncomingSubscribe() callback. 840 931 */ 841 struct IncomingSubscribeParam 842 { 843 /* 844 * @param srv_pres Server presence subscription instance. If 845 * application delays the acceptance of the request, 846 * it will need to specify this object when calling 847 * #pjsua_pres_notify(). 848 * @param acc_id Account ID most appropriate for this request. 849 * @param buddy_id ID of the buddy matching the sender of the 850 * request, if any, or PJSUA_INVALID_ID if no 851 * matching buddy is found. 852 * @param from The From URI of the request. 853 * @param rdata The incoming request. 854 * @param code The status code to respond to the request. The 855 * default value is 200. Application may set this 856 * to other final status code to accept or reject 857 * the request. 858 * @param reason The reason phrase to respond to the request. 859 * @param msg_data If the application wants to send additional 860 * headers in the response, it can put it in this 861 * parameter. 862 */ 863 864 //pjsua_srv_pres *srv_pres, 865 // pjsua_buddy_id buddy_id, 866 // const pj_str_t *from, 867 // pjsip_rx_data *rdata, 868 // pjsua_msg_data *msg_data 932 struct OnIncomingSubscribeParam 933 { 934 /** 935 * Sender URI. 936 */ 937 string fromUri; 938 939 /** 940 * The incoming message. 941 */ 942 SipRxData rdata; 869 943 870 944 /** … … 873 947 * reject the request. 874 948 */ 875 pjsip_status_code 949 pjsip_status_code code; 876 950 877 951 /** 878 952 * The reason phrase to respond to the request. 879 953 */ 880 string reason; 954 string reason; 955 956 /** 957 * Additional data to be sent with the response, if any. 958 */ 959 SipTxOption txOption; 960 }; 961 962 /** 963 * Parameters for onInstantMessage() account callback. 964 */ 965 struct OnInstantMessageParam 966 { 967 /** 968 * Sender From URI. 969 */ 970 string fromUri; 971 972 /** 973 * To URI of the request. 974 */ 975 string toUri; 976 977 /** 978 * Contact URI of the sender. 979 */ 980 string contactUri; 981 982 /** 983 * MIME type of the message body. 984 */ 985 string contentType; 986 987 /** 988 * The message body. 989 */ 990 string msgBody; 991 992 /** 993 * The whole message. 994 */ 995 SipRxData rdata; 996 }; 997 998 /** 999 * Parameters for onInstantMessageStatus() account callback. 1000 */ 1001 struct OnInstantMessageStatusParam 1002 { 1003 /** 1004 * Token or a user data that was associated with the pager 1005 * transmission. 1006 */ 1007 Token userData; 1008 1009 /** 1010 * Destination URI. 1011 */ 1012 string toUri; 1013 1014 /** 1015 * The message body. 1016 */ 1017 string msgBody; 1018 1019 /** 1020 * The SIP status code of the transaction. 1021 */ 1022 pjsip_status_code status; 1023 1024 /** 1025 * The reason phrase of the transaction. 1026 */ 1027 string reason; 1028 1029 /** 1030 * The incoming response that causes this callback to be called. 1031 * If the transaction fails because of time out or transport error, 1032 * the content will be empty. 1033 */ 1034 SipRxData rdata; 1035 }; 1036 1037 /** 1038 * Parameters for onTypingIndication() account callback. 1039 */ 1040 struct OnTypingIndicationParam 1041 { 1042 /** 1043 * Sender/From URI. 1044 */ 1045 string fromUri; 1046 1047 /** 1048 * To URI. 1049 */ 1050 string toUri; 1051 1052 /** 1053 * The Contact URI. 1054 */ 1055 string contactUri; 1056 1057 /** 1058 * Boolean to indicate if sender is typing. 1059 */ 1060 bool isTyping; 1061 1062 /** 1063 * The whole message buffer. 1064 */ 1065 SipRxData rdata; 1066 }; 1067 1068 /** 1069 * Parameters for onMwiInfo() account callback. 1070 */ 1071 struct OnMwiInfoParam 1072 { 1073 /** 1074 * MWI subscription state. 1075 */ 1076 pjsip_evsub_state state; 1077 1078 /** 1079 * The whole message buffer. 1080 */ 1081 SipRxData rdata; 881 1082 }; 882 1083 … … 895 1096 * @param prm Callback parameter. 896 1097 */ 897 virtual void onIncomingCall(IncomingCallParam &prm) 1098 virtual void onIncomingCall(OnIncomingCallParam &prm) 1099 {} 1100 1101 /** 1102 * Notify application when registration or unregistration has been 1103 * initiated. Note that this only notifies the initial registration 1104 * and unregistration. Once registration session is active, subsequent 1105 * refresh will not cause this callback to be called. 1106 * 1107 * @param prm Callback parameter. 1108 */ 1109 virtual void onRegStarted(OnRegStartedParam &prm) 898 1110 {} 899 1111 … … 903 1115 * registration details. 904 1116 * 905 * @param acc_id The account ID.906 */ 907 virtual void onRegState( RegStateParam &prm)1117 * @param prm Callback parameter. 1118 */ 1119 virtual void onRegState(OnRegStateParam &prm) 908 1120 {} 909 1121 … … 937 1149 * Application MUST return from this callback immediately (e.g. it must 938 1150 * not block in this callback while waiting for user confirmation). 939 */ 940 virtual void onIncomingSubscribe(IncomingSubscribeParam &prm) 1151 * 1152 * @param prm Callback parameter. 1153 */ 1154 virtual void onIncomingSubscribe(OnIncomingSubscribeParam &prm) 941 1155 {} 942 1156 1157 /** 1158 * Notify application on incoming instant message or pager (i.e. MESSAGE 1159 * request) that was received outside call context. 1160 * 1161 * @param prm Callback parameter. 1162 */ 1163 virtual void onInstantMessage(OnInstantMessageParam &prm) 1164 {} 1165 1166 /** 1167 * Notify application about the delivery status of outgoing pager/instant 1168 * message (i.e. MESSAGE) request. 1169 * 1170 * @param prm Callback parameter. 1171 */ 1172 virtual void onInstantMessageStatus(OnInstantMessageStatusParam &prm) 1173 {} 1174 1175 /** 1176 * Notify application about typing indication. 1177 * 1178 * @param prm Callback parameter. 1179 */ 1180 virtual void onTypingIndication(OnTypingIndicationParam &prm) 1181 {} 1182 1183 /** 1184 * Notification about MWI (Message Waiting Indication) status change. 1185 * This callback can be called upon the status change of the 1186 * SUBSCRIBE request (for example, 202/Accepted to SUBSCRIBE is received) 1187 * or when a NOTIFY reqeust is received. 1188 * 1189 * @param prm Callback parameter. 1190 */ 1191 virtual void onMwiInfo(OnMwiInfoParam &prm) 1192 {} 943 1193 }; 944 1194 … … 960 1210 { 961 1211 public: 962 void setTransport(); 1212 /** 1213 * Check if this account is still valid. 1214 * 1215 * @return True if it is. 1216 */ 1217 bool isValid() const; 1218 1219 /** 1220 * Set this as default account to be used when incoming and outgoing 1221 * requests don't match any accounts. 1222 * 1223 * @return PJ_SUCCESS on success. 1224 */ 1225 void setDefault() throw(Error); 1226 1227 /** 1228 * Check if this account is the default account. Default account will be 1229 * used for incoming and outgoing requests that don't match any other 1230 * accounts. 1231 * 1232 * @return True if this is the default account. 1233 */ 1234 bool isDefault() const; 1235 1236 /** 1237 * Get PJSUA-LIB account ID or index associated with this account. 1238 * 1239 * @return Integer greater than or equal to zero. 1240 */ 1241 int getIndex() const; 1242 1243 /** 1244 * Set arbitrary data to be associated with the account. 1245 * 1246 * @param user_data User/application data. 1247 */ 1248 void setUserData(Token user_data); 1249 1250 /** 1251 * Get the user data that was associated with the account. 1252 * 1253 * @return The user data. 1254 */ 1255 Token getUserData() const; 1256 1257 /** 1258 * Get account info. 1259 * 1260 * @return Account info. 1261 */ 1262 AccountInfo getInfo() const; 1263 1264 /** 1265 * Modify the account to use the specified account configuration. 1266 * Depending on the changes, this may cause unregistration or 1267 * reregistration on the account. 1268 * 1269 * @param cfg New account config to be applied to the account. 1270 */ 1271 void modify(const AccountConfig &acc) throw(Error); 1272 1273 /** 1274 * Update registration or perform unregistration. Application normally 1275 * only needs to call this function if it wants to manually update the 1276 * registration or to unregister from the server. 1277 * 1278 * @param renew If False, this will start unregistration 1279 * process. 1280 */ 1281 void setRegistration(bool renew) throw(Error); 1282 1283 /** 1284 * Set or modify account's presence online status to be advertised to 1285 * remote/presence subscribers. This would trigger the sending of 1286 * outgoing NOTIFY request if there are server side presence subscription 1287 * for this account, and/or outgoing PUBLISH if presence publication is 1288 * enabled for this account. 1289 * 1290 * @param pres_st Presence online status. 1291 */ 1292 void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 1293 1294 /** 1295 * Lock/bind this account to a specific transport/listener. Normally 1296 * application shouldn't need to do this, as transports will be selected 1297 * automatically by the library according to the destination. 1298 * 1299 * When account is locked/bound to a specific transport, all outgoing 1300 * requests from this account will use the specified transport (this 1301 * includes SIP registration, dialog (call and event subscription), and 1302 * out-of-dialog requests such as MESSAGE). 1303 * 1304 * Note that transport id may be specified in AccountConfig too. 1305 * 1306 * @param tp_id The transport ID. 1307 */ 1308 void setTransport(TransportId tp_id) throw(Error); 963 1309 964 1310 protected: … … 968 1314 }; 969 1315 1316 } // namespace pj 1317 970 1318 /** 971 1319 * @} // PJSUA2_ACC -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4597 r4608 40 40 41 41 42 ////////////////////////////////////////////////////////////////////////////// 43 44 /** 45 * Argument to EpCallback::onNatDetectionComplete() callback. 46 */ 47 struct OnNatDetectionCompleteParam 48 { 49 /** 50 * Status of the detection process. If this value is not PJ_SUCCESS, 51 * the detection has failed and \a nat_type field will contain 52 * PJ_STUN_NAT_TYPE_UNKNOWN. 53 */ 54 pj_status_t status; 55 56 /** 57 * The text describing the status, if the status is not PJ_SUCCESS. 58 */ 59 string reason; 60 61 /** 62 * This contains the NAT type as detected by the detection procedure. 63 * This value is only valid when the \a status is PJ_SUCCESS. 64 */ 65 pj_stun_nat_type natType; 66 67 /** 68 * Text describing that NAT type. 69 */ 70 string natTypeName; 71 72 }; 73 74 /** 75 * Argument to EpCallback::onNatCheckStunServersComplete() callback. 76 */ 77 struct OnNatCheckStunServersCompleteParam 78 { 79 /** 80 * Arbitrary user data that was passed to Endpoint::natCheckStunServers() 81 * function. 82 */ 83 Token userData; 84 85 /** 86 * This will contain PJ_SUCCESS if at least one usable STUN server 87 * is found, otherwise it will contain the last error code during 88 * the operation. 89 */ 90 pj_status_t status; 91 92 /** 93 * The server name that yields successful result. This will only 94 * contain value if status is successful. 95 */ 96 string name; 97 98 /** 99 * The server IP address and port in "IP:port" format. This will only 100 * contain value if status is successful. 101 */ 102 SocketAddress addr; 103 }; 104 105 /** 106 * Parameter of EpCallback::OnTimer() callback. 107 */ 108 struct OnTimerParam 109 { 110 /** 111 * Arbitrary user data that was passed to Endpoint::utilTimerSchedule() 112 * function. 113 */ 114 Token userData; 115 116 /** 117 * The interval of this timer, in miliseconds. 118 */ 119 unsigned msecDelay; 120 }; 121 122 /** 123 * Parameter of EpCallback::onTransportState() callback. 124 */ 125 struct OnTransportStateParam 126 { 127 /** 128 * The transport handle. 129 */ 130 TransportHandle hnd; 131 132 /** 133 * Transport current state. 134 */ 135 pjsip_transport_state state; 136 137 /** 138 * The last error code related to the transport state. 139 */ 140 pj_status_t lastError; 141 }; 142 143 /** 144 * Parameter of EpCallback::onSelectAccount() callback. 145 */ 146 struct OnSelectAccountParam 147 { 148 /** 149 * The incoming request. 150 */ 151 SipRxData rdata; 152 153 /** 154 * The account index to be used to handle the request. 155 * Upon entry, this will be filled by the account index 156 * chosen by the library. Application may change it to 157 * another value to use another account. 158 */ 159 int accountIndex; 160 }; 161 162 ////////////////////////////////////////////////////////////////////////////// 163 42 164 /** 43 165 * Interface for receiving callbacks from the library. Application inherits … … 58 180 */ 59 181 virtual void onNatDetectionComplete( 60 const NatDetectionCompleteParam &prm)182 const OnNatDetectionCompleteParam &prm) 61 183 {} 62 184 … … 68 190 */ 69 191 virtual void onNatCheckStunServersComplete( 70 const NatCheckStunServersCompleteParam &prm)192 const OnNatCheckStunServersCompleteParam &prm) 71 193 {} 72 194 … … 76 198 * @param prm Callback parameters. 77 199 */ 78 virtual void onTransportState Changed(79 const TransportStateChangedParam &prm)200 virtual void onTransportState( 201 const OnTransportStateParam &prm) 80 202 {} 81 203 … … 86 208 * @param prm Callback parameters. 87 209 */ 88 virtual void OnTimerComplete(const TimerCompleteParam &prm)210 virtual void onTimer(const OnTimerParam &prm) 89 211 {} 90 }; 212 213 /** 214 * This callback can be used by application to override the account 215 * to be used to handle an incoming message. Initially, the account to 216 * be used will be calculated automatically by the library. This initial 217 * account will be used if application does not implement this callback, 218 * or application sets an invalid account upon returning from this 219 * callback. 220 * 221 * Note that currently the incoming messages requiring account assignment 222 * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback 223 * may be called before the callback of the SIP event itself, i.e: 224 * incoming call, pager, subscription, or unsolicited-event. 225 * 226 * @param prm Callback parameters. 227 */ 228 virtual void onSelectAccount(OnSelectAccountParam &prm) 229 {} 230 }; 231 232 233 ////////////////////////////////////////////////////////////////////////////// 234 235 struct UaConfig 236 { 237 /** 238 * Maximum calls to support (default: 4). The value specified here 239 * must be smaller than the compile time maximum settings 240 * PJSUA_MAX_CALLS, which by default is 32. To increase this 241 * limit, the library must be recompiled with new PJSUA_MAX_CALLS 242 * value. 243 */ 244 unsigned maxCalls; 245 246 /** 247 * Number of worker threads. Normally application will want to have at 248 * least one worker thread, unless when it wants to poll the library 249 * periodically, which in this case the worker thread can be set to 250 * zero. 251 */ 252 unsigned threadCnt; 253 254 /** 255 * Array of nameservers to be used by the SIP resolver subsystem. 256 * The order of the name server specifies the priority (first name 257 * server will be used first, unless it is not reachable). 258 */ 259 StringVector nameserver; 260 261 /** 262 * Optional user agent string (default empty). If it's empty, no 263 * User-Agent header will be sent with outgoing requests. 264 */ 265 string userAgent; 266 267 /** 268 * Array of STUN servers to try. The library will try to resolve and 269 * contact each of the STUN server entry until it finds one that is 270 * usable. Each entry may be a domain name, host name, IP address, and 271 * it may contain an optional port number. For example: 272 * - "pjsip.org" (domain name) 273 * - "sip.pjsip.org" (host name) 274 * - "pjsip.org:33478" (domain name and a non-standard port number) 275 * - "10.0.0.1:3478" (IP address and port number) 276 * 277 * When nameserver is configured in the \a pjsua_config.nameserver field, 278 * if entry is not an IP address, it will be resolved with DNS SRV 279 * resolution first, and it will fallback to use DNS A resolution if this 280 * fails. Port number may be specified even if the entry is a domain name, 281 * in case the DNS SRV resolution should fallback to a non-standard port. 282 * 283 * When nameserver is not configured, entries will be resolved with 284 * #pj_gethostbyname() if it's not an IP address. Port number may be 285 * specified if the server is not listening in standard STUN port. 286 */ 287 StringVector stunServer; 288 289 /** 290 * This specifies if the library startup should ignore failure with the 291 * STUN servers. If this is set to PJ_FALSE, the library will refuse to 292 * start if it fails to resolve or contact any of the STUN servers. 293 * 294 * Default: TRUE 295 */ 296 bool stunIgnoreFailure; 297 298 /** 299 * Support for adding and parsing NAT type in the SDP to assist 300 * troubleshooting. The valid values are: 301 * - 0: no information will be added in SDP, and parsing is disabled. 302 * - 1: only the NAT type number is added. 303 * - 2: add both NAT type number and name. 304 * 305 * Default: 1 306 */ 307 int natTypeInSdp; 308 309 /** 310 * Handle unsolicited NOTIFY requests containing message waiting 311 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests 312 * which are not requested by client with SUBSCRIBE request. 313 * 314 * If this is enabled, the library will respond 200/OK to the NOTIFY 315 * request and forward the request to EpCallback.onMwiInfo() callback. 316 * 317 * See also AccountMwiConfig.enabled. 318 * 319 * Default: PJ_TRUE 320 */ 321 bool mwiUnsolicitedEnabled; 322 323 public: 324 /** 325 * Default constructor to initialize with default values. 326 */ 327 UaConfig(); 328 329 /** 330 * Construct from pjsua_config. 331 */ 332 void fromPj(const pjsua_config &ua_cfg); 333 334 /** 335 * Export to pjsua_config 336 */ 337 pjsua_config toPj() const; 338 }; 339 340 341 /** 342 * Data containing log entry to be written by the LogWriter. 343 */ 344 struct LogEntry 345 { 346 /** Log verbosity level of this message */ 347 int level; 348 349 /** The log message */ 350 string msg; 351 352 /** ID of current thread */ 353 long threadId; 354 355 /** The name of the thread that writes this log */ 356 string threadName; 357 }; 358 359 360 /** 361 * Interface for writing log messages. Applications can inherit this class 362 * and supply it in the LogConfig structure to implement custom log 363 * writing facility. 364 */ 365 class LogWriter 366 { 367 public: 368 /** Destructor */ 369 virtual ~LogWriter() {} 370 371 /** Write a log entry. */ 372 virtual void write(const LogEntry &entry) = 0; 373 }; 374 375 376 /** 377 * Logging configuration, which can be (optionally) specified when calling 378 * Lib::init(). 379 */ 380 struct LogConfig 381 { 382 /** Log incoming and outgoing SIP message? Yes! */ 383 unsigned msgLogging; 384 385 /** Input verbosity level. Value 5 is reasonable. */ 386 unsigned level; 387 388 /** Verbosity level for console. Value 4 is reasonable. */ 389 unsigned consoleLevel; 390 391 /** Log decoration. */ 392 unsigned decor; 393 394 /** Optional log filename if app wishes the library to write to log file. 395 */ 396 string filename; 397 398 /** 399 * Additional flags to be given to #pj_file_open() when opening 400 * the log file. By default, the flag is PJ_O_WRONLY. Application 401 * may set PJ_O_APPEND here so that logs are appended to existing 402 * file instead of overwriting it. 403 * 404 * Default is 0. 405 */ 406 unsigned fileFlags; 407 408 /** 409 * Custom log writer, if required. If specified, the instance of LogWriter 410 * must be kept alive througout the duration of the application. 411 */ 412 LogWriter *writer; 413 414 public: 415 /** Default constructor initialises with default values */ 416 LogConfig(); 417 418 /** Construct from pjsua_logging_config */ 419 void fromPj(const pjsua_logging_config &lc); 420 421 /** Generate pjsua_logging_config. */ 422 pjsua_logging_config toPj() const; 423 }; 424 425 426 /** 427 * This structure describes media configuration, which will be specified 428 * when calling Lib::init(). 429 */ 430 struct MediaConfig 431 { 432 public: 433 /** 434 * Clock rate to be applied to the conference bridge. 435 * If value is zero, default clock rate will be used 436 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz). 437 */ 438 unsigned clockRate; 439 440 /** 441 * Clock rate to be applied when opening the sound device. 442 * If value is zero, conference bridge clock rate will be used. 443 */ 444 unsigned sndClockRate; 445 446 /** 447 * Channel count be applied when opening the sound device and 448 * conference bridge. 449 */ 450 unsigned channelCount; 451 452 /** 453 * Specify audio frame ptime. The value here will affect the 454 * samples per frame of both the sound device and the conference 455 * bridge. Specifying lower ptime will normally reduce the 456 * latency. 457 * 458 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME 459 */ 460 unsigned audioFramePtime; 461 462 /** 463 * Specify maximum number of media ports to be created in the 464 * conference bridge. Since all media terminate in the bridge 465 * (calls, file player, file recorder, etc), the value must be 466 * large enough to support all of them. However, the larger 467 * the value, the more computations are performed. 468 * 469 * Default value: PJSUA_MAX_CONF_PORTS 470 */ 471 unsigned maxMediaPorts; 472 473 /** 474 * Specify whether the media manager should manage its own 475 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created 476 * and at least one worker thread will be created too. If no, 477 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets, 478 * and no worker thread is needed. 479 * 480 * Normally application would say yes here, unless it wants to 481 * run everything from a single thread. 482 */ 483 bool hasIoqueue; 484 485 /** 486 * Specify the number of worker threads to handle incoming RTP 487 * packets. A value of one is recommended for most applications. 488 */ 489 unsigned threadCnt; 490 491 /** 492 * Media quality, 0-10, according to this table: 493 * 5-10: resampling use large filter, 494 * 3-4: resampling use small filter, 495 * 1-2: resampling use linear. 496 * The media quality also sets speex codec quality/complexity to the 497 * number. 498 * 499 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY). 500 */ 501 unsigned quality; 502 503 /** 504 * Specify default codec ptime. 505 * 506 * Default: 0 (codec specific) 507 */ 508 unsigned ptime; 509 510 /** 511 * Disable VAD? 512 * 513 * Default: 0 (no (meaning VAD is enabled)) 514 */ 515 bool noVad; 516 517 /** 518 * iLBC mode (20 or 30). 519 * 520 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE) 521 */ 522 unsigned ilbcMode; 523 524 /** 525 * Percentage of RTP packet to drop in TX direction 526 * (to simulate packet lost). 527 * 528 * Default: 0 529 */ 530 unsigned txDropPct; 531 532 /** 533 * Percentage of RTP packet to drop in RX direction 534 * (to simulate packet lost). 535 * 536 * Default: 0 537 */ 538 unsigned rxDropPct; 539 540 /** 541 * Echo canceller options (see #pjmedia_echo_create()) 542 * 543 * Default: 0. 544 */ 545 unsigned ecOptions; 546 547 /** 548 * Echo canceller tail length, in miliseconds. Setting this to zero 549 * will disable echo cancellation. 550 * 551 * Default: PJSUA_DEFAULT_EC_TAIL_LEN 552 */ 553 unsigned ecTailLen; 554 555 /** 556 * Audio capture buffer length, in milliseconds. 557 * 558 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY 559 */ 560 unsigned sndRecLatency; 561 562 /** 563 * Audio playback buffer length, in milliseconds. 564 * 565 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY 566 */ 567 unsigned sndPlayLatency; 568 569 /** 570 * Jitter buffer initial prefetch delay in msec. The value must be 571 * between jb_min_pre and jb_max_pre below. 572 * 573 * Default: -1 (to use default stream settings, currently 150 msec) 574 */ 575 int jbInit; 576 577 /** 578 * Jitter buffer minimum prefetch delay in msec. 579 * 580 * Default: -1 (to use default stream settings, currently 60 msec) 581 */ 582 int jbMinPre; 583 584 /** 585 * Jitter buffer maximum prefetch delay in msec. 586 * 587 * Default: -1 (to use default stream settings, currently 240 msec) 588 */ 589 int jbMaxPre; 590 591 /** 592 * Set maximum delay that can be accomodated by the jitter buffer msec. 593 * 594 * Default: -1 (to use default stream settings, currently 360 msec) 595 */ 596 int jbMax; 597 598 /** 599 * Specify idle time of sound device before it is automatically closed, 600 * in seconds. Use value -1 to disable the auto-close feature of sound 601 * device 602 * 603 * Default : 1 604 */ 605 int sndAutoCloseTime; 606 607 /** 608 * Specify whether built-in/native preview should be used if available. 609 * In some systems, video input devices have built-in capability to show 610 * preview window of the device. Using this built-in preview is preferable 611 * as it consumes less CPU power. If built-in preview is not available, 612 * the library will perform software rendering of the input. If this 613 * field is set to PJ_FALSE, software preview will always be used. 614 * 615 * Default: PJ_TRUE 616 */ 617 bool vidPreviewEnableNative; 618 619 public: 620 /** Default constructor initialises with default values */ 621 MediaConfig(); 622 623 /** Construct from pjsua_media_config. */ 624 void fromPj(const pjsua_media_config &mc); 625 626 /** Export */ 627 pjsua_media_config toPj() const; 628 }; 629 630 631 /** 632 * Endpoint configuration 633 */ 634 struct EpConfig 635 { 636 /** UA config */ 637 UaConfig uaConfig; 638 639 /** Logging config */ 640 LogConfig logConfig; 641 642 /** Media config */ 643 MediaConfig medConfig; 644 }; 645 646 ////////////////////////////////////////////////////////////////////////////// 91 647 92 648 /** … … 214 770 /** 215 771 * Schedule a timer with the specified interval and user data. When the 216 * interval elapsed, EpCallback::OnTimer Complete() callback will be772 * interval elapsed, EpCallback::OnTimer() callback will be 217 773 * called. Note that the callback may be executed by different thread, 218 774 * depending on whether worker thread is enabled or not. -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp
r4597 r4608 94 94 pj_status_t status; 95 95 96 /** The PJSUA API operation that throws the error. */ 97 string title; 98 96 99 /** The error message */ 97 100 string reason; 98 99 /** The PJSUA API operation that throws the error. */100 string title;101 101 102 102 /** The PJSUA source file that throws the error */ … … 115 115 */ 116 116 Error(pj_status_t prm_status, 117 const string &prm_title, 117 118 const string &prm_reason, 118 const string &prm_title,119 119 const string &prm_src_file, 120 120 int prm_src_line); 121 121 }; 122 122 123 /** 124 * This is a utility macro to check the status code and raise an Error 125 * exception on error.123 124 /* 125 * Error utilities. 126 126 */ 127 127 #if PJSUA2_ERROR_HAS_EXTRA_INFO 128 # define PJSUA2_CHECK_RAISE_ERROR(op, status) \ 129 do { \ 130 if (status != PJ_SUCCESS) \ 131 throw Error(status, string(), op, __FILE__, __LINE__); \ 132 } while (0) 128 # define PJSUA2_RAISE_ERROR(status) \ 129 PJSUA2_RAISE_ERROR2(status, __FUNCTION__) 130 131 # define PJSUA2_RAISE_ERROR2(status,op) \ 132 PJSUA2_RAISE_ERROR3(status, op, string()) 133 134 # define PJSUA2_RAISE_ERROR3(status,op,txt) \ 135 throw Error(status, op, txt, __FILE__, __LINE__) 136 133 137 #else 134 # define PJSUA2_CHECK_RAISE_ERROR(op, status) \ 135 do { \ 136 if (status != PJ_SUCCESS) \ 137 throw Error(status, string(), string(), string(), 0); \ 138 } while (0) 138 # define PJSUA2_RAISE_ERROR(status) \ 139 PJSUA2_RAISE_ERROR2(status, string()) 140 141 # define PJSUA2_RAISE_ERROR2(status,op) \ 142 PJSUA2_RAISE_ERROR3(status, op, string()) 143 144 # define PJSUA2_RAISE_ERROR3(status,op,txt) \ 145 throw Error(status, op, txt, string(), 0) 146 139 147 #endif 148 149 #define PJSUA2_CHECK_RAISE_ERROR2(status, op) \ 150 do { \ 151 if (status != PJ_SUCCESS) \ 152 PJSUA2_RAISE_ERROR2(status, op); \ 153 } while (0) 154 155 #define PJSUA2_CHECK_RAISE_ERROR(status) \ 156 PJSUA2_CHECK_RAISE_ERROR2(status, "") 157 140 158 141 159 ////////////////////////////////////////////////////////////////////////////// … … 182 200 183 201 /** Permanent subscriber key. */ 184 string aka _k;202 string akaK; 185 203 186 204 /** Operator variant key. */ 187 string aka _op;205 string akaOp; 188 206 189 207 /** Authentication Management Field */ 190 string aka_amf; 191 192 /** 193 * Default constructor. 194 */ 195 AuthCredInfo(); 208 string akaAmf; 209 196 210 }; 197 211 198 212 /** Array of SIP credentials */ 199 213 typedef std::vector<AuthCredInfo> AuthCredInfoVector; 200 201 //////////////////////////////////////////////////////////////////////////////202 203 struct UaConfig204 {205 /**206 * Maximum calls to support (default: 4). The value specified here207 * must be smaller than the compile time maximum settings208 * PJSUA_MAX_CALLS, which by default is 32. To increase this209 * limit, the library must be recompiled with new PJSUA_MAX_CALLS210 * value.211 */212 unsigned maxCalls;213 214 /**215 * Number of worker threads. Normally application will want to have at216 * least one worker thread, unless when it wants to poll the library217 * periodically, which in this case the worker thread can be set to218 * zero.219 */220 unsigned threadCnt;221 222 /**223 * Array of nameservers to be used by the SIP resolver subsystem.224 * The order of the name server specifies the priority (first name225 * server will be used first, unless it is not reachable).226 */227 StringVector nameserver;228 229 /**230 * Optional user agent string (default empty). If it's empty, no231 * User-Agent header will be sent with outgoing requests.232 */233 string userAgent;234 235 /**236 * Array of STUN servers to try. The library will try to resolve and237 * contact each of the STUN server entry until it finds one that is238 * usable. Each entry may be a domain name, host name, IP address, and239 * it may contain an optional port number. For example:240 * - "pjsip.org" (domain name)241 * - "sip.pjsip.org" (host name)242 * - "pjsip.org:33478" (domain name and a non-standard port number)243 * - "10.0.0.1:3478" (IP address and port number)244 *245 * When nameserver is configured in the \a pjsua_config.nameserver field,246 * if entry is not an IP address, it will be resolved with DNS SRV247 * resolution first, and it will fallback to use DNS A resolution if this248 * fails. Port number may be specified even if the entry is a domain name,249 * in case the DNS SRV resolution should fallback to a non-standard port.250 *251 * When nameserver is not configured, entries will be resolved with252 * #pj_gethostbyname() if it's not an IP address. Port number may be253 * specified if the server is not listening in standard STUN port.254 */255 StringVector stunServer;256 257 /**258 * This specifies if the library startup should ignore failure with the259 * STUN servers. If this is set to PJ_FALSE, the library will refuse to260 * start if it fails to resolve or contact any of the STUN servers.261 *262 * Default: TRUE263 */264 bool stunIgnoreFailure;265 266 /**267 * Support for adding and parsing NAT type in the SDP to assist268 * troubleshooting. The valid values are:269 * - 0: no information will be added in SDP, and parsing is disabled.270 * - 1: only the NAT type number is added.271 * - 2: add both NAT type number and name.272 *273 * Default: 1274 */275 int natTypeInSdp;276 277 /**278 * Handle unsolicited NOTIFY requests containing message waiting279 * indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests280 * which are not requested by client with SUBSCRIBE request.281 *282 * If this is enabled, the library will respond 200/OK to the NOTIFY283 * request and forward the request to EpCallback.onMwiInfo() callback.284 *285 * See also AccountMwiConfig.enabled.286 *287 * Default: PJ_TRUE288 */289 bool mwiUnsolicitedEnabled;290 291 public:292 /**293 * Default constructor to initialize with default values.294 */295 UaConfig();296 297 /**298 * Construct from pjsua_config.299 */300 void fromPj(const pjsua_config &ua_cfg);301 302 /**303 * Export to pjsua_config304 */305 pjsua_config toPj() const;306 };307 308 309 /**310 * Data containing log entry to be written by the LogWriter.311 */312 struct LogEntry313 {314 /** Log verbosity level of this message */315 int level;316 317 /** The log message */318 string msg;319 320 /** ID of current thread */321 long threadId;322 323 /** The name of the thread that writes this log */324 string threadName;325 };326 327 328 /**329 * Interface for writing log messages. Applications can inherit this class330 * and supply it in the LogConfig structure to implement custom log331 * writing facility.332 */333 class LogWriter334 {335 public:336 /** Destructor */337 virtual ~LogWriter() {}338 339 /** Write a log entry. */340 virtual void write(const LogEntry &entry) = 0;341 };342 343 344 /**345 * Logging configuration, which can be (optionally) specified when calling346 * Lib::init().347 */348 struct LogConfig349 {350 /** Log incoming and outgoing SIP message? Yes! */351 unsigned msgLogging;352 353 /** Input verbosity level. Value 5 is reasonable. */354 unsigned level;355 356 /** Verbosity level for console. Value 4 is reasonable. */357 unsigned consoleLevel;358 359 /** Log decoration. */360 unsigned decor;361 362 /** Optional log filename if app wishes the library to write to log file.363 */364 string filename;365 366 /**367 * Additional flags to be given to #pj_file_open() when opening368 * the log file. By default, the flag is PJ_O_WRONLY. Application369 * may set PJ_O_APPEND here so that logs are appended to existing370 * file instead of overwriting it.371 *372 * Default is 0.373 */374 unsigned fileFlags;375 376 /**377 * Custom log writer, if required. If specified, the instance of LogWriter378 * must be kept alive througout the duration of the application.379 */380 LogWriter *writer;381 382 public:383 /** Default constructor initialises with default values */384 LogConfig();385 386 /** Construct from pjsua_logging_config */387 void fromPj(const pjsua_logging_config &lc);388 389 /** Generate pjsua_logging_config. */390 pjsua_logging_config toPj() const;391 };392 393 394 /**395 * This structure describes media configuration, which will be specified396 * when calling Lib::init().397 */398 struct MediaConfig399 {400 public:401 /**402 * Clock rate to be applied to the conference bridge.403 * If value is zero, default clock rate will be used404 * (PJSUA_DEFAULT_CLOCK_RATE, which by default is 16KHz).405 */406 unsigned clockRate;407 408 /**409 * Clock rate to be applied when opening the sound device.410 * If value is zero, conference bridge clock rate will be used.411 */412 unsigned sndClockRate;413 414 /**415 * Channel count be applied when opening the sound device and416 * conference bridge.417 */418 unsigned channelCount;419 420 /**421 * Specify audio frame ptime. The value here will affect the422 * samples per frame of both the sound device and the conference423 * bridge. Specifying lower ptime will normally reduce the424 * latency.425 *426 * Default value: PJSUA_DEFAULT_AUDIO_FRAME_PTIME427 */428 unsigned audioFramePtime;429 430 /**431 * Specify maximum number of media ports to be created in the432 * conference bridge. Since all media terminate in the bridge433 * (calls, file player, file recorder, etc), the value must be434 * large enough to support all of them. However, the larger435 * the value, the more computations are performed.436 *437 * Default value: PJSUA_MAX_CONF_PORTS438 */439 unsigned maxMediaPorts;440 441 /**442 * Specify whether the media manager should manage its own443 * ioqueue for the RTP/RTCP sockets. If yes, ioqueue will be created444 * and at least one worker thread will be created too. If no,445 * the RTP/RTCP sockets will share the same ioqueue as SIP sockets,446 * and no worker thread is needed.447 *448 * Normally application would say yes here, unless it wants to449 * run everything from a single thread.450 */451 bool hasIoqueue;452 453 /**454 * Specify the number of worker threads to handle incoming RTP455 * packets. A value of one is recommended for most applications.456 */457 unsigned threadCnt;458 459 /**460 * Media quality, 0-10, according to this table:461 * 5-10: resampling use large filter,462 * 3-4: resampling use small filter,463 * 1-2: resampling use linear.464 * The media quality also sets speex codec quality/complexity to the465 * number.466 *467 * Default: 5 (PJSUA_DEFAULT_CODEC_QUALITY).468 */469 unsigned quality;470 471 /**472 * Specify default codec ptime.473 *474 * Default: 0 (codec specific)475 */476 unsigned ptime;477 478 /**479 * Disable VAD?480 *481 * Default: 0 (no (meaning VAD is enabled))482 */483 bool noVad;484 485 /**486 * iLBC mode (20 or 30).487 *488 * Default: 30 (PJSUA_DEFAULT_ILBC_MODE)489 */490 unsigned ilbcMode;491 492 /**493 * Percentage of RTP packet to drop in TX direction494 * (to simulate packet lost).495 *496 * Default: 0497 */498 unsigned txDropPct;499 500 /**501 * Percentage of RTP packet to drop in RX direction502 * (to simulate packet lost).503 *504 * Default: 0505 */506 unsigned rxDropPct;507 508 /**509 * Echo canceller options (see #pjmedia_echo_create())510 *511 * Default: 0.512 */513 unsigned ecOptions;514 515 /**516 * Echo canceller tail length, in miliseconds. Setting this to zero517 * will disable echo cancellation.518 *519 * Default: PJSUA_DEFAULT_EC_TAIL_LEN520 */521 unsigned ecTailLen;522 523 /**524 * Audio capture buffer length, in milliseconds.525 *526 * Default: PJMEDIA_SND_DEFAULT_REC_LATENCY527 */528 unsigned sndRecLatency;529 530 /**531 * Audio playback buffer length, in milliseconds.532 *533 * Default: PJMEDIA_SND_DEFAULT_PLAY_LATENCY534 */535 unsigned sndPlayLatency;536 537 /**538 * Jitter buffer initial prefetch delay in msec. The value must be539 * between jb_min_pre and jb_max_pre below.540 *541 * Default: -1 (to use default stream settings, currently 150 msec)542 */543 int jbInit;544 545 /**546 * Jitter buffer minimum prefetch delay in msec.547 *548 * Default: -1 (to use default stream settings, currently 60 msec)549 */550 int jbMinPre;551 552 /**553 * Jitter buffer maximum prefetch delay in msec.554 *555 * Default: -1 (to use default stream settings, currently 240 msec)556 */557 int jbMaxPre;558 559 /**560 * Set maximum delay that can be accomodated by the jitter buffer msec.561 *562 * Default: -1 (to use default stream settings, currently 360 msec)563 */564 int jbMax;565 566 /**567 * Specify idle time of sound device before it is automatically closed,568 * in seconds. Use value -1 to disable the auto-close feature of sound569 * device570 *571 * Default : 1572 */573 int sndAutoCloseTime;574 575 /**576 * Specify whether built-in/native preview should be used if available.577 * In some systems, video input devices have built-in capability to show578 * preview window of the device. Using this built-in preview is preferable579 * as it consumes less CPU power. If built-in preview is not available,580 * the library will perform software rendering of the input. If this581 * field is set to PJ_FALSE, software preview will always be used.582 *583 * Default: PJ_TRUE584 */585 bool vidPreviewEnableNative;586 587 public:588 /** Default constructor initialises with default values */589 MediaConfig();590 591 /** Construct from pjsua_media_config. */592 void fromPj(const pjsua_media_config &mc);593 594 /** Export */595 pjsua_media_config toPj() const;596 };597 598 599 /**600 * Endpoint configuration601 */602 struct EpConfig603 {604 /** UA config */605 UaConfig uaConfig;606 607 /** Logging config */608 LogConfig logConfig;609 610 /** Media config */611 MediaConfig medConfig;612 };613 614 615 //////////////////////////////////////////////////////////////////////////////616 617 /**618 * Argument to EpCallback::onNatDetectionComplete() callback.619 */620 struct NatDetectionCompleteParam621 {622 /**623 * Status of the detection process. If this value is not PJ_SUCCESS,624 * the detection has failed and \a nat_type field will contain625 * PJ_STUN_NAT_TYPE_UNKNOWN.626 */627 pj_status_t status;628 629 /**630 * The text describing the status, if the status is not PJ_SUCCESS.631 */632 string reason;633 634 /**635 * This contains the NAT type as detected by the detection procedure.636 * This value is only valid when the \a status is PJ_SUCCESS.637 */638 pj_stun_nat_type natType;639 640 /**641 * Text describing that NAT type.642 */643 string natTypeName;644 645 };646 647 /**648 * Argument to EpCallback::onNatCheckStunServersComplete() callback.649 */650 struct NatCheckStunServersCompleteParam651 {652 /**653 * Arbitrary user data that was passed to Endpoint::natCheckStunServers()654 * function.655 */656 Token userData;657 658 /**659 * This will contain PJ_SUCCESS if at least one usable STUN server660 * is found, otherwise it will contain the last error code during661 * the operation.662 */663 pj_status_t status;664 665 /**666 * The server name that yields successful result. This will only667 * contain value if status is successful.668 */669 string name;670 671 /**672 * The server IP address and port in "IP:port" format. This will only673 * contain value if status is successful.674 */675 SocketAddress addr;676 };677 678 /**679 * Parameter of EpCallback::OnTimerComplete() callback.680 */681 struct TimerCompleteParam682 {683 /**684 * Arbitrary user data that was passed to Endpoint::utilTimerSchedule()685 * function.686 */687 Token userData;688 689 /**690 * The interval of this timer, in miliseconds.691 */692 unsigned msecDelay;693 };694 695 /**696 * Parameter of EpCallback::onTransportStateChanged() callback.697 */698 struct TransportStateChangedParam699 {700 /**701 * The transport handle.702 */703 TransportHandle hnd;704 705 /**706 * Transport current state.707 */708 pjsip_transport_state state;709 710 /**711 * The last error code related to the transport state.712 */713 pj_status_t lastError;714 };715 214 716 215 ////////////////////////////////////////////////////////////////////////////// … … 866 365 867 366 /** 367 * Specify the port range for socket binding, relative to the start 368 * port number specified in \a port. Note that this setting is only 369 * applicable when the start port number is non zero. 370 * 371 * Default value is zero. 372 */ 373 unsigned portRange; 374 375 /** 868 376 * Optional address to advertise as the address of this transport. 869 377 * Application can specify any address or hostname for this field, … … 960 468 }; 961 469 470 ////////////////////////////////////////////////////////////////////////////// 471 472 /** 473 * This structure describes an incoming SIP message. It corresponds to the 474 * pjsip_rx_data structure in PJSIP library. 475 */ 476 struct SipRxData 477 { 478 /** 479 * A short info string describing the request, which normally contains 480 * the request method and its CSeq. 481 */ 482 string info; 483 484 /** 485 * The whole message data as a string, containing both the header section 486 * and message body section. 487 */ 488 string wholeMsg; 489 490 /** 491 * Source IP address of the message. 492 */ 493 string srcIp; 494 495 /** 496 * Source port number of the message. 497 */ 498 unsigned srcPort; 499 }; 500 501 502 ////////////////////////////////////////////////////////////////////////////// 503 504 /** 505 * SIP media type containing type and subtype. For example, for 506 * "application/sdp", the type is "application" and the subtype is "sdp". 507 */ 508 struct SipMediaType 509 { 510 /** Media type. */ 511 string type; 512 513 /** Media subtype. */ 514 string subType; 515 }; 516 517 /** 518 * Simple SIP header. 519 */ 520 struct SipHeader 521 { 522 /** 523 * Header name. 524 */ 525 string hName; 526 527 /** 528 * Header value. 529 */ 530 string hValue; 531 532 /** 533 * Initiaize from PJSIP header. 534 */ 535 void fromPj(const pjsip_hdr *) throw(Error); 536 537 /** 538 * Convert to PJSIP header. 539 */ 540 pjsip_generic_string_hdr &toPj() const; 541 542 private: 543 /** Interal buffer for conversion to PJSIP header */ 544 mutable pjsip_generic_string_hdr pjHdr; 545 }; 546 547 548 /** Array of strings */ 549 typedef std::vector<SipHeader> SipHeaderVector; 550 551 /** 552 * This describes each multipart part. 553 */ 554 struct SipMultipartPart 555 { 556 /** 557 * Optional headers to be put in this multipart part. 558 */ 559 SipHeaderVector headers; 560 561 /** 562 * The MIME type of the body part of this multipart part. 563 */ 564 SipMediaType contentType; 565 566 /** 567 * The body part of tthis multipart part. 568 */ 569 string body; 570 }; 571 572 /** Array of multipart parts */ 573 typedef std::vector<SipMultipartPart> SipMultipartPartVector; 574 575 /** 576 * Additional options when sending outgoing SIP message. This corresponds to 577 * pjsua_msg_data structure in PJSIP library. 578 */ 579 struct SipTxOption 580 { 581 /** 582 * Optional remote target URI (i.e. Target header). If NULL, the target 583 * will be set to the remote URI (To header). At the moment this field 584 * is only used when sending initial INVITE and MESSAGE requests. 585 */ 586 string targetUri; 587 588 /** 589 * Additional message headers to be included in the outgoing message. 590 */ 591 SipHeaderVector headers; 592 593 /** 594 * MIME type of the message body, if application specifies the messageBody 595 * in this structure. 596 */ 597 string contentType; 598 599 /** 600 * Optional message body to be added to the message, only when the 601 * message doesn't have a body. 602 */ 603 string msgBody; 604 605 /** 606 * Content type of the multipart body. If application wants to send 607 * multipart message bodies, it puts the parts in multipartParts and set 608 * the content type in multipartContentType. If the message already 609 * contains a body, the body will be added to the multipart bodies. 610 */ 611 SipMediaType multipartContentType; 612 613 /** 614 * Array of multipart parts. If application wants to send multipart 615 * message bodies, it puts the parts in \a parts and set the content 616 * type in \a multipart_ctype. If the message already contains a body, 617 * the body will be added to the multipart bodies. 618 */ 619 SipMultipartPartVector multipartParts; 620 621 }; 622 962 623 963 624 } // namespace pj -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4598 r4608 18 18 */ 19 19 #include <pjsua2/endpoint.hpp> 20 #include "util.hpp" 20 21 21 22 using namespace pj; … … 29 30 { 30 31 pj_uint32_t signature; 31 TimerCompleteParam prm;32 OnTimerParam prm; 32 33 pj_timer_entry entry; 33 34 }; … … 35 36 36 37 /////////////////////////////////////////////////////////////////////////////// 38 39 UaConfig::UaConfig() 40 { 41 pjsua_config ua_cfg; 42 43 pjsua_config_default(&ua_cfg); 44 fromPj(ua_cfg); 45 } 46 47 void UaConfig::fromPj(const pjsua_config &ua_cfg) 48 { 49 unsigned i; 50 51 this->maxCalls = ua_cfg.max_calls; 52 this->threadCnt = ua_cfg.thread_cnt; 53 this->userAgent = pj2Str(ua_cfg.user_agent); 54 55 for (i=0; i<ua_cfg.nameserver_count; ++i) { 56 this->nameserver.push_back(pj2Str(ua_cfg.nameserver[i])); 57 } 58 59 for (i=0; i<ua_cfg.stun_srv_cnt; ++i) { 60 this->stunServer.push_back(pj2Str(ua_cfg.stun_srv[i])); 61 } 62 63 this->stunIgnoreFailure = ua_cfg.stun_ignore_failure; 64 this->natTypeInSdp = ua_cfg.nat_type_in_sdp; 65 this->mwiUnsolicitedEnabled = ua_cfg.enable_unsolicited_mwi; 66 } 67 68 pjsua_config UaConfig::toPj() const 69 { 70 unsigned i; 71 pjsua_config pua_cfg; 72 73 pjsua_config_default(&pua_cfg); 74 75 pua_cfg.max_calls = this->maxCalls; 76 pua_cfg.thread_cnt = this->threadCnt; 77 pua_cfg.user_agent = str2Pj(this->userAgent); 78 79 for (i=0; i<this->nameserver.size() && i<PJ_ARRAY_SIZE(pua_cfg.nameserver); 80 ++i) 81 { 82 pua_cfg.nameserver[i] = str2Pj(this->nameserver[i]); 83 } 84 pua_cfg.nameserver_count = i; 85 86 for (i=0; i<this->stunServer.size() && i<PJ_ARRAY_SIZE(pua_cfg.stun_srv); 87 ++i) 88 { 89 pua_cfg.stun_srv[i] = str2Pj(this->stunServer[i]); 90 } 91 pua_cfg.stun_srv_cnt = i; 92 93 pua_cfg.nat_type_in_sdp = this->natTypeInSdp; 94 pua_cfg.enable_unsolicited_mwi = this->mwiUnsolicitedEnabled; 95 96 return pua_cfg; 97 } 98 99 /////////////////////////////////////////////////////////////////////////////// 100 101 LogConfig::LogConfig() 102 { 103 pjsua_logging_config lc; 104 105 pjsua_logging_config_default(&lc); 106 fromPj(lc); 107 } 108 109 void LogConfig::fromPj(const pjsua_logging_config &lc) 110 { 111 this->msgLogging = lc.msg_logging; 112 this->level = lc.level; 113 this->consoleLevel = lc.console_level; 114 this->decor = lc.decor; 115 this->filename = pj2Str(lc.log_filename); 116 this->fileFlags = lc.log_file_flags; 117 this->writer = NULL; 118 } 119 120 pjsua_logging_config LogConfig::toPj() const 121 { 122 pjsua_logging_config lc; 123 124 pjsua_logging_config_default(&lc); 125 126 lc.msg_logging = this->msgLogging; 127 lc.level = this->level; 128 lc.console_level = this->consoleLevel; 129 lc.decor = this->decor; 130 lc.log_file_flags = this->fileFlags; 131 lc.log_filename = str2Pj(this->filename); 132 133 return lc; 134 } 135 136 /////////////////////////////////////////////////////////////////////////////// 137 138 MediaConfig::MediaConfig() 139 { 140 pjsua_media_config mc; 141 142 pjsua_media_config_default(&mc); 143 fromPj(mc); 144 } 145 146 void MediaConfig::fromPj(const pjsua_media_config &mc) 147 { 148 this->clockRate = mc.clock_rate; 149 this->sndClockRate = mc.snd_clock_rate; 150 this->channelCount = mc.channel_count; 151 this->audioFramePtime = mc.audio_frame_ptime; 152 this->maxMediaPorts = mc.max_media_ports; 153 this->hasIoqueue = mc.has_ioqueue; 154 this->threadCnt = mc.thread_cnt; 155 this->quality = mc.quality; 156 this->ptime = mc.ptime; 157 this->noVad = mc.no_vad; 158 this->ilbcMode = mc.ilbc_mode; 159 this->txDropPct = mc.tx_drop_pct; 160 this->rxDropPct = mc.rx_drop_pct; 161 this->ecOptions = mc.ec_options; 162 this->ecTailLen = mc.ec_tail_len; 163 this->sndRecLatency = mc.snd_rec_latency; 164 this->sndPlayLatency = mc.snd_play_latency; 165 this->jbInit = mc.jb_init; 166 this->jbMinPre = mc.jb_min_pre; 167 this->jbMaxPre = mc.jb_max_pre; 168 this->jbMax = mc.jb_max; 169 this->sndAutoCloseTime = mc.snd_auto_close_time; 170 this->vidPreviewEnableNative = mc.vid_preview_enable_native; 171 } 172 173 pjsua_media_config MediaConfig::toPj() const 174 { 175 pjsua_media_config mcfg; 176 177 pjsua_media_config_default(&mcfg); 178 179 mcfg.clock_rate = this->clockRate; 180 mcfg.snd_clock_rate = this->sndClockRate; 181 mcfg.channel_count = this->channelCount; 182 mcfg.audio_frame_ptime = this->audioFramePtime; 183 mcfg.max_media_ports = this->maxMediaPorts; 184 mcfg.has_ioqueue = this->hasIoqueue; 185 mcfg.thread_cnt = this->threadCnt; 186 mcfg.quality = this->quality; 187 mcfg.ptime = this->ptime; 188 mcfg.no_vad = this->noVad; 189 mcfg.ilbc_mode = this->ilbcMode; 190 mcfg.tx_drop_pct = this->txDropPct; 191 mcfg.rx_drop_pct = this->rxDropPct; 192 mcfg.ec_options = this->ecOptions; 193 mcfg.ec_tail_len = this->ecTailLen; 194 mcfg.snd_rec_latency = this->sndRecLatency; 195 mcfg.snd_play_latency = this->sndPlayLatency; 196 mcfg.jb_init = this->jbInit; 197 mcfg.jb_min_pre = this->jbMinPre; 198 mcfg.jb_max_pre = this->jbMaxPre; 199 mcfg.jb_max = this->jbMax; 200 mcfg.snd_auto_close_time = this->sndAutoCloseTime; 201 mcfg.vid_preview_enable_native = this->vidPreviewEnableNative; 202 203 return mcfg; 204 } 205 206 207 /////////////////////////////////////////////////////////////////////////////// 37 208 /* 38 209 * Endpoint instance … … 51 222 void Endpoint::testException() throw(Error) 52 223 { 53 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::testException()",PJ_EINVALIDOP);224 PJSUA2_CHECK_RAISE_ERROR(PJ_EINVALIDOP); 54 225 } 55 226 … … 82 253 return; 83 254 84 NatCheckStunServersCompleteParam prm;255 OnNatCheckStunServersCompleteParam prm; 85 256 86 257 prm.userData = res->token; … … 106 277 return; 107 278 108 ep.epCallback-> OnTimerComplete(ut->prm);279 ep.epCallback->onTimer(ut->prm); 109 280 } 110 281 … … 116 287 return; 117 288 118 NatDetectionCompleteParam prm;289 OnNatDetectionCompleteParam prm; 119 290 120 291 prm.status = res->status; … … 135 306 return; 136 307 137 TransportStateChangedParam prm;308 OnTransportStateParam prm; 138 309 139 310 prm.hnd = (TransportHandle)tp; … … 141 312 prm.lastError = info ? info->status : PJ_SUCCESS; 142 313 143 ep.epCallback->onTransportState Changed(prm);314 ep.epCallback->onTransportState(prm); 144 315 } 145 316 … … 153 324 154 325 status = pjsua_create(); 155 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libCreate()",status);326 PJSUA2_CHECK_RAISE_ERROR(status); 156 327 } 157 328 … … 186 357 /* Init! */ 187 358 status = pjsua_init(&ua_cfg, &log_cfg, &med_cfg); 188 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libInit()",status);359 PJSUA2_CHECK_RAISE_ERROR(status); 189 360 } 190 361 … … 194 365 195 366 status = pjsua_start(); 196 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libStart()",status);367 PJSUA2_CHECK_RAISE_ERROR(status); 197 368 } 198 369 … … 210 381 } 211 382 212 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::libDestroy()",status);383 PJSUA2_CHECK_RAISE_ERROR(status); 213 384 } 214 385 … … 271 442 if (status != PJ_SUCCESS) { 272 443 delete ut; 273 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::utilTimerSchedule()",status);444 PJSUA2_CHECK_RAISE_ERROR(status); 274 445 } 275 446 … … 302 473 303 474 status = pj_ssl_cipher_get_availables(ciphers, &count); 304 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::utilSslGetAvailableCiphers()",status);475 PJSUA2_CHECK_RAISE_ERROR(status); 305 476 306 477 return IntVector(ciphers, ciphers + count); … … 319 490 320 491 status = pjsua_detect_nat_type(); 321 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natDetectType()",status);492 PJSUA2_CHECK_RAISE_ERROR(status); 322 493 } 323 494 … … 328 499 329 500 status = pjsua_get_nat_type(&type); 330 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natGetType()",status);501 PJSUA2_CHECK_RAISE_ERROR(status); 331 502 332 503 return type; … … 349 520 status = pjsua_resolve_stun_servers(count, srv, wait, token, 350 521 &Endpoint::stun_resolve_cb); 351 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natCheckStunServers()",status);522 PJSUA2_CHECK_RAISE_ERROR(status); 352 523 } 353 524 … … 358 529 359 530 status = pjsua_cancel_stun_resolution(token, notify_cb); 360 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::natCancelCheckStunServers()",status);531 PJSUA2_CHECK_RAISE_ERROR(status); 361 532 } 362 533 … … 374 545 tcfg = cfg.toPj(); 375 546 status = pjsua_transport_create(type, &tcfg, &tid); 376 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportCreate()",status);547 PJSUA2_CHECK_RAISE_ERROR(status); 377 548 378 549 return tid; … … 386 557 387 558 status = pjsua_enum_transports(tids, &count); 388 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportEnum()",status);559 PJSUA2_CHECK_RAISE_ERROR(status); 389 560 390 561 return IntVector(tids, tids+count); … … 397 568 398 569 status = pjsua_transport_get_info(id, &tinfo); 399 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportGetInfo()",status);570 PJSUA2_CHECK_RAISE_ERROR(status); 400 571 401 572 return TransportInfo(tinfo); … … 407 578 408 579 status = pjsua_transport_set_enable(id, enabled); 409 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportSetEnable()",status);580 PJSUA2_CHECK_RAISE_ERROR(status); 410 581 } 411 582 … … 415 586 416 587 status = pjsua_transport_close(id, PJ_FALSE); 417 PJSUA2_CHECK_RAISE_ERROR( "Endpoint::transportClose()",status);418 } 419 588 PJSUA2_CHECK_RAISE_ERROR(status); 589 } 590 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/types.cpp
r4598 r4608 18 18 */ 19 19 #include <pjsua2/types.hpp> 20 #include "util.hpp" 20 21 21 22 using namespace pj; … … 23 24 24 25 /////////////////////////////////////////////////////////////////////////////// 25 inline pj_str_t str2Pj(const string &is)26 {27 pj_str_t os;28 os.ptr = (char*)is.c_str();29 os.slen = is.size();30 return os;31 }32 33 inline string pj2Str(const pj_str_t &is)34 {35 return string(is.ptr, is.slen);36 }37 38 ///////////////////////////////////////////////////////////////////////////////39 26 40 27 Error::Error() 41 : status(PJ_SUCCESS) 28 : status(PJ_SUCCESS), srcLine(0) 42 29 { 43 30 } 44 31 45 32 Error::Error( pj_status_t prm_status, 33 const string &prm_title, 46 34 const string &prm_reason, 47 const string &prm_title,48 35 const string &prm_src_file, 49 36 int prm_src_line) 50 : status(prm_status), reason(prm_reason), title(prm_title),37 : status(prm_status), title(prm_title), reason(prm_reason), 51 38 srcFile(prm_src_file), srcLine(prm_src_line) 52 39 { … … 58 45 } 59 46 60 ///////////////////////////////////////////////////////////////////////////////61 62 AuthCredInfo::AuthCredInfo()63 : dataType(0)64 {65 }66 67 ///////////////////////////////////////////////////////////////////////////////68 69 UaConfig::UaConfig()70 {71 pjsua_config ua_cfg;72 73 pjsua_config_default(&ua_cfg);74 fromPj(ua_cfg);75 }76 77 void UaConfig::fromPj(const pjsua_config &ua_cfg)78 {79 unsigned i;80 81 this->maxCalls = ua_cfg.max_calls;82 this->threadCnt = ua_cfg.thread_cnt;83 this->userAgent = pj2Str(ua_cfg.user_agent);84 85 for (i=0; i<ua_cfg.nameserver_count; ++i) {86 this->nameserver.push_back(pj2Str(ua_cfg.nameserver[i]));87 }88 89 for (i=0; i<ua_cfg.stun_srv_cnt; ++i) {90 this->stunServer.push_back(pj2Str(ua_cfg.stun_srv[i]));91 }92 93 this->stunIgnoreFailure = ua_cfg.stun_ignore_failure;94 this->natTypeInSdp = ua_cfg.nat_type_in_sdp;95 this->mwiUnsolicitedEnabled = ua_cfg.enable_unsolicited_mwi;96 }97 98 pjsua_config UaConfig::toPj() const99 {100 unsigned i;101 pjsua_config pua_cfg;102 103 pjsua_config_default(&pua_cfg);104 105 pua_cfg.max_calls = this->maxCalls;106 pua_cfg.thread_cnt = this->threadCnt;107 pua_cfg.user_agent = str2Pj(this->userAgent);108 109 for (i=0; i<this->nameserver.size() && i<PJ_ARRAY_SIZE(pua_cfg.nameserver);110 ++i)111 {112 pua_cfg.nameserver[i] = str2Pj(this->nameserver[i]);113 }114 pua_cfg.nameserver_count = i;115 116 for (i=0; i<this->stunServer.size() && i<PJ_ARRAY_SIZE(pua_cfg.stun_srv);117 ++i)118 {119 pua_cfg.stun_srv[i] = str2Pj(this->stunServer[i]);120 }121 pua_cfg.stun_srv_cnt = i;122 123 pua_cfg.nat_type_in_sdp = this->natTypeInSdp;124 pua_cfg.enable_unsolicited_mwi = this->mwiUnsolicitedEnabled;125 126 return pua_cfg;127 }128 129 ///////////////////////////////////////////////////////////////////////////////130 131 LogConfig::LogConfig()132 {133 pjsua_logging_config lc;134 135 pjsua_logging_config_default(&lc);136 fromPj(lc);137 }138 139 void LogConfig::fromPj(const pjsua_logging_config &lc)140 {141 this->msgLogging = lc.msg_logging;142 this->level = lc.level;143 this->consoleLevel = lc.console_level;144 this->decor = lc.decor;145 this->filename = pj2Str(lc.log_filename);146 this->fileFlags = lc.log_file_flags;147 this->writer = NULL;148 }149 150 pjsua_logging_config LogConfig::toPj() const151 {152 pjsua_logging_config lc;153 154 pjsua_logging_config_default(&lc);155 156 lc.msg_logging = this->msgLogging;157 lc.level = this->level;158 lc.console_level = this->consoleLevel;159 lc.decor = this->decor;160 lc.log_file_flags = this->fileFlags;161 lc.log_filename = str2Pj(this->filename);162 163 return lc;164 }165 166 ///////////////////////////////////////////////////////////////////////////////167 168 MediaConfig::MediaConfig()169 {170 pjsua_media_config mc;171 172 pjsua_media_config_default(&mc);173 fromPj(mc);174 }175 176 void MediaConfig::fromPj(const pjsua_media_config &mc)177 {178 this->clockRate = mc.clock_rate;179 this->sndClockRate = mc.snd_clock_rate;180 this->channelCount = mc.channel_count;181 this->audioFramePtime = mc.audio_frame_ptime;182 this->maxMediaPorts = mc.max_media_ports;183 this->hasIoqueue = mc.has_ioqueue;184 this->threadCnt = mc.thread_cnt;185 this->quality = mc.quality;186 this->ptime = mc.ptime;187 this->noVad = mc.no_vad;188 this->ilbcMode = mc.ilbc_mode;189 this->txDropPct = mc.tx_drop_pct;190 this->rxDropPct = mc.rx_drop_pct;191 this->ecOptions = mc.ec_options;192 this->ecTailLen = mc.ec_tail_len;193 this->sndRecLatency = mc.snd_rec_latency;194 this->sndPlayLatency = mc.snd_play_latency;195 this->jbInit = mc.jb_init;196 this->jbMinPre = mc.jb_min_pre;197 this->jbMaxPre = mc.jb_max_pre;198 this->jbMax = mc.jb_max;199 this->sndAutoCloseTime = mc.snd_auto_close_time;200 this->vidPreviewEnableNative = mc.vid_preview_enable_native;201 }202 203 pjsua_media_config MediaConfig::toPj() const204 {205 pjsua_media_config mcfg;206 207 pjsua_media_config_default(&mcfg);208 209 mcfg.clock_rate = this->clockRate;210 mcfg.snd_clock_rate = this->sndClockRate;211 mcfg.channel_count = this->channelCount;212 mcfg.audio_frame_ptime = this->audioFramePtime;213 mcfg.max_media_ports = this->maxMediaPorts;214 mcfg.has_ioqueue = this->hasIoqueue;215 mcfg.thread_cnt = this->threadCnt;216 mcfg.quality = this->quality;217 mcfg.ptime = this->ptime;218 mcfg.no_vad = this->noVad;219 mcfg.ilbc_mode = this->ilbcMode;220 mcfg.tx_drop_pct = this->txDropPct;221 mcfg.rx_drop_pct = this->rxDropPct;222 mcfg.ec_options = this->ecOptions;223 mcfg.ec_tail_len = this->ecTailLen;224 mcfg.snd_rec_latency = this->sndRecLatency;225 mcfg.snd_play_latency = this->sndPlayLatency;226 mcfg.jb_init = this->jbInit;227 mcfg.jb_min_pre = this->jbMinPre;228 mcfg.jb_max_pre = this->jbMaxPre;229 mcfg.jb_max = this->jbMax;230 mcfg.snd_auto_close_time = this->sndAutoCloseTime;231 mcfg.vid_preview_enable_native = this->vidPreviewEnableNative;232 233 return mcfg;234 }235 47 236 48 /////////////////////////////////////////////////////////////////////////////// … … 299 111 { 300 112 this->port = prm.port; 113 this->portRange = prm.port_range; 301 114 this->publicAddress = pj2Str(prm.public_addr); 302 115 this->boundAddress = pj2Str(prm.bound_addr); … … 311 124 312 125 tc.port = this->port; 126 tc.port_range = this->portRange; 313 127 tc.public_addr = str2Pj(this->publicAddress); 314 128 tc.bound_addr = str2Pj(this->boundAddress); … … 342 156 } 343 157 158 /////////////////////////////////////////////////////////////////////////////// 159 160 void SipHeader::fromPj(const pjsip_hdr *hdr) throw(Error) 161 { 162 char buf[256]; 163 164 int len = pjsip_hdr_print_on((void*)hdr, buf, sizeof(buf)-1); 165 if (len <= 0) 166 PJSUA2_RAISE_ERROR(PJ_ETOOSMALL); 167 buf[len] = '\0'; 168 169 char *pos = strchr(buf, ':'); 170 if (!pos) 171 PJSUA2_RAISE_ERROR(PJSIP_EINVALIDHDR); 172 173 // Trim white space after header name 174 char *end_name = pos; 175 while (end_name>buf && pj_isspace(*(end_name-1))) --end_name; 176 177 // Trim whitespaces after colon 178 char *start_val = pos+1; 179 while (*start_val && pj_isspace(*start_val)) ++start_val; 180 181 hName = string(buf, end_name); 182 hValue = string(start_val); 183 } 184 185 pjsip_generic_string_hdr &SipHeader::toPj() const 186 { 187 pj_str_t hname = str2Pj(hName); 188 pj_str_t hvalue = str2Pj(hValue); 189 190 pjsip_generic_string_hdr_init2(&pjHdr, &hname, &hvalue); 191 return pjHdr; 192 }
Note: See TracChangeset
for help on using the changeset viewer.