File: frame.h

package info (click to toggle)
opal 2.2.3.dfsg-3
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 29,504 kB
  • ctags: 30,804
  • sloc: cpp: 196,251; ansic: 42,509; makefile: 872; sh: 268
file content (1166 lines) | stat: -rw-r--r-- 47,216 bytes parent folder | download | duplicates (3)
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
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
/*
 *
 * Inter Asterisk Exchange 2
 * 
 * Open Phone Abstraction Library (OPAL)
 *
 * Define the classes that carry information over the ethernet.
 *
 * Copyright (c) 2005 Indranet Technologies Ltd.
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 *
 * The Original Code is Open Phone Abstraction Library.
 *
 * The Initial Developer of the Original Code is Indranet Technologies Ltd.
 *
 * The author of this code is Derek J Smithies
 *
 *  $Log: frame.h,v $
 *  Revision 1.6  2005/08/26 03:07:38  dereksmithies
 *  Change naming convention, so all class names contain the string "IAX2"
 *
 *  Revision 1.5  2005/08/25 03:26:06  dereksmithies
 *  Add patch from Adrian Sietsma to correctly set the packet timestamps under windows.
 *  Many thanks.
 *
 *  Revision 1.4  2005/08/24 04:56:25  dereksmithies
 *  Add code from Adrian Sietsma to send FullFrameTexts and FullFrameDtmfs to
 *  the remote end.  Many Thanks.
 *
 *  Revision 1.3  2005/08/24 01:38:38  dereksmithies
 *  Add encryption, iax2 style. Numerous tidy ups. Use the label iax2, not iax
 *
 *  Revision 1.2  2005/08/04 08:14:17  rjongbloed
 *  Fixed Windows build under DevStudio 2003 of IAX2 code
 *
 *  Revision 1.1  2005/07/30 07:01:32  csoutheren
 *  Added implementation of IAX2 (Inter Asterisk Exchange 2) protocol
 *  Thanks to Derek Smithies of Indranet Technologies Ltd. for
 *  writing and contributing this code
 *
 *
 *
 *
 */

#ifndef FRAME_H
#define FRAME_H


class IAX2Frame;
class IAX2FrameList;
class IAX2FullFrame;
class IAX2FullFrameCng;
class IAX2FullFrameDtmf;
class IAX2FullFrameHtml;
class IAX2FullFrameImage;
class IAX2FullFrameNull;
class IAX2FullFrameProtocol;
class IAX2FullFrameSessionControl;
class IAX2FullFrameText;
class IAX2FullFrameVideo;
class IAX2FullFrameVoice;
class IAX2EndPoint;
class IAX2Processor;
class IAX2IeList;
class IAX2MiniFrame;
class IAX2Transmitter;

#include <iax2/ies.h>
#include <iax2/remote.h>
#include <ptlib.h>
#include <ptlib/sockets.h>

#ifdef P_USE_PRAGMA
#pragma interface
#endif



/**Base class for holding data to be sent to a remote endpoint*/
class IAX2Frame :  public PObject
{
  PCLASSINFO(IAX2Frame, PObject);
 public:
  /**construction */
  IAX2Frame(IAX2EndPoint &_endpoint);
  
  /**Destructor - which is empty */
  virtual ~IAX2Frame();
  
  /**Wait on the designated socket for an incoming UDP packet. This
     method is only called by the receiver. This method does NO interpretation*/
  BOOL ReadNetworkPacket(PUDPSocket &sock);
  
  /**Interpret the data from the read process*/
  virtual BOOL ProcessNetworkPacket();
  
  /**True if this is a full frame */
  virtual BOOL IsFullFrame();
  
  /**True if it is a video frame */
  BOOL IsVideo() const;
  
  /**True if is is an audio frame */
  BOOL IsAudio() const;

  /**Pointer to the beginning of the media (after the header) in this packet.
     The low level frame has no idea on headers, so just return pointer to beginning
     of data. */
  virtual BYTE *GetMediaDataPointer() { return data.GetPointer(); }
  
  /**Number of bytes in the media section of this packet. The low
     level frame has no idea on headers, so just return the number of
     bytes in the packet.*/
  virtual PINDEX GetMediaDataSize() { return DataSize();}
  
  /**Reporting function, to describe the number of bytes in this packet */
  PINDEX DataSize() { return data.GetSize(); }
  
  /**Get the value of the Remote structure */
  IAX2Remote & GetRemoteInfo() { return remote; }
  
  /**Obtain a pointer to the current position in the incoming data array */
  const BYTE * GetDataPointer() { return data + currentReadIndex; }
  
  /** Read the input frame, and create the correct IAX2MiniFrame,
      FullFrame, and set frame type variables.  If a password is
      supplied, decrypt the frame with this password

      This method will never delete the input frame.
      If the output is null, it failed to derive a result.*/
  IAX2Frame * BuildAppropriateFrameType(IAX2Encryption &encryptionInfo);

  /**Same as the preceeding function, except that encryption is off */
  IAX2Frame * BuildAppropriateFrameType();

  /** How many bytes are unread in the incoming data array */
  PINDEX   GetUnReadBytes() { return data.GetSize() - currentReadIndex; }
  
