summaryrefslogtreecommitdiff
path: root/dispatcher.h
blob: 256aa67202f3cc791e9399372ad34e219477f955 (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
89
90
91
92
93
/*
 * dispatcher.h
 */

#ifndef __DISPATCHER_H
#define __DISPATCHER_H

#include "audioreceiver.h"

#include <vdr/device.h>
#include <vdr/thread.h>
#include <vdr/status.h>

class cChannelList : public cListObject {
    char *channelstring;
    char *comment;

    tChannelID channel_id;
    cChannel *channel;

    cAudioReceiver *audioreceiver;
public:
    cChannelList(void);
    cChannelList(const char *_channelstring, const char *_comment);
    void Set(const char *_channelstring, const char *_comment);
    cAudioReceiver *NewAudioReceiver();
    void DeleteAudioReceiver(void);
    bool Parse(char *s);
    const char *ChannelString(void) { return channelstring; }
    const char *Comment(void) { return comment; }
    cAudioReceiver *AudioReceiver(void) { return audioreceiver; }
    cChannel *Channel(void) { return channel; }
    ~cChannelList();
};


class cRecorderChannels : public cConfig<cChannelList> {
    cChannelList *current;
public:
    virtual bool Load(const char *filename, bool dummy=false);
    void SetSource(cChannelList *source) { current=source; }
    cChannelList *GetChannel(void) { return current; }
};

class cDispatcher : public cThread, cStatus {
private:
        bool active;
        int counter;
        // cAudioReceiver **audioreceivers;

        void attach_receivers(void);

        int get_transponder_of_first_receiver(int device_number);
	/*
	 * returns the transponder of the first attached audioreceiver on the
	 * given device
	 */

        void detach_receivers(int detach_device_number, int devices_remaining);
        /*
         * detaches all audioreceivers on the given device_number, until
         * devices_remaining are remaining.
         * if detach_device_number == -1, all audioreceivers are
         * detached.
         */

        bool check_free_disc_space(void);
protected:
        virtual void Activate(bool on);
        virtual void Action(void);

        virtual void ChannelSwitch(const cDevice *device, int channel_number, bool LiveView);
public:
	cDispatcher(void);
	~cDispatcher();

        void stop(void) { Activate(false); }
        void start(void) { Activate(true); }
        bool is_active(void) { return active; }

        int get_recording_receivers(void);
        int get_recording_status(const cChannel *channel);
        int get_attached_receivers(int device_number);
        int get_no_of_channels(void);

        /*
         * returns the number of the attached audioreceivers on the given
         * device. if device_number == -1, the number of all attached
         * audioreceivers is returned.
         */
};

#endif /* __DISPATCHER_H */