HTTPConnectionManager.h 2.64 KB
Newer Older
Christopher Mueller's avatar
Christopher Mueller committed
1 2 3 4 5 6 7 8 9
/*
 * HTTPConnectionManager.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 HTTPCONNECTIONMANAGER_H_
#define HTTPCONNECTIONMANAGER_H_

28 29 30 31
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

32 33
#include "../logic/IDownloadRateObserver.h"

Christopher Mueller's avatar
Christopher Mueller committed
34 35
#include <vlc_common.h>
#include <vector>
36
#include <string>
Christopher Mueller's avatar
Christopher Mueller committed
37

38
namespace adaptive
Christopher Mueller's avatar
Christopher Mueller committed
39 40 41
{
    namespace http
    {
42
        class HTTPConnection;
43
        class Downloader;
44

45
        class HTTPConnectionManager : public IDownloadRateObserver
Christopher Mueller's avatar
Christopher Mueller committed
46 47
        {
            public:
48
                HTTPConnectionManager           (vlc_object_t *stream);
Christopher Mueller's avatar
Christopher Mueller committed
49 50
                virtual ~HTTPConnectionManager  ();

51
                void    closeAllConnections ();
52 53 54
                HTTPConnection * getConnection(const std::string &scheme,
                                               const std::string &hostname,
                                               uint16_t port);
55

56 57
                virtual void updateDownloadRate(size_t, mtime_t); /* reimpl */
                void setDownloadRateObserver(IDownloadRateObserver *);
58
                Downloader *downloader;
59

60
            private:
61 62
                void    releaseAllConnections ();
                vlc_mutex_t                                         lock;
63 64
                std::vector<HTTPConnection *>                       connectionPool;
                vlc_object_t                                       *stream;
65
                IDownloadRateObserver                              *rateObserver;
66
                HTTPConnection * getConnection(const std::string &hostname, uint16_t port, int);
Christopher Mueller's avatar
Christopher Mueller committed
67 68 69 70 71
        };
    }
}

#endif /* HTTPCONNECTIONMANAGER_H_ */