  /**Cause the header bytes for this particular frame type to be written to the internal array */
  virtual BOOL WriteHeader() { return FALSE; }
  
  /**Send this packet on the specified socket to the remote host. This method is only
     called by the transmiter.*/
  virtual BOOL TransmitPacket(PUDPSocket &sock);
  
  /**Pretty print this frame data to the designated stream*/
  virtual void PrintOn(ostream & strm) const;
  
  /**Calculate the timestamp value, given the call start tick*/
  static DWORD CalcTimeStamp(const PTimeInterval & callStartTick);

  /**Write the timestamp value, in preparation for writing the
     header. When sending a packet, the timestamp is written at packet
     construction.*/
  virtual void BuildTimeStamp(const PTimeInterval & callStartTick);
  
  /**Return a reference to the endpoint structure */
  IAX2EndPoint & GetEndpoint() { return endpoint; }
  
  /**Globally unique ID string for this frame, to help track frames */
  PString IdString() const { return PString("FR-ID#") + PString(frameIndex); }
  
  
  /**Get the timestamp as used by this class*/
  DWORD  GetTimeStamp() { return timeStamp; }
  
  /** Report flag stating that this call must be active when this frame is transmitted*/
  virtual BOOL CallMustBeActive() { return TRUE; }     
  
  /**Specify the type of this frame. */
  enum IAX2FrameType {
    undefType        = 0,     /*!< full frame type is  Undefined                     */
    dtmfType         = 1,     /*!< full frame type is  DTMF                          */
    voiceType        = 2,     /*!< full frame type is  Audio                         */
    videoType        = 3,     /*!< full frame type is  Video                         */
    controlType      = 4,     /*!< full frame type is  Session Control               */
    nullType         = 5,     /*!< full frame type is  NULL - frame ignored.         */
    iax2ProtocolType = 6,     /*!< full frame type is  IAX protocol specific         */
    textType         = 7,     /*!< full frame type is  text message                  */
    imageType        = 8,     /*!< full frame type is  image                         */
    htmlType         = 9,     /*!< full frame type is  HTML                          */
    cngType          = 10,    /*!< full frame type is  CNG (comfort noise generation */
    numFrameTypes    = 11     /*!< the number of defined IAX2 frame types            */
  };
  
  /**Access the current value of the variable controlling frame type,
     which is used when reading data from the network socket. */
  IAX2FrameType GetFrameType() { return frameType; }
    
  /**Method supplied here to provide basis for descendant classes.

   Whenever a frame is transmitted, this method will be called.*/
  virtual void InitialiseHeader(IAX2Processor * /*processor*/) { }
  
  /**Return true if this frame should be retransmitted. Acks are never retransmitted. cmdNew are retransmitted.*/
  BOOL CanRetransmitFrame() const {return canRetransmitFrame; } 
  
  /**Get the string which uniquely identifies the IAXConnection that sent this frame */
  PString GetConnectionToken() const { return connectionToken; }

  /**Set the string which uniquely identifies the IAXConnection that is responsible for
     this frame */
  void SetConnectionToken(PString newToken) { connectionToken = newToken; } 

  /**Create the connection token id, which uniquely identifies the
     connection to process this call */
  void BuildConnectionTokenId();

  /**Write the data in the variables to this frame's data array. If
     encryption is on, the data will be encrypted */
  BOOL EncryptContents(IAX2Encryption &encData);

  /**Get the offset to the beginning of the encrypted region */
  virtual PINDEX GetEncryptionOffset();

 protected:

  /**Use the supplied encryptionKey, and data in storage, to decrypt this frame.
   
  Return False if the decryption fails, TRUE if the decryption works.*/
  BOOL DecryptContents(IAX2Encryption & encryption);

  /**Specification of the location (address, call number etc) of the far endpoint */
  IAX2Remote  remote;
  
  /**Variable specifying the IAX type of frame that this is. Used only in reading from the network */
  IAX2FrameType frameType;
  
  /** Read 1 byte from the internal area, (Internal area is filled when reading the packet in). Big Endian.*/
  BOOL          Read1Byte(BYTE & res);
  
  /** Read 2 bytes from the internal area, (Internal area is filled when reading the packet in)  Big Endian.*/
  BOOL          Read2Bytes(PINDEX & res);
  
  /** Read 2 bytes from the internal area, (Internal area is filled when reading the packet in)  Big Endian.*/
  BOOL          Read2Bytes(WORD & res);
  
  /** Read 4 bytes from the internal area, (Internal area is filled when reading the packet in)  Big Endian.*/
  BOOL          Read4Bytes(DWORD & res);
  
  /** Write 1 byte to the internal area, as part of writing the header info */
  void          Write1Byte(BYTE newVal);
  
  /** Write 1 byte to the internal area, as part of writing the header info. Send only the lowest 8 bits of source*/
  void          Write1Byte(PINDEX newVal);
  
  /** Write 2 bytes to the internal area, as part of writing the header info  Big Endian.*/
  void          Write2Bytes(PINDEX newVal);
  
  /** Write 4 bytes to the internal area, as part of writing the header info  Big Endian.*/
  void          Write4Bytes(unsigned int newVal);
  
