congestiondetector.h 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) implementation with additional features.
 * Copyright (C) 2017 Belledonne Communications SARL
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */


#ifndef CONGESTIONDETECTOR_H
#define CONGESTIONDETECTOR_H

#include <ortp/port.h>
#include <ortp/utils.h>
26
#include <bctoolbox/list.h>
27 28 29
struct _JitterControl;

typedef enum _OrtpCongestionState {
30 31 32 33
	CongestionStateNormal,
	CongestionStateSuspected,
	CongestionStateDetected,
	CongestionStateResolving
34 35 36 37 38
} OrtpCongestionState;

typedef struct _OrtpCongestionDetector{
	OrtpKalmanRLS rls;
	uint64_t start_ms;
39
	uint64_t last_packet_recv;
40
	uint32_t loss_begin, seq_begin;
41
	bool_t initialized;
42 43
	bool_t is_in_congestion;
	bool_t skip;
44
	bool_t too_much_loss;
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	OrtpCongestionState state;
	struct _RtpSession *session;
}OrtpCongestionDetector;

OrtpCongestionDetector * ortp_congestion_detector_new(struct _RtpSession *session);

/*
 * Returns TRUE if the congestion state is changed.
**/
bool_t ortp_congestion_detector_record(OrtpCongestionDetector *obj, uint32_t packet_ts, uint32_t cur_str_ts);

void ortp_congestion_detector_destroy(OrtpCongestionDetector *obj);

void ortp_congestion_detector_reset(OrtpCongestionDetector *cd);

#endif