Qt 4.8
qsoundqss_qws.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QSOUNDQSS_QWS_H
43 #define QSOUNDQSS_QWS_H
44 
45 #include <QtCore/qglobal.h>
46 
47 #ifndef QT_NO_SOUND
48 
49 #include <QtNetwork/qtcpserver.h>
50 #include <QtNetwork/qtcpsocket.h>
51 #include <QtGui/qwssocket_qws.h>
52 
54 
56 
57 QT_MODULE(Gui)
58 
59 #if defined(QT_NO_NETWORK) || defined(QT_NO_DNS)
60 #define QT_NO_QWS_SOUNDSERVER
61 #endif
62 
63 #ifndef Q_OS_MAC
64 
66 
67 class Q_GUI_EXPORT QWSSoundServer : public QObject {
68  Q_OBJECT
69 public:
70  explicit QWSSoundServer(QObject *parent=0);
71  ~QWSSoundServer();
72  void playFile( int id, const QString& filename );
73  void stopFile( int id );
74  void pauseFile( int id );
75  void resumeFile( int id );
76 
77 Q_SIGNALS:
78  void soundCompleted( int );
79 
80 private Q_SLOTS:
81  void translateSoundCompleted( int, int );
82 
83 private:
85 };
86 
87 #ifndef QT_NO_QWS_SOUNDSERVER
88 class Q_GUI_EXPORT QWSSoundClient : public QWSSocket {
89  Q_OBJECT
90 public:
91 
92  enum SoundFlags {
93  Priority = 0x01,
94  Streaming = 0x02 // currently ignored, but but could set up so both Raw and non raw can be done streaming or not.
95  };
96  enum DeviceErrors {
97  ErrOpeningAudioDevice = 0x01,
98  ErrOpeningFile = 0x02,
99  ErrReadingFile = 0x04
100  };
101  explicit QWSSoundClient(QObject* parent=0);
102  ~QWSSoundClient( );
103  void reconnect();
104  void play( int id, const QString& filename );
105  void play( int id, const QString& filename, int volume, int flags = 0 );
106  void playRaw( int id, const QString&, int, int, int, int flags = 0 );
107 
108  void pause( int id );
109  void stop( int id );
110  void resume( int id );
111  void setVolume( int id, int left, int right );
112  void setMute( int id, bool m );
113 
114  // to be used by server only, to protect phone conversation/rings.
115  void playPriorityOnly(bool);
116 
117  // If silent, tell sound server to release audio device
118  // Otherwise, allow sound server to regain audio device
119  void setSilent(bool);
120 
121 Q_SIGNALS:
122  void soundCompleted(int);
123  void deviceReady(int id);
124  void deviceError(int id, QWSSoundClient::DeviceErrors);
125 
126 private Q_SLOTS:
127  void tryReadCommand();
128  void emitConnectionRefused();
129 
130 private:
131  void sendServerMessage(QString msg);
132 };
133 
134 class QWSSoundServerSocket : public QWSServerSocket {
135  Q_OBJECT
136 
137 public:
138  explicit QWSSoundServerSocket(QObject *parent=0);
139 public Q_SLOTS:
140  void newConnection();
141 
142 public:
143 #ifdef QT3_SUPPORT
144  QT3_SUPPORT_CONSTRUCTOR QWSSoundServerSocket(QObject *parent, const char *name);
145 #endif
146 
147 Q_SIGNALS:
148  void playFile(int, int, const QString&);
149  void playFile(int, int, const QString&, int, int);
150  void playRawFile(int, int, const QString&, int, int, int, int);
151  void pauseFile(int, int);
152  void stopFile(int, int);
153  void resumeFile(int, int);
154  void setVolume(int, int, int, int);
155  void setMute(int, int, bool);
156 
157  void stopAll(int);
158 
159  void playPriorityOnly(bool);
160 
161  void setSilent(bool);
162 
163  void soundFileCompleted(int, int);
164  void deviceReady(int, int);
165  void deviceError(int, int, int);
166 };
167 #endif
168 
169 #endif // Q_OS_MAC
170 
172 
174 
175 #endif // QT_NO_SOUND
176 
177 #endif // QSOUNDQSS_QWS_H
double d
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const char * name
#define Q_OBJECT
Definition: qobjectdefs.h:157
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define QT_END_HEADER
Definition: qglobal.h:137