  /** Initialise all internal storage in this structrue */
  void          ZeroAllValues();
  
  /**Reference to the global variable of this program */
  IAX2EndPoint      & endpoint;
  
  /**Internal storage array, ready for sending to remote node, or ready for receiving from remote node*/
  PBYTEArray         data;
  
  /**Flag to indicate if this is a MiniFrame or FullFrame */
  BOOL               isFullFrame;
  
  /**Flag to indicate if this is a MiniFrame with video */
  BOOL               isVideo;
  
  /**Flag to indicate if this is a MiniFrame with audio */
  BOOL               isAudio;
  
  /**Index of where we are reading from the internal data area */
  PINDEX               currentReadIndex;  
  
  /**Index of where we are writing to  the internal data area */  
  PINDEX               currentWriteIndex;  
  
  /**unsigned 32 bit representaiton of the time of this day */
  DWORD                timeStamp;  
  
  /** Internal variable that uniquely identifies this frame */
  int                frameIndex;
  
  /**Indicate if this frame can be retransmitted*/
  BOOL               canRetransmitFrame;

  /**Connection Token, which uniquely identifies the IAXConnection
     that sent this frame. The token will (except for the first setup
     packet) uniquely identify the IAXConnection that is to receive
     this incoming frame.  */
  PString            connectionToken;

  /**The time stamp to use, for those cases when the user demands a particular
   * timestamp on construction. */
  PINDEX presetTimeStamp;
};

/////////////////////////////////////////////////////////////////////////////    
/**Class to manage a mini frame, which is sent unreliable to the remote endpoint*/
class IAX2MiniFrame : public IAX2Frame
{
  PCLASSINFO(IAX2MiniFrame, IAX2Frame);
 public:
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2MiniFrame(IAX2Frame & srcFrame);
  
  /** Construction from an endpoint, to create an empty frame. */
  IAX2MiniFrame(IAX2EndPoint & _endpoint); 
  
  /**Construction from an encoded audio array (stored in a
     PBYTEArray), in preparation to sending to remote node.  The
     constructor will not delete the supplied PBYTEArray structure.

     TimeStamp will be calculated from time since call started, if the users timestamp is 0.
     If the users timeStamp is non zero, the frames timestamp will be this.
  */
  IAX2MiniFrame(IAX2Processor * con, PBYTEArray &sound, BOOL isAudio, PINDEX usersTimeStamp = 0);

  /**Destructor*/
  virtual ~IAX2MiniFrame();
  
  /** Process the incoming frame some more, but process it as this frame type demands*/
  virtual BOOL ProcessNetworkPacket();
  
  /**Write the header to the internal data area */
  virtual BOOL WriteHeader();
  
  /**Pretty print this frame data to the designated stream*/
  virtual void PrintOn(ostream & strm) const;
  
  /**Pointer to the beginning of the media (after the header) in this packet */
  virtual BYTE *GetMediaDataPointer();
  
  /**Number of bytes in the media section of this packet. */
  virtual PINDEX GetMediaDataSize();
  
  /**Fix the timestamp in this class, after being shrunk in the MiniFrames */
  void AlterTimeStamp(PINDEX newValue);
  
  /**Given the supplied Connection class, write the first 12 bytes of the frame.
     This method is called by the frame constructors, in preparation for transmission.
     This method is never called when processing a received frame.

     Whenever a frame is transmitted, this method will be called.*/ 
  virtual void InitialiseHeader(IAX2Processor *processor);
  
  /**Get the offset to the beginning of the encrypted region */
  virtual PINDEX GetEncryptionOffset();

 protected:
  /**Initialise valus in this class to some preset value */
  void ZeroAllValues();
};

/////////////////////////////////////////////////////////////////////////////    
/**Class to handle a full frame, which is sent reliably to the remote endpoint */
class IAX2FullFrame : public IAX2Frame
{
  PCLASSINFO(IAX2FullFrame, IAX2Frame);
 public:
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrame(IAX2Frame & srcFrame);
  
  /** Construction from an endpoint, to create an empty frame. 
      In this case, the class is filled with the various methods*/
  IAX2FullFrame(IAX2EndPoint  &_endpoint);
  
  /**Delete this frame now, but first we have to delete every timer on it.
   */
  virtual ~IAX2FullFrame();
  
  /**Return True if this an ack frame */
  BOOL IsAckFrame() { return isAckFrame; }
  
  /**Return True if this is a PING frame */
  BOOL IsPingFrame();

  /**Return True if this is a NEW frame */
  BOOL IsNewFrame();

  /**Return True if this is a LAGRQ frame */
  BOOL IsLagRqFrame();

  /**Return True if this is a LAGRP frame */
  BOOL IsLagRpFrame();

  /**Return True if this is a PONG frame */
  BOOL IsPongFrame();

  /**Return True if this is a AuthReq frame */
  BOOL IsAuthReqFrame();

  /**Return True if this is a VNAK frame */
  BOOL IsVNakFrame();

  /**Return True if this FullFrame is of a type that increments the InSeqNo */
  BOOL FrameIncrementsInSeqNo();

  /**True if this is a full frame - always returns true as this is a full frame. */
  virtual BOOL IsFullFrame() { return TRUE; }  
  
