OPAL  Version 3.12.9
opal.h
Go to the documentation of this file.
1 /*
2  * opal.h
3  *
4  * "C" language interface for OPAL
5  *
6  * Open Phone Abstraction Library (OPAL)
7  *
8  * Copyright (c) 2008 Vox Lucida
9  *
10  * The contents of this file are subject to the Mozilla Public License
11  * Version 1.0 (the "License"); you may not use this file except in
12  * compliance with the License. You may obtain a copy of the License at
13  * http://www.mozilla.org/MPL/
14  *
15  * Software distributed under the License is distributed on an "AS IS"
16  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17  * the License for the specific language governing rights and limitations
18  * under the License.
19  *
20  * The Original Code is Open Phone Abstraction Library.
21  *
22  * The Initial Developer of the Original Code is Vox Lucida (Robert Jongbloed)
23  *
24  * This code was initially written with the assisance of funding from
25  * Stonevoice. http://www.stonevoice.com.
26  *
27  * Contributor(s): ______________________________________.
28  *
29  * $Revision: 29938 $
30  * $Author: rjongbloed $
31  * $Date: 2013-06-13 12:19:41 +1000 (Thu, 13 Jun 2013) $
32  */
33 
34 #ifndef OPAL_OPAL_H
35 #define OPAL_OPAL_H
36 
37 #include <stdlib.h>
38 
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
70 #ifdef _WIN32
71  #define OPAL_EXPORT __stdcall
72 #else
73  #define OPAL_EXPORT
74 #endif
75 
77 typedef struct OpalHandleStruct * OpalHandle;
78 
79 
80 typedef struct OpalMessage OpalMessage;
81 
83 #define OPAL_C_API_VERSION 29
84 
85 
87 
138 OpalHandle OPAL_EXPORT OpalInitialise(unsigned * version, const char * options);
139 
143 #define OPAL_INITIALISE_FUNCTION "OpalInitialise"
144 
148 typedef OpalHandle (OPAL_EXPORT *OpalInitialiseFunction)(unsigned * version, const char * options);
149 
150 
152 
161 void OPAL_EXPORT OpalShutDown(OpalHandle opal);
162 
166 #define OPAL_SHUTDOWN_FUNCTION "OpalShutDown"
167 
171 typedef void (OPAL_EXPORT *OpalShutDownFunction)(OpalHandle opal);
172 
173 
175 
212 OpalMessage * OPAL_EXPORT OpalGetMessage(OpalHandle opal, unsigned timeout);
213 
217 #define OPAL_GET_MESSAGE_FUNCTION "OpalGetMessage"
218 
222 typedef OpalMessage * (OPAL_EXPORT *OpalGetMessageFunction)(OpalHandle opal, unsigned timeout);
223 
224 
226 
267 OpalMessage * OPAL_EXPORT OpalSendMessage(OpalHandle opal, const OpalMessage * message);
268 
272 typedef OpalMessage * (OPAL_EXPORT *OpalSendMessageFunction)(OpalHandle opal, const OpalMessage * message);
273 
277 #define OPAL_SEND_MESSAGE_FUNCTION "OpalSendMessage"
278 
279 
281 
285 void OPAL_EXPORT OpalFreeMessage(OpalMessage * message);
286 
290 #define OPAL_FREE_MESSAGE_FUNCTION "OpalFreeMessage"
291 
296 
297 
299 
300 #define OPAL_PREFIX_H323 "h323"
301 #define OPAL_PREFIX_SIP "sip"
302 #define OPAL_PREFIX_IAX2 "iax2"
303 #define OPAL_PREFIX_PCSS "pc"
304 #define OPAL_PREFIX_LOCAL "local"
305 #define OPAL_PREFIX_POTS "pots"
306 #define OPAL_PREFIX_PSTN "pstn"
307 #define OPAL_PREFIX_FAX "fax"
308 #define OPAL_PREFIX_T38 "t38"
309 #define OPAL_PREFIX_IVR "ivr"
310 #define OPAL_PREFIX_IM "im"
311 
312 #define OPAL_PREFIX_ALL OPAL_PREFIX_H323 " " \
313  OPAL_PREFIX_SIP " " \
314  OPAL_PREFIX_IAX2 " " \
315  OPAL_PREFIX_PCSS " " \
316  OPAL_PREFIX_LOCAL " " \
317  OPAL_PREFIX_POTS " " \
318  OPAL_PREFIX_PSTN " " \
319  OPAL_PREFIX_FAX " " \
320  OPAL_PREFIX_T38 " " \
321  OPAL_PREFIX_IVR " " \
322  OPAL_PREFIX_IM
323 
324 
327 typedef enum OpalMessageType {
439 // Always add new messages to ethe end to maintain backward compatibility
442 
443 
447 typedef enum OpalSilenceDetectMode {
453 
454 
458 typedef enum OpalEchoCancelMode {
463 
464 
479 typedef int (*OpalMediaDataFunction)(
480  const char * token,
482  const char * stream,
486  const char * format,
487  void * userData,
488  void * data,
489  int size
490 );
491 
492 
510  const OpalMessage * message
511 );
512 
513 
521 typedef enum OpalMediaDataType {
528 
529 
547 typedef enum OpalMediaTiming {
557 
558 
591 typedef struct OpalParamGeneral {
592  const char * m_audioRecordDevice;
593  const char * m_audioPlayerDevice;
594  const char * m_videoInputDevice;
595  const char * m_videoOutputDevice;
596  const char * m_videoPreviewDevice;
597  const char * m_mediaOrder;
600  const char * m_mediaMask;
603  const char * m_autoRxMedia;
607  const char * m_autoTxMedia;
611  const char * m_natMethod;
615  const char * m_natServer;
617  unsigned m_tcpPortBase;
619  unsigned m_tcpPortMax;
621  unsigned m_udpPortBase;
623  unsigned m_udpPortMax;
625  unsigned m_rtpPortBase;
627  unsigned m_rtpPortMax;
633  unsigned m_minAudioJitter;
637  unsigned m_maxAudioJitter;
646  unsigned m_signalDeadband;
648  unsigned m_silenceDeadband;
655  unsigned m_audioBuffers;
669  const char * m_mediaOptions;
678  unsigned m_audioBufferTime;
681  unsigned m_manualAlerting;
695 
696 
699 typedef struct OpalProductDescription {
700  const char * m_vendor;
703  const char * m_name;
706  const char * m_version;
709  unsigned m_t35CountryCode;
714  unsigned m_t35Extension;
726 
727 
731 typedef enum OpalUserInputModes {
739 
740 
757 typedef struct OpalParamProtocol {
758  const char * m_prefix;
761  const char * m_userName;
764  const char * m_displayName;
767  const char * m_interfaceAddresses;
778  const char * m_defaultOptions;
781 
782 
784 #define OPAL_MWI_EVENT_PACKAGE "message-summary"
785 
787 #define OPAL_LINE_APPEARANCE_EVENT_PACKAGE "dialog;sla;ma"
788 
861 typedef struct OpalParamRegistration {
862  const char * m_protocol;
864  const char * m_identifier;
870  const char * m_hostName;
874  const char * m_authUserName;
875  const char * m_password;
876  const char * m_adminEntity;
879  unsigned m_timeToLive;
881  unsigned m_restoreTime;
884  const char * m_eventPackage;
892  const char * m_attributes;
897 
898 
914 
915 
919 typedef struct OpalStatusRegistration {
920  const char * m_protocol;
922  const char * m_serverName;
925  const char * m_error;
932 
933 
970 typedef struct OpalParamSetUpCall {
971  const char * m_partyA;
985  const char * m_partyB;
997  const char * m_callToken;
1002  const char * m_alertingType;
1021  const char * m_protocolCallId;
1027 
1028 
1032 typedef struct OpalStatusIncomingCall {
1033  const char * m_callToken;
1034  const char * m_localAddress;
1035  const char * m_remoteAddress;
1036  const char * m_remotePartyNumber;
1037  const char * m_remoteDisplayName;
1038  const char * m_calledAddress;
1039  const char * m_calledPartyNumber;
1041  const char * m_alertingType;
1053  const char * m_protocolCallId;
1055  const char * m_referredByAddress;
1056  const char * m_redirectingNumber;
1058 
1059 
1068 typedef struct OpalParamAnswerCall {
1069  const char * m_callToken;
1073  unsigned m_withMedia;
1076 
1081 typedef enum OpalMediaStates {
1091 } OpalMediaStates;
1092 
1093 
1100 typedef struct OpalStatusMediaStream {
1101  const char * m_callToken;
1102  const char * m_identifier;
1105  const char * m_type;
1110  const char * m_format;
1117  int m_volume;
1122 
1123 
1126 typedef struct OpalParamSetUserData {
1127  const char * m_callToken;
1128  void * m_userData;
1130 
1131 
1137 typedef struct OpalStatusUserInput {
1138  const char * m_callToken;
1139  const char * m_userInput;
1140  unsigned m_duration;
1145 } OpalStatusUserInput, OpalParamUserInput;
1146 
1147 
1152  const char * m_party;
1153  const char * m_type;
1154  const char * m_extraInfo;
1158 
1159 
1173  OpalLineIdle = OpalLineTerminated // Kept for backward compatibility
1175 
1176 
1181  const char * m_line;
1186  const char * m_callId;
1190  const char * m_partyA;
1191  const char * m_partyB;
1193 
1194 
1198 typedef enum OpalPresenceStates {
1208 
1209 
1238 typedef struct OpalPresenceStatus {
1239  const char * m_entity;
1242  const char * m_target;
1244  const char * m_service;
1246  const char * m_contact;
1247  const char * m_capabilities;
1250  const char * m_activities;
1254  const char * m_note;
1258  const char * m_infoType;
1259  const char * m_infoData;
1261 
1262 
1271 typedef struct OpalInstantMessage {
1272  const char * m_from;
1273  const char * m_to;
1274  const char * m_host;
1276  const char * m_conversationId;
1280  const char * m_textBody;
1282  unsigned m_bodyCount;
1283  const char ** m_mimeType;
1284  const char ** m_bodies;
1285  unsigned m_messageId;
1290 
1291 
1313 
1314 
1317 typedef struct OpalParamRecording {
1318  const char * m_callToken;
1319  const char * m_file;
1321  unsigned m_channels;
1324  const char * m_audioFormat;
1328  const char * m_videoFormat;
1332  unsigned m_videoWidth;
1333  unsigned m_videoHeight;
1334  unsigned m_videoRate;
1337 
1338 
1342 typedef struct OpalStatusTransferCall {
1343  const char * m_callToken;
1344  const char * m_protocolCallId;
1346  const char * m_result;
1361  const char * m_info;
1366 
1367 
1371 typedef struct OpalStatusIVR {
1372  const char * m_callToken;
1373  const char * m_variables;
1378 } OpalStatusIVR;
1379 
1380 
1384 typedef struct OpalStatusCallCleared {
1385  const char * m_callToken;
1386  const char * m_reason;
1392 
1393 
1398 typedef enum OpalCallEndReason {
1431 
1432 
1435 typedef struct OpalParamCallCleared {
1436  const char * m_callToken;
1440 
1441 
1445 struct OpalMessage {
1447  union {
1448  const char * m_commandError;
1454  const char * m_callToken;
1457  OpalStatusUserInput m_userInput;
1469 
1470  } m_param;
1471 };
1472 
1473 
1474 #ifdef __cplusplus
1475 };
1476 #endif
1477 
1478 #if defined(__cplusplus) || defined(DOC_PLUS_PLUS)
1479 
1482 {
1483  public:
1485  ~OpalMessagePtr();
1486 
1487  OpalMessageType GetType() const;
1488  void SetType(OpalMessageType type);
1489 
1490  const char * GetCallToken() const;
1491  void SetCallToken(const char * token);
1492 
1493  const char * GetCommandError() const;
1494 
1499  OpalParamSetUpCall * GetCallSetUp() const;
1502  OpalStatusUserInput * GetUserInput() const;
1509  OpalParamRecording * GetRecording() const;
1513 
1514  protected:
1516 
1517  private:
1518  OpalMessagePtr(const OpalMessagePtr &) { }
1519  void operator=(const OpalMessagePtr &) { }
1520 
1521  friend class OpalContext;
1522 };
1523 
1524 
1525 #ifdef GetMessage
1526 #undef GetMessage
1527 #endif
1528 #ifdef SendMessage
1529 #undef SendMessage
1530 #endif
1531 
1532 
1541 {
1542  public:
1544  OpalContext();
1545 
1547  virtual ~OpalContext();
1548 
1551  unsigned Initialise(
1552  const char * options,
1553  unsigned version = OPAL_C_API_VERSION
1554  );
1555 
1557  bool IsInitialised() const { return m_handle != NULL; }
1558 
1560  void ShutDown();
1561 
1563  bool GetMessage(
1564  OpalMessagePtr & message,
1565  unsigned timeout = 0
1566  );
1567 
1569  bool SendMessage(
1570  const OpalMessagePtr & message,
1571  OpalMessagePtr & response
1572  );
1573 
1574 
1576  bool SetUpCall(
1577  OpalMessagePtr & response,
1578  const char * partyB,
1579  const char * partyA = NULL,
1580  const char * alertingType = NULL
1581  );
1582 
1584  bool AnswerCall(
1585  const char * callToken
1586  );
1587 
1589  bool ClearCall(
1590  const char * callToken,
1592  );
1593 
1595  bool SendUserInput(
1596  const char * callToken,
1597  const char * userInput,
1598  unsigned duration = 0
1599  );
1600 
1601  protected:
1603 };
1604 
1605 #endif
1606 
1607 #endif // OPAL_OPAL_H
1608 
1609