Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / libtransmission / ratecontrol.h
blob3b7132d2de2da1c690d3da223a6c9459890ca053
1 /******************************************************************************
2 * $Id: ratecontrol.h 10931 2010-07-03 00:25:22Z charles $
4 * Copyright (c) 2006-2008 Transmission authors and contributors
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
25 #ifndef __TRANSMISSION__
26 #error only libtransmission should #include this header.
27 #endif
29 #ifndef _TR_RATECONTROL_H_
30 #define _TR_RATECONTROL_H_
32 #include <string.h> /* memset() */
34 #include "transmission.h"
36 /* these are PRIVATE IMPLEMENTATION details that should not be touched.
37 * it's included in the header for inlining and composition. */
38 enum
40 TR_RC_HISTORY_MSEC = 2000,
41 TR_RC_GRANULARITY_MSEC = 250,
42 TR_RC_HISTORY_SIZE = ( TR_RC_HISTORY_MSEC / TR_RC_GRANULARITY_MSEC )
45 /* these are PRIVATE IMPLEMENTATION details that should not be touched.
46 * it's included in the header for inlining and composition. */
47 struct tr_transfer
49 uint64_t date;
50 uint64_t size;
53 /* these are PRIVATE IMPLEMENTATION details that should not be touched.
54 * it's included in the header for inlining and composition. */
55 typedef struct tr_ratecontrol
57 int newest;
58 struct tr_transfer transfers[TR_RC_HISTORY_SIZE];
60 tr_ratecontrol;
62 /***
63 ****
64 ***/
66 static inline void tr_rcConstruct ( tr_ratecontrol * rc ) { memset( rc, 0, sizeof( tr_ratecontrol ) ); }
68 static inline void tr_rcDestruct ( tr_ratecontrol * rc ) { memset( rc, 0xDEAD, sizeof( tr_ratecontrol ) ); }
70 void tr_rcTransferred ( tr_ratecontrol * ratecontrol,
71 size_t byteCount );
73 int tr_rcRate_Bps ( const tr_ratecontrol * ratecontrol,
74 uint64_t now );
77 #endif