  /** Initialise to zero all the members of this particular class */
  void ZeroAllValues();
  
  /** Process the incoming frame some more, but process it as a full frame */
  virtual BOOL ProcessNetworkPacket();
  
  /**Send this packet on the specified socket to the remote host. This method is only
     called by the transmiter.*/
  virtual BOOL TransmitPacket(PUDPSocket &sock);
  
  /**Get text descrption of this frame type*/
  PString GetFullFrameName() const;
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const
    { return PString(" subclass=") + PString(subClass); }
  
  /**Stop the timer, so this packet is not retransmitted. Mark packet as dead. This happens
     when a packet has been received that matches one of the previously sent packets. */
  void MarkDeleteNow();
  
  /**Pointer to the beginning of the media (after the header) in this packet */
  virtual BYTE *GetMediaDataPointer();
  
  /**Number of bytes in the media section of this packet. */
  virtual PINDEX GetMediaDataSize();
  
  /**Deteremine the current value of the subClass variable */
  PINDEX GetSubClass() const { return subClass; }
  
  /**Dry the current value of the subClass variable */
  void SetSubClass(int newValue) { subClass = newValue;}
  
  /**Write the header for this class to the internal data array. 12
     bytes of data are writen.  The application developer must write the
     remaining bytes, before transmiting this frame. */
  virtual BOOL WriteHeader();
  
  /**Alter the two bytes for in and out sequence values. (in the header)*/
  void ModifyFrameHeaderSequenceNumbers(PINDEX inNo, PINDEX outNo);

  /**Alter the four bytes for this frames timestamp. It is required,
     when transmitting full frames, that there is a 3ms interval to
     last full frame in the timestamps. This is required by
     limitations in the handline of time in asterisk. */
  void ModifyFrameTimeStamp(PINDEX newTimeStamp);

  /**Mark this frame as having (or not having) information elements*/
  virtual BOOL InformationElementsPresent() { return FALSE; }  
  
  /**Get flag to see if this frame is ready to be sent (or resent). In other words, has the timer expired?*/
  BOOL  SendFrameNow() { return sendFrameNow; }
  
  /**Get flag to see if this frame is ready for deletion. In other words. Has it been sent too many times? */
  BOOL  DeleteFrameNow() { return deleteFrameNow; }
  
  /**Get the sequence number info (inSeqNo and outSeqNo) */
  IAX2SequenceNumbers & GetSequenceInfo() { return sequence; }
  
  /**Pretty print this frame data to the designated stream*/
  virtual void PrintOn(ostream & strm) const;
  
  /**Mark this frame as having been resent (set bit 7 of data[2])*/
  void MarkAsResent();
  
  /**Compare this FullFrame with another full frame, which is used when determining if we are
     dealing with a frame we have already processed */
  BOOL operator *= (IAX2FullFrame & other);
  
  /**enum to define if the call must be active when sending this
     frame*/
  enum ConnectionRequired {
    callActive,      /*!< the call must be active when sending frame*/
    callIrrelevant   /*!< the call may, or may not be, active when sending frame*/
  };
  
  /**Return the FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return 0; }

  /**Get the offset to the beginning of the encrypted region */
  virtual PINDEX GetEncryptionOffset() { return 4; }
  
 protected:
  /** Report flag stating that this call must be active when this frame is transmitted*/
  virtual BOOL CallMustBeActive() { return callMustBeActive; }
  
  /**Turn the 8 bit subClass value into a 16 bit representation */
  void UnCompressSubClass(BYTE a);
  
  /**Turn the 16 bit subClass value into a 8 bit representation */
  int  CompressSubClass();
  
  /**Mark this frame as not to be sent, and not to be deleted */
  void ClearListFlags();
  
  /**Given the supplied Connection class, write the first 12 bytes of the frame.
     This method is called by the frame construcors, in preparation for transmission.
     This method is never called when processing a received frame.

     Whenever a frame is transmitted, this method will be called.*/
  virtual void InitialiseHeader(IAX2Processor *processor);
  
#ifdef DOC_PLUS_PLUS
  /** pwlib constructs to cope with timeout, when transmitting a full frame.  This
      happens when a full frame has not been acknowledged in the
      required time period. This frame will be resent.*/
  void OnTransmissionTimeout(PTimer &, INT);
#else
  PDECLARE_NOTIFIER(PTimer, IAX2FullFrame, OnTransmissionTimeout);
#endif
  /** The timer which is used to test for no reply to this frame (on transmission) */
  PTimer transmissionTimer;
  
  /** integer variable specifying the uncompressed subClass value for this particular frame */
  PINDEX subClass;
  
  /**Time to wait between retries */
  PTimeInterval retryDelta;     
  
  /**Time delta between call start and sending (or receiving)*/
  PTimeInterval timeOffset;     
  
  /**Number of retries this frame has undergone*/
  PINDEX       retries;        
  
  /** Internal variables specifying the retry time periods (in milliseconds) */
  enum RetryTime {
    minRetryTime = 500,    /*!< 500 milliseconds     */
    maxRetryTime = 010000, /*!< 10 seconds           */
    maxRetries   = 10,     /*!< number of retries    */
  };
  
