src/gui/embedded/qsoundqss_qws.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    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 
       
    53 QT_BEGIN_HEADER
       
    54 
       
    55 QT_BEGIN_NAMESPACE
       
    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 
       
    65 class QWSSoundServerPrivate;
       
    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:
       
    84     QWSSoundServerPrivate* d;
       
    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 #ifdef QT3_SUPPORT
       
   143 public:
       
   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 
       
   171 QT_END_NAMESPACE
       
   172 
       
   173 QT_END_HEADER
       
   174 
       
   175 #endif // QT_NO_SOUND
       
   176 
       
   177 #endif // QSOUNDQSS_QWS_H