- Timestamp:
- Oct 1, 2013 9:41:01 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.