  /**Class holding the sequence numbers, which is used by all classes which have a FullFrame ancestor. */
  IAX2SequenceNumbers sequence;
  
  /**List flag, indicating if this frame ready for sending*/
  BOOL         sendFrameNow;   
  
  /**List flag, this frame is ready for deletion (too many retries)*/
  BOOL         deleteFrameNow; 
  
  /**A tracking flag to indicate this fame has been resent*/
  BOOL         packetResent;   
  
  /** Flag stating that this call must be active when this frame is transmitted  */
  BOOL callMustBeActive;
  
  /** flag to indicate if this is an ack frame */
  BOOL isAckFrame;  
};

/////////////////////////////////////////////////////////////////////////////    

/**Used for transmitting dtmf characters in a reliable fashion. One
   frame per dtmf character.  No data is carried in the data
   section */

class IAX2FullFrameDtmf : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameDtmf, IAX2FullFrame);
 public:
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameDtmf(IAX2Frame & srcFrame);

  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameDtmf(IAX2FullFrame & srcFrame);
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameDtmf(IAX2Processor *processor, /*!< Iax Processor from which this frame originates      */ 
		    char  subClassValue       /*!< IAX protocol command for remote end to process   */
		    );
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameDtmf(IAX2Processor *processor, /*!< Iax Processor from which this frame originates      */ 
		PString  subClassValue    /*!< IAX protocol command for remote end to process   */
		);
  
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const; 
  
  /**enum comtaining the possible subclass value for these dtmf frames */
  enum DtmfSc {
    dtmf0 = 48,     /*!< DTMF character 0     */
    dtmf1 = 49,     /*!< DTMF character 1     */
    dtmf2 = 50,     /*!< DTMF character 2     */
    dtmf3 = 51,     /*!< DTMF character 3     */
    dtmf4 = 52,     /*!< DTMF character 4     */
    dtmf5 = 53,     /*!< DTMF character 5     */
    dtmf6 = 54,     /*!< DTMF character 6     */
    dtmf7 = 55,     /*!< DTMF character 7     */
    dtmf8 = 56,     /*!< DTMF character 8     */
    dtmf9 = 57,     /*!< DTMF character 9     */
    dtmfA = 65,     /*!< DTMF character A     */
    dtmfB = 66,     /*!< DTMF character B     */
    dtmfC = 67,     /*!< DTMF character C     */
    dtmfD = 68,     /*!< DTMF character D     */
    dtmfStar = 42,  /*!< DTMF character *     */
    dtmfHash = 35   /*!< DTMF character #     */
  };
  
  /**Return the FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return dtmfType; }
  
 protected:
};

/////////////////////////////////////////////////////////////////////////////    
/**Used for transmitting voice packets in a relaible
   fashion. Typically, one is sent at the start of the call, and then
   at regular intervals in the call to keep the timestamps in sync.
   
   This class has the ability to build audio codecs, and report on available formats.
   
   The contents the data section is the compressed audio frame. */
class IAX2FullFrameVoice : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameVoice, IAX2FullFrame);
 public:
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameVoice(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameVoice(IAX2FullFrame & srcFrame);
  
  /**Construction from an encoded audio array (stored in a
     PBYTEArray), in preparation to sending to remote node.  The
     constructor will not delete the supplied PBYTEArray structure.

     The full frame will use the specified timeStamp, if it is > 0.  If the
     specified timeStamp == 0, the timeStamp will be calculated from when the
     call started.
  */
  IAX2FullFrameVoice(IAX2Processor *processor, PBYTEArray &sound, 
		 PINDEX usersTimeStamp = 0);
  
  /**Declare an empty destructor */
  virtual ~IAX2FullFrameVoice();

  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Get text description of the subclass contents, given the supplied
     argument*/
  static PString GetSubClassName(unsigned short testValue)
     { return GetSubClassName((unsigned int) testValue); }

  /**Get text description of the subclass contents, given the supplied
     argument*/
  static PString GetSubClassName(unsigned int testValue);
  
  /**Get text description of the subclass contents, given the supplied
   argument.  The name returned is that recoginised by the OPAL
   library. */
  static PString GetOpalNameOfCodec(PINDEX testValue);
  
  /**Get text description of the subclass contents, given the supplied argument*/
  static PString GetSubClassName(int testValue) 
    { return GetSubClassName((unsigned short) testValue); }
  
  /**Turn the OPAL string (which describes the codec) into a AudioSc value. If there is no conversion
     found, return 0. */
  static unsigned short OpalNameToIax2Value(const PString opalName);

  /**enum comtaining the possible (uncompressed) subclass value for these voice frames */
  enum AudioSc {
    g7231    = 1,         /*!< G.723.1 audio format in this frame        */
    gsm      = 2,         /*!< GSM audio format in this frame            */
    g711ulaw = 4,         /*!< G.711 uLaw audio format in this frame     */
    g711alaw = 8,         /*!< G.711 ALaw audio format in this frame     */
    mp3      = 0x10,      /*!< MPeg 3 audio format in this frame         */
    adpcm    = 0x20,      /*!< ADPCM audio format in this frame          */
    pcm      = 0x40,      /*!< PCM audio format in this frame            */
    lpc10    = 0x80,      /*!< LPC10 audio format in this frame          */
    g729     = 0x100,     /*!< G.729 audio format in this frame          */
    speex    = 0x200,     /*!< Speex audio format in this frame          */
    ilbc     = 0x400,     /*!< ILBC audio format in this frame           */
    supportedCodecs = 11  /*!< The number of codecs defined by this enum */
  };
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return voiceType; }
};
/////////////////////////////////////////////////////////////////////////////    
/**Used for transmitting video packets in a relaible
   fashion. Typically, one is sent at the start of the call, and then
   at regular intervals in the call to keep the timestamps in sync.
   
   The contents the data section is compressed video. */
