sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
|
sl@0
|
17 |
#ifndef MMFCLIENTAUDIOINPUTSTREAM_H
|
sl@0
|
18 |
#define MMFCLIENTAUDIOINPUTSTREAM_H
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <mmf/server/sounddevice.h>
|
sl@0
|
21 |
#include <mmf/common/mmfstandardcustomcommands.h>
|
sl@0
|
22 |
#include <mda/common/audio.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
template<class T>
|
sl@0
|
25 |
class CMMFFifo;
|
sl@0
|
26 |
class CMMFBuffer;
|
sl@0
|
27 |
class MMdaAudioInputStreamCallback;
|
sl@0
|
28 |
class TMdaPackage;
|
sl@0
|
29 |
|
sl@0
|
30 |
class CMMFMdaAudioInputStream;
|
sl@0
|
31 |
NONSHARABLE_CLASS( CMMFMdaAudioInputStream ): public CBase,
|
sl@0
|
32 |
public MDevSoundObserver
|
sl@0
|
33 |
{
|
sl@0
|
34 |
enum TIsOpenState
|
sl@0
|
35 |
{
|
sl@0
|
36 |
EIsNotOpen,
|
sl@0
|
37 |
EIsOpening, // Open() called but not responded to
|
sl@0
|
38 |
EIsOpen, // Open callback made and successfully opened
|
sl@0
|
39 |
};
|
sl@0
|
40 |
public:
|
sl@0
|
41 |
static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback);
|
sl@0
|
42 |
static CMMFMdaAudioInputStream* NewL(MMdaAudioInputStreamCallback& aCallback, TInt aPriority, TInt aPref);
|
sl@0
|
43 |
~CMMFMdaAudioInputStream();
|
sl@0
|
44 |
|
sl@0
|
45 |
void SetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
|
sl@0
|
46 |
void Open(TMdaPackage* aSettings);
|
sl@0
|
47 |
void SetGain(TInt aGain);
|
sl@0
|
48 |
TInt Gain() const;
|
sl@0
|
49 |
TInt MaxGain() const;
|
sl@0
|
50 |
void SetBalanceL(TInt aBalance = KMMFBalanceCenter);
|
sl@0
|
51 |
TInt GetBalanceL() const;
|
sl@0
|
52 |
void SetPriority(TInt aPriority, TInt aPref);
|
sl@0
|
53 |
void ReadL(TDes8& aData);
|
sl@0
|
54 |
void Stop();
|
sl@0
|
55 |
const TTimeIntervalMicroSeconds& Position();
|
sl@0
|
56 |
TInt GetBytes();
|
sl@0
|
57 |
void SetDataTypeL(TFourCC aAudioType);
|
sl@0
|
58 |
TFourCC DataType() const;
|
sl@0
|
59 |
void GetSupportedBitRatesL(RArray<TInt>& aSupportedBitRates);
|
sl@0
|
60 |
TInt BitRateL() const;
|
sl@0
|
61 |
void SetBitRateL(TInt aBitRate);
|
sl@0
|
62 |
TAny* CustomInterface(TUid aInterfaceId);
|
sl@0
|
63 |
void SetSingleBufferMode(TBool aSingleMode);
|
sl@0
|
64 |
void RequestStop();
|
sl@0
|
65 |
void ShutDown();
|
sl@0
|
66 |
|
sl@0
|
67 |
public:
|
sl@0
|
68 |
// from MDevSoundObserver
|
sl@0
|
69 |
void InitializeComplete(TInt aError);
|
sl@0
|
70 |
void ToneFinished(TInt aError);
|
sl@0
|
71 |
void BufferToBeFilled(CMMFBuffer* aBuffer);
|
sl@0
|
72 |
void PlayError(TInt aError);
|
sl@0
|
73 |
void BufferToBeEmptied(CMMFBuffer* aBuffer);
|
sl@0
|
74 |
void RecordError(TInt aError);
|
sl@0
|
75 |
void ConvertError(TInt aError);
|
sl@0
|
76 |
void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
|
sl@0
|
77 |
|
sl@0
|
78 |
private:
|
sl@0
|
79 |
void RealSetAudioPropertiesL(TInt aSampleRate, TInt aChannels);
|
sl@0
|
80 |
|
sl@0
|
81 |
private:
|
sl@0
|
82 |
// class to allow asynchronous user callbacks
|
sl@0
|
83 |
class CActiveCallback : public CActive
|
sl@0
|
84 |
{
|
sl@0
|
85 |
public:
|
sl@0
|
86 |
CActiveCallback(MMdaAudioInputStreamCallback& aCallback);
|
sl@0
|
87 |
~CActiveCallback();
|
sl@0
|
88 |
void Signal(const TInt aReason);
|
sl@0
|
89 |
protected:
|
sl@0
|
90 |
void RunL();
|
sl@0
|
91 |
void DoCancel();
|
sl@0
|
92 |
private:
|
sl@0
|
93 |
MMdaAudioInputStreamCallback& iCallback;
|
sl@0
|
94 |
};
|
sl@0
|
95 |
private:
|
sl@0
|
96 |
enum TState { EStopped, ERecording, EStopping };
|
sl@0
|
97 |
private:
|
sl@0
|
98 |
CMMFMdaAudioInputStream(MMdaAudioInputStreamCallback& aCallback);
|
sl@0
|
99 |
void ConstructL(TInt aPriority, TInt aPref);
|
sl@0
|
100 |
TInt Read(TDes8& aData);
|
sl@0
|
101 |
private:
|
sl@0
|
102 |
MMdaAudioInputStreamCallback& iCallback;
|
sl@0
|
103 |
TTimeIntervalMicroSeconds iPosition;
|
sl@0
|
104 |
CMMFDevSound* iDevSound;
|
sl@0
|
105 |
CMMFFifo<TDes8>* iFifo;
|
sl@0
|
106 |
TBool iSingleBuffer;
|
sl@0
|
107 |
TPtr8 iStorageItem;
|
sl@0
|
108 |
TPtr8 iBufferPtr;
|
sl@0
|
109 |
TInt iState;
|
sl@0
|
110 |
CActiveCallback* iActiveCallback;
|
sl@0
|
111 |
TInt iBytesRecorded;//tracks bytes supplied by devsound
|
sl@0
|
112 |
TFourCC iDataTypeCode;
|
sl@0
|
113 |
TIsOpenState iIsOpenState;
|
sl@0
|
114 |
TMdaAudioDataSettings iSettings;
|
sl@0
|
115 |
TBool iAudioDataStored;
|
sl@0
|
116 |
// only for testing
|
sl@0
|
117 |
friend class CTestStepUnitMMFAudClient;
|
sl@0
|
118 |
TBool iInitCallFrmSetDataType;//Flag to indicate that InitializeL is called from SetDataTypeL.
|
sl@0
|
119 |
TInt iInitializeState;
|
sl@0
|
120 |
CActiveSchedulerWait* iActiveSchedulerWait;
|
sl@0
|
121 |
};
|
sl@0
|
122 |
|
sl@0
|
123 |
#endif
|