00001 /* Copyright (C) 2002 Jean-Marc Valin 00002 File: speex_jitter.h 00003 00004 Adaptive jitter buffer for Speex 00005 00006 Redistribution and use in source and binary forms, with or without 00007 modification, are permitted provided that the following conditions 00008 are met: 00009 00010 - Redistributions of source code must retain the above copyright 00011 notice, this list of conditions and the following disclaimer. 00012 00013 - Redistributions in binary form must reproduce the above copyright 00014 notice, this list of conditions and the following disclaimer in the 00015 documentation and/or other materials provided with the distribution. 00016 00017 - Neither the name of the Xiph.org Foundation nor the names of its 00018 contributors may be used to endorse or promote products derived from 00019 this software without specific prior written permission. 00020 00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 00025 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00027 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00028 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00029 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00030 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00031 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 00033 */ 00034 00035 #include "speex.h" 00036 #include "speex_bits.h" 00037 00038 #ifndef SPEEX_JITTER_H 00039 #define SPEEX_JITTER_H 00040 00041 #define SPEEX_JITTER_MAX_PACKET_SIZE 2000 00042 #define SPEEX_JITTER_MAX_BUFFER_SIZE 20 00043 00044 typedef struct SpeexJitter { 00045 int buffer_size; 00046 int pointer_timestamp; 00047 00048 SpeexBits current_packet; 00049 int valid_bits; 00050 00051 char buf[SPEEX_JITTER_MAX_BUFFER_SIZE][SPEEX_JITTER_MAX_PACKET_SIZE]; 00052 int timestamp[SPEEX_JITTER_MAX_BUFFER_SIZE]; 00053 int len[SPEEX_JITTER_MAX_BUFFER_SIZE]; 00054 00055 void *dec; 00056 int frame_size; 00057 int frame_time; 00058 00059 int underflow_count; 00060 int drop_frame; 00061 int interp_frame; 00062 00063 } SpeexJitter; 00064 00065 void speex_jitter_init(SpeexJitter *jitter, void *decoder, int sampling_rate); 00066 00067 void speex_jitter_destroy(SpeexJitter *jitter); 00068 00069 void speex_jitter_put(SpeexJitter *jitter, char *packet, int len, int time); 00070 00071 void speex_jitter_get(SpeexJitter *jitter, float *out); 00072 00073 00074 #endif