Debian Codegraph @

Xpjproject/pjsip/include/pjsua2/siptypes.hpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2032 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #ifndef __PJSUA2_SIPTYPES_HPP__
19 #define __PJSUA2_SIPTYPES_HPP__
20
21 /**
22 * @file pjsua2/types.hpp
23 * @brief PJSUA2 Base Types
24 */
25 #include <pjsua2/types.hpp>
26 #include <pjsua2/persistent.hpp>
27
28 #include <string>
29 #include <vector>
30
31 /** PJSUA2 API is inside pj namespace */
32 namespace pj
33 {
34
35 /**
36 * @defgroup PJSUA2_SIP_Types SIP Types
37 * @ingroup PJSUA2_DS
38 * @{
39 */
40
41 /**
42 * Credential information. Credential contains information to authenticate
43 * against a service.
44 */
45 struct AuthCredInfo : public PersistentObject
46 {
47 /**
48 * The authentication scheme (e.g. "digest").
49 */
50 string scheme;
51
52 /**
53 * Realm on which this credential is to be used. Use "*" to make
54 * a credential that can be used to authenticate against any challenges.
55 */
56 string realm;
57
58 /**
59 * Authentication user name.
60 */
61 string username;
62
63 /**
64 * Type of data that is contained in the "data" field. Use 0 if the data
65 * contains plain text password.
66 */
67 int dataType;
68
69 /**
70 * The data, which can be a plain text password or a hashed digest.
71 */
72 string data;
73
74
75 /**
76 * Digest algorithm type.
77 */
78 pjsip_auth_algorithm_type algoType;
79
80 /*
81 * Digest AKA credential information. Note that when AKA credential
82 * is being used, the \a data field of this pjsip_cred_info is
83 * not used, but it still must be initialized to an empty string.
84 * Please see PJSIP_AUTH_AKA_API for more information.
85 */
86
87 /** Permanent subscriber key. */
88 string akaK;
89
90 /** Operator variant key. */
91 string akaOp;
92
93 /** Authentication Management Field */
94 string akaAmf;
95
96 public:
97 /** Default constructor */
98 AuthCredInfo();
99
100 /** Construct a credential with the specified parameters */
101 AuthCredInfo(const string &scheme,
102 const string &realm,
103 const string &user_name,
104 const int data_type,
105 const string data);
106
107 /**
108 * Convert from pjsip
109 */
110 void fromPj(const pjsip_cred_info &prm);
111
112 /**
113 * Convert to pjsip
114 */
115 pjsip_cred_info toPj() const;
116
117 /**
118 * Read this object from a container node.
119 *
120 * @param node Container to read values from.
121 */
122 virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
123
124 /**
125 * Write this object to a container node.
126 *
127 * @param node Container to write values to.
128 */
129 virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
130 };
131
132
133 //////////////////////////////////////////////////////////////////////////////
134
135 /**
136 * Socket option type.
137 */
138 struct SockOpt {
139 /**
140 * The level at which the option is defined.
141 */
142 int level;
143
144 /**
145 * Option name.
146 */
147 int optName;
148
149 public:
150 /** Default constructor. */
151 SockOpt();
152
153 /** Construct a socket option with the specified parameters. */
154 SockOpt(int level, int optName, int optVal);
155
156 /**
157 * Set option value of type integer.
158 *
159 * @param opt_val Option value.
160 */
161 void setOptValInt(int opt_val);
162
163 private:
164 friend struct SockOptParams;
165
166 /** Pointer to the buffer in which the option is specified. */
167 void *optVal;
168
169 /** Buffer size of the buffer pointed by optVal. */
170 int optLen;
171
172 /** Option value if the type is integer. */
173 int optValInt;
174 };
175
176 /** Array of socket options */
177 typedef std::vector<SockOpt> SockOptVector;
178
179 /**
180 * Socket option parameters, to be specified in TransportConfig.
181 */
182 struct SockOptParams : public PersistentObject
183 {
184 /**
185 * Array of socket options.
186 */
187 SockOptVector sockOpts;
188
189 public:
190 /** Default constructor initialises with default values */
191 SockOptParams();
192
193 /** Convert to pjsip */
194 pj_sockopt_params toPj() const;
195
196 /** Convert from pjsip */
197 void fromPj(const pj_sockopt_params &prm);
198
199 /**
200 * Read this object from a container node.
201 *
202 * @param node Container to read values from.
203 */
204 virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
205
206 /**
207 * Write this object to a container node.
208 *
209 * @param node Container to write values to.
210 */
211 virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
212 };
213
214
215 /**
216 * TLS transport settings, to be specified in TransportConfig.
217 */
218 struct TlsConfig : public PersistentObject
219 {
220 /**
221 * Certificate of Authority (CA) list file.
222 */
223 string CaListFile;
224
225 /**
226 * Public endpoint certificate file, which will be used as client-
227 * side certificate for outgoing TLS connection, and server-side
228 * certificate for incoming TLS connection.
229 */
230 string certFile;
231
232 /**
233 * Optional private key of the endpoint certificate to be used.
234 */
235 string privKeyFile;
236
237 /**
238 * Password to open private key.
239 */
240 string password;
241
242 /**
243 * Certificate of Authority (CA) buffer. If CaListFile, certFile or
244 * privKeyFile are set, this setting will be ignored.
245 */
246 string CaBuf;
247
248 /**
249 * Public endpoint certificate buffer, which will be used as client-
250 * side certificate for outgoing TLS connection, and server-side
251 * certificate for incoming TLS connection. If CaListFile, certFile or
252 * privKeyFile are set, this setting will be ignored.
253 */
254 string certBuf;
255
256 /**
257 * Optional private key buffer of the endpoint certificate to be used.
258 * If CaListFile, certFile or privKeyFile are set, this setting will
259 * be ignored.
260 */
261 string privKeyBuf;
262
263 /**
264 * Lookup certificate from OS certificate store, this setting will
265 * specify the field type to lookup.
266 *
267 * Currently only used by Windows Schannel backend, see also
268 * \a pj_ssl_cert_load_from_store() for more info.
269 */
270 pj_ssl_cert_lookup_type certLookupType;
271
272 /**
273 * Lookup certificate from OS certificate store, this setting will
274 * specify the keyword to match on the field specified in
275 * \a certLookupType above.
276 *
277 * Currently only used by Windows Schannel backend, see also
278 * \a pj_ssl_cert_load_from_store() for more info.
279 */
280 string certLookupKeyword;
281
282 /**
283 * When using backend specific credentials objects, specify the backend
284 * object types using this bit flag, see also \ref pj_ssl_cert_direct_type.
285 */
286 unsigned credDirectType;
287
288 /**
289 * Optional backend specific private key. See also
290 * \a pj_ssl_cert_load_direct().
291 *
292 * Currently only the OpenSSL backend is supported. This setting
293 * corresponds to an OpenSSL EVP_PKEY instance. When this is set,
294 * specify PJ_SSL_CERT_DIRECT_OPENSSL_EVP_PKEY flag in \a certDirectType.
295 */
296 Token privKeyDirect;
297
298 /**
299 * Optional backend specific certificate. See also
300 * \a pj_ssl_cert_load_direct().
301 *
302 * Currently only the OpenSSL backend is supported, this setting
303 * corresponds to an OpenSSL X509 instance. When this is set,
304 * specify PJ_SSL_CERT_DIRECT_OPENSSL_X509_CERT flag in \a certDirectType.
305 */
306 Token certDirect;
307
308 /**
309 * TLS protocol method from #pjsip_ssl_method. In the future, this field
310 * might be deprecated in favor of <b>proto</b> field. For now, this field
311 * is only applicable only when <b>proto</b> field is set to zero.
312 *
313 * Default is PJSIP_SSL_UNSPECIFIED_METHOD (0), which in turn will
314 * use PJSIP_SSL_DEFAULT_METHOD, which default value is PJSIP_TLSV1_METHOD.
315 */
316 pjsip_ssl_method method;
317
318 /**
319 * TLS protocol type from #pj_ssl_sock_proto. Use this field to enable
320 * specific protocol type. Use bitwise OR operation to combine the protocol
321 * type.
322 *
323 * Default is PJSIP_SSL_DEFAULT_PROTO.
324 */
325 unsigned proto;
326
327 /**
328 * Ciphers and order preference. The Endpoint::utilSslGetAvailableCiphers()
329 * can be used to check the available ciphers supported by backend.
330 * If the array is empty, then default cipher list of the backend
331 * will be used.
332 */
333 IntVector ciphers;
334
335 /**
336 * Specifies TLS transport behavior on the server TLS certificate
337 * verification result:
338 * - If \a verifyServer is disabled, TLS transport will just notify
339 * the application via pjsip_tp_state_callback with state
340 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.
341 * - If \a verifyServer is enabled, TLS transport will be shutdown
342 * and application will be notified with state
343 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification
344 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.
345 *
346 * In any cases, application can inspect pjsip_tls_state_info in the
347 * callback to see the verification detail.
348 *
349 * Default value is false.
350 */
351 bool verifyServer;
352
353 /**
354 * Specifies TLS transport behavior on the client TLS certificate
355 * verification result:
356 * - If \a verifyClient is disabled, TLS transport will just notify
357 * the application via pjsip_tp_state_callback with state
358 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.
359 * - If \a verifyClient is enabled, TLS transport will be shutdown
360 * and application will be notified with state
361 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification
362 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.
363 *
364 * In any cases, application can inspect pjsip_tls_state_info in the
365 * callback to see the verification detail.
366 *
367 * Default value is PJ_FALSE.
368 */
369 bool verifyClient;
370
371 /**
372 * When acting as server (incoming TLS connections), reject incoming
373 * connection if client doesn't supply a TLS certificate.
374 *
375 * This setting corresponds to SSL_VERIFY_FAIL_IF_NO_PEER_CERT flag.
376 * Default value is PJ_FALSE.
377 */
378 bool requireClientCert;
379
380 /**
381 * TLS negotiation timeout to be applied for both outgoing and incoming
382 * connection, in milliseconds. If zero, the SSL negotiation doesn't
383 * have a timeout.
384 *
385 * Default: zero
386 */
387 unsigned msecTimeout;
388
389 /**
390 * QoS traffic type to be set on this transport. When application wants
391 * to apply QoS tagging to the transport, it's preferable to set this
392 * field rather than \a qosParam fields since this is more portable.
393 *
394 * Default value is PJ_QOS_TYPE_BEST_EFFORT.
395 */
396 pj_qos_type qosType;
397
398 /**
399 * Set the low level QoS parameters to the transport. This is a lower
400 * level operation than setting the \a qosType field and may not be
401 * supported on all platforms.
402 *
403 * By default all settings in this structure are disabled.
404 */
405 pj_qos_params qosParams;
406
407 /**
408 * Specify if the transport should ignore any errors when setting the QoS
409 * traffic type/parameters.
410 *
411 * Default: PJ_TRUE
412 */
413 bool qosIgnoreError;
414
415 /**
416 * Specify options to be set on the transport.
417 *
418 * By default, this is unset, which means that the underlying sockopt
419 * params as returned by #pj_ssl_sock_param_default() will be used.
420 */
421 SockOptParams sockOptParams;
422
423 /**
424 * Specify if the transport should ignore any errors when setting the
425 * sockopt parameters.
426 *
427 * Default: true
428 */
429 bool sockOptIgnoreError;
430
431 /**
432 * Specify if renegotiation is enabled for TLSv1.2 or earlier.
433 *
434 * Default: PJ_TRUE
435 */
436 bool enableRenegotiation;
437
438 public:
439 /** Default constructor initialises with default values */
440 TlsConfig();
441
442 /** Convert to pjsip */
443 pjsip_tls_setting toPj() const;
444
445 /** Convert from pjsip */
446 void fromPj(const pjsip_tls_setting &prm);
447
448 /**
449 * Read this object from a container node.
450 *
451 * @param node Container to read values from.
452 */
453 virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
454
455 /**
456 * Write this object to a container node.
457 *
458 * @param node Container to write values to.
459 */
460 virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
461 };
462
463
464 /**
465 * Parameters to create a transport instance.
466 */
467 struct TransportConfig : public PersistentObject
468 {
469 /**
470 * UDP port number to bind locally. This setting MUST be specified
471 * even when default port is desired. If the value is zero, the
472 * transport will be bound to any available port, and application
473 * can query the port by querying the transport info.
474 */
475 unsigned port;
476
477 /**
478 * Specify the port range for socket binding, relative to the start
479 * port number specified in \a port. Note that this setting is only
480 * applicable for media transport when the start port number is non zero.
481 * Media transport is configurable via account setting,
482 * i.e: AccountMediaConfig::transportConfig, please check the media
483 * transport config docs for more info.
484 *
485 * Available ports are in the range of [\a port, \a port + \a portRange].
486 *
487 * Default value is zero.
488 */
489 unsigned portRange;
490
491 /**
492 * Specify whether to randomly pick the starting port number from
493 * the range of [\a port, \a port + \a port_range]. This setting is
494 * used only if both port and port_range are non-zero, and only
495 * applicable for the port selection of UDP and loop media transport.
496 *
497 * Default is PJ_FALSE.
498 */
499 bool randomizePort;
500
501 /**
502 * Optional address to advertise as the address of this transport.
503 * Application can specify any address or hostname for this field,
504 * for example it can point to one of the interface address in the
505 * system, or it can point to the public address of a NAT router
506 * where port mappings have been configured for the application.
507 *
508 * Note: this option can be used for both UDP and TCP as well!
509 */
510 string publicAddress;
511
512 /**
513 * Optional address where the socket should be bound to. This option
514 * SHOULD only be used to selectively bind the socket to particular
515 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the
516 * published address of a transport (the public_addr field should be
517 * used for that purpose).
518 *
519 * Note that unlike public_addr field, the address (or hostname) here
520 * MUST correspond to the actual interface address in the host, since
521 * this address will be specified as bind() argument.
522 */
523 string boundAddress;
524
525 /**
526 * This specifies TLS settings for TLS transport.
527 * It's only used when creating a SIP TLS transport.
528 */
529 TlsConfig tlsConfig;
530
531 /**
532 * QoS traffic type to be set on this transport. When application wants
533 * to apply QoS tagging to the transport, it's preferable to set this
534 * field rather than \a qosParam fields since this is more portable.
535 *
536 * For TLS transport, this field will be ignored, the QoS traffic type
537 * can be set via tlsConfig.
538 *
539 * Default is QoS not set.
540 */
541 pj_qos_type qosType;
542
543 /**
544 * Set the low level QoS parameters to the transport. This is a lower
545 * level operation than setting the \a qosType field and may not be
546 * supported on all platforms.
547 *
548 * For TLS transport, this field will be ignored, the low level QoS
549 * parameters can be set via tlsConfig.
550 *
551 * Default is QoS not set.
552 */
553 pj_qos_params qosParams;
554
555 /**
556 * Set the low level socket options to the transport.
557 *
558 * For TLS transport, this field will be ignored, the socket options
559 * can be set via tlsConfig.
560 *
561 * Default is no socket option set.
562 */
563 SockOptParams sockOptParams;
564
565 public:
566 /** Default constructor initialises with default values */
567 TransportConfig();
568
569 /** Convert from pjsip */
570 void fromPj(const pjsua_transport_config &prm);
571
572 /** Convert to pjsip */
573 pjsua_transport_config toPj() const;
574
575 /**
576 * Read this object from a container node.
577 *
578 * @param node Container to read values from.
579 */
580 virtual void readObject(const ContainerNode &node) PJSUA2_THROW(Error);
581
582 /**
583 * Write this object to a container node.
584 *
585 * @param node Container to write values to.
586 */
587 virtual void writeObject(ContainerNode &node) const PJSUA2_THROW(Error);
588 };
589
590 /**
591 * This structure describes transport information returned by
592 * Endpoint::transportGetInfo() function.
593 */
594 struct TransportInfo
595 {
596 /** PJSUA transport identification. */
597 TransportId id;
598
599 /** Transport type. */
600 pjsip_transport_type_e type;
601
602 /** Transport type name. */
603 string typeName;
604
605 /** Transport string info/description. */
606 string info;
607
608 /** Transport flags (see pjsip_transport_flags_e). */
609 unsigned flags;
610
611 /** Local/bound address. */
612 SocketAddress localAddress;
613
614 /** Published address (or transport address name). */
615 SocketAddress localName;
616
617 /** Current number of objects currently referencing this transport. */
618 unsigned usageCount;
619
620 public:
621 /**
622 * Default constructor.
623 */
624 TransportInfo();
625
626 /** Construct from pjsua_transport_info */
627 void fromPj(const pjsua_transport_info &info);
628 };
629
630 //////////////////////////////////////////////////////////////////////////////
631
632 /**
633 * This structure describes an incoming SIP message. It corresponds to the
634 * pjsip_rx_data structure in PJSIP library.
635 */
636 struct SipRxData
637 {
638 /**
639 * A short info string describing the request, which normally contains
640 * the request method and its CSeq.
641 */
642 string info;
643
644 /**
645 * The whole message data as a string, containing both the header section
646 * and message body section.
647 */
648 string wholeMsg;
649
650 /**
651 * Source address of the message.
652 */
653 SocketAddress srcAddress;
654
655 /**
656 * Pointer to original pjsip_rx_data. Only valid when the struct
657 * is constructed from PJSIP's pjsip_rx_data.
658 */
659 void *pjRxData;
660
661 public:
662 /**
663 * Default constructor.
664 */
665 SipRxData();
666
667 /**
668 * Construct from PJSIP's pjsip_rx_data
669 */
670 void fromPj(pjsip_rx_data &rdata);
671 };
672
673 /**
674 * This structure describes an outgoing SIP message. It corresponds to the
675 * pjsip_tx_data structure in PJSIP library.
676 */
677 struct SipTxData
678 {
679 /**
680 * A short info string describing the request, which normally contains
681 * the request method and its CSeq.
682 */
683 string info;
684
685 /**
686 * The whole message data as a string, containing both the header section
687 * and message body section.
688 */
689 string wholeMsg;
690
691 /**
692 * Destination address of the message.
693 */
694 SocketAddress dstAddress;
695
696 /**
697 * Pointer to original pjsip_tx_data. Only valid when the struct
698 * is constructed from PJSIP's pjsip_tx_data.
699 */
700 void *pjTxData;
701
702 public:
703 /**
704 * Default constructor.
705 */
706 SipTxData();
707
708 /**
709 * Construct from PJSIP's pjsip_tx_data
710 */
711 void fromPj(pjsip_tx_data &tdata);
712 };
713
714 /**
715 * This structure describes SIP transaction object. It corresponds to the
716 * pjsip_transaction structure in PJSIP library.
717 */
718 struct SipTransaction
719 {
720 /* Transaction identification. */
721 pjsip_role_e role; /**< Role (UAS or UAC) */
722 string method; /**< The method. */
723
724 /* State and status. */
725 int statusCode; /**< Last status code seen. */
726 string statusText; /**< Last reason phrase. */
727 pjsip_tsx_state_e state; /**< State. */
728
729 /* Messages and timer. */
730 SipTxData lastTx; /**< Msg kept for retrans. */
731
732 /* Original pjsip_transaction. */
733 void *pjTransaction; /**< pjsip_transaction. */
734
735 public:
736 /**
737 * Default constructor.
738 */
739 SipTransaction();
740
741 /**
742 * Construct from PJSIP's pjsip_transaction
743 */
744 void fromPj(pjsip_transaction &tsx);
745 };
746
747 /**
748 * This structure describes timer event.
749 */
750 struct TimerEvent
751 {
752 TimerEntry entry; /**< The timer entry. */
753 };
754
755 /**
756 * This structure describes transaction state event source.
757 */
758 struct TsxStateEventSrc
759 {
760 SipRxData rdata; /**< The incoming message. */
761 SipTxData tdata; /**< The outgoing message. */
762 TimerEntry timer; /**< The timer. */
763 pj_status_t status; /**< Transport error status. */
764 GenericData data; /**< Generic data. */
765
766 TsxStateEventSrc()
767 : timer(NULL), status(PJ_SUCCESS), data(NULL)
768 {}
769 };
770
771 /**
772 * This structure describes transaction state changed event.
773 */
774 struct TsxStateEvent
775 {
776 TsxStateEventSrc src; /**< Event source. */
777 SipTransaction tsx; /**< The transaction. */
778 pjsip_tsx_state_e prevState; /**< Previous state. */
779 pjsip_event_id_e type; /**< Type of event source:
780 * - PJSIP_EVENT_TX_MSG
781 * - PJSIP_EVENT_RX_MSG,
782 * - PJSIP_EVENT_TRANSPORT_ERROR
783 * - PJSIP_EVENT_TIMER
784 * - PJSIP_EVENT_USER
785 */
786
787 TsxStateEvent();
788 };
789
790 /**
791 * This structure describes message transmission event.
792 */
793 struct TxMsgEvent
794 {
795 SipTxData tdata; /**< The transmit data buffer. */
796 };
797
798 /**
799 * This structure describes transmission error event.
800 */
801 struct TxErrorEvent
802 {
803 SipTxData tdata; /**< The transmit data. */
804 SipTransaction tsx; /**< The transaction. */
805 };
806
807 /**
808 * This structure describes message arrival event.
809 */
810 struct RxMsgEvent
811 {
812 SipRxData rdata; /**< The receive data buffer. */
813 };
814
815 /**
816 * This structure describes user event.
817 */
818 struct UserEvent
819 {
820 GenericData user1; /**< User data 1. */
821 GenericData user2; /**< User data 2. */
822 GenericData user3; /**< User data 3. */
823 GenericData user4; /**< User data 4. */
824 };
825
826 /**
827 * The event body.
828 */
829 struct SipEventBody
830 {
831 /**
832 * Timer event.
833 */
834 TimerEvent timer;
835
836 /**
837 * Transaction state has changed event.
838 */
839 TsxStateEvent tsxState;
840
841 /**
842 * Message transmission event.
843 */
844 TxMsgEvent txMsg;
845
846 /**
847 * Transmission error event.
848 */
849 TxErrorEvent txError;
850
851 /**
852 * Message arrival event.
853 */
854 RxMsgEvent rxMsg;
855
856 /**
857 * User event.
858 */
859 UserEvent user;
860
861 };
862
863 /**
864 * This structure describe event descriptor to fully identify a SIP event. It
865 * corresponds to the pjsip_event structure in PJSIP library.
866 */
867 struct SipEvent
868 {
869 /**
870 * The event type, can be any value of \b pjsip_event_id_e.
871 */
872 pjsip_event_id_e type;
873
874 /**
875 * The event body, which fields depends on the event type.
876 */
877 SipEventBody body;
878
879 /**
880 * Pointer to its original pjsip_event. Only valid when the struct is
881 * constructed from PJSIP's pjsip_event.
882 */
883 void *pjEvent;
884
885 public:
886 /**
887 * Default constructor.
888 */
889 SipEvent();
890
891 /**
892 * Construct from PJSIP's pjsip_event
893 */
894 void fromPj(const pjsip_event &ev);
895 };
896
897 //////////////////////////////////////////////////////////////////////////////
898
899 /**
900 * SIP media type containing type and subtype. For example, for
901 * "application/sdp", the type is "application" and the subtype is "sdp".
902 */
903 struct SipMediaType
904 {
905 /** Media type. */
906 string type;
907
908 /** Media subtype. */
909 string subType;
910
911 public:
912 /**
913 * Construct from PJSIP's pjsip_media_type
914 */
915 void fromPj(const pjsip_media_type &prm);
916
917 /**
918 * Convert to PJSIP's pjsip_media_type.
919 */
920 pjsip_media_type toPj() const;
921 };
922
923 /**
924 * Simple SIP header.
925 */
926 struct SipHeader
927 {
928 /**
929 * Header name.
930 */
931 string hName;
932
933 /**
934 * Header value.
935 */
936 string hValue;
937
938 public:
939 /**
940 * Default constructor.
941 */
942 SipHeader();
943
944 /**
945 * Initiaize from PJSIP header.
946 */
947 void fromPj(const pjsip_hdr *) PJSUA2_THROW(Error);
948
949 /**
950 * Convert to PJSIP header.
951 */
952 pjsip_generic_string_hdr &toPj() const;
953
954 private:
955 /** Interal buffer for conversion to PJSIP header */
956 mutable pjsip_generic_string_hdr pjHdr;
957 };
958
959
960 /** Array of strings */
961 typedef std::vector<SipHeader> SipHeaderVector;
962
963 /**
964 * This describes each multipart part.
965 */
966 struct SipMultipartPart
967 {
968 /**
969 * Optional headers to be put in this multipart part.
970 */
971 SipHeaderVector headers;
972
973 /**
974 * The MIME type of the body part of this multipart part.
975 */
976 SipMediaType contentType;
977
978 /**
979 * The body part of tthis multipart part.
980 */
981 string body;
982
983 public:
984 SipMultipartPart();
985
986 /**
987 * Initiaize from PJSIP's pjsip_multipart_part.
988 */
989 void fromPj(const pjsip_multipart_part &prm) PJSUA2_THROW(Error);
990
991 /**
992 * Convert to PJSIP's pjsip_multipart_part.
993 */
994 pjsip_multipart_part& toPj() const;
995
996 private:
997 /** Interal buffer for conversion to PJSIP pjsip_multipart_part */
998 mutable pjsip_multipart_part pjMpp;
999 mutable pjsip_msg_body pjMsgBody;
1000 };
1001
1002 /** Array of multipart parts */
1003 typedef std::vector<SipMultipartPart> SipMultipartPartVector;
1004
1005 /**
1006 * Additional options when sending outgoing SIP message. This corresponds to
1007 * pjsua_msg_data structure in PJSIP library.
1008 */
1009 struct SipTxOption
1010 {
1011 /**
1012 * Optional remote target URI (i.e. Target header). If empty (""), the
1013 * target will be set to the remote URI (To header). At the moment this
1014 * field is only used when sending initial INVITE and MESSAGE requests.
1015 */
1016 string targetUri;
1017
1018 /**
1019 * Optional local URI (i.e. From header). If empty (""), the
1020 * \a AccountConfig::idUri is used for the From header. At the moment this
1021 * field is only used when sending initial INVITE and MESSAGE requests.
1022 */
1023 string localUri;
1024
1025 /**
1026 * Optional contact URI to be used for this call. If empty (""), the
1027 * contact will be generated automatically based on the account
1028 * configuration. At the moment this field is only used when sending
1029 * initial INVITE requests.
1030 */
1031 string contactUri;
1032
1033 /**
1034 * Additional message headers to be included in the outgoing message.
1035 *
1036 * Application may override Max-Forwards header value (the default is
1037 * #PJSIP_MAX_FORWARDS_VALUE) by adding a Max-Forwards header here.
1038 */
1039 SipHeaderVector headers;
1040
1041 /**
1042 * MIME type of the message body, if application specifies the messageBody
1043 * in this structure.
1044 */
1045 string contentType;
1046
1047 /**
1048 * Optional message body to be added to the message, only when the
1049 * message doesn't have a body.
1050 */
1051 string msgBody;
1052
1053 /**
1054 * Content type of the multipart body. If application wants to send
1055 * multipart message bodies, it puts the parts in multipartParts and set
1056 * the content type in multipartContentType. If the message already
1057 * contains a body, the body will be added to the multipart bodies.
1058 */
1059 SipMediaType multipartContentType;
1060
1061 /**
1062 * Array of multipart parts. If application wants to send multipart
1063 * message bodies, it puts the parts in \a parts and set the content
1064 * type in \a multipart_ctype. If the message already contains a body,
1065 * the body will be added to the multipart bodies.
1066 */
1067 SipMultipartPartVector multipartParts;
1068
1069 public:
1070 /**
1071 * Check if the options are empty. If the options are set with empty
1072 * values, there will be no additional information sent with outgoing
1073 * SIP message.
1074 *
1075 * @return True if the options are empty.
1076 */
1077 bool isEmpty() const;
1078
1079 /**
1080 * Initiaize from PJSUA's pjsua_msg_data.
1081 */
1082 void fromPj(const pjsua_msg_data &prm) PJSUA2_THROW(Error);
1083
1084 /**
1085 * Convert to PJSUA's pjsua_msg_data.
1086 */
1087 void toPj(pjsua_msg_data &msg_data) const;
1088 };
1089
1090 //////////////////////////////////////////////////////////////////////////////
1091
1092 /**
1093 * This structure contains parameters for sending instance message methods,
1094 * e.g: Buddy::sendInstantMessage(), Call:sendInstantMessage().
1095 */
1096 struct SendInstantMessageParam
1097 {
1098 /**
1099 * MIME type. Default is "text/plain".
1100 */
1101 string contentType;
1102
1103 /**
1104 * The message content.
1105 */
1106 string content;
1107
1108 /**
1109 * List of headers etc to be included in outgoing request.
1110 */
1111 SipTxOption txOption;
1112
1113 /**
1114 * User data, which will be given back when the IM callback is called.
1115 */
1116 Token userData;
1117
1118 public:
1119 /**
1120 * Default constructor initializes with zero/empty values.
1121 */
1122 SendInstantMessageParam();
1123 };
1124
1125
1126 /**
1127 * This structure contains parameters for sending typing indication methods,
1128 * e.g: Buddy::sendTypingIndication(), Call:sendTypingIndication().
1129 */
1130 struct SendTypingIndicationParam
1131 {
1132 /**
1133 * True to indicate to remote that local person is currently typing an IM.
1134 */
1135 bool isTyping;
1136
1137 /**
1138 * List of headers etc to be included in outgoing request.
1139 */
1140 SipTxOption txOption;
1141
1142 public:
1143 /**
1144 * Default constructor initializes with zero/empty values.
1145 */
1146 SendTypingIndicationParam();
1147 };
1148
1149
1150 /* Utilities */
1151 #ifndef SWIG
1152 //! @cond Doxygen_Suppress
1153 void readIntVector( ContainerNode &node,
1154 const string &array_name,
1155 IntVector &v) PJSUA2_THROW(Error);
1156 void writeIntVector(ContainerNode &node,
1157 const string &array_name,
1158 const IntVector &v) PJSUA2_THROW(Error);
1159 void readQosParams( ContainerNode &node,
1160 pj_qos_params &qos) PJSUA2_THROW(Error);
1161 void writeQosParams( ContainerNode &node,
1162 const pj_qos_params &qos) PJSUA2_THROW(Error);
1163 void readSipHeaders( const ContainerNode &node,
1164 const string &array_name,
1165 SipHeaderVector &headers) PJSUA2_THROW(Error);
1166 void writeSipHeaders(ContainerNode &node,
1167 const string &array_name,
1168 const SipHeaderVector &headers) PJSUA2_THROW(Error);
1169 //! @endcond
1170 #endif // SWIG
1171
1172 /**
1173 * @} PJSUA2
1174 */
1175
1176 } // namespace pj
1177
1178
1179
1180 #endif /* __PJSUA2_SIPTYPES_HPP__ */