Sayonara Player
StreamServer.h
1 /* StreamServer.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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 "Utils/Pimpl.h"
26 
27 // also needed for AcceptError
28 #include <QTcpSocket>
29 
30 class PlayManager;
32 
37 class StreamServer :
38  public QObject
39 {
40  Q_OBJECT
41  PIMPL(StreamServer)
42 
43  signals:
44  void sigNewConnection(const QString& ip);
45  void sigConnectionClosed(const QString& ip);
46  void sigListening(bool);
47 
48  public:
49  explicit StreamServer(PlayManager* playManager, RawAudioDataProvider* audioDataProvider, QObject* parent = nullptr);
50  ~StreamServer();
51 
52  QStringList connectedClients() const;
53 
54  public slots:
55  void dismiss(int idx);
56 
57  void disconnect(StreamWriterPtr sw);
58  void disconnectAll();
59 
60  bool listen();
61  void close();
62  void restart();
63 
64  private slots:
65  void acceptClient(QTcpSocket* socket, const QString& ip);
66  void rejectClient(QTcpSocket* socket, const QString& ip);
67 
68  void serverDestroyed();
69 
70  void newClientRequest();
71  void newClientRequestError(QAbstractSocket::SocketError socketError);
72 
73  void disconnected(StreamWriter* sw);
74  void newConnection(const QString& ip);
75 
76  void activeChanged();
77  void portChanged();
78 };
79 
80 #endif
Global handler for current playback state (Singleton)
Definition: PlayManager.h:36
Definition: AudioDataProvider.h:55
The StreamServer class. This class is listening for new connections and holds and administrates curre...
Definition: StreamServer.h:39
The StreamWriter class. This class is the interface between StreamDataSender and StreamServer....
Definition: StreamWriter.h:43