aboutsummaryrefslogtreecommitdiffstats
path: root/addons/ooh323c/src/ooCalls.h
blob: 8f367769fe9874a81e1932ac922ff713baf0d01f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
/*
 * Copyright (C) 2004-2005 by Objective Systems, Inc.
 *
 * This software is furnished under an open source license and may be 
 * used and copied only in accordance with the terms of this license. 
 * The text of the license may generally be found in the root 
 * directory of this installation in the COPYING file.  It 
 * can also be viewed online at the following URL:
 *
 *   http://www.obj-sys.com/open/license.html
 *
 * Any redistributions of this file including modified versions must 
 * maintain this copyright notice.
 *
 *****************************************************************************/
/**
 * @file ooCalls.h 
 * This file contains call management functions. 
 */
#ifndef _OOCALLS_H_
#define _OOCALLS_H_

#include "ooLogChan.h"
#include "ooCapability.h"
#include <regex.h>

#ifdef __cplusplus
extern "C" {
#endif


/** 
 * @defgroup callmgmt  Call Management
 * @{
 */
/* Flag mask values */
/* DISABLEGK is used to selectively disable gatekeeper use. For incoming calls
   DISABLEGK can be set in onReceivedSetup callback by application.
   Very useful in pbx applications where gk is used only when call is
   to or from outside pbx domian. For outgoing calls, ooMakeCallNoGk
   disables use of gk for specific call.
*/


#define OO_M_ENDSESSION_BUILT   ASN1UINTCNT(0x00800000)
#define OO_M_RELEASE_BUILT      ASN1UINTCNT(0x00400000)
#define OO_M_FASTSTARTANSWERED  ASN1UINTCNT(0x04000000)

#define OO_M_ENDPOINTCREATED    ASN1UINTCNT(0x00010000)
#define OO_M_GKROUTED           ASN1UINTCNT(0x00200000)
#define OO_M_AUTOANSWER         ASN1UINTCNT(0x00100000)
#define OO_M_TUNNELING	        ASN1UINTCNT(0x08000000)
#define OO_M_MEDIAWAITFORCONN   ASN1UINTCNT(0x20000000)
#define OO_M_FASTSTART	        ASN1UINTCNT(0x02000000)
#define OO_M_DISABLEGK          ASN1UINTCNT(0x01000000)
#define OO_M_MANUALRINGBACK     ASN1UINTCNT(0x10000000)

#define OO_M_TRYBEMASTER	ASN1UINTCNT(0x00000010)
#define OO_M_AUDIOSESSION	ASN1UINTCNT(0x00000100)
#define OO_M_DATASESSION	ASN1UINTCNT(0x00000200)
#define OO_M_T38SUPPORTED	ASN1UINTCNT(0x00000400)

/** 
 * Call states.
 */
typedef enum {
   OO_CALL_CREATED,               /*!< Call created. */
   OO_CALL_WAITING_ADMISSION,     /*!< Call waiting for admission by GK */
   OO_CALL_CONNECTING,            /*!< Call in process of connecting */
   OO_CALL_CONNECTED,             /*!< Call currently connected. */
   OO_CALL_PAUSED,                /*!< Call Paused for hold/transfer. */
   OO_CALL_CLEAR,                 /*!< Call marked for clearing */
   OO_CALL_CLEAR_RELEASERECVD,    /*!< Release command received. */
   OO_CALL_CLEAR_RELEASESENT,     /*!< Release sent */
   OO_CALL_CLEARED,               /*!< Call cleared */
   OO_CALL_REMOVED		  /* call removed */
} OOCallState;

/** 
 * H.245 session states.
 */
typedef enum {
   OO_H245SESSION_IDLE,
   OO_H245SESSION_PAUSED,
   OO_H245SESSION_ACTIVE,
   OO_H245SESSION_ENDSENT, 
   OO_H245SESSION_ENDRECVD,
   OO_H245SESSION_CLOSED
} OOH245SessionState;

/**
 * Structure to store local and remote media endpoint info for a 
 * given media type.
 */
typedef struct OOMediaInfo{
   char   dir[15]; /* transmit/receive*/
   int   cap;
   int   lMediaPort;
   int   lMediaCntrlPort;
   char  lMediaIP[20];
   struct OOMediaInfo *next;
} OOMediaInfo;

#define ooMediaInfo OOMediaInfo

struct OOAliases;

/**
 * Structure to hold information on a forwarded call.
 */
typedef struct OOCallFwdData {
   char ip[20];
   int port;
   struct OOAliases *aliases;
   OOBOOL fwdedByRemote; /*Set when we are being fwded by remote*/
} OOCallFwdData;      

/**
 * Structure to store information on an H.323 channel (H.225 or H.245) for 
 * a particular call.
 */
typedef struct OOH323Channel {
   OOSOCKET sock;      /*!< Socket connection for the channel */
   int      port;      /*!< Port assigned to the channel */
   DList    outQueue;  /*!< Output message queue */
} OOH323Channel;

/**
 * Structure to store information on fast start response (H.225) to 
 * reply same answer in CALL PROCEEDING, ALERTING & CONNECT.
 */
typedef struct EXTERN FastStartResponse {
   ASN1UINT n;
   ASN1DynOctStr *elem;
} FastStartResponse;

typedef struct OOH323Regex {
   regex_t regex;
   int inuse;
   ast_mutex_t lock;
} OOH323Regex;


/**
 * This structure is used to maintain all information on an active call. 
 * A list of these structures is maintained within the global endpoint 
 * structure.
 */
typedef struct OOH323CallData {
   OOCTXT               *pctxt;
   OOCTXT               *msgctxt;
   pthread_t		callThread;
   ast_cond_t		gkWait;
   ast_mutex_t		Lock;
   OOBOOL 		Monitor;
   OOBOOL		fsSent;
   OOSOCKET		CmdChan;
   OOSOCKET		cmdSock;
   ast_mutex_t*		CmdChanLock;
   char                 callToken[20]; /* ex: ooh323c_call_1 */
   char                 callType[10]; /* incoming/outgoing */
   OOCallMode           callMode;
   int			transfercap;
   ASN1USINT            callReference;
   char                 ourCallerId[256];
   H225CallIdentifier   callIdentifier;/* The call identifier for the active 
                                          call. */
   char                 *callingPartyNumber;
   char                 *calledPartyNumber; 
   H225ConferenceIdentifier confIdentifier;
   ASN1UINT             flags;
   OOCallState          callState;
   OOCallClearReason    callEndReason;
   int			q931cause;
   ASN1UINT		h225version;
   unsigned             h245ConnectionAttempts;
   OOH245SessionState   h245SessionState;
   int                  dtmfmode;
   int			dtmfcodec;
   OOMediaInfo          *mediaInfo;
   OOCallFwdData        *pCallFwdData;
   char                 localIP[20];/* Local IP address */
   OOH323Channel*       pH225Channel;
   OOH323Channel*       pH245Channel;
   OOSOCKET             *h245listener;
   int                  *h245listenport;
   char                 remoteIP[20];/* Remote IP address */
   int                  remotePort;
   int                  remoteH245Port;
   char                 *remoteDisplayName;
   struct OOAliases     *remoteAliases;
   struct OOAliases     *ourAliases; /*aliases used in the call for us */
   OOMasterSlaveState   masterSlaveState;   /*!< Master-Slave state */
   OOMSAckStatus	msAckStatus; /* Master-Slave ack's status */
   ASN1UINT             statusDeterminationNumber;
   OOCapExchangeState   localTermCapState;
   OOCapExchangeState   remoteTermCapState;
   struct ooH323EpCapability* ourCaps;
   struct ooH323EpCapability* remoteCaps; /* TODO: once we start using jointCaps, get rid of remoteCaps*/
   struct ooH323EpCapability* jointCaps;
   int                  jointDtmfMode;
   DList                remoteFastStartOLCs;
   ASN1UINT8            remoteTermCapSeqNo;
   ASN1UINT8            localTermCapSeqNo;
   OOCapPrefs           capPrefs;   
   OOLogicalChannel*    logicalChans; 
   int                  noOfLogicalChannels;
   int                  logicalChanNoBase;
   int                  logicalChanNoMax;
   int                  logicalChanNoCur;
   unsigned             nextSessionID; /* Note by default 1 is audio session, 2 is video and 3 is data, from 3 onwards master decides*/
   DList                timerList;
   ASN1UINT             msdRetries;
   ASN1UINT8		requestSequence;
   ASN1UINT		reqFlags;
   ASN1UINT		t38sides;
   H235TimeStamp	alertingTime, connectTime, endTime; /* time data for gatekeeper */
   FastStartResponse    *pFastStartRes; /* fast start response */
   struct OOH323Regex*		rtpMask;
   char			rtpMaskStr[120];
   char			lastDTMF;
   ASN1UINT		nextDTMFstamp;
   int			rtdrInterval, rtdrCount;	/* roundTripDelay interval and unreplied count */
   ASN1UINT		rtdrSend, rtdrRecv;		/* last sended/replied RTD request */
   void                 *usrData; /*!<User can set this to user specific data*/
   struct OOH323CallData* next;
   struct OOH323CallData* prev;
} OOH323CallData;

#define ooCallData OOH323CallData

/**
 * This callback function is triggered when a new call structure is 
 * created inside the stack for an incoming or outgoing call.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnNewCallCreated)(OOH323CallData* call);

/**
 * This callback function is triggered when a Q.931 alerting message is 
 * received for an outgoing call or when a Q.931 alerting message is sent 
 * for an incoming call.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnAlerting)(OOH323CallData * call);

/**
 * This callback function is triggered when there is an incoming call. 
 * In the case where a gatekeeper is in use, the call must first be 
 * admitted by the gatekeeper before this callback is triggered.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnIncomingCall)(OOH323CallData* call );

/**
 * This callback function is triggered after a Q.931 setup message 
 * is sent for an outgoing call.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnOutgoingCall)(OOH323CallData* call );

/**
 * This callback function is triggered when a Q.931 connect message is 
 * sent in case of incoming call.  In case of outgoing call, this is invoked 
 * when a Q.931 connect message is received. It is not invoked until after 
 * fast start and H.245 tunneling messages within the connect message are 
 * processed.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnCallEstablished)(struct OOH323CallData* call);

/**
 * This callback function is triggered when a call is cleared.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OnCallCleared)(struct OOH323CallData* call);

/**
 * This callback function is triggered when master-slave determination 
 * and capabilities negotiation procedures are successfully completed 
 * for a call.
 *
 * @param call H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure.
 */
typedef int (*cb_OpenLogicalChannels)(struct OOH323CallData* call);

/**
 * This callback function is triggered when a call is forwarded by
 * a remote endpoint to another remote destination.
 * @param call Associated H.323 call data structure
 * @return 0 if callback was successful, non-zero error code if failure
 */
typedef int (*cb_OnCallForwarded)(struct OOH323CallData* call);

/**
 * This callback function is triggered when dtmf is received over Q.931(keypad)
 * or H.245(alphanumeric) or H.245(signal). This is not triggered when rfc
 * 2833 based dtmf is received.
 */
typedef int (*cb_OnReceivedDTMF)
   (struct OOH323CallData *call, const char *dtmf);

/**
 * This callback function is triggered when dtmf is received over Q.931(keypad)
 * or H.245(alphanumeric) or H.245(signal). This is not triggered when rfc
 * 2833 based dtmf is received.
 */
typedef void (*cb_OnModeChanged)
   (struct OOH323CallData *call, int isT38Mode);

/**
 * This structure holds all of the H.323 signaling callback function 
 * addresses.
 * @see ooH323EpSetH323Callbacks
 */
typedef struct OOH323CALLBACKS {
   cb_OnAlerting onNewCallCreated;
   cb_OnAlerting onAlerting;
   cb_OnAlerting onProgress;
   cb_OnIncomingCall onIncomingCall;
   cb_OnOutgoingCall onOutgoingCall;
   cb_OnCallEstablished onCallEstablished;
   cb_OnCallForwarded onCallForwarded;
   cb_OnCallCleared onCallCleared;
   cb_OpenLogicalChannels openLogicalChannels;
   cb_OnReceivedDTMF onReceivedDTMF;
   cb_OnModeChanged onModeChanged;
} OOH323CALLBACKS;

/**
 * This function is used to create a new call entry.
 * @param type         Type of the call (incoming/outgoing)
 * @param callToken    Call Token, an uniques identifier for the call
 *
 * @return             Pointer to a newly created call
 */
EXTERN OOH323CallData* ooCreateCall(char *type, char *callToken);

/**
 * This function is used to add a call to the list of existing calls.
 * @param call         Pointer to the call to be added.
 * @return             OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooAddCallToList (OOH323CallData *call);

/**
 * This function is used to set the caller ID for a call.
 *
 * @param call          Handle to the call
 * @param callerid      caller ID value
 * @return              OO_OK, on success. OO_FAILED, otherwise.
 */
EXTERN int ooCallSetCallerId
(OOH323CallData* call, const char* callerid);

/**
 * This function is used to set calling party number for a particular call.
 * @param call          Handle to the call.
 * @param number        Calling Party number value.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallSetCallingPartyNumber
(OOH323CallData *call, const char *number);

/**
 * This function is used to retrieve calling party number of a particular call.
 * @param call          Handle to the call.
 * @param buffer        Handle to the buffer in which value will be returned.
 * @param len           Length of the supplied buffer.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallGetCallingPartyNumber
(OOH323CallData *call, char *buffer, int len);

/**
 * This function is used to retrieve called party number of a particular call.
 * @param call          Handle to the call.
 * @param buffer        Handle to the buffer in which value will be returned.
 * @param len           Length of the supplied buffer.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallGetCalledPartyNumber
(OOH323CallData *call, char *buffer, int len);

/**
 * This function is used to set called party number for a particular call.
 * @param call          Handle to the call.
 * @param number        Called Party number value.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallSetCalledPartyNumber
(OOH323CallData *call, const char *number);

/**
 * This function is used to clear the local aliases used by this call.
 * @param call          Handle to the call.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallClearAliases(OOH323CallData *call);

/**
 * This function is used to add an H323ID alias to be used by local endpoint 
 * for a particular call.
 * @param call          Handle to the call
 * @param h323id        H323ID to add for the local endpoint for the call.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddAliasH323ID(OOH323CallData *call, const char* h323id);

/**
 * This function is used to add an dialedDigits alias to be used by local 
 * endpoint for a particular call.
 * @param call          Handle to the call
 * @param dialedDigits  DialedDigits to add for the local endpoint for call.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddAliasDialedDigits
                             (OOH323CallData *call, const char* dialedDigits);

/**
 * This function is used to add an email-id alias to be used by local 
 * endpoint for a particular call.
 * @param call          Handle to the call
 * @param email         Email-id to add for the local endpoint for call.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddAliasEmailID(OOH323CallData *call, const char* email);


/**
 * This function is used to add an email-id alias to be used by local 
 * endpoint for a particular call.
 * @param call          Handle to the call
 * @param url           URL-id to add for the local endpoint for call.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddAliasURLID(OOH323CallData *call, const char* url);


/**
 * This is a helper function used by other call related add aliases functions 
 * to add a particular alias. This function is not supposed to be called 
 * directly.
 * @param call          Handle to the call
 * @param aliasType     Type of alias being added
 * @param value         Alias value
 * @param local         Whether alias is for local party or remote party
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
int ooCallAddAlias
   (OOH323CallData *call, int aliasType, const char *value, OOBOOL local);


/**
 * This function is used to add an dialed digits alias for the remote endpoint 
 * involved in a particular call.
 * @param call          Handle to the call
 * @param dialedDigits  dialedDigits alias to add for the remote endpoint.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddRemoteAliasDialedDigits
   (OOH323CallData *call, const char* dialedDigits);

/**
 * This function is used to add an H323ID alias for the remote endpoint 
 * involved in a particular call.
 * @param call          Handle to the call
 * @param h323id        H323ID to add for the remote endpoint.
 *
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCallAddRemoteAliasH323ID(OOH323CallData *call, const char* h323id);


/**
 * This function is used to add G7231 capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Capability to be added.
 * @param txframes             Number of frames per packet for transmission. 
 * @param rxframes             Number of frames per packet for reception.
 * @param silenceSuppression   Indicates support for silenceSuppression.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddG7231Capability(OOH323CallData *call, int cap, int txframes, 
                            int rxframes, OOBOOL silenceSuppression, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);

/**
 * This function is used to add G728 capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Capability to be added.
 * @param txframes             Number of frames per packet for transmission. 
 * @param rxframes             Number of frames per packet for reception.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddG728Capability(OOH323CallData *call, int cap, int txframes, 
                            int rxframes, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);

/**
 * This function is used to add G729 capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Capability to be added.
 * @param txframes             Number of frames per packet for transmission. 
 * @param rxframes             Number of frames per packet for reception.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddG729Capability(OOH323CallData *call, int cap, int txframes, 
                            int rxframes, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);

/**
 * This function is used to add G711 capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Capability to be added.
 * @param txframes             Number of frames per packet for transmission. 
 * @param rxframes             Number of frames per packet for reception.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddG711Capability(OOH323CallData *call, int cap, int txframes, 
                            int rxframes, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);


/**
 * This function is used to add GSM capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Type of GSM capability to be added.
 * @param framesPerPkt         Number of GSM frames pre packet. 
 * @param comfortNoise         Comfort noise spec for the capability. 
 * @param scrambled            Scrambled enabled/disabled for the capability.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddGSMCapability(OOH323CallData* call, int cap, 
                                  ASN1USINT framesPerPkt, OOBOOL comfortNoise, 
                                  OOBOOL scrambled, int dir,
                                  cb_StartReceiveChannel startReceiveChannel,
                                  cb_StartTransmitChannel startTransmitChannel,
                                  cb_StopReceiveChannel stopReceiveChannel,
                                  cb_StopTransmitChannel stopTransmitChannel);




/**
 * This function is used to add H263 video capability for the call. The 
 * "ooCallAdd...Capability" functions allow to override the global endpoint 
 * capabilities and use specific capabilities for specific calls.
 * @param call                 Call for which capability has to be added.
 * @param cap                  Capability type - OO_H263VIDEO
 * @param sqcifMPI             Minimum picture interval for encoding/decoding 
 *                             of SQCIF pictures.
 * @param qcifMPI              Minimum picture interval for encoding/decoding 
 *                             of QCIF pictures.
 * @param cifMPI               Minimum picture interval for encoding/decoding 
 *                             of CIF pictures.
 * @param cif4MPI              Minimum picture interval for encoding/decoding 
 *                             of CIF4 pictures.
 * @param cif16MPI             Minimum picture interval for encoding/decoding 
 *                             of CIF16 pictures.
 * @param maxBitRate           Maximum bit rate in units of 100 bits/s at
 *                             which a transmitter can transmit video or a 
 *                             receiver can receive video.
 * @param dir                  Direction of capability.OORX, OOTX, OORXANDTX
 * @param startReceiveChannel  Callback function to start receive channel.
 * @param startTransmitChannel Callback function to start transmit channel.
 * @param stopReceiveChannel   Callback function to stop receive channel.
 * @param stopTransmitChannel  Callback function to stop transmit channel.
 *
 * @return                     OO_OK, on success. OO_FAILED, on failure. 
 */
EXTERN int ooCallAddH263VideoCapability(OOH323CallData *call, int cap, 
                                 unsigned sqcifMPI, unsigned qcifMPI, 
                                 unsigned cifMPI, unsigned cif4MPI, 
                                 unsigned cif16MPI, unsigned maxBitRate, 
                                 int dir, 
                                 cb_StartReceiveChannel startReceiveChannel,
                                 cb_StartTransmitChannel startTransmitChannel,
                                 cb_StopReceiveChannel stopReceiveChannel,
                                 cb_StopTransmitChannel stopTransmitChannel);


/**
 * This function is used to enable rfc 2833 capability for the call. By default
 * the stack uses the dtmf settings for the endpoint. But if you want to
 * enable/disable dtmf for a specific call, then you can override end-point
 * settings using this function
 * @param call                  Call for which rfc2833 has to be enabled.
 * @param dynamicRTPPayloadType dynamicRTPPayloadType to be used.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallEnableDTMFRFC2833
          (OOH323CallData *call, int dynamicRTPPayloadType);


/**
 * This function is used to disable rfc 2833 capability for the call. 
 * By default the stack uses the dtmf settings for the endpoint. But if you 
 * want to enable/disable dtmf for a specific call, then you can override 
 * end-point settings using this function
 * @param call                  Call for which rfc2833 has to be disabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallDisableDTMFRFC2833(OOH323CallData *call);


/**
 * This function is used to enable H.245(alphanumeric) dtmf support for the 
 * call. By default the stack uses the dtmf settings for the endpoint. But if 
 * you want to enable H.245(alphanumeric) dtmf for a specific call, then you 
 * can override end-point settings using this function
 * @param call                  Call for which H.245(alphanumeric) dtmf support
 *                              has to be enabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallEnableDTMFH245Alphanumeric(OOH323CallData *call);

/**
 * This function is used to disable H.245(alphanumeric) dtmf support for the 
 * call. By default the stack uses the dtmf settings for the endpoint. But if 
 * you want to disable H.245(alphanumeric) dtmf for a specific call, then you 
 * can override end-point settings using this function
 * @param call                  Call for which H.245(alphanumeric) dtmf support
 *                              has to be disabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallDisableDTMFH245Alphanumeric(OOH323CallData *call);

/**
 * This function is used to enable H.245(signal) dtmf support for the call. 
 * By default the stack uses the dtmf settings for the endpoint. But if you 
 * want to enable H.245(signal) dtmf for a specific call, then you can override
 * end-point settings using this function
 * @param call                  Call for which H.245(signal) dtmf support
 *                              has to be enabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallEnableDTMFH245Signal(OOH323CallData *call);


/**
 * This function is used to disable H.245(signal) dtmf support for the call. 
 * By default the stack uses the dtmf settings for the endpoint. But if you 
 * want to disable H.245(signal) dtmf for a specific call, then you can 
 * override end-point settings using this function
 * @param call                  Call for which H.245(signal) dtmf support
 *                              has to be disabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallDisableDTMFH245Signal(OOH323CallData *call);


/**
 * This function is used to enable Q.931(keypad) dtmf support for the call.
 * By default the stack uses the dtmf settings for the endpoint. But if you 
 * want to enable Q.931(keypad) dtmf support for a specific call, then you can
 * override end-point settings using this function
 * @param call                  Call for which Q.931(keypad) dtmf support
 *                              has to be enabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallEnableDTMFQ931Keypad(OOH323CallData *call);

/**
 * This function is used to disable Q.931(keypad) dtmf support for the call.
 * By default the stack uses the dtmf settings for the endpoint. But if you 
 * want to disable Q.931(keypad) dtmf support for a specific call, then you can
 * override end-point settings using this function
 * @param call                  Call for which Q.931(keypad) dtmf support
 *                              has to be disabled.
 *
 * @return                      OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallDisableDTMFQ931Keypad(OOH323CallData *call);


/**
 * This function is used to find a call by using the unique token for the call.
 * @param callToken      The unique token for the call.
 *
 * @return               Pointer to the call if found, NULL otherwise.
 */
EXTERN OOH323CallData* ooFindCallByToken(const char *callToken);

/**
 * This function is used to end a call. Based on what stage of clearance the
 * call is it takes appropriate action.
 *
 * @param call   Handle to the call which has to be cleared.
 * @return       OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooEndCall(OOH323CallData *call);

/**
 * This function is used to remove a call from the list of existing calls.
 * 
 * @param call          Pointer to the call to be removed.
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooRemoveCallFromList (OOH323CallData *call);

/**
 * This function is used to clean up a call. It closes all associated sockets, 
 * removes the call from the global list and frees up associated memory.
 *
 * @param call          Pointer to the call to be cleared.
 * @return              OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooCleanCall(OOH323CallData *call);

/**
 * This function is used to check whether a specified session in specified 
 * direction is active for the call.
 * @param call       Handle to call for which session has to be queried.
 * @param sessionID  Session id to identify the type of session(1 for audio, 
 *                   2 for voice and 3 for data)
 * @param dir        Direction of the session(transmit/receive)
 *
 * @return           1, if session active. 0, otherwise. 
 */
EXTERN ASN1BOOL ooIsSessionEstablished
(OOH323CallData *call, int sessionID, char* dir);

/**
 * This function can be used by an application to specify media endpoint 
 * information for different types of media. The stack by default uses local IP
 * and port for media. An application can provide mediainfo if it wants to 
 * override default.
 * @param call      Handle to the call
 * @param mediaInfo Structure which defines the media endpoint to be 
 *                  used.
 *
 * @return          OO_OK, on success. OO_FAILED, on failure.
 */
EXTERN int ooAddMediaInfo(OOH323CallData *call, OOMediaInfo mediaInfo);

/**
 * This function is used to generate a media session id for the new media 
 * session for the call.
 * @param call       Handle to the call.
 * @param type       Type of media session.
 * @param dir        Direction of session
 *
 * @return           Generated session id.
 */
EXTERN unsigned ooCallGenerateSessionID
                    (OOH323CallData *call, OOCapType type, char *dir);

/**
 * This is an handler for H245 connection retry timer. When remote end is not 
 * yet listening for H245 connections, this timer provides a wait and retry
 * mechanism to establish H245 connection.
 * @param data      Timer callback data.
 *
 * @return          OO_OK, on success. OO_FAILED, on failure
 */
EXTERN int ooCallH245ConnectionRetryTimerExpired(void *data);

/**
 * This function is used to retrieve the description text for a reason
 * code.
 *
 * @param code     Reason code.
 * @return         The text description string.
 */
EXTERN const char* ooGetReasonCodeText (OOUINT32 code);

/**
 * This function is used to retrieve the description text for a call
 * state.
 *
 * @param callState Call state.
 * @return         The text description string.
 */
EXTERN const char* ooGetCallStateText (OOCallState callState);

/** 
 * @} 
 */

int isRunning(char *callToken);

int ooCallAddG726Capability(struct OOH323CallData *call, int cap, int txframes,
                            int rxframes, OOBOOL silenceSuppression, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);
int ooCallAddAMRNBCapability(struct OOH323CallData *call, int cap, int txframes,
                            int rxframes, OOBOOL silenceSuppression, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);
int ooCallAddSpeexCapability(struct OOH323CallData *call, int cap, int txframes,
                            int rxframes, OOBOOL silenceSuppression, int dir,
                            cb_StartReceiveChannel startReceiveChannel,
                            cb_StartTransmitChannel startTransmitChannel,
                            cb_StopReceiveChannel stopReceiveChannel,
                            cb_StopTransmitChannel stopTransmitChannel);
int ooCallEnableDTMFCISCO(struct OOH323CallData *call, int dynamicRTPPayloadType);
int ooCallDisableDTMFCISCO(struct OOH323CallData *call);

#ifdef __cplusplus
}
#endif

#endif