Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #ifndef MMFCLIENTAUDIOINPUTSTREAM_H
18 #define MMFCLIENTAUDIOINPUTSTREAM_H
20 #include <mmf/server/sounddevice.h>
21 #include <mmf/common/mmfstandardcustomcommands.h>
22 #include <mda/common/audio.h>
27 class MMdaAudioInputStreamCallback;
30 class CMMFMdaAudioInputStream;
31 NONSHARABLE_CLASS( CMMFMdaAudioInputStream ): public CBase,
32 public MDevSoundObserver
37 EIsOpening, // Open() called but not responded to
38 EIsOpen, // Open callback made and successfully opened
41 static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback);
42 static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback, TInt aPriority, TInt aPref);
43 ~CMMFMdaAudioInputStream();
45 void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
46 void Open(TMdaPackage* aSettings);
47 void SetGain(TInt aGain);
50 void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
51 TInt GetBalanceL() const;
52 void SetPriority(TInt aPriority, TInt aPref);
53 void ReadL(TDes8& aData);
55 const TTimeIntervalMicroSeconds& Position();
57 void SetDataTypeL(TFourCC aAudioType);
58 TFourCC DataType() const;
59 void GetSupportedBitRatesL(RArray<TInt>& aSupportedBitRates);
60 TInt BitRateL() const;
61 void SetBitRateL(TInt aBitRate);
62 TAny* CustomInterface(TUid aInterfaceId);
63 void SetSingleBufferMode(TBool aSingleMode);
68 // from MDevSoundObserver
69 void InitializeComplete(TInt aError);
70 void ToneFinished(TInt aError);
71 void BufferToBeFilled(CMMFBuffer* aBuffer);
72 void PlayError(TInt aError);
73 void BufferToBeEmptied(CMMFBuffer* aBuffer);
74 void RecordError(TInt aError);
75 void ConvertError(TInt aError);
76 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
79 void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
82 // class to allow asynchronous user callbacks
83 class CActiveCallback : public CActive
86 CActiveCallback(MMdaAudioInputStreamCallback& aCallback);
88 void Signal(const TInt aReason);
93 MMdaAudioInputStreamCallback& iCallback;
96 enum TState { EStopped, ERecording, EStopping };
98 CMMFMdaAudioInputStream(MMdaAudioInputStreamCallback& aCallback);
99 void ConstructL(TInt aPriority, TInt aPref);
100 TInt Read(TDes8& aData);
102 MMdaAudioInputStreamCallback& iCallback;
103 TTimeIntervalMicroSeconds iPosition;
104 CMMFDevSound* iDevSound;
105 CMMFFifo<TDes8>* iFifo;
110 CActiveCallback* iActiveCallback;
111 TInt iBytesRecorded;//tracks bytes supplied by devsound
112 TFourCC iDataTypeCode;
113 TIsOpenState iIsOpenState;
114 TMdaAudioDataSettings iSettings;
115 TBool iAudioDataStored;
117 friend class CTestStepUnitMMFAudClient;
118 TBool iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
119 TInt iInitializeState;
120 CActiveSchedulerWait* iActiveSchedulerWait;