summaryrefslogtreecommitdiff
path: root/plexgdm.h
blob: 8db4dac3cc69dc0087af0bd0ef3f953f224510c3 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef PLEXGDM_H
#define PLEXGDM_H

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <vector>

#include <Poco/Net/SocketAddress.h>
#include <Poco/Net/MulticastSocket.h>
#include <Poco/Format.h>

#include <vdr/thread.h>
#include <vdr/tools.h>

#include "PlexServer.h"

namespace plexclient {

    class plexgdm : public cThread {
    public:
        static plexgdm &GetInstance() {
            static plexgdm instance;
            return instance;
        }

        ~plexgdm();

        void clientDetails(std::string c_id, std::string c_name, std::string c_port, std::string c_product,
                           std::string c_version);

        std::string getClientDetails();

        PlexServer *GetServer(std::string ip, int port);

        PlexServer *GetServer(std::string uuid);

        bool AddServer(PlexServer server);

        PlexServer *GetFirstServer();

        void discover();

        void Action(void);

        void stopRegistration();

        std::vector<PlexServer> &GetPlexservers() {
            return m_vServers;
        }

    protected:


    private:
        plexgdm();

        cMutex m_mutex;
        cCondVar m_waitCondition;
        int _discoverInterval;
        cTimeMs _discoverTimer;
        bool _helloSent;

        Poco::Net::SocketAddress m_discoverAdress;
        Poco::Net::SocketAddress m_clientRegisterGroup;

        volatile int m_discoveryInterval;

        volatile bool m_discoveryComplete;
        volatile bool m_clientRegistered;
        volatile bool m_discoveryIsRunning;
        volatile bool m_registrationIsRunning;

        std::string _discoverMessage;
        std::string _clientHeader;
        std::string _clientData;
        std::string _clientId;
        std::string _multicastAddress;
        int _clientUpdatePort;
        std::vector<PlexServer> m_vServers;
    };

}
#endif // PLEXGDM_H