Public feed #376597

Mine

public text v1 · immutable
Raw Edit
·published 2007-03-01 03:48 UTC
rendered paste body
int getMsInJitter() {
	const static int MAX_MARGIN = 30;
	const static int SPEEX_JITTER_MAX_BUFFER_SIZE = 200;
	struct TmpJitterBuffer {
		spx_uint32_t pointer_timestamp;                                        /**< Timestamp of what we will *get* next */
		spx_uint32_t current_timestamp;                                        /**< Timestamp of the local clock (what we will *play* next) */
		
		char *buf[SPEEX_JITTER_MAX_BUFFER_SIZE];                               /**< Buffer of packets (NULL if slot is free) */
		spx_uint32_t timestamp[SPEEX_JITTER_MAX_BUFFER_SIZE];                  /**< Timestamp of packet                 */
		int span[SPEEX_JITTER_MAX_BUFFER_SIZE];                                /**< Timestamp of packet                 */
		int len[SPEEX_JITTER_MAX_BUFFER_SIZE];                                 /**< Number of bytes in packet           */
		
		int tick_size;                                                         /**< Output granularity                  */
		int reset_state;                                                       /**< True if state was just reset        */
		int buffer_margin;                                                     /**< How many frames we want to keep in the buffer (lower bound) */
		
		int lost_count;                                                        /**< Number of consecutive lost packets  */
		float shortterm_margin[MAX_MARGIN];                                    /**< Short term margin histogram         */
		float longterm_margin[MAX_MARGIN];                                     /**< Long term margin histogram          */
		float loss_rate;                                                       /**< Average loss rate                   */
	};
	int count = 0;
	for (int j=0;j<SPEEX_JITTER_MAX_BUFFER_SIZE;j++) {
		if ((TmpJitterBuffer*)(void*)m_pJitterBuffer->buf[j]) {
			count++;
		}
	}
	return count * 20; //20ms per packet
}