qtmobility/plugins/multimedia/symbian/audiosource/s60audiocapturesession.h
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
     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 Qt Mobility Components.
       
     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 S60AUDIOCAPTURESESSION_H
       
    43 #define S60AUDIOCAPTURESESSION_H
       
    44 
       
    45 #include <QFile>
       
    46 #include <QUrl>
       
    47 
       
    48 #include "s60audioencodercontrol.h"
       
    49 #include "s60audioendpointselector.h"
       
    50 #include "s60audiomediarecordercontrol.h"
       
    51 
       
    52 #include <QAudioFormat>
       
    53 
       
    54 #include <Mda\Common\Audio.h>
       
    55 #include <Mda\Common\Resource.h>
       
    56 #include <Mda\Client\Utility.h>
       
    57 #include <MdaAudioSampleEditor.h>
       
    58 
       
    59 struct ItemData
       
    60 {
       
    61 	int controllerUid;
       
    62 	int destinationFormatUid;
       
    63 	QString destinationFormatDescription;
       
    64 };
       
    65 
       
    66 
       
    67 class S60AudioCaptureSession : public QObject, public MMdaObjectStateChangeObserver
       
    68 {
       
    69     Q_OBJECT
       
    70 
       
    71 public:
       
    72     S60AudioCaptureSession(QObject *parent = 0);
       
    73     ~S60AudioCaptureSession();
       
    74 
       
    75     QAudioFormat format() const;
       
    76     bool isFormatSupported(const QAudioFormat &format) const;
       
    77     bool setFormat(const QAudioFormat &format);
       
    78     QStringList supportedAudioCodecs() const;
       
    79     QString codecDescription(const QString &codecName);
       
    80     bool setAudioCodec(const QString &codecName);
       
    81     QString audioCodec() const;
       
    82 
       
    83     QUrl outputLocation() const;
       
    84     bool setOutputLocation(const QUrl& sink);
       
    85     qint64 position() const;
       
    86     int state() const;
       
    87     void record();
       
    88     void pause();
       
    89     void stop();
       
    90 
       
    91 public slots:
       
    92     void setCaptureDevice(const QString &deviceName);
       
    93 
       
    94 signals:
       
    95     void stateChanged(QMediaRecorder::State state);
       
    96     void positionChanged(qint64 position);
       
    97 
       
    98 private slots:
       
    99     void stateChanged(QAudio::State state);
       
   100     void notify();
       
   101 
       
   102 private:
       
   103     enum TStatus
       
   104     {
       
   105         ENotReady,
       
   106         EOpen
       
   107     };
       
   108     
       
   109     void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState,
       
   110             TInt aCurrentState, TInt aErrorCode);
       
   111     void MoscoStateChangeEventL(CBase* aObject, TInt aPreviousState,
       
   112             TInt aCurrentState, TInt aErrorCode);
       
   113     
       
   114     void fetchAudioCodecsL();
       
   115 
       
   116     
       
   117     QString m_captureDevice;
       
   118     QUrl m_sink;
       
   119     QMediaRecorder::State m_state;
       
   120     
       
   121     CMdaAudioRecorderUtility *m_recorderUtility;
       
   122     QAudioFormat m_format;
       
   123     qint64 m_position;
       
   124     bool wavFile;
       
   125     
       
   126     QHash<QString, ItemData> m_controllerIdMap;
       
   127     
       
   128     // WAV header stuff
       
   129 
       
   130     struct chunk
       
   131     {
       
   132         char        id[4];
       
   133         quint32     size;
       
   134     };
       
   135 
       
   136     struct RIFFHeader
       
   137     {
       
   138         chunk       descriptor;
       
   139         char        type[4];
       
   140     };
       
   141 
       
   142     struct WAVEHeader
       
   143     {
       
   144         chunk       descriptor;
       
   145         quint16     audioFormat;        // PCM = 1
       
   146         quint16     numChannels;
       
   147         quint32     sampleRate;
       
   148         quint32     byteRate;
       
   149         quint16     blockAlign;
       
   150         quint16     bitsPerSample;
       
   151     };
       
   152 
       
   153     struct DATAHeader
       
   154     {
       
   155         chunk       descriptor;
       
   156         quint8      data[4];
       
   157     };
       
   158 
       
   159     struct CombinedHeader
       
   160     {
       
   161         RIFFHeader  riff;
       
   162         WAVEHeader  wave;
       
   163         DATAHeader  data;
       
   164     };
       
   165 
       
   166     CombinedHeader      header;
       
   167 };
       
   168 
       
   169 #endif // S60AUDIOCAPTURESESSION_H