bufferpool.h

Go to the documentation of this file.
00001 /* * 
00002  * This file is part of libnemesi
00003  *
00004  * Copyright (C) 2007 by LScube team <team@streaming.polito.it>
00005  * See AUTHORS for more details
00006  * 
00007  * libnemesi is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * libnemesi is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with libnemesi; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  *  
00021  * */
00022 
00042 #ifndef NEMESI_BUFFERPOOL_H
00043 #define NEMESI_BUFFERPOOL_H
00044 #ifdef HAVE_CONFIG_H
00045 #include <config.h>
00046 #endif
00047 #include <stdio.h>
00048 #include <stdlib.h>
00049 #include <string.h>
00050 #include <pthread.h>
00051 #include <stdint.h>
00052             /* #define BP_SLOT_NUM 50 */
00054 /* 1000ms / 20ms = Playout Buffer Size (in seconds) / Required RTP payload size (in seconds) */
00055 #define BP_SLOT_NUM 150        // Bigger buffer. For video needs.
00056 
00059 /*#define BP_SLOT_SIZE 548 *//* 576 - 20 - 8 = Minimum Reassembly Buffer Size - IP datagram header -  UDP hedaer */
00060 #define BP_SLOT_SIZE 2048    /* bigger slot */
00061 
00063 #define BP_SIZE BP_SLOT_NUM*BP_SLOT_SIZE    /* 1 sec G.711 - 8kHz * 8bit
00064                            per sample */
00065 
00066 #define BP_MAX_SIZE BP_SLOT_NUM*50
00067 
00068 
00075 typedef struct {
00076     char x[BP_SLOT_SIZE];    
00079 } bp_slot;
00080 
00088 typedef struct {
00089     int pktlen; 
00090     int prev;   
00091     int next;   
00092 } poitem;
00093 
00101 typedef struct playout_buff_t {
00102     bp_slot **bufferpool;        
00105     poitem pobuff[BP_MAX_SIZE]; 
00108     pthread_mutex_t po_mutex;   
00111     /* pthread_cond_t cond_empty; */
00114     int pocount;            
00115     int pohead;            
00116     int potail;            
00117     uint32_t cycles;            
00119                                          // shawill: probably to be moved.
00120 } playout_buff;
00121 
00131 typedef struct buffer_pool_t {
00132     bp_slot *bufferpool;       
00134     pthread_mutex_t fl_mutex;  
00135     pthread_cond_t cond_full;  
00136     int *freelist;             
00137     int flhead;                
00138     int flcount;               
00139     int size;
00140 } buffer_pool;
00141 
00142 #define PKT_DUPLICATED    1
00143 #define PKT_MISORDERED    2
00144 
00145 int poinit(playout_buff *, buffer_pool *);
00146 int poadd(playout_buff *, int, uint32_t);
00147 int podel(playout_buff *, int);
00148 int bpinit(buffer_pool *);
00149 int bpkill(buffer_pool *);
00150 int bpget(buffer_pool *);
00151 int bpfree(buffer_pool *, int);
00152 int bprmv(buffer_pool *, playout_buff *, int);
00153 int bpenlarge(buffer_pool * bp);
00154 
00155 #endif /* NEMESI_BUFFERPOOL_H */
00156 /* @} */

Generated on Tue Feb 3 03:10:02 2009 for libnemesi by  doxygen 1.5.4