eX_call.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. eXosip - This is the eXtended osip library.
  3. Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com
  4. eXosip 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. eXosip is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. In addition, as a special exception, the copyright holders give
  16. permission to link the code of portions of this program with the
  17. OpenSSL library under certain conditions as described in each
  18. individual source file, and distribute linked combinations
  19. including the two.
  20. You must obey the GNU General Public License in all respects
  21. for all of the code used other than OpenSSL. If you modify
  22. file(s) with this exception, you may extend this exception to your
  23. version of the file(s), but you are not obligated to do so. If you
  24. do not wish to do so, delete this exception statement from your
  25. version. If you delete this exception statement from all source
  26. files in the program, then also delete it here.
  27. */
  28. #ifdef ENABLE_MPATROL
  29. #include <mpatrol.h>
  30. #endif
  31. #ifndef __EX_CALL_H__
  32. #define __EX_CALL_H__
  33. #include <osipparser2/osip_parser.h>
  34. #include <osipparser2/sdp_message.h>
  35. #include <time.h>
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /**
  40. * @file eX_call.h
  41. * @brief eXosip call API
  42. *
  43. * This file provide the API needed to control calls. You can
  44. * use it to:
  45. *
  46. * <ul>
  47. * <li>build initial invite.</li>
  48. * <li>send initial invite.</li>
  49. * <li>build request within the call.</li>
  50. * <li>send request within the call.</li>
  51. * </ul>
  52. *
  53. * This API can be used to build the following messages:
  54. * <pre>
  55. * INVITE, INFO, OPTIONS, REFER, UPDATE, NOTIFY
  56. * </pre>
  57. */
  58. /**
  59. * @defgroup eXosip2_call eXosip2 INVITE and Call Management
  60. * @ingroup eXosip2_msg
  61. * @{
  62. */
  63. struct eXosip_call_t;
  64. /**
  65. * Set a new application context for an existing call
  66. *
  67. * @param excontext eXosip_t instance.
  68. * @param id call-id or dialog-id of call
  69. * @param reference New application context.
  70. */
  71. int eXosip_call_set_reference(struct eXosip_t *excontext, int id, void *reference);
  72. /**
  73. * Get the application context pointer for an existing call.
  74. *
  75. * @param excontext eXosip_t instance.
  76. * @param cid id of the call.
  77. * @return Application context reference
  78. */
  79. void *eXosip_call_get_reference(struct eXosip_t *excontext, int cid);
  80. /**
  81. * Build a default INVITE message for a new call.
  82. *
  83. * @param excontext eXosip_t instance.
  84. * @param invite Pointer for the SIP element to hold.
  85. * @param to SIP url for callee.
  86. * @param from SIP url for caller.
  87. * @param route Route header for INVITE. (optional)
  88. * @param subject Subject for the call.
  89. */
  90. int eXosip_call_build_initial_invite(struct eXosip_t *excontext, osip_message_t **invite, const char *to, const char *from, const char *route, const char *subject);
  91. /**
  92. * Initiate a call.
  93. *
  94. * @param excontext eXosip_t instance.
  95. * @param invite SIP INVITE message to send.
  96. */
  97. int eXosip_call_send_initial_invite(struct eXosip_t *excontext, osip_message_t *invite);
  98. /**
  99. * Build a default request within a call. (INVITE, OPTIONS, INFO, REFER)
  100. *
  101. * @param excontext eXosip_t instance.
  102. * @param did dialog id of call.
  103. * @param method request type to build.
  104. * @param request The sip request to build.
  105. */
  106. int eXosip_call_build_request(struct eXosip_t *excontext, int did, const char *method, osip_message_t **request);
  107. /**
  108. * Build a default ACK for a 200ok received.
  109. *
  110. * @param excontext eXosip_t instance.
  111. * @param tid transaction id of INVITE/2xx.
  112. * @param ack The sip request to build.
  113. */
  114. int eXosip_call_build_ack(struct eXosip_t *excontext, int tid, osip_message_t **ack);
  115. /**
  116. * Send the ACK for the 200ok received..
  117. *
  118. * @param excontext eXosip_t instance.
  119. * @param tid transaction id of INVITE/2xx.
  120. * @param ack SIP ACK message to send.
  121. */
  122. int eXosip_call_send_ack(struct eXosip_t *excontext, int tid, osip_message_t *ack);
  123. /**
  124. * Build a default REFER for a call transfer.
  125. *
  126. * @param excontext eXosip_t instance.
  127. * @param did dialog id of call.
  128. * @param refer_to url for call transfer (Refer-To header).
  129. * @param request The sip request to build.
  130. */
  131. int eXosip_call_build_refer(struct eXosip_t *excontext, int did, const char *refer_to, osip_message_t **request);
  132. /**
  133. * Build a default INFO within a call.
  134. *
  135. * @param excontext eXosip_t instance.
  136. * @param did dialog id of call.
  137. * @param request The sip request to build.
  138. */
  139. int eXosip_call_build_info(struct eXosip_t *excontext, int did, osip_message_t **request);
  140. /**
  141. * Build a default OPTIONS within a call.
  142. *
  143. * @param excontext eXosip_t instance.
  144. * @param did dialog id of call.
  145. * @param request The sip request to build.
  146. */
  147. int eXosip_call_build_options(struct eXosip_t *excontext, int did, osip_message_t **request);
  148. /**
  149. * Build a default UPDATE within a call.
  150. *
  151. * @param excontext eXosip_t instance.
  152. * @param did dialog id of call.
  153. * @param request The sip request to build.
  154. */
  155. int eXosip_call_build_update(struct eXosip_t *excontext, int did, osip_message_t **request);
  156. /**
  157. * Build a default NOTIFY within a call.
  158. *
  159. * @param excontext eXosip_t instance.
  160. * @param did dialog id of call.
  161. * @param subscription_status Subscription status of the request.
  162. * @param request The sip request to build.
  163. */
  164. int eXosip_call_build_notify(struct eXosip_t *excontext, int did, int subscription_status, osip_message_t **request);
  165. /**
  166. * send the request within call. (INVITE, OPTIONS, INFO, REFER, UPDATE)
  167. *
  168. * @param excontext eXosip_t instance.
  169. * @param did dialog id of call.
  170. * @param request The sip request to send.
  171. */
  172. int eXosip_call_send_request(struct eXosip_t *excontext, int did, osip_message_t *request);
  173. /**
  174. * Build default Answer for request.
  175. *
  176. * @param excontext eXosip_t instance.
  177. * @param tid id of transaction to answer.
  178. * @param status Status code to use.
  179. * @param answer The sip answer to build.
  180. */
  181. int eXosip_call_build_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t **answer);
  182. /**
  183. * Send Answer for invite.
  184. *
  185. * @param excontext eXosip_t instance.
  186. * @param tid id of transaction to answer.
  187. * @param status response status if answer is NULL. (not allowed for 2XX)
  188. * @param answer The sip answer to send.
  189. */
  190. int eXosip_call_send_answer(struct eXosip_t *excontext, int tid, int status, osip_message_t *answer);
  191. /**
  192. * Terminate a call.
  193. * send CANCEL, BYE or 603 Decline.
  194. *
  195. * @param excontext eXosip_t instance.
  196. * @param cid call id of call.
  197. * @param did dialog id of call.
  198. */
  199. int eXosip_call_terminate(struct eXosip_t *excontext, int cid, int did);
  200. /**
  201. * Terminate a call and add a Reason header.
  202. * send CANCEL, BYE or 603 Decline.
  203. *
  204. * @param excontext eXosip_t instance.
  205. * @param cid call id of call.
  206. * @param did dialog id of call.
  207. * @param reason Reason header.
  208. */
  209. int eXosip_call_terminate_with_reason(struct eXosip_t *excontext, int cid, int did, const char *reason);
  210. /**
  211. * Terminate a call and add a Reason header.
  212. * send CANCEL, BYE or 603 Decline.
  213. *
  214. * @param excontext eXosip_t instance.
  215. * @param cid call id of call.
  216. * @param did dialog id of call.
  217. * @param header_name header name.
  218. * @param header_value header value.
  219. */
  220. int eXosip_call_terminate_with_header(struct eXosip_t *excontext, int cid, int did, const char *header_name, const char *header_value);
  221. /**
  222. * Build a PRACK for invite.
  223. *
  224. * @param excontext eXosip_t instance.
  225. * @param tid id of the invite transaction.
  226. * @param response1xx The sip response for which we build a PRACK.
  227. * @param prack The sip prack to build.
  228. */
  229. int eXosip_call_build_prack(struct eXosip_t *excontext, int tid, osip_message_t *response1xx, osip_message_t **prack);
  230. /**
  231. * Send a PRACK for invite.
  232. *
  233. * @param excontext eXosip_t instance.
  234. * @param tid id of the invite transaction.
  235. * @param prack The sip prack to send.
  236. */
  237. int eXosip_call_send_prack(struct eXosip_t *excontext, int tid, osip_message_t *prack);
  238. /**
  239. * Get Refer-To header with Replace parameter from dialog.
  240. *
  241. * @param excontext eXosip_t instance.
  242. * @param did id of the dialog.
  243. * @param refer_to buffer to be filled with refer-to info.
  244. * @param refer_to_len size of refer_to buffer.
  245. */
  246. int eXosip_call_get_referto(struct eXosip_t *excontext, int did, char *refer_to, size_t refer_to_len);
  247. /**
  248. * Return did (or cid) for the replace header.
  249. *
  250. * @param excontext eXosip_t instance.
  251. * @param replaces buffer to be filled with refer-to info.
  252. */
  253. int eXosip_call_find_by_replaces(struct eXosip_t *excontext, char *replaces);
  254. /** @} */
  255. #ifdef __cplusplus
  256. }
  257. #endif
  258. #endif