]> git.tdb.fi Git - xinema.git/blob - remote/source/xinemacontrol.h
573207365c27b2dcfcbd0422620f176bd688faba
[xinema.git] / remote / source / xinemacontrol.h
1 #ifndef XINEMACONTROL_H_
2 #define XINEMACONTROL_H_
3
4 #include <QObject>
5 #include <QTcpSocket>
6
7 class XinemaControl: public QObject
8 {
9         Q_OBJECT
10
11 public:
12         enum PlaybackState
13         {
14                 STOPPED,
15                 PAUSED,
16                 PLAYING
17         };
18
19         enum
20         {
21                 OFF = -1
22         };
23
24 private:
25         QTcpSocket socket;
26         QByteArray buffer;
27         PlaybackState playback_state;
28         QString title;
29         float duration;
30         float position;
31         QStringList audio_channels;
32         QStringList spu_channels;
33         int current_audio_channel;
34         int current_spu_channel;
35
36 public:
37         XinemaControl();
38
39         void connect(const QHostAddress &);
40         bool is_connected() const;
41
42         void list_directory(const QString &);
43         void play_file(const QString &);
44
45         PlaybackState get_playback_state() const { return playback_state; }
46         const QString &get_title() const { return title; }
47         float get_duration() const { return duration; }
48         float get_position() const { return position; }
49
50         void play();
51         void seek(float);
52         void pause();
53         void stop();
54
55         const QStringList &get_audio_channels() const { return audio_channels; }
56         const QStringList &get_spu_channels() const { return spu_channels; }
57         void select_audio_channel(int);
58         void select_spu_channel(int);
59         int get_current_audio_channel() const { return current_audio_channel; }
60         int get_current_spu_channel() const { return current_spu_channel; }
61
62 signals:
63         void connected();
64         void disconnected();
65         void directory_started(const QString &);
66         void file_added(const QString &);
67         void subdirectory_added(const QString &);
68         void playback_state_changed(PlaybackState);
69         void title_changed(const QString &);
70         void duration_changed(float);
71         void position_changed(float);
72         void channels_changed();
73         void current_audio_channel_changed(int);
74         void current_spu_channel_changed(int);
75
76 private:
77         void send_request(const QString &);
78
79 private slots:
80         void data_available();
81         void process_reply(const QString &);
82         static int convert_channel(const QString &);
83         static void resize_list(QStringList &, int);
84 };
85
86 #endif