1 /***************************************************************************
2 
3     copyright            : (C) 2006 by mean
4     email                : fixounet@free.fr
5  ***************************************************************************/
6 
7 /***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15 #ifndef ADM_PACKET_QUEUE_H
16 #define ADM_PACKET_QUEUE_H
17 
18 typedef struct
19 {
20   uint32_t      size;       //< Size of the packet
21   uint32_t      sample;
22   uint32_t      startAt;    //< Index in the buffer where the packet start
23 }Slots;
24 /*!
25   This class defines an packetQueue. The big buffer is split into slots
26   (dynamically allocated).
27   */
28 class PacketQueue
29 {
30   protected:
31             admMutex *_mutex;
32             admCond  *_pusherCond;
33             admCond  *_poperCond;
34             uint32_t _nbSlots;
35             Slots    *_slots;
36             uint8_t  *_buffer;
37             uint32_t  _bufferSize;
38 
39             uint32_t  _slotHead,_slotQueue;
40             uint32_t  _bufferHead, _bufferQueue;
41             char      *_name;
42             uint8_t   _eof;
43             uint32_t  availableSpace(void);
44             uint8_t  _aborted;
45   public:
46           PacketQueue(const char *name,uint32_t nbSlot,uint32_t buffSize);
47           ~PacketQueue();
48           uint8_t   Push(uint8_t *ptr, uint32_t size,uint32_t sample);
49           uint8_t   Pop(uint8_t *ptr, uint32_t *size,uint32_t *sample);
50           uint8_t   IsFull(void);
51           uint8_t   IsEmpty(void);
52           uint8_t   Finished(void);
53           uint8_t   Abort(void);
54           uint8_t   isEof(void);
isAborted(void)55           uint8_t   isAborted(void) {return _aborted;}
56 };
57 
58 
59 #endif
60 //EOF
61 
62