Changeset 4644
- Timestamp:
- Nov 6, 2013 8:05:11 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2/pjsip
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/build/Makefile
r4608 r4644 90 90 export PJSUA2_LIB_SRCDIR = ../src/pjsua2 91 91 export PJSUA2_LIB_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \ 92 account.o endpoint.o types.o 92 account.o endpoint.o json.o persistent.o types.o \ 93 siptypes.o 93 94 export PJSUA2_LIB_CFLAGS += $(_CFLAGS) $(PJ_VIDEO_CFLAGS) 94 95 export PJSUA2_LIB_CXXFLAGS = $(PJSUA2_LIB_CFLAGS) -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2.hpp
r4631 r4644 22 22 #include <pjsua2/endpoint.hpp> 23 23 #include <pjsua2/account.hpp> 24 #include <pjsua2/json.hpp> 24 25 25 26 #endif -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/account.hpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 20 08-2012Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 25 25 */ 26 26 #include <pjsua-lib/pjsua.h> 27 #include <pjsua2/types.hpp> 27 #include <pjsua2/persistent.hpp> 28 #include <pjsua2/siptypes.hpp> 28 29 29 30 /** … … 46 47 * Account registration config. This will be specified in AccountConfig. 47 48 */ 48 struct AccountRegConfig 49 struct AccountRegConfig : public PersistentObject 49 50 { 50 51 /** … … 138 139 */ 139 140 unsigned proxyUse; 141 142 public: 143 /** 144 * Read this object from a container node. 145 * 146 * @param node Container to read values from. 147 */ 148 virtual void readObject(const ContainerNode &node) throw(Error); 149 150 /** 151 * Write this object to a container node. 152 * 153 * @param node Container to write values to. 154 */ 155 virtual void writeObject(ContainerNode &node) const throw(Error); 156 140 157 }; 141 158 … … 147 164 * AccountConfig. 148 165 */ 149 struct AccountSipConfig 166 struct AccountSipConfig : public PersistentObject 150 167 { 151 168 /** … … 221 238 */ 222 239 TransportId transportId; 240 241 public: 242 /** 243 * Read this object from a container node. 244 * 245 * @param node Container to read values from. 246 */ 247 virtual void readObject(const ContainerNode &node) throw(Error); 248 249 /** 250 * Write this object to a container node. 251 * 252 * @param node Container to write values to. 253 */ 254 virtual void writeObject(ContainerNode &node) const throw(Error); 223 255 }; 224 256 … … 226 258 * Account's call settings. This will be specified in AccountConfig. 227 259 */ 228 struct AccountCallConfig 260 struct AccountCallConfig : public PersistentObject 229 261 { 230 262 /** … … 265 297 unsigned timerSessExpiresSec; 266 298 299 public: 300 /** 301 * Read this object from a container node. 302 * 303 * @param node Container to read values from. 304 */ 305 virtual void readObject(const ContainerNode &node) throw(Error); 306 307 /** 308 * Write this object to a container node. 309 * 310 * @param node Container to write values to. 311 */ 312 virtual void writeObject(ContainerNode &node) const throw(Error); 267 313 }; 268 314 … … 270 316 * Account presence config. This will be specified in AccountConfig. 271 317 */ 272 struct AccountPresConfig 318 struct AccountPresConfig : public PersistentObject 273 319 { 274 320 /** … … 317 363 */ 318 364 string pidfTupleId; 365 366 public: 367 /** 368 * Read this object from a container node. 369 * 370 * @param node Container to read values from. 371 */ 372 virtual void readObject(const ContainerNode &node) throw(Error); 373 374 /** 375 * Write this object to a container node. 376 * 377 * @param node Container to write values to. 378 */ 379 virtual void writeObject(ContainerNode &node) const throw(Error); 319 380 }; 320 381 … … 323 384 * in AccountConfig. 324 385 */ 325 struct AccountMwiConfig 386 struct AccountMwiConfig : public PersistentObject 326 387 { 327 388 /** … … 342 403 */ 343 404 unsigned expirationSec; 405 406 public: 407 /** 408 * Read this object from a container node. 409 * 410 * @param node Container to read values from. 411 */ 412 virtual void readObject(const ContainerNode &node) throw(Error); 413 414 /** 415 * Write this object to a container node. 416 * 417 * @param node Container to write values to. 418 */ 419 virtual void writeObject(ContainerNode &node) const throw(Error); 344 420 }; 345 421 … … 348 424 * specified in AccountConfig. 349 425 */ 350 struct AccountNatConfig 426 struct AccountNatConfig : public PersistentObject 351 427 { 352 428 /** … … 561 637 */ 562 638 string udpKaData; 639 640 public: 641 /** 642 * Read this object from a container node. 643 * 644 * @param node Container to read values from. 645 */ 646 virtual void readObject(const ContainerNode &node) throw(Error); 647 648 /** 649 * Write this object to a container node. 650 * 651 * @param node Container to write values to. 652 */ 653 virtual void writeObject(ContainerNode &node) const throw(Error); 563 654 }; 564 655 … … 567 658 * specified in AccountConfig. 568 659 */ 569 struct AccountMediaConfig 660 struct AccountMediaConfig : public PersistentObject 570 661 { 571 662 /** … … 618 709 */ 619 710 pjsua_ipv6_use ipv6Use; 711 712 public: 713 /** 714 * Read this object from a container node. 715 * 716 * @param node Container to read values from. 717 */ 718 virtual void readObject(const ContainerNode &node) throw(Error); 719 720 /** 721 * Write this object to a container node. 722 * 723 * @param node Container to write values to. 724 */ 725 virtual void writeObject(ContainerNode &node) const throw(Error); 620 726 }; 621 727 … … 623 729 * Account video config. This will be specified in AccountConfig. 624 730 */ 625 struct AccountVideoConfig 731 struct AccountVideoConfig : public PersistentObject 626 732 { 627 733 /** … … 694 800 */ 695 801 unsigned rateControlBandwidth; 802 803 public: 804 /** 805 * Read this object from a container node. 806 * 807 * @param node Container to read values from. 808 */ 809 virtual void readObject(const ContainerNode &node) throw(Error); 810 811 /** 812 * Write this object to a container node. 813 * 814 * @param node Container to write values to. 815 */ 816 virtual void writeObject(ContainerNode &node) const throw(Error); 696 817 }; 697 818 … … 699 820 * Account configuration. 700 821 */ 701 struct AccountConfig 822 struct AccountConfig : public PersistentObject 702 823 { 703 824 /** … … 777 898 void fromPj(const pjsua_acc_config &prm, const pjsua_media_config *mcfg); 778 899 900 /** 901 * Read this object from a container node. 902 * 903 * @param node Container to read values from. 904 */ 905 virtual void readObject(const ContainerNode &node) throw(Error); 906 907 /** 908 * Write this object to a container node. 909 * 910 * @param node Container to write values to. 911 */ 912 virtual void writeObject(ContainerNode &node) const throw(Error); 779 913 }; 780 914 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/config.hpp
r4597 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 20 08-2012Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 20 08-2012Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 24 24 * @brief PJSUA2 Base Agent Operation 25 25 */ 26 #include <pjsua2/types.hpp> 26 #include <pjsua2/persistent.hpp> 27 #include <pjsua2/siptypes.hpp> 27 28 28 29 /** PJSUA2 API is inside pj namespace */ … … 162 163 ////////////////////////////////////////////////////////////////////////////// 163 164 164 struct UaConfig 165 struct UaConfig : public PersistentObject 165 166 { 166 167 /** … … 265 266 */ 266 267 pjsua_config toPj() const; 268 269 /** 270 * Read this object from a container. 271 * 272 * @param node Container to write values from. 273 */ 274 virtual void readObject(const ContainerNode &node) throw(Error); 275 276 /** 277 * Write this object to a container. 278 * 279 * @param node Container to write values to. 280 */ 281 virtual void writeObject(ContainerNode &node) const throw(Error); 282 267 283 }; 268 284 … … 307 323 * Lib::init(). 308 324 */ 309 struct LogConfig 325 struct LogConfig : public PersistentObject 310 326 { 311 327 /** Log incoming and outgoing SIP message? Yes! */ … … 350 366 /** Generate pjsua_logging_config. */ 351 367 pjsua_logging_config toPj() const; 368 369 /** 370 * Read this object from a container. 371 * 372 * @param node Container to write values from. 373 */ 374 virtual void readObject(const ContainerNode &node) throw(Error); 375 376 /** 377 * Write this object to a container. 378 * 379 * @param node Container to write values to. 380 */ 381 virtual void writeObject(ContainerNode &node) const throw(Error); 352 382 }; 353 383 … … 357 387 * when calling Lib::init(). 358 388 */ 359 struct MediaConfig 389 struct MediaConfig : public PersistentObject 360 390 { 361 391 public: … … 555 585 /** Export */ 556 586 pjsua_media_config toPj() const; 587 588 /** 589 * Read this object from a container. 590 * 591 * @param node Container to write values from. 592 */ 593 virtual void readObject(const ContainerNode &node) throw(Error); 594 595 /** 596 * Write this object to a container. 597 * 598 * @param node Container to write values to. 599 */ 600 virtual void writeObject(ContainerNode &node) const throw(Error); 557 601 }; 558 602 … … 561 605 * Endpoint configuration 562 606 */ 563 struct EpConfig 607 struct EpConfig : public PersistentObject 564 608 { 565 609 /** UA config */ … … 571 615 /** Media config */ 572 616 MediaConfig medConfig; 617 618 /** 619 * Read this object from a container. 620 * 621 * @param node Container to write values from. 622 */ 623 virtual void readObject(const ContainerNode &node) throw(Error); 624 625 /** 626 * Write this object to a container. 627 * 628 * @param node Container to write values to. 629 */ 630 virtual void writeObject(ContainerNode &node) const throw(Error); 631 573 632 }; 574 633 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 20 08-2012Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 21 21 22 22 /** 23 * @file pjsua2/ ua.hpp24 * @brief PJSUA2 Base Agent Operation23 * @file pjsua2/types.hpp 24 * @brief PJSUA2 Base Types 25 25 */ 26 26 #include <pjsua2/config.hpp> … … 207 207 }; 208 208 209 //////////////////////////////////////////////////////////////////////////////210 211 /**212 * Credential information. Credential contains information to authenticate213 * against a service.214 */215 struct AuthCredInfo216 {217 /**218 * The authentication scheme (e.g. "digest").219 */220 string scheme;221 222 /**223 * Realm on which this credential is to be used. Use "*" to make224 * a credential that can be used to authenticate against any challenges.225 */226 string realm;227 228 /**229 * Authentication user name.230 */231 string username;232 233 /**234 * Type of data that is contained in the "data" field. Use 0 if the data235 * contains plain text password.236 */237 int dataType;238 239 /**240 * The data, which can be a plain text password or a hashed digest.241 */242 string data;243 244 /*245 * Digest AKA credential information. Note that when AKA credential246 * is being used, the \a data field of this #pjsip_cred_info is247 * not used, but it still must be initialized to an empty string.248 * Please see \ref PJSIP_AUTH_AKA_API for more information.249 */250 251 /** Permanent subscriber key. */252 string akaK;253 254 /** Operator variant key. */255 string akaOp;256 257 /** Authentication Management Field */258 string akaAmf;259 260 /** Default constructor */261 AuthCredInfo();262 263 /** Construct a credential with the specified parameters */264 AuthCredInfo(const string &scheme,265 const string &realm,266 const string &user_name,267 const int data_type,268 const string data);269 270 };271 272 273 //////////////////////////////////////////////////////////////////////////////274 275 /**276 * TLS transport settings, to be specified in TransportConfig.277 */278 struct TlsConfig279 {280 /**281 * Certificate of Authority (CA) list file.282 */283 string CaListFile;284 285 /**286 * Public endpoint certificate file, which will be used as client-287 * side certificate for outgoing TLS connection, and server-side288 * certificate for incoming TLS connection.289 */290 string certFile;291 292 /**293 * Optional private key of the endpoint certificate to be used.294 */295 string privKeyFile;296 297 /**298 * Password to open private key.299 */300 string password;301 302 /**303 * TLS protocol method from #pjsip_ssl_method.304 *305 * Default is PJSIP_SSL_UNSPECIFIED_METHOD (0), which in turn will306 * use PJSIP_SSL_DEFAULT_METHOD, which default value is307 * PJSIP_TLSV1_METHOD.308 */309 pjsip_ssl_method method;310 311 /**312 * Ciphers and order preference. The Endpoint::utilSslGetAvailableCiphers()313 * can be used to check the available ciphers supported by backend.314 * If the array is empty, then default cipher list of the backend315 * will be used.316 */317 IntVector ciphers;318 319 /**320 * Specifies TLS transport behavior on the server TLS certificate321 * verification result:322 * - If \a verifyServer is disabled, TLS transport will just notify323 * the application via #pjsip_tp_state_callback with state324 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.325 * - If \a verifyServer is enabled, TLS transport will be shutdown326 * and application will be notified with state327 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification328 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.329 *330 * In any cases, application can inspect #pjsip_tls_state_info in the331 * callback to see the verification detail.332 *333 * Default value is false.334 */335 bool verifyServer;336 337 /**338 * Specifies TLS transport behavior on the client TLS certificate339 * verification result:340 * - If \a verifyClient is disabled, TLS transport will just notify341 * the application via #pjsip_tp_state_callback with state342 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.343 * - If \a verifyClient is enabled, TLS transport will be shutdown344 * and application will be notified with state345 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification346 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.347 *348 * In any cases, application can inspect #pjsip_tls_state_info in the349 * callback to see the verification detail.350 *351 * Default value is PJ_FALSE.352 */353 bool verifyClient;354 355 /**356 * When acting as server (incoming TLS connections), reject incoming357 * connection if client doesn't supply a TLS certificate.358 *359 * This setting corresponds to SSL_VERIFY_FAIL_IF_NO_PEER_CERT flag.360 * Default value is PJ_FALSE.361 */362 bool requireClientCert;363 364 /**365 * TLS negotiation timeout to be applied for both outgoing and incoming366 * connection, in milliseconds. If zero, the SSL negotiation doesn't367 * have a timeout.368 *369 * Default: zero370 */371 unsigned msecTimeout;372 373 /**374 * QoS traffic type to be set on this transport. When application wants375 * to apply QoS tagging to the transport, it's preferable to set this376 * field rather than \a qosParam fields since this is more portable.377 *378 * Default value is PJ_QOS_TYPE_BEST_EFFORT.379 */380 pj_qos_type qosType;381 382 /**383 * Set the low level QoS parameters to the transport. This is a lower384 * level operation than setting the \a qosType field and may not be385 * supported on all platforms.386 *387 * By default all settings in this structure are disabled.388 */389 pj_qos_params qosParams;390 391 /**392 * Specify if the transport should ignore any errors when setting the QoS393 * traffic type/parameters.394 *395 * Default: PJ_TRUE396 */397 bool qosIgnoreError;398 399 public:400 /** Default constructor initialises with default values */401 TlsConfig();402 403 /** Convert to pjsip */404 pjsip_tls_setting toPj() const;405 406 /** Convert from pjsip */407 void fromPj(const pjsip_tls_setting &prm);408 };409 410 411 /**412 * Parameters to create a transport instance.413 */414 struct TransportConfig415 {416 /**417 * UDP port number to bind locally. This setting MUST be specified418 * even when default port is desired. If the value is zero, the419 * transport will be bound to any available port, and application420 * can query the port by querying the transport info.421 */422 unsigned port;423 424 /**425 * Specify the port range for socket binding, relative to the start426 * port number specified in \a port. Note that this setting is only427 * applicable when the start port number is non zero.428 *429 * Default value is zero.430 */431 unsigned portRange;432 433 /**434 * Optional address to advertise as the address of this transport.435 * Application can specify any address or hostname for this field,436 * for example it can point to one of the interface address in the437 * system, or it can point to the public address of a NAT router438 * where port mappings have been configured for the application.439 *440 * Note: this option can be used for both UDP and TCP as well!441 */442 string publicAddress;443 444 /**445 * Optional address where the socket should be bound to. This option446 * SHOULD only be used to selectively bind the socket to particular447 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the448 * published address of a transport (the public_addr field should be449 * used for that purpose).450 *451 * Note that unlike public_addr field, the address (or hostname) here452 * MUST correspond to the actual interface address in the host, since453 * this address will be specified as bind() argument.454 */455 string boundAddress;456 457 /**458 * This specifies TLS settings for TLS transport. It is only be used459 * when this transport config is being used to create a SIP TLS460 * transport.461 */462 TlsConfig tlsConfig;463 464 /**465 * QoS traffic type to be set on this transport. When application wants466 * to apply QoS tagging to the transport, it's preferable to set this467 * field rather than \a qosParam fields since this is more portable.468 *469 * Default is QoS not set.470 */471 pj_qos_type qosType;472 473 /**474 * Set the low level QoS parameters to the transport. This is a lower475 * level operation than setting the \a qosType field and may not be476 * supported on all platforms.477 *478 * Default is QoS not set.479 */480 pj_qos_params qosParams;481 482 public:483 /** Default constructor initialises with default values */484 TransportConfig();485 486 /** Convert from pjsip */487 void fromPj(const pjsua_transport_config &prm);488 489 /** Convert to pjsip */490 pjsua_transport_config toPj() const;491 };492 493 /**494 * This structure describes transport information returned by495 * Endpoint::transportGetInfo() function.496 */497 struct TransportInfo498 {499 /** PJSUA transport identification. */500 TransportId id;501 502 /** Transport type. */503 pjsip_transport_type_e type;504 505 /** Transport type name. */506 string typeName;507 508 /** Transport string info/description. */509 string info;510 511 /** Transport flags (see #pjsip_transport_flags_e). */512 unsigned flags;513 514 /** Local/bound address. */515 SocketAddress localAddress;516 517 /** Published address (or transport address name). */518 SocketAddress localName;519 520 /** Current number of objects currently referencing this transport. */521 unsigned usageCount;522 523 /** Construct from pjsip */524 TransportInfo(const pjsua_transport_info &info);525 526 };527 528 //////////////////////////////////////////////////////////////////////////////529 530 /**531 * This structure describes an incoming SIP message. It corresponds to the532 * pjsip_rx_data structure in PJSIP library.533 */534 struct SipRxData535 {536 /**537 * A short info string describing the request, which normally contains538 * the request method and its CSeq.539 */540 string info;541 542 /**543 * The whole message data as a string, containing both the header section544 * and message body section.545 */546 string wholeMsg;547 548 /**549 * Source IP address of the message.550 */551 string srcIp;552 553 /**554 * Source port number of the message.555 */556 unsigned srcPort;557 558 /**559 * Construct from PJSIP's pjsip_rx_data560 */561 void fromPj(pjsip_rx_data &rdata);562 };563 564 565 //////////////////////////////////////////////////////////////////////////////566 567 /**568 * SIP media type containing type and subtype. For example, for569 * "application/sdp", the type is "application" and the subtype is "sdp".570 */571 struct SipMediaType572 {573 /** Media type. */574 string type;575 576 /** Media subtype. */577 string subType;578 };579 580 /**581 * Simple SIP header.582 */583 struct SipHeader584 {585 /**586 * Header name.587 */588 string hName;589 590 /**591 * Header value.592 */593 string hValue;594 595 /**596 * Initiaize from PJSIP header.597 */598 void fromPj(const pjsip_hdr *) throw(Error);599 600 /**601 * Convert to PJSIP header.602 */603 pjsip_generic_string_hdr &toPj() const;604 605 private:606 /** Interal buffer for conversion to PJSIP header */607 mutable pjsip_generic_string_hdr pjHdr;608 };609 610 611 /** Array of strings */612 typedef std::vector<SipHeader> SipHeaderVector;613 614 /**615 * This describes each multipart part.616 */617 struct SipMultipartPart618 {619 /**620 * Optional headers to be put in this multipart part.621 */622 SipHeaderVector headers;623 624 /**625 * The MIME type of the body part of this multipart part.626 */627 SipMediaType contentType;628 629 /**630 * The body part of tthis multipart part.631 */632 string body;633 };634 635 /** Array of multipart parts */636 typedef std::vector<SipMultipartPart> SipMultipartPartVector;637 638 /**639 * Additional options when sending outgoing SIP message. This corresponds to640 * pjsua_msg_data structure in PJSIP library.641 */642 struct SipTxOption643 {644 /**645 * Optional remote target URI (i.e. Target header). If NULL, the target646 * will be set to the remote URI (To header). At the moment this field647 * is only used when sending initial INVITE and MESSAGE requests.648 */649 string targetUri;650 651 /**652 * Additional message headers to be included in the outgoing message.653 */654 SipHeaderVector headers;655 656 /**657 * MIME type of the message body, if application specifies the messageBody658 * in this structure.659 */660 string contentType;661 662 /**663 * Optional message body to be added to the message, only when the664 * message doesn't have a body.665 */666 string msgBody;667 668 /**669 * Content type of the multipart body. If application wants to send670 * multipart message bodies, it puts the parts in multipartParts and set671 * the content type in multipartContentType. If the message already672 * contains a body, the body will be added to the multipart bodies.673 */674 SipMediaType multipartContentType;675 676 /**677 * Array of multipart parts. If application wants to send multipart678 * message bodies, it puts the parts in \a parts and set the content679 * type in \a multipart_ctype. If the message already contains a body,680 * the body will be added to the multipart bodies.681 */682 SipMultipartPartVector multipartParts;683 684 };685 686 209 687 210 } // namespace pj -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/account.cpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 201 2Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 27 27 #define THIS_FILE "account.cpp" 28 28 29 /////////////////////////////////////////////////////////////////////////////// 30 31 void AccountRegConfig::readObject(const ContainerNode &node) throw(Error) 32 { 33 ContainerNode this_node = node.readContainer("AccountRegConfig"); 34 35 NODE_READ_STRING (this_node, registrarUri); 36 NODE_READ_BOOL (this_node, registerOnAdd); 37 NODE_READ_UNSIGNED (this_node, timeoutSec); 38 NODE_READ_UNSIGNED (this_node, retryIntervalSec); 39 NODE_READ_UNSIGNED (this_node, firstRetryIntervalSec); 40 NODE_READ_UNSIGNED (this_node, delayBeforeRefreshSec); 41 NODE_READ_BOOL (this_node, dropCallsOnFail); 42 NODE_READ_UNSIGNED (this_node, unregWaitSec); 43 NODE_READ_UNSIGNED (this_node, proxyUse); 44 45 readSipHeaders(this_node, "headers", headers); 46 } 47 48 void AccountRegConfig::writeObject(ContainerNode &node) const throw(Error) 49 { 50 ContainerNode this_node = node.writeNewContainer("AccountRegConfig"); 51 52 NODE_WRITE_STRING (this_node, registrarUri); 53 NODE_WRITE_BOOL (this_node, registerOnAdd); 54 NODE_WRITE_UNSIGNED (this_node, timeoutSec); 55 NODE_WRITE_UNSIGNED (this_node, retryIntervalSec); 56 NODE_WRITE_UNSIGNED (this_node, firstRetryIntervalSec); 57 NODE_WRITE_UNSIGNED (this_node, delayBeforeRefreshSec); 58 NODE_WRITE_BOOL (this_node, dropCallsOnFail); 59 NODE_WRITE_UNSIGNED (this_node, unregWaitSec); 60 NODE_WRITE_UNSIGNED (this_node, proxyUse); 61 62 writeSipHeaders(this_node, "headers", headers); 63 } 64 65 /////////////////////////////////////////////////////////////////////////////// 66 67 void AccountSipConfig::readObject(const ContainerNode &node) throw(Error) 68 { 69 ContainerNode this_node = node.readContainer("AccountSipConfig"); 70 71 NODE_READ_STRINGV (this_node, proxies); 72 NODE_READ_STRING (this_node, contactForced); 73 NODE_READ_STRING (this_node, contactParams); 74 NODE_READ_STRING (this_node, contactUriParams); 75 NODE_READ_BOOL (this_node, authInitialEmpty); 76 NODE_READ_STRING (this_node, authInitialAlgorithm); 77 NODE_READ_INT (this_node, transportId); 78 79 ContainerNode creds_node = this_node.readArray("authCreds"); 80 authCreds.resize(0); 81 while (creds_node.hasUnread()) { 82 AuthCredInfo cred; 83 cred.readObject(creds_node); 84 authCreds.push_back(cred); 85 } 86 } 87 88 void AccountSipConfig::writeObject(ContainerNode &node) const throw(Error) 89 { 90 ContainerNode this_node = node.writeNewContainer("AccountSipConfig"); 91 92 NODE_WRITE_STRINGV (this_node, proxies); 93 NODE_WRITE_STRING (this_node, contactForced); 94 NODE_WRITE_STRING (this_node, contactParams); 95 NODE_WRITE_STRING (this_node, contactUriParams); 96 NODE_WRITE_BOOL (this_node, authInitialEmpty); 97 NODE_WRITE_STRING (this_node, authInitialAlgorithm); 98 NODE_WRITE_INT (this_node, transportId); 99 100 ContainerNode creds_node = this_node.writeNewArray("authCreds"); 101 for (unsigned i=0; i<authCreds.size(); ++i) { 102 authCreds[i].writeObject(creds_node); 103 } 104 } 105 106 /////////////////////////////////////////////////////////////////////////////// 107 108 void AccountCallConfig::readObject(const ContainerNode &node) throw(Error) 109 { 110 ContainerNode this_node = node.readContainer("AccountCallConfig"); 111 112 NODE_READ_NUM_T ( this_node, pjsua_call_hold_type, holdType); 113 NODE_READ_NUM_T ( this_node, pjsua_100rel_use, prackUse); 114 NODE_READ_NUM_T ( this_node, pjsua_sip_timer_use, timerUse); 115 NODE_READ_UNSIGNED( this_node, timerMinSESec); 116 NODE_READ_UNSIGNED( this_node, timerSessExpiresSec); 117 } 118 119 void AccountCallConfig::writeObject(ContainerNode &node) const throw(Error) 120 { 121 ContainerNode this_node = node.writeNewContainer("AccountCallConfig"); 122 123 NODE_WRITE_NUM_T ( this_node, pjsua_call_hold_type, holdType); 124 NODE_WRITE_NUM_T ( this_node, pjsua_100rel_use, prackUse); 125 NODE_WRITE_NUM_T ( this_node, pjsua_sip_timer_use, timerUse); 126 NODE_WRITE_UNSIGNED( this_node, timerMinSESec); 127 NODE_WRITE_UNSIGNED( this_node, timerSessExpiresSec); 128 } 129 130 /////////////////////////////////////////////////////////////////////////////// 131 132 void AccountPresConfig::readObject(const ContainerNode &node) throw(Error) 133 { 134 ContainerNode this_node = node.readContainer("AccountPresConfig"); 135 136 NODE_READ_BOOL ( this_node, publishEnabled); 137 NODE_READ_BOOL ( this_node, publishQueue); 138 NODE_READ_UNSIGNED( this_node, publishShutdownWaitMsec); 139 NODE_READ_STRING ( this_node, pidfTupleId); 140 141 readSipHeaders(this_node, "headers", headers); 142 } 143 144 void AccountPresConfig::writeObject(ContainerNode &node) const throw(Error) 145 { 146 ContainerNode this_node = node.writeNewContainer("AccountPresConfig"); 147 148 NODE_WRITE_BOOL ( this_node, publishEnabled); 149 NODE_WRITE_BOOL ( this_node, publishQueue); 150 NODE_WRITE_UNSIGNED( this_node, publishShutdownWaitMsec); 151 NODE_WRITE_STRING ( this_node, pidfTupleId); 152 153 writeSipHeaders(this_node, "headers", headers); 154 } 155 156 /////////////////////////////////////////////////////////////////////////////// 157 158 void AccountMwiConfig::readObject(const ContainerNode &node) throw(Error) 159 { 160 ContainerNode this_node = node.readContainer("AccountMwiConfig"); 161 162 NODE_READ_BOOL ( this_node, enabled); 163 NODE_READ_UNSIGNED( this_node, expirationSec); 164 } 165 166 void AccountMwiConfig::writeObject(ContainerNode &node) const throw(Error) 167 { 168 ContainerNode this_node = node.writeNewContainer("AccountMwiConfig"); 169 170 NODE_WRITE_BOOL ( this_node, enabled); 171 NODE_WRITE_UNSIGNED( this_node, expirationSec); 172 } 173 174 /////////////////////////////////////////////////////////////////////////////// 175 176 void AccountNatConfig::readObject(const ContainerNode &node) throw(Error) 177 { 178 ContainerNode this_node = node.readContainer("AccountNatConfig"); 179 180 NODE_READ_NUM_T ( this_node, pjsua_stun_use, sipStunUse); 181 NODE_READ_NUM_T ( this_node, pjsua_stun_use, mediaStunUse); 182 NODE_READ_BOOL ( this_node, iceEnabled); 183 NODE_READ_INT ( this_node, iceMaxHostCands); 184 NODE_READ_BOOL ( this_node, iceAggressiveNomination); 185 NODE_READ_UNSIGNED( this_node, iceNominatedCheckDelayMsec); 186 NODE_READ_INT ( this_node, iceWaitNominationTimeoutMsec); 187 NODE_READ_BOOL ( this_node, iceNoRtcp); 188 NODE_READ_BOOL ( this_node, iceAlwaysUpdate); 189 NODE_READ_BOOL ( this_node, turnEnabled); 190 NODE_READ_STRING ( this_node, turnServer); 191 NODE_READ_NUM_T ( this_node, pj_turn_tp_type, turnConnType); 192 NODE_READ_STRING ( this_node, turnUserName); 193 NODE_READ_INT ( this_node, turnPasswordType); 194 NODE_READ_STRING ( this_node, turnPassword); 195 NODE_READ_INT ( this_node, contactRewriteUse); 196 NODE_READ_INT ( this_node, contactRewriteMethod); 197 NODE_READ_INT ( this_node, viaRewriteUse); 198 NODE_READ_INT ( this_node, sdpNatRewriteUse); 199 NODE_READ_INT ( this_node, sipOutboundUse); 200 NODE_READ_STRING ( this_node, sipOutboundInstanceId); 201 NODE_READ_STRING ( this_node, sipOutboundRegId); 202 NODE_READ_UNSIGNED( this_node, udpKaIntervalSec); 203 NODE_READ_STRING ( this_node, udpKaData); 204 } 205 206 void AccountNatConfig::writeObject(ContainerNode &node) const throw(Error) 207 { 208 ContainerNode this_node = node.writeNewContainer("AccountNatConfig"); 209 210 NODE_WRITE_NUM_T ( this_node, pjsua_stun_use, sipStunUse); 211 NODE_WRITE_NUM_T ( this_node, pjsua_stun_use, mediaStunUse); 212 NODE_WRITE_BOOL ( this_node, iceEnabled); 213 NODE_WRITE_INT ( this_node, iceMaxHostCands); 214 NODE_WRITE_BOOL ( this_node, iceAggressiveNomination); 215 NODE_WRITE_UNSIGNED( this_node, iceNominatedCheckDelayMsec); 216 NODE_WRITE_INT ( this_node, iceWaitNominationTimeoutMsec); 217 NODE_WRITE_BOOL ( this_node, iceNoRtcp); 218 NODE_WRITE_BOOL ( this_node, iceAlwaysUpdate); 219 NODE_WRITE_BOOL ( this_node, turnEnabled); 220 NODE_WRITE_STRING ( this_node, turnServer); 221 NODE_WRITE_NUM_T ( this_node, pj_turn_tp_type, turnConnType); 222 NODE_WRITE_STRING ( this_node, turnUserName); 223 NODE_WRITE_INT ( this_node, turnPasswordType); 224 NODE_WRITE_STRING ( this_node, turnPassword); 225 NODE_WRITE_INT ( this_node, contactRewriteUse); 226 NODE_WRITE_INT ( this_node, contactRewriteMethod); 227 NODE_WRITE_INT ( this_node, viaRewriteUse); 228 NODE_WRITE_INT ( this_node, sdpNatRewriteUse); 229 NODE_WRITE_INT ( this_node, sipOutboundUse); 230 NODE_WRITE_STRING ( this_node, sipOutboundInstanceId); 231 NODE_WRITE_STRING ( this_node, sipOutboundRegId); 232 NODE_WRITE_UNSIGNED( this_node, udpKaIntervalSec); 233 NODE_WRITE_STRING ( this_node, udpKaData); 234 } 235 236 /////////////////////////////////////////////////////////////////////////////// 237 238 void AccountMediaConfig::readObject(const ContainerNode &node) throw(Error) 239 { 240 ContainerNode this_node = node.readContainer("AccountMediaConfig"); 241 242 NODE_READ_BOOL ( this_node, lockCodecEnabled); 243 NODE_READ_BOOL ( this_node, streamKaEnabled); 244 NODE_READ_NUM_T ( this_node, pjmedia_srtp_use, srtpUse); 245 NODE_READ_INT ( this_node, srtpSecureSignaling); 246 NODE_READ_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 247 NODE_READ_OBJ ( this_node, transportConfig); 248 } 249 250 void AccountMediaConfig::writeObject(ContainerNode &node) const throw(Error) 251 { 252 ContainerNode this_node = node.writeNewContainer("AccountMediaConfig"); 253 254 NODE_WRITE_BOOL ( this_node, lockCodecEnabled); 255 NODE_WRITE_BOOL ( this_node, streamKaEnabled); 256 NODE_WRITE_NUM_T ( this_node, pjmedia_srtp_use, srtpUse); 257 NODE_WRITE_INT ( this_node, srtpSecureSignaling); 258 NODE_WRITE_NUM_T ( this_node, pjsua_ipv6_use, ipv6Use); 259 NODE_WRITE_OBJ ( this_node, transportConfig); 260 } 261 262 /////////////////////////////////////////////////////////////////////////////// 263 264 void AccountVideoConfig::readObject(const ContainerNode &node) throw(Error) 265 { 266 ContainerNode this_node = node.readContainer("AccountVideoConfig"); 267 268 NODE_READ_BOOL ( this_node, autoShowIncoming); 269 NODE_READ_BOOL ( this_node, autoTransmitOutgoing); 270 NODE_READ_UNSIGNED( this_node, windowFlags); 271 NODE_READ_NUM_T ( this_node, pjmedia_vid_dev_index, defaultCaptureDevice); 272 NODE_READ_NUM_T ( this_node, pjmedia_vid_dev_index, defaultRenderDevice); 273 NODE_READ_NUM_T ( this_node, pjmedia_vid_stream_rc_method, rateControlMethod); 274 NODE_READ_UNSIGNED( this_node, rateControlBandwidth); 275 } 276 277 void AccountVideoConfig::writeObject(ContainerNode &node) const throw(Error) 278 { 279 ContainerNode this_node = node.writeNewContainer("AccountVideoConfig"); 280 281 NODE_WRITE_BOOL ( this_node, autoShowIncoming); 282 NODE_WRITE_BOOL ( this_node, autoTransmitOutgoing); 283 NODE_WRITE_UNSIGNED( this_node, windowFlags); 284 NODE_WRITE_NUM_T ( this_node, pjmedia_vid_dev_index, defaultCaptureDevice); 285 NODE_WRITE_NUM_T ( this_node, pjmedia_vid_dev_index, defaultRenderDevice); 286 NODE_WRITE_NUM_T ( this_node, pjmedia_vid_stream_rc_method, rateControlMethod); 287 NODE_WRITE_UNSIGNED( this_node, rateControlBandwidth); 288 } 29 289 30 290 /////////////////////////////////////////////////////////////////////////////// … … 331 591 } 332 592 593 void AccountConfig::readObject(const ContainerNode &node) throw(Error) 594 { 595 ContainerNode this_node = node.readContainer("AccountConfig"); 596 597 NODE_READ_INT ( this_node, priority); 598 NODE_READ_STRING ( this_node, idUri); 599 NODE_READ_OBJ ( this_node, regConfig); 600 NODE_READ_OBJ ( this_node, sipConfig); 601 NODE_READ_OBJ ( this_node, callConfig); 602 NODE_READ_OBJ ( this_node, presConfig); 603 NODE_READ_OBJ ( this_node, mwiConfig); 604 NODE_READ_OBJ ( this_node, natConfig); 605 NODE_READ_OBJ ( this_node, mediaConfig); 606 NODE_READ_OBJ ( this_node, videoConfig); 607 } 608 609 void AccountConfig::writeObject(ContainerNode &node) const throw(Error) 610 { 611 ContainerNode this_node = node.writeNewContainer("AccountConfig"); 612 613 NODE_WRITE_INT ( this_node, priority); 614 NODE_WRITE_STRING ( this_node, idUri); 615 NODE_WRITE_OBJ ( this_node, regConfig); 616 NODE_WRITE_OBJ ( this_node, sipConfig); 617 NODE_WRITE_OBJ ( this_node, callConfig); 618 NODE_WRITE_OBJ ( this_node, presConfig); 619 NODE_WRITE_OBJ ( this_node, mwiConfig); 620 NODE_WRITE_OBJ ( this_node, natConfig); 621 NODE_WRITE_OBJ ( this_node, mediaConfig); 622 NODE_WRITE_OBJ ( this_node, videoConfig); 623 } 624 625 333 626 /////////////////////////////////////////////////////////////////////////////// 334 627 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 201 2Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 99 99 } 100 100 101 void UaConfig::readObject(const ContainerNode &node) throw(Error) 102 { 103 ContainerNode this_node = node.readContainer("UaConfig"); 104 105 NODE_READ_UNSIGNED( this_node, maxCalls); 106 NODE_READ_UNSIGNED( this_node, threadCnt); 107 NODE_READ_STRINGV ( this_node, nameserver); 108 NODE_READ_STRING ( this_node, userAgent); 109 NODE_READ_STRINGV ( this_node, stunServer); 110 NODE_READ_BOOL ( this_node, stunIgnoreFailure); 111 NODE_READ_INT ( this_node, natTypeInSdp); 112 NODE_READ_BOOL ( this_node, mwiUnsolicitedEnabled); 113 } 114 115 void UaConfig::writeObject(ContainerNode &node) const throw(Error) 116 { 117 ContainerNode this_node = node.writeNewContainer("UaConfig"); 118 119 NODE_WRITE_UNSIGNED( this_node, maxCalls); 120 NODE_WRITE_UNSIGNED( this_node, threadCnt); 121 NODE_WRITE_STRINGV ( this_node, nameserver); 122 NODE_WRITE_STRING ( this_node, userAgent); 123 NODE_WRITE_STRINGV ( this_node, stunServer); 124 NODE_WRITE_BOOL ( this_node, stunIgnoreFailure); 125 NODE_WRITE_INT ( this_node, natTypeInSdp); 126 NODE_WRITE_BOOL ( this_node, mwiUnsolicitedEnabled); 127 } 128 101 129 /////////////////////////////////////////////////////////////////////////////// 102 130 … … 134 162 135 163 return lc; 164 } 165 166 void LogConfig::readObject(const ContainerNode &node) throw(Error) 167 { 168 ContainerNode this_node = node.readContainer("LogConfig"); 169 170 NODE_READ_UNSIGNED( this_node, msgLogging); 171 NODE_READ_UNSIGNED( this_node, level); 172 NODE_READ_UNSIGNED( this_node, consoleLevel); 173 NODE_READ_UNSIGNED( this_node, decor); 174 NODE_READ_STRING ( this_node, filename); 175 NODE_READ_UNSIGNED( this_node, fileFlags); 176 } 177 178 void LogConfig::writeObject(ContainerNode &node) const throw(Error) 179 { 180 ContainerNode this_node = node.writeNewContainer("LogConfig"); 181 182 NODE_WRITE_UNSIGNED( this_node, msgLogging); 183 NODE_WRITE_UNSIGNED( this_node, level); 184 NODE_WRITE_UNSIGNED( this_node, consoleLevel); 185 NODE_WRITE_UNSIGNED( this_node, decor); 186 NODE_WRITE_STRING ( this_node, filename); 187 NODE_WRITE_UNSIGNED( this_node, fileFlags); 136 188 } 137 189 … … 206 258 } 207 259 260 void MediaConfig::readObject(const ContainerNode &node) throw(Error) 261 { 262 ContainerNode this_node = node.readContainer("MediaConfig"); 263 264 NODE_READ_UNSIGNED( this_node, clockRate); 265 NODE_READ_UNSIGNED( this_node, sndClockRate); 266 NODE_READ_UNSIGNED( this_node, channelCount); 267 NODE_READ_UNSIGNED( this_node, audioFramePtime); 268 NODE_READ_UNSIGNED( this_node, maxMediaPorts); 269 NODE_READ_BOOL ( this_node, hasIoqueue); 270 NODE_READ_UNSIGNED( this_node, threadCnt); 271 NODE_READ_UNSIGNED( this_node, quality); 272 NODE_READ_UNSIGNED( this_node, ptime); 273 NODE_READ_BOOL ( this_node, noVad); 274 NODE_READ_UNSIGNED( this_node, ilbcMode); 275 NODE_READ_UNSIGNED( this_node, txDropPct); 276 NODE_READ_UNSIGNED( this_node, rxDropPct); 277 NODE_READ_UNSIGNED( this_node, ecOptions); 278 NODE_READ_UNSIGNED( this_node, ecTailLen); 279 NODE_READ_UNSIGNED( this_node, sndRecLatency); 280 NODE_READ_UNSIGNED( this_node, sndPlayLatency); 281 NODE_READ_INT ( this_node, jbInit); 282 NODE_READ_INT ( this_node, jbMinPre); 283 NODE_READ_INT ( this_node, jbMaxPre); 284 NODE_READ_INT ( this_node, jbMax); 285 NODE_READ_INT ( this_node, sndAutoCloseTime); 286 NODE_READ_BOOL ( this_node, vidPreviewEnableNative); 287 } 288 289 void MediaConfig::writeObject(ContainerNode &node) const throw(Error) 290 { 291 ContainerNode this_node = node.writeNewContainer("MediaConfig"); 292 293 NODE_WRITE_UNSIGNED( this_node, clockRate); 294 NODE_WRITE_UNSIGNED( this_node, sndClockRate); 295 NODE_WRITE_UNSIGNED( this_node, channelCount); 296 NODE_WRITE_UNSIGNED( this_node, audioFramePtime); 297 NODE_WRITE_UNSIGNED( this_node, maxMediaPorts); 298 NODE_WRITE_BOOL ( this_node, hasIoqueue); 299 NODE_WRITE_UNSIGNED( this_node, threadCnt); 300 NODE_WRITE_UNSIGNED( this_node, quality); 301 NODE_WRITE_UNSIGNED( this_node, ptime); 302 NODE_WRITE_BOOL ( this_node, noVad); 303 NODE_WRITE_UNSIGNED( this_node, ilbcMode); 304 NODE_WRITE_UNSIGNED( this_node, txDropPct); 305 NODE_WRITE_UNSIGNED( this_node, rxDropPct); 306 NODE_WRITE_UNSIGNED( this_node, ecOptions); 307 NODE_WRITE_UNSIGNED( this_node, ecTailLen); 308 NODE_WRITE_UNSIGNED( this_node, sndRecLatency); 309 NODE_WRITE_UNSIGNED( this_node, sndPlayLatency); 310 NODE_WRITE_INT ( this_node, jbInit); 311 NODE_WRITE_INT ( this_node, jbMinPre); 312 NODE_WRITE_INT ( this_node, jbMaxPre); 313 NODE_WRITE_INT ( this_node, jbMax); 314 NODE_WRITE_INT ( this_node, sndAutoCloseTime); 315 NODE_WRITE_BOOL ( this_node, vidPreviewEnableNative); 316 } 317 318 /////////////////////////////////////////////////////////////////////////////// 319 320 void EpConfig::readObject(const ContainerNode &node) throw(Error) 321 { 322 ContainerNode this_node = node.readContainer("EpConfig"); 323 NODE_READ_OBJ( this_node, uaConfig); 324 NODE_READ_OBJ( this_node, logConfig); 325 NODE_READ_OBJ( this_node, medConfig); 326 } 327 328 void EpConfig::writeObject(ContainerNode &node) const throw(Error) 329 { 330 ContainerNode this_node = node.writeNewContainer("EpConfig"); 331 NODE_WRITE_OBJ( this_node, uaConfig); 332 NODE_WRITE_OBJ( this_node, logConfig); 333 NODE_WRITE_OBJ( this_node, medConfig); 334 } 208 335 209 336 /////////////////////////////////////////////////////////////////////////////// … … 783 910 784 911 tcfg = cfg.toPj(); 785 PJSUA2_CHECK_EXPR( pjsua_transport_create(type, &tcfg, &tid) ); 912 PJSUA2_CHECK_EXPR( pjsua_transport_create(type, 913 &tcfg, &tid) ); 786 914 787 915 return tid; -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/types.cpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 201 2Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 86 86 } 87 87 88 ///////////////////////////////////////////////////////////////////////////////89 90 AuthCredInfo::AuthCredInfo()91 : dataType(0)92 {93 }94 95 AuthCredInfo::AuthCredInfo(const string ¶m_scheme,96 const string ¶m_realm,97 const string ¶m_user_name,98 const int param_data_type,99 const string param_data)100 : scheme(param_scheme), realm(param_realm), username(param_user_name),101 dataType(param_data_type), data(param_data)102 {103 }104 105 106 ///////////////////////////////////////////////////////////////////////////////107 108 TlsConfig::TlsConfig()109 {110 pjsip_tls_setting ts;111 pjsip_tls_setting_default(&ts);112 this->fromPj(ts);113 }114 115 pjsip_tls_setting TlsConfig::toPj() const116 {117 pjsip_tls_setting ts;118 119 ts.ca_list_file = str2Pj(this->CaListFile);120 ts.cert_file = str2Pj(this->certFile);121 ts.privkey_file = str2Pj(this->privKeyFile);122 ts.password = str2Pj(this->password);123 ts.method = this->method;124 ts.ciphers_num = this->ciphers.size();125 // The following will only work if sizeof(enum)==sizeof(int)126 pj_assert(sizeof(ts.ciphers[0]) == sizeof(int));127 ts.ciphers = (pj_ssl_cipher*)&this->ciphers[0];128 ts.verify_server = this->verifyServer;129 ts.verify_client = this->verifyClient;130 ts.require_client_cert = this->requireClientCert;131 ts.timeout.sec = this->msecTimeout / 1000;132 ts.timeout.msec = this->msecTimeout % 1000;133 ts.qos_type = this->qosType;134 ts.qos_params = this->qosParams;135 ts.qos_ignore_error = this->qosIgnoreError;136 137 return ts;138 }139 140 void TlsConfig::fromPj(const pjsip_tls_setting &prm)141 {142 this->CaListFile = pj2Str(prm.ca_list_file);143 this->certFile = pj2Str(prm.cert_file);144 this->privKeyFile = pj2Str(prm.privkey_file);145 this->password = pj2Str(prm.password);146 this->method = (pjsip_ssl_method)prm.method;147 // The following will only work if sizeof(enum)==sizeof(int)148 pj_assert(sizeof(prm.ciphers[0]) == sizeof(int));149 this->ciphers = IntVector(prm.ciphers, prm.ciphers+prm.ciphers_num);150 this->verifyServer = prm.verify_server;151 this->verifyClient = prm.verify_client;152 this->requireClientCert = prm.require_client_cert;153 this->msecTimeout = PJ_TIME_VAL_MSEC(prm.timeout);154 this->qosType = prm.qos_type;155 this->qosParams = prm.qos_params;156 this->qosIgnoreError = prm.qos_ignore_error;157 }158 159 ///////////////////////////////////////////////////////////////////////////////160 161 TransportConfig::TransportConfig()162 {163 pjsua_transport_config tc;164 pjsua_transport_config_default(&tc);165 this->fromPj(tc);166 }167 168 void TransportConfig::fromPj(const pjsua_transport_config &prm)169 {170 this->port = prm.port;171 this->portRange = prm.port_range;172 this->publicAddress = pj2Str(prm.public_addr);173 this->boundAddress = pj2Str(prm.bound_addr);174 this->tlsConfig.fromPj(prm.tls_setting);175 this->qosType = prm.qos_type;176 this->qosParams = prm.qos_params;177 }178 179 pjsua_transport_config TransportConfig::toPj() const180 {181 pjsua_transport_config tc;182 183 tc.port = this->port;184 tc.port_range = this->portRange;185 tc.public_addr = str2Pj(this->publicAddress);186 tc.bound_addr = str2Pj(this->boundAddress);187 tc.tls_setting = this->tlsConfig.toPj();188 tc.qos_type = this->qosType;189 tc.qos_params = this->qosParams;190 191 return tc;192 }193 194 ///////////////////////////////////////////////////////////////////////////////195 196 TransportInfo::TransportInfo(const pjsua_transport_info &info)197 {198 this->id = info.id;199 this->type = info.type;200 this->typeName = pj2Str(info.type_name);201 this->info = pj2Str(info.info);202 this->flags = info.flag;203 204 char straddr[PJ_INET6_ADDRSTRLEN+10];205 pj_sockaddr_print(&info.local_addr, straddr, sizeof(straddr), 3);206 this->localAddress = straddr;207 208 pj_ansi_snprintf(straddr, sizeof(straddr), "%.*s:%d",209 (int)info.local_name.host.slen,210 info.local_name.host.ptr,211 info.local_name.port);212 this->localName = straddr;213 this->usageCount = info.usage_count;214 }215 216 ///////////////////////////////////////////////////////////////////////////////217 218 void SipRxData::fromPj(pjsip_rx_data &rdata)219 {220 info = pjsip_rx_data_get_info(&rdata);221 wholeMsg = string(rdata.msg_info.msg_buf, rdata.msg_info.len);222 srcIp = rdata.pkt_info.src_name;223 srcPort = rdata.pkt_info.src_port;224 }225 226 ///////////////////////////////////////////////////////////////////////////////227 228 void SipHeader::fromPj(const pjsip_hdr *hdr) throw(Error)229 {230 char buf[256];231 232 int len = pjsip_hdr_print_on((void*)hdr, buf, sizeof(buf)-1);233 if (len <= 0)234 PJSUA2_RAISE_ERROR(PJ_ETOOSMALL);235 buf[len] = '\0';236 237 char *pos = strchr(buf, ':');238 if (!pos)239 PJSUA2_RAISE_ERROR(PJSIP_EINVALIDHDR);240 241 // Trim white space after header name242 char *end_name = pos;243 while (end_name>buf && pj_isspace(*(end_name-1))) --end_name;244 245 // Trim whitespaces after colon246 char *start_val = pos+1;247 while (*start_val && pj_isspace(*start_val)) ++start_val;248 249 hName = string(buf, end_name);250 hValue = string(start_val);251 }252 253 pjsip_generic_string_hdr &SipHeader::toPj() const254 {255 pj_str_t hname = str2Pj(hName);256 pj_str_t hvalue = str2Pj(hValue);257 258 pjsip_generic_string_hdr_init2(&pjHdr, &hname, &hvalue);259 return pjHdr;260 } -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/util.hpp
r4608 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 201 2Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify
Note: See TracChangeset
for help on using the changeset viewer.