Sayonara Player
StreamServer.h
1 /* StreamServer.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef STREAM_SERVER_H
22 #define STREAM_SERVER_H
23 
24 #include "StreamWriter.h"
25 #include "Helper/Settings/SayonaraClass.h"
26 #include "Helper/Pimpl.h"
27 
28 #include <QThread>
29 
30 class QTcpSocket;
35 class StreamServer :
36  public QThread,
37  protected SayonaraClass
38 {
39  Q_OBJECT
40  PIMPL(StreamServer)
41 
42  signals:
43  void sig_new_connection(const QString& ip);
44  void sig_connection_closed(const QString& ip);
45  void sig_can_listen(bool);
46 
47  public:
48  explicit StreamServer(QObject* parent=nullptr);
49  ~StreamServer();
50 
51  private:
52  // create new server and listen
53  void create_server();
54 
55  // listen for connection
56  bool listen_for_connection();
57 
58 
59  protected:
60  void run() override;
61 
62 
63  public slots:
64 
65  void accept_client(QTcpSocket* socket, const QString& ip);
66  void reject_client(QTcpSocket* socket, const QString& ip);
67  void dismiss(int idx);
68 
69  void disconnect(StreamWriterPtr sw);
70  void disconnect_all();
71 
72  void server_close();
73  void stop();
74  void retry();
75 
76 
77  private slots:
78  void track_changed(const MetaData&);
79  void server_destroyed();
80 
81  void new_client_request();
82  void disconnected(StreamWriter* sw);
83  void new_connection(const QString& ip);
84 
85  void _sl_active_changed();
86  void _sl_port_changed();
87  void _sl_mp3_enc_found();
88 };
89 
90 #endif
The StreamWriter class. This class is the interface between StreamDataSender and StreamServer. It watches the client socket and spreads data to its client.
Definition: StreamWriter.h:41
The StreamServer class. This class is listening for new connections and holds and administrates curre...
Definition: StreamServer.h:35
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
The MetaData class MetaDataHelper.
Definition: MetaData.h:55