class IAX2FullFrameVideo : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameVideo, IAX2FullFrame);
 public:
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameVideo(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameVideo(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**enum comtaining the possible (uncompressed) subclass value for these video frames */
  enum VideoSc {
    jpeg  = 0x10000,   /*!< Jpeg video format in this frame     */
    png   = 0x20000,   /*!< PNG video format in this frame      */
    h261  = 0x40000,   /*!< H.261 video format in this frame    */
    h263  = 0x80000    /*!< H.263 video fromat in this frame    */
  };
  
  /**Return the FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return videoType; }
 protected:
};

/////////////////////////////////////////////////////////////////////////////    
/**Used for sending  Control Frames. These are used to manipulate the session. 
   
Asterisk calls these AST_FRAME_CONTROLs

No data is carried in the data section */
class IAX2FullFrameSessionControl : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameSessionControl, IAX2FullFrame);
 public:
  
  /**enum comtaining the possible subclass value for these Session Control frames */
  enum SessionSc {
    hangup          = 1,     /*!< Other end has hungup    */
    ring            = 2,     /*!< Local ring    */
    ringing         = 3,     /*!< Remote end is ringing    */
    answer          = 4,     /*!< Remote end has answered    */
    busy            = 5,     /*!< Remote end is busy    */
    tkoffhk         = 6,     /*!< Make it go off hook    */
    offhook         = 7,     /*!< Line is off hook    */
    congestion      = 8,     /*!< Congestion (circuits busy)    */
    flashhook       = 9,     /*!< Flash hook    */
    wink            = 10,    /*!< Wink    */
    option          = 11,    /*!< Set a low-level option    */
    keyRadio        = 12,    /*!< Key Radio    */
    unkeyRadio      = 13,    /*!< Un-Key Radio    */
    callProgress    = 14,    /*!< Indicate PROGRESS    */
    callProceeding  = 15,    /*!< Indicate CALL PROCEEDING    */
    callOnHold      = 16,    /*!< Call has been placed on hold    */
    callHoldRelease = 17,    /*!< Call is no longer on hold    */
    stopSounds      = 255    /*!< Indicates the transition from ringback to bidirectional audio */
  };
  
  
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameSessionControl(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameSessionControl(IAX2FullFrame & srcFrame);
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameSessionControl(IAX2Processor *processor, /*!<Iax Processor from which this frame originates    */ 
			  PINDEX subClassValue/*!<IAX protocol command for remote end to process   */
			  );
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameSessionControl(IAX2Processor *processor,     /*!< Iax Processor from which this frame originates */
			  SessionSc subClassValue /*!< IAX protocol command for remote end to process*/
			  );
  
  /**Declare an empty destructor*/
  virtual ~IAX2FullFrameSessionControl() { }

  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return controlType; }
  
 protected:
};

/////////////////////////////////////////////////////////////////////////////    
/**Class for transfering Nothing. It is essentially a NO Op 
   It is used internally to indicate that the sound card should play a silence frame.
   
   These frames are sent reliably.
   There is no data in the subclass section.
   There is no data in the data section */
class IAX2FullFrameNull : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameNull, IAX2FullFrame);
 public:
  /**Construct an empty Full Frame.
     Classes generated like this are used to handle transmitted information */
  IAX2FullFrameNull(IAX2EndPoint & endpoint) : IAX2FullFrame(endpoint)   { }
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet.
     Classes generated like this are used to handle received data. */
  IAX2FullFrameNull(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet.
     Classes generated like this are used to handle received data. */
  IAX2FullFrameNull(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const { return  PString(""); }
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return nullType; }
  
 protected:
};

/////////////////////////////////////////////////////////////////////////////    
/**Handle IAX specific protocol issues. Used for initiating a call,
   closing a call, registration, reject a call etc.. These are used to
   manipulate the session.
   
   The data section contains information elements, or type Ie classes. */

