qtmobility/plugins/multimedia/symbian/mmf/audiosource/s60audiocapturesession.h
changeset 4 90517678cc4f
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 <qmobilityglobal.h>
       
    46 #include <QtCore/qobject.h>
       
    47 #include <QFile>
       
    48 #include <QUrl>
       
    49 #include <QList>
       
    50 #include <QHash>
       
    51 #include <QAudioFormat>
       
    52 
       
    53 #include <Mda\Common\Audio.h>
       
    54 #include <Mda\Common\Resource.h>
       
    55 #include <Mda\Client\Utility.h>
       
    56 #include <MdaAudioSampleEditor.h>
       
    57 #include <mmf\common\mmfutilities.h>
       
    58 
       
    59 QTM_BEGIN_NAMESPACE
       
    60 struct ControllerData
       
    61 {
       
    62 	int controllerUid;
       
    63 	int destinationFormatUid;
       
    64 	QString destinationFormatDescription;
       
    65 };
       
    66 
       
    67 struct CodecData
       
    68 {
       
    69     TFourCC fourCC;
       
    70     QString codecDescription;
       
    71 };
       
    72 QTM_END_NAMESPACE
       
    73 
       
    74 QTM_USE_NAMESPACE
       
    75 
       
    76 class S60AudioCaptureSession : public QObject, public MMdaObjectStateChangeObserver
       
    77 {
       
    78     Q_OBJECT
       
    79     Q_PROPERTY(qint64 position READ position NOTIFY positionChanged)
       
    80     Q_ENUMS(TAudioCaptureState)
       
    81 public:
       
    82     
       
    83     enum TAudioCaptureState
       
    84     {
       
    85         ENotInitialized = 0,
       
    86         EInitializing,
       
    87         EInitialized,
       
    88         EOpenCompelete,
       
    89         ERecording,
       
    90         EPaused,
       
    91         ERecordComplete
       
    92     };
       
    93     
       
    94     S60AudioCaptureSession(QObject *parent = 0);
       
    95     ~S60AudioCaptureSession();
       
    96 
       
    97     QAudioFormat format() const;    
       
    98     bool setFormat(const QAudioFormat &format);
       
    99     QStringList supportedAudioCodecs() const;
       
   100     QString codecDescription(const QString &codecName);
       
   101     bool setAudioCodec(const QString &codecName);
       
   102     QString audioCodec() const;
       
   103     QString audioContainer() const;
       
   104     QStringList supportedAudioContainers() const;
       
   105     bool setAudioContainer(const QString &containerMimeType); 
       
   106     QString audioContainerDescription(const QString &containerName);
       
   107     QList<int> supportedAudioSampleRates() const;
       
   108     QUrl outputLocation() const;
       
   109     bool setOutputLocation(const QUrl& sink);
       
   110     qint64 position() const;    
       
   111     void record();
       
   112     void pause();
       
   113     void stop();
       
   114     
       
   115 private:    
       
   116     void initializeSessionL();
       
   117     void updateAudioContainersL();    
       
   118     void populateAudioCodecsDataL();
       
   119     void retrieveSupportedAudioSampleRatesL();
       
   120     void applyAudioSettingsL();
       
   121     TFourCC determinePCMFormat();
       
   122     void setDefaultSettings();
       
   123     void createFileWithHeader(const TPtrC &path);
       
   124     // MMdaObjectStateChangeObserver
       
   125     void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState,
       
   126             TInt aCurrentState, TInt aErrorCode);
       
   127     void MoscoStateChangeEventL(CBase* aObject, TInt aPreviousState,
       
   128             TInt aCurrentState, TInt aErrorCode);    
       
   129 
       
   130 public slots:
       
   131     void setCaptureDevice(const QString &deviceName);
       
   132 
       
   133 Q_SIGNALS:
       
   134     void stateChanged(S60AudioCaptureSession::TAudioCaptureState);
       
   135     void positionChanged(qint64 position);
       
   136 
       
   137 private:
       
   138     QString m_container;    
       
   139     QString m_captureDevice;
       
   140     QUrl m_sink;
       
   141     TTimeIntervalMicroSeconds m_pausedPosition;
       
   142     CMdaAudioRecorderUtility *m_recorderUtility;
       
   143     TAudioCaptureState m_captureState;
       
   144     QAudioFormat m_format;    
       
   145     QHash<QString, ControllerData> m_controllerIdMap;
       
   146     QHash<QString, CodecData>  m_audioCodeclist;
       
   147     QList<int> m_supportedSampleRates;    
       
   148 };
       
   149 
       
   150 #endif // S60AUDIOCAPTURESESSION_H