1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Audio/mmfclientaudioinputstream.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,123 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +#ifndef MMFCLIENTAUDIOINPUTSTREAM_H
1.21 +#define MMFCLIENTAUDIOINPUTSTREAM_H
1.22 +
1.23 +#include <mmf/server/sounddevice.h>
1.24 +#include <mmf/common/mmfstandardcustomcommands.h>
1.25 +#include <mda/common/audio.h>
1.26 +
1.27 +template<class T>
1.28 +class CMMFFifo;
1.29 +class CMMFBuffer;
1.30 +class MMdaAudioInputStreamCallback;
1.31 +class TMdaPackage;
1.32 +
1.33 +class CMMFMdaAudioInputStream;
1.34 +NONSHARABLE_CLASS( CMMFMdaAudioInputStream ): public CBase,
1.35 + public MDevSoundObserver
1.36 + {
1.37 + enum TIsOpenState
1.38 + {
1.39 + EIsNotOpen,
1.40 + EIsOpening, // Open() called but not responded to
1.41 + EIsOpen, // Open callback made and successfully opened
1.42 + };
1.43 +public:
1.44 + static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback);
1.45 + static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback, TInt aPriority, TInt aPref);
1.46 + ~CMMFMdaAudioInputStream();
1.47 +
1.48 + void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
1.49 + void Open(TMdaPackage* aSettings);
1.50 + void SetGain(TInt aGain);
1.51 + TInt Gain() const;
1.52 + TInt MaxGain() const;
1.53 + void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
1.54 + TInt GetBalanceL() const;
1.55 + void SetPriority(TInt aPriority, TInt aPref);
1.56 + void ReadL(TDes8& aData);
1.57 + void Stop();
1.58 + const TTimeIntervalMicroSeconds& Position();
1.59 + TInt GetBytes();
1.60 + void SetDataTypeL(TFourCC aAudioType);
1.61 + TFourCC DataType() const;
1.62 + void GetSupportedBitRatesL(RArray<TInt>& aSupportedBitRates);
1.63 + TInt BitRateL() const;
1.64 + void SetBitRateL(TInt aBitRate);
1.65 + TAny* CustomInterface(TUid aInterfaceId);
1.66 + void SetSingleBufferMode(TBool aSingleMode);
1.67 + void RequestStop();
1.68 + void ShutDown();
1.69 +
1.70 +public:
1.71 + // from MDevSoundObserver
1.72 + void InitializeComplete(TInt aError);
1.73 + void ToneFinished(TInt aError);
1.74 + void BufferToBeFilled(CMMFBuffer* aBuffer);
1.75 + void PlayError(TInt aError);
1.76 + void BufferToBeEmptied(CMMFBuffer* aBuffer);
1.77 + void RecordError(TInt aError);
1.78 + void ConvertError(TInt aError);
1.79 + void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
1.80 +
1.81 +private:
1.82 + void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
1.83 +
1.84 +private:
1.85 + // class to allow asynchronous user callbacks
1.86 + class CActiveCallback : public CActive
1.87 + {
1.88 + public:
1.89 + CActiveCallback(MMdaAudioInputStreamCallback& aCallback);
1.90 + ~CActiveCallback();
1.91 + void Signal(const TInt aReason);
1.92 + protected:
1.93 + void RunL();
1.94 + void DoCancel();
1.95 + private:
1.96 + MMdaAudioInputStreamCallback& iCallback;
1.97 + };
1.98 +private:
1.99 + enum TState { EStopped, ERecording, EStopping };
1.100 +private:
1.101 + CMMFMdaAudioInputStream(MMdaAudioInputStreamCallback& aCallback);
1.102 + void ConstructL(TInt aPriority, TInt aPref);
1.103 + TInt Read(TDes8& aData);
1.104 +private:
1.105 + MMdaAudioInputStreamCallback& iCallback;
1.106 + TTimeIntervalMicroSeconds iPosition;
1.107 + CMMFDevSound* iDevSound;
1.108 + CMMFFifo<TDes8>* iFifo;
1.109 + TBool iSingleBuffer;
1.110 + TPtr8 iStorageItem;
1.111 + TPtr8 iBufferPtr;
1.112 + TInt iState;
1.113 + CActiveCallback* iActiveCallback;
1.114 + TInt iBytesRecorded;//tracks bytes supplied by devsound
1.115 + TFourCC iDataTypeCode;
1.116 + TIsOpenState iIsOpenState;
1.117 + TMdaAudioDataSettings iSettings;
1.118 + TBool iAudioDataStored;
1.119 + // only for testing
1.120 + friend class CTestStepUnitMMFAudClient;
1.121 + TBool iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
1.122 + TInt iInitializeState;
1.123 + CActiveSchedulerWait* iActiveSchedulerWait;
1.124 + };
1.125 +
1.126 +#endif