class IAX2FullFrameProtocol : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameProtocol, IAX2FullFrame);
 public:
  
  /**enum comtaining the possible subclass value for these IAX protocol control frames */
  enum ProtocolSc {
    cmdNew       =  1,       /*!< Create a new call    */
    cmdPing      =  2,       /*!< Ping request, which is done on an open call. It is "Are you Alive    */
    cmdPong      =  3,       /*!< reply to a Ping    */
    cmdAck       =  4,       /*!< Acknowledge a Reliably sent full frame    */
    cmdHangup    =  5,       /*!< Request to terminate this call    */
    cmdReject    =  6,       /*!< Refuse to accept this call. May happen if authentication faile    */
    cmdAccept    =  7,       /*!< Allow this call to procee    */
    cmdAuthReq   =  8,       /*!< Ask remote end to supply authenticatio    */
    cmdAuthRep   =  9,       /*!< A reply, that contains authenticatio    */
    cmdInval     =  10,      /*!< Destroy this call immediatly    */
    cmdLagRq     =  11,      /*!< Initial message, used to measure the round trip time    */
    cmdLagRp     =  12,      /*!< Reply to cmdLagrq, which tells us the round trip time    */
    cmdRegReq    =  13,      /*!< Request fore Registration    */
    cmdRegAuth   =  14,      /*!< Registration is required for  authentication    */
    cmdRegAck    =  15,      /*!< Registration has been accepted    */
    cmdRegRej    =  16,      /*!< Registration has been rejected    */
    cmdRegRel    =  17,      /*!< Force the release of the current registration    */
    cmdVnak      =  18,      /*!< This indicates out of order frames, and can be read as voice not acknowledged */
    cmdDpReq     =  19,      /*!< Request the status of an entry for dialplan     */
    cmdDpRep     =  20,      /*!< Request status of an entry for  dialplan     */
    cmdDial      =  21,      /*!< Request that there is a dial (TBD) on a channel    */
    cmdTxreq     =  22,      /*!< Request a Transfer    */
    cmdTxcnt     =  23,      /*!< Connect up a  Transfer     */
    cmdTxacc     =  24,      /*!< Transfer has been accepted    */
    cmdTxready   =  25,      /*!< Transfer is ready to happen   */
    cmdTxrel     =  26,      /*!< Release a Transfer    */
    cmdTxrej     =  27,      /*!< Reject a Transfer   */
    cmdQuelch    =  28,      /*!< Stop media transmission    */
    cmdUnquelch  =  29,      /*!< Resume media transmission    */
    cmdPoke      =  30,      /*!< Query the remote endpoint (there is no open connection) */
    cmdPage      =  31,      /*!< Do a Page */
    cmdMwi       =  32,      /*!< Indicate : message waiting */
    cmdUnsupport =  33,      /*!< We have received an unsupported message */
    cmdTransfer  =  34,      /*!< Initiate the remote end to do a transfer */
    cmdProvision =  35,      /*!< Provision the remote end    */
    cmdFwDownl   =  36,      /*!< The remote end must download some firmware    */
    cmdFwData    =  37       /*!< This message contains firmware.    */
  };
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet.
     Classes generated like this are used to handle received data. */
  IAX2FullFrameProtocol(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet.
     Classes generated like this are used to handle received data. */
  IAX2FullFrameProtocol(IAX2FullFrame & srcFrame);
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameProtocol(IAX2Processor *processor,         /*!< Iax Processor from which this frame originates            */ 
		    PINDEX subClassValue,            /*!< IAX protocol command for remote end to process         */
		    ConnectionRequired needCon = IAX2FullFrame::callActive
		                                     /*!< this frame is only sent if the Connection class exists */
		    );
  
  /**Construction from an Connection class. 
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameProtocol(IAX2Processor *processor,         /*!< Iax Processor from which this frame originates            */ 
		    ProtocolSc  subClassValue,       /*!< IAX protocol command for remote end to process         */
		    ConnectionRequired needCon=IAX2FullFrame::callActive 
		                                     /*!< this frame is only sent if the Connection class exists */
		    );
  
  /**Construction from a Connection class. 
     Classes generated from this are then on sent to a remote endpoint.
     
     We have received a IAX2FullFrameProtocol, and this constructor is used to create a reply.
     Use the iseqno and time stamp from the supplied frame to construct the reply */
  IAX2FullFrameProtocol(IAX2Processor *processor,         /*!< Iax Processor from which this frame originates            */ 
		    ProtocolSc  subClassValue,       /*!< IAX protocol command for remote end to process         */
		    IAX2FullFrame *inReplyTo,            /*!< this message was sent in reply to this frame           */
		    ConnectionRequired needCon = IAX2FullFrame::callActive
		                                     /*!< this frame is only sent if the Connection class exists */
		    );
  
  /**Destructor, which deletes all current Information Elements */
  virtual ~IAX2FullFrameProtocol();
  
  /**Set internal variable to say that this frame does not need to be retransmitted*/
  void SetRetransmissionRequired();
  
  /**Mark this frame as having (or not having) information elements*/
  virtual BOOL InformationElementsPresent() { return !ieElements.IsEmpty(); }
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const; 
  
  /**Return a pointer to the n'th Ie in the internal list. If it is not
     there, a NULL is returned */
  IAX2Ie *GetIeAt(PINDEX i) {      return ieElements.GetIeAt(i); }
  
  /**Add a new Information Element (Ie) to the intenral list */
  void AppendIe(IAX2Ie *newElement) { ieElements.AppendIe(newElement); }
  
  /**Write the contents of the Ie internal list to the frame data array.
     This is usually done in preparation to transmitting this frame */
  void WriteIeAsBinaryData();
  
  /**Transfer the data (stored in the IeList) and place it in into
     the IeData class.  This is done when precessing a frame we
     have received from an external node, which has to be stored in the IeData class*/
  void CopyDataFromIeListTo(IAX2IeData &res);
  
  /**Look through the list of IEs, and look for remote capabability
     and preferred codec */
  void GetRemoteCapability(unsigned int & capability, unsigned int & preferred);

  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return iax2ProtocolType; }
  
 protected:
  
  /**Read the information elements from the incoming data array 
     to generate a list of information element classes*/
  BOOL ReadInformationElements();
  
  /**A list of the IEs read from/(or  written to) the data section of this frame,*/
  IAX2IeList ieElements;
};

