1 /* 2 * SpanDSP - a series of DSP components for telephony 3 * 4 * private/playout.h 5 * 6 * Written by Steve Underwood <steveu@coppice.org> 7 * 8 * Copyright (C) 2005 Steve Underwood 9 * 10 * All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 2.1, 14 * as published by the Free Software Foundation. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 */ 25 26 #if !defined(_SPANDSP_PRIVATE_PLAYOUT_H_) 27 #define _SPANDSP_PRIVATE_PLAYOUT_H_ 28 29 struct playout_frame_s 30 { 31 /*! The actual frame data */ 32 void *data; 33 /*! The type of frame */ 34 int type; 35 /*! The timestamp assigned by the sending end */ 36 timestamp_t sender_stamp; 37 /*! The timespan covered by the data in this frame */ 38 timestamp_t sender_len; 39 /*! The timestamp assigned by the receiving end */ 40 timestamp_t receiver_stamp; 41 /*! Pointer to the next earlier frame */ 42 struct playout_frame_s *earlier; 43 /*! Pointer to the next later frame */ 44 struct playout_frame_s *later; 45 }; 46 47 /*! 48 Playout (jitter buffer) descriptor. This defines the working state 49 for a single instance of playout buffering. 50 */ 51 struct playout_state_s 52 { 53 /*! True if the buffer is dynamically sized */ 54 bool dynamic; 55 /*! The minimum length (dynamic) or fixed length (static) of the buffer */ 56 int min_length; 57 /*! The maximum length (dynamic) or fixed length (static) of the buffer */ 58 int max_length; 59 /*! The target filter threshold for adjusting dynamic buffering. */ 60 int dropable_threshold; 61 62 int start; 63 64 /*! The queued frame list */ 65 playout_frame_t *first_frame; 66 playout_frame_t *last_frame; 67 /*! The free frame pool */ 68 playout_frame_t *free_frames; 69 70 /*! The total frames input to the buffer, to date. */ 71 int frames_in; 72 /*! The total frames output from the buffer, to date. */ 73 int frames_out; 74 /*! The number of frames received out of sequence. */ 75 int frames_oos; 76 /*! The number of frames which were discarded, due to late arrival. */ 77 int frames_late; 78 /*! The number of frames which were never received. */ 79 int frames_missing; 80 /*! The number of frames trimmed from the stream, due to buffer shrinkage. */ 81 int frames_trimmed; 82 83 timestamp_t latest_expected; 84 /*! The present jitter adjustment */ 85 timestamp_t current; 86 /*! The sender_stamp of the last speech frame */ 87 timestamp_t last_speech_sender_stamp; 88 /*! The duration of the last speech frame */ 89 timestamp_t last_speech_sender_len; 90 91 int not_first; 92 /*! The time since the target buffer length was last changed. */ 93 timestamp_t since_last_step; 94 /*! Filter state for tracking the packets arriving just in time */ 95 int32_t state_just_in_time; 96 /*! Filter state for tracking the packets arriving late */ 97 int32_t state_late; 98 /*! The current target length of the buffer */ 99 int target_buffer_length; 100 /*! The current actual length of the buffer, which may lag behind the target value */ 101 int actual_buffer_length; 102 }; 103 104 #endif 105 /*- End of file ------------------------------------------------------------*/ 106