- 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/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.
Note: See TracChangeset
for help on using the changeset viewer.