/////////////////////////////////////////////////////////////////////////////    
/**Class for transfering text. These frames are sent reliably.
   There is no data in the subclass section.
   
   The text is carried in the data section.
*/
class IAX2FullFrameText : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameText, IAX2FullFrame);
 public:

  /**Construction from a Connection class.
     Classes generated from this are then on sent to a remote endpoint. */
  IAX2FullFrameText(IAX2Processor *processor,       /*!< Iax Processor from which this frame originates      */
		const PString&  textValue/*!< text to send to remote end   */
		);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameText(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameText(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return textType; }

  /**Return the text data*/
  PString GetTextString() const;

 protected:

  /**The text string that will be placed in the body of this message */
  PString internalText;
};
/////////////////////////////////////////////////////////////////////////////    

/**Class for transfering images. These frames are sent reliably.
   The subclass describes the image compression format.
   
   The contents of the data section is the raw image data */
class IAX2FullFrameImage : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameImage, IAX2FullFrame);
 public:
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameImage(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameImage(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return imageType; }
 protected:
};

/////////////////////////////////////////////////////////////////////////////    

/**Class for transfering html. These frames are sent reliably.
   The subclass describes the html frame type.
   
   The contents of the data section is message specific */
class IAX2FullFrameHtml : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameHtml, IAX2FullFrame);
 public:
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameHtml(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameHtml(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return htmlType; }
 protected:
};

/////////////////////////////////////////////////////////////////////////////    
/**Class for transfering Cng (comfort noise generation). These frames are sent reliably.
   

The contents of the data section is message specific */
class IAX2FullFrameCng : public IAX2FullFrame
{
  PCLASSINFO(IAX2FullFrameCng, IAX2FullFrame);
 public:
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameCng(IAX2Frame & srcFrame);
  
  /**Construction from a supplied dataframe.
     In this case, this class is filled from an incoming data packet*/
  IAX2FullFrameCng(IAX2FullFrame & srcFrame);
  
  /**Get text description of the subclass contents*/
  virtual PString GetSubClassName() const;
  
  /**Return the IAX2FullFrame type represented here (voice, protocol, session etc*/
  virtual BYTE GetFullFrameType() { return cngType; }
 protected:
};

/////////////////////////////////////////////////////////////////////////////    

PDECLARE_LIST (IAX2FrameList, IAX2Frame *)
#ifdef DOC_PLUS_PLUS     //This makes emacs bracket matching code happy.
/** A list of all frames waiting for processing
	 
    Note please, this class is thread safe.
     
   You do not need to protect acces to this class.
*/     
class IAX2FrameList : public IAX2Frame *  
{
#endif
 public:
  ~IAX2FrameList();
  
  /**Report the frames queued in this list*/
  void ReportList();
  
  /**Get pointer to last frame in the list. Remove this frame from the list */
  IAX2Frame *GetLastFrame();
  
  /**Removing item from list will not automatically delete it */
  void Initialise() {  DisallowDeleteObjects(); }
    
  /**True if this frame list is empty*/
  BOOL Empty() { return GetSize() == 0; }
  
  /**Copy to this frame the contents of the frameList pointed to by src*/
  void GrabContents(IAX2FrameList &src);
  
  /**Delete the frame that has been sent, which is waiting for this
   * reply. The reply is the argument. */
  void DeleteMatchingSendFrame(IAX2FullFrame *reply);
  
  /**Add the frame (supplied as an argument) to the end of this list*/
  void AddNewFrame(IAX2Frame *src);
  
  /**Get a list of frames to send, and delete the timed out frames */
  void GetResendFramesDeleteOldFrames(IAX2FrameList & framesToSend);
  
  /**Thread safe read of the number of elements on this list. */
  virtual PINDEX GetSize() { PWaitAndSignal m(mutex); return PAbstractList::GetSize(); }
  
  /**Mark every frame on this list as having been resent*/
  void MarkAllAsResent();
  
 protected:
  /**NON Thread safe read of the number of elements on this list. */
  virtual PINDEX GetEntries() { return PAbstractList::GetSize(); }
  
  /**Local variable which protects access. */
  PMutex mutex;
};


/////////////////////////////////////////////////////////////////////////////    


#endif // FRAME_H
/* The comment below is magic for those who use emacs to edit this file. */
/* With the comment below, the tab key does auto indent to 4 spaces.     */

/*
 * Local Variables:
 * mode:c
 * c-file-style:linux
 * c-basic-offset:2
 * End:
 */