1 /*
2  *
3  *
4  * Inter Asterisk Exchange 2
5  *
6  * A thread safe list of sound packets.
7  *
8  * Open Phone Abstraction Library (OPAL)
9  *
10  * Copyright (c) 2005 Indranet Technologies Ltd.
11  *
12  * The contents of this file are subject to the Mozilla Public License
13  * Version 1.0 (the "License"); you may not use this file except in
14  * compliance with the License. You may obtain a copy of the License at
15  * http://www.mozilla.org/MPL/
16  *
17  * Software distributed under the License is distributed on an "AS IS"
18  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19  * the License for the specific language governing rights and limitations
20  * under the License.
21  *
22  * The Original Code is Open Phone Abstraction Library.
23  *
24  * The Initial Developer of the Original Code is Indranet Technologies Ltd.
25  *
26  * The author of this code is Derek J Smithies
27  *
28  * $Revision: 24606 $
29  * $Author: dereksmithies $
30  * $Date: 2010-07-28 22:51:05 -0500 (Wed, 28 Jul 2010) $
31  */
32 
33 #ifndef OPAL_IAX2_SOUND_H
34 #define OPAL_IAX2_SOUND_H
35 
36 #ifndef _PTLIB_H
37 #include <ptlib.h>
38 #endif
39 
40 #include <opal/buildopts.h>
41 
42 #if OPAL_IAX2
43 
44 #ifdef P_USE_PRAGMA
45 #pragma interface
46 #endif
47 
48 class IAX2Frame;
49 class IAXConnection;
50 class PSoundChannel;
51 
52 ////////////////////////////////////////////////////////////////////////////////
53 
54 /**The soundlist is a list of PBYTEArray pointers, which are the
55    medium of data exchange with the play/record devices.
56 
57    New sound blocks are added to the beginning of the list.
58 
59    Old sound blocks are removed from the end of the list.
60 
61    The IAX2SoundList is a thread safe storage of PBYTEArray structures.
62 */
PDECLARE_LIST(IAX2SoundList,PBYTEArray *)63 PDECLARE_LIST(IAX2SoundList, PBYTEArray *)
64 #ifdef DOC_PLUS_PLUS                           //This makes emacs bracket matching code happy.
65 class IAX2SoundList : public PBYTEArray *
66 {
67 #endif
68  public:
69   /**Destructor, which deletes all sound packets on this list*/
70   ~IAX2SoundList();
71 
72   /**Removing item from list will not automatically delete it */
73   void Initialise() {  DisallowDeleteObjects(); }
74 
75   /**Return a pointer to the last element on the list.
76      This will remove this element from the list.
77      Returns NULL if the list is empty */
78   PBYTEArray *GetLastEntry();
79 
80   /** Place a new data block at the beginning of the last. */
81   void AddNewEntry(PBYTEArray *newEntry);
82 
83   /**Return a copy of all entries, and purge list */
84   void GetAllDeleteAll(IAX2SoundList &dest);
85 
86   /** Thread safe read of the size of the list */
87   PINDEX GetSize() { PWaitAndSignal m(mutex); return PAbstractList::GetSize(); }
88 
89  protected:
90   /**Mutex to give thread safety. */
91   PMutex      mutex;
92 };
93 
94 
95 #endif // OPAL_IAX2
96 
97 #endif // OPAL_IAX2_SOUND_H
98 
99 /* The comment below is magic for those who use emacs to edit this file.
100  * With the comment below, the tab key does auto indent to 2 spaces.
101  *
102  * Local Variables:
103  * mode:c
104  * c-basic-offset:2
105  * End:
106  */
107