RateBasedAdaptationLogic.h 2.62 KB
Newer Older
Christopher Mueller's avatar
Christopher Mueller committed
1 2 3 4 5 6 7 8 9
/*
 * RateBasedAdaptationLogic.h
 *****************************************************************************
 * Copyright (C) 2010 - 2011 Klagenfurt University
 *
 * Created on: Aug 10, 2010
 * Authors: Christopher Mueller <christopher.mueller@itec.uni-klu.ac.at>
 *          Christian Timmerer  <christian.timmerer@itec.uni-klu.ac.at>
 *
10 11
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
Christopher Mueller's avatar
Christopher Mueller committed
12 13 14 15 16
 * by the Free Software Foundation; either version 2.1 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
17 18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
Christopher Mueller's avatar
Christopher Mueller committed
19 20
 *
 * You should have received a copy of the GNU Lesser General Public License
21 22
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
Christopher Mueller's avatar
Christopher Mueller committed
23 24 25 26 27
 *****************************************************************************/

#ifndef RATEBASEDADAPTATIONLOGIC_H_
#define RATEBASEDADAPTATIONLOGIC_H_

28
#include "AbstractAdaptationLogic.h"
29
#include "../tools/MovingAverage.hpp"
Christopher Mueller's avatar
Christopher Mueller committed
30

31
namespace adaptive
Christopher Mueller's avatar
Christopher Mueller committed
32 33 34
{
    namespace logic
    {
35

Christopher Mueller's avatar
Christopher Mueller committed
36 37 38
        class RateBasedAdaptationLogic : public AbstractAdaptationLogic
        {
            public:
39
                RateBasedAdaptationLogic            (vlc_object_t *);
40
                virtual ~RateBasedAdaptationLogic   ();
Christopher Mueller's avatar
Christopher Mueller committed
41

42
                BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *);
43
                virtual void updateDownloadRate(const ID &, size_t, mtime_t); /* reimpl */
44
                virtual void trackerEvent(const SegmentTrackerEvent &); /* reimpl */
Christopher Mueller's avatar
Christopher Mueller committed
45 46

            private:
47
                size_t                  bpsAvg;
48
                size_t                  currentBps;
49
                size_t                  usedBps;
50
                vlc_object_t *          p_obj;
51

52
                MovingAverage<size_t>   average;
53 54 55

                size_t                  dlsize;
                mtime_t                 dllength;
56 57

                vlc_mutex_t             lock;
Christopher Mueller's avatar
Christopher Mueller committed
58
        };
59 60 61 62

        class FixedRateAdaptationLogic : public AbstractAdaptationLogic
        {
            public:
63
                FixedRateAdaptationLogic(size_t);
64

65
                BaseRepresentation *getNextRepresentation(BaseAdaptationSet *, BaseRepresentation *);
66 67 68 69

            private:
                size_t                  currentBps;
        };
Christopher Mueller's avatar
Christopher Mueller committed
70 71 72 73
    }
}

#endif /* RATEBASEDADAPTATIONLOGIC_H_ */