qsoundqss_qws.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QSOUNDQSS_QWS_H
00043 #define QSOUNDQSS_QWS_H
00044 
00045 #include <QtCore/qglobal.h>
00046 
00047 #ifndef QT_NO_SOUND
00048 
00049 #include <QtNetwork/qtcpserver.h>
00050 #include <QtNetwork/qtcpsocket.h>
00051 #include <QtGui/qwssocket_qws.h>
00052 
00053 QT_BEGIN_HEADER
00054 
00055 QT_BEGIN_NAMESPACE
00056 
00057 QT_MODULE(Gui)
00058 
00059 #if defined(QT_NO_NETWORK) || defined(QT_NO_DNS)
00060 #define QT_NO_QWS_SOUNDSERVER
00061 #endif
00062 
00063 #ifndef Q_OS_MAC
00064 
00065 class QWSSoundServerPrivate;
00066 
00067 class Q_GUI_EXPORT QWSSoundServer : public QObject {
00068     Q_OBJECT
00069 public:
00070     explicit QWSSoundServer(QObject *parent=0);
00071     ~QWSSoundServer();
00072     void playFile( int id, const QString& filename );
00073     void stopFile( int id );
00074     void pauseFile( int id );
00075     void resumeFile( int id );
00076     
00077 Q_SIGNALS:
00078     void soundCompleted( int );
00079     
00080 private Q_SLOTS:
00081     void translateSoundCompleted( int, int );
00082 
00083 private:
00084     QWSSoundServerPrivate* d;
00085 };
00086 
00087 #ifndef QT_NO_QWS_SOUNDSERVER
00088 class Q_GUI_EXPORT QWSSoundClient : public QWSSocket {
00089     Q_OBJECT
00090 public:
00091 
00092     enum SoundFlags {
00093     Priority = 0x01,
00094     Streaming = 0x02  // currently ignored, but but could set up so both Raw and non raw can be done streaming or not.
00095     };
00096     enum DeviceErrors {
00097     ErrOpeningAudioDevice = 0x01,
00098     ErrOpeningFile = 0x02,
00099     ErrReadingFile = 0x04
00100     };
00101     explicit QWSSoundClient(QObject* parent=0);
00102     ~QWSSoundClient( );
00103     void reconnect();
00104     void play( int id, const QString& filename );
00105     void play( int id, const QString& filename, int volume, int flags = 0 );
00106     void playRaw( int id, const QString&, int, int, int, int flags = 0 );
00107 
00108     void pause( int id );
00109     void stop( int id );
00110     void resume( int id );
00111     void setVolume( int id, int left, int right );
00112     void setMute( int id, bool m );
00113     
00114     // to be used by server only, to protect phone conversation/rings.
00115     void playPriorityOnly(bool);
00116 
00117     // If silent, tell sound server to release audio device
00118     // Otherwise, allow sound server to regain audio device
00119     void setSilent(bool);
00120     
00121 Q_SIGNALS:
00122     void soundCompleted(int);
00123     void deviceReady(int id);
00124     void deviceError(int id, QWSSoundClient::DeviceErrors);
00125 
00126 private Q_SLOTS:
00127     void tryReadCommand();
00128     void emitConnectionRefused();
00129     
00130 private:
00131     void sendServerMessage(QString msg);
00132 };
00133 
00134 class QWSSoundServerSocket : public QWSServerSocket {
00135     Q_OBJECT
00136 
00137 public:
00138     explicit QWSSoundServerSocket(QObject *parent=0);
00139 public Q_SLOTS:    
00140     void newConnection();
00141 
00142 #ifdef QT3_SUPPORT
00143 public:
00144     QT3_SUPPORT_CONSTRUCTOR QWSSoundServerSocket(QObject *parent, const char *name);
00145 #endif
00146 
00147 Q_SIGNALS:
00148     void playFile(int, int, const QString&);
00149     void playFile(int, int, const QString&, int, int);
00150     void playRawFile(int, int, const QString&, int, int, int, int);
00151     void pauseFile(int, int);
00152     void stopFile(int, int);
00153     void resumeFile(int, int);
00154     void setVolume(int, int, int, int);
00155     void setMute(int, int, bool);
00156 
00157     void stopAll(int);
00158 
00159     void playPriorityOnly(bool);
00160 
00161     void setSilent(bool);
00162 
00163     void soundFileCompleted(int, int);
00164     void deviceReady(int, int);
00165     void deviceError(int, int, int);
00166 };
00167 #endif
00168 
00169 #endif // Q_OS_MAC
00170 
00171 QT_END_NAMESPACE
00172 
00173 QT_END_HEADER
00174 
00175 #endif // QT_NO_SOUND
00176 
00177 #endif // QSOUNDQSS_QWS_H