src/plugins/audio/symbian/symbianaudioutils.h
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 QtMultimedia 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 SYMBIANAUDIOUTILS_H
       
    43 #define SYMBIANAUDIOUTILS_H
       
    44 
       
    45 #include <QtCore/qnamespace.h>
       
    46 #include <QtMultimedia/qaudioformat.h>
       
    47 #include <QtMultimedia/qaudio.h>
       
    48 #include <sounddevice.h>
       
    49 #include "symbianaudio.h"
       
    50 
       
    51 QT_BEGIN_NAMESPACE
       
    52 
       
    53 namespace SymbianAudio {
       
    54 
       
    55 /*
       
    56  * Helper class for querying DevSound codec / format support
       
    57  */
       
    58 class DevSoundCapabilities {
       
    59 public:
       
    60     DevSoundCapabilities(CMMFDevSound &devsound, QAudio::Mode mode);
       
    61     ~DevSoundCapabilities();
       
    62 
       
    63     const RArray<TFourCC>& fourCC() const   { return m_fourCC; }
       
    64     const TMMFCapabilities& caps() const    { return m_caps; }
       
    65 
       
    66 private:
       
    67     void constructL(CMMFDevSound &devsound, QAudio::Mode mode);
       
    68 
       
    69 private:
       
    70     RArray<TFourCC> m_fourCC;
       
    71     TMMFCapabilities m_caps;
       
    72 };
       
    73 
       
    74 namespace Utils {
       
    75 
       
    76 /**
       
    77  * Convert native audio capabilities to QAudio lists.
       
    78  */
       
    79 void capabilitiesNativeToQt(const DevSoundCapabilities &caps,
       
    80                             QList<int> &frequencies,
       
    81                             QList<int> &channels,
       
    82                             QList<int> &sampleSizes,
       
    83                             QList<QAudioFormat::Endian> &byteOrders,
       
    84                             QList<QAudioFormat::SampleType> &sampleTypes);
       
    85 
       
    86 /**
       
    87  * Check whether format is supported.
       
    88  */
       
    89 bool isFormatSupported(const QAudioFormat &format,
       
    90                        const DevSoundCapabilities &caps);
       
    91 
       
    92 /**
       
    93  * Convert QAudioFormat to native format types.
       
    94  *
       
    95  * Note that, despite the name, DevSound uses TMMFCapabilities to specify
       
    96  * single formats as well as capabilities.
       
    97  *
       
    98  * Note that this function does not modify outputFormat.iBufferSize.
       
    99  */
       
   100 bool formatQtToNative(const QAudioFormat &inputFormat,
       
   101                       TUint32 &outputFourCC,
       
   102                       TMMFCapabilities &outputFormat);
       
   103 
       
   104 /**
       
   105  * Convert internal states to QAudio states.
       
   106  */
       
   107 QAudio::State stateNativeToQt(State nativeState,
       
   108                               QAudio::State initializingState);
       
   109 
       
   110 /**
       
   111  * Convert data length to number of samples.
       
   112  */
       
   113 qint64 bytesToSamples(const QAudioFormat &format, qint64 length);
       
   114 
       
   115 /**
       
   116  * Convert number of samples to data length.
       
   117  */
       
   118 qint64 samplesToBytes(const QAudioFormat &format, qint64 samples);
       
   119 
       
   120 } // namespace Utils
       
   121 } // namespace SymbianAudio
       
   122 
       
   123 QT_END_NAMESPACE
       
   124 
       
   125 #endif