Sayonara Player
StreamWriter.h
1 /* StreamWriter.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_WRITER_H
22 #define STREAM_WRITER_H
23 
24 #include "StreamHttpParser.h"
25 #include "Interfaces/RawSoundReceiver/RawSoundReceiverInterface.h"
26 #include "Helper/Pimpl.h"
27 
28 #include <QObject>
29 
30 class StreamDataSender;
31 class EngineHandler;
32 class MetaData;
33 class QTcpSocket;
34 
35 
41 class StreamWriter :
42  public QObject,
44 
45 {
46  Q_OBJECT
47  PIMPL(StreamWriter)
48 
49  signals:
50  void sig_new_connection(const QString& ip);
51  void sig_disconnected(StreamWriter* sw);
52 
53 
54  public:
55  enum class Type : quint8
56  {
57  Undefined,
58  Standard,
59  Invalid,
60  Streaming
61  };
62 
63 
70  StreamWriter(QTcpSocket* socket, const QString& ip, const MetaData& md);
71  ~StreamWriter();
72 
77  QString get_ip() const;
78 
83  void change_track(const MetaData& md);
84 
85 
90  bool send_playlist();
91 
96  bool send_favicon();
97 
102  bool send_metadata();
103 
108  bool send_bg();
109 
114  bool send_html5();
115 
121  bool send_header(bool reject);
122 
123  StreamHttpParser::HttpAnswer parse_message();
124 
128  void disconnect();
129 
133  void dismiss();
134 
140  void new_audio_data(const uchar* data, quint64 size) override;
141 
142  private:
143  void reset();
144 
145  private slots:
146  void socket_disconnected();
147  void data_available();
148 };
149 
150 typedef std::shared_ptr<StreamWriter> StreamWriterPtr;
151 #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
StreamWriter(QTcpSocket *socket, const QString &ip, const MetaData &md)
StreamWriter.
QString get_ip() const
get client ip address
void new_audio_data(const uchar *data, quint64 size) override
new audio data has arrived and has to be forwarded to the socket
The StreamDataSender class. This class is used for sending the raw bytes.
Definition: StreamDataSender.h:34
The MetaData class MetaDataHelper.
Definition: MetaData.h:55
bool send_playlist()
Send a m3u playlist (see StreamDataSender)
void dismiss()
stop sending sound over the client socket
void disconnect()
disconnect a client socket
The RawSoundReceiver interface.
Definition: RawSoundReceiverInterface.h:30
bool send_html5()
send a html5 website (see StreamDataSender)
The EngineHandler class.
Definition: EngineHandler.h:41
void change_track(const MetaData &md)
send new icy data to clients, and send new metadata to remote controls.
bool send_header(bool reject)
send a appropriate header based on the type of request (see StreamDataSender)
bool send_bg()
Send website background (see StreamDataSender)
HttpAnswer
The HttpAnswer enum.
Definition: StreamHttpParser.h:40
bool send_favicon()
Send the http favicon (see StreamDataSender)
bool send_metadata()
Send track information (see StreamDataSender)