Example #1
0
        /// <summary>
        /// Take the following timing into consideration for future calculations
        /// </summary>
        /// <param name="timing"></param>
        void UpdateTimings(int timing)
        {
            if (timing < short.MinValue)
            {
                timing = short.MinValue;
            }
            if (timing > short.MaxValue)
            {
                timing = short.MaxValue;
            }
            short localTiming = (short)timing;

            /* If the current sub-window is full, perform a rotation and discard oldest sub-widow */
            if (timeBuffers[0].curr_count >= subwindow_size)
            {
                int i;
                /*fprintf(stderr, "Rotate buffer\n");*/
                TimingBuffer tmp = timeBuffers[MAX_BUFFERS - 1];
                for (i = MAX_BUFFERS - 1; i >= 1; i--)
                {
                    timeBuffers[i] = timeBuffers[i - 1];
                }
                timeBuffers[0] = tmp;
                timeBuffers[0].Init();
            }
            timeBuffers[0].Add(localTiming);
        }
Example #2
0
        /// <summary>
        /// Initializes the jitterbuffer with a given <paramref name="step_size"/>.
        /// </summary>
        /// <param name="step_size"></param>
        public void Init(int step_size)
        {
            if (step_size <= 0)
            {
                throw new ArgumentOutOfRangeException("step_size");
            }

            int i;
            int tmp;

            for (i = 0; i < MAX_BUFFER_SIZE; i++)
            {
                packets[i].data = null;
            }

            for (i = 0; i < MAX_BUFFERS; i++)
            {
                _tb[i] = new TimingBuffer();
            }

            delay_step       = step_size;
            concealment_size = step_size;
            /*FIXME: Should this be 0 or 1?*/
            buffer_margin         = 0;
            late_cutoff           = 50;
            DestroyBufferCallback = null;
            latency_tradeoff      = 0;
            auto_adjust           = true;
            tmp = 4;
            SetMaxLateRate(tmp);
            Reset();
        }