|
1 // Copyright (c) 2003-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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // mmfswaudioinput.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef SWAUDIOINPUT_H |
|
19 #define SWAUDIOINPUT_H |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <d32soundsc.h> |
|
23 |
|
24 |
|
25 //TAudioInputParams |
|
26 //- give sample rate and buffer size |
|
27 class TAudioInputParams |
|
28 { |
|
29 public: |
|
30 IMPORT_C TAudioInputParams(); |
|
31 |
|
32 TInt iSampleRate; |
|
33 // The sample rate of the data past to the client. Ideally, but not |
|
34 // necessarily that used on the device |
|
35 TInt iNumChannels; |
|
36 // Number of channels to use. 1 = mono. 2 = (interleaved) stereo. |
|
37 TInt iNominalBufferSize; |
|
38 // "Full buffers" are to be of this size. (Only the penultimate can be shorter) |
|
39 TInt iInitialGain; |
|
40 // Gain to use on start. |
|
41 }; |
|
42 |
|
43 // Observer class for MAudioInput |
|
44 class MAudioInputObserver |
|
45 { |
|
46 public: |
|
47 virtual void InputBufferAvailable(const TDesC8& aBuffer)=0; |
|
48 // A buffer of data is available. Assume single buffering |
|
49 |
|
50 virtual void InputFinished()=0; |
|
51 // called following Pause() to say no more data left |
|
52 |
|
53 virtual void InputError(TInt aError)=0; |
|
54 // called on fatal(ish) error. Client should call Stop() and/or Close() |
|
55 }; |
|
56 |
|
57 // Interface to SwWrapper AudioInput |
|
58 class MAudioInput |
|
59 { |
|
60 public: |
|
61 IMPORT_C static MAudioInput* CreateL(MAudioInputObserver& aObserver); |
|
62 // Create new object |
|
63 |
|
64 virtual void Release()=0; |
|
65 // destructor call |
|
66 |
|
67 virtual TInt Initialize(const TAudioInputParams& aParams)=0; |
|
68 // Initialize with given properties. synchronous call. |
|
69 |
|
70 virtual void Close()=0; |
|
71 // undo of Initialize() - return to created state. Implied Stop() if required. |
|
72 |
|
73 virtual TInt Start()=0; |
|
74 // Start to record and supply buffers. Only valid if initialized |
|
75 // subsequently BufferToEmpty() will be called |
|
76 |
|
77 virtual void BufferAck()=0; |
|
78 // The buffer supplied by InputBufferAvailable has been read. |
|
79 // Client must have stopped reading from the buffer |
|
80 |
|
81 virtual TInt Pause()=0; |
|
82 // pause (temporarily stop) recording. When all buffers have been passed |
|
83 // InputFinished() is called. |
|
84 |
|
85 virtual TInt Resume()=0; |
|
86 // resume from paused mode. If InputFinished() has not been sent |
|
87 // already it won't be |
|
88 |
|
89 virtual TInt Flush()=0; |
|
90 // throw away any partially recorded buffers than have not been |
|
91 // received. Implied BufferAck(). Only legal when paused |
|
92 |
|
93 virtual void Stop()=0; |
|
94 // immediate stop, but does not close. Akin to Cancel() if we are running. |
|
95 |
|
96 virtual TAny* Interface(TUid aInterfaceUid)=0; |
|
97 // for standard extension pattern |
|
98 }; |
|
99 |
|
100 // Parameter access. Do as CI since API not so clear |
|
101 const TUid KUidAIParamInterface = {0x10287080}; |
|
102 class MAIParamInterface |
|
103 { |
|
104 public: |
|
105 virtual TInt SetGain(TInt aGain)=0; |
|
106 // set basic gain |
|
107 |
|
108 virtual TInt GetBufferSizes(TInt& aMinSize, TInt& aMaxSize)=0; |
|
109 // min and max buffer size supported (or at least recommended) |
|
110 |
|
111 virtual TInt GetSupportedSampleRates(RArray<TInt>& aSupportedSampleRates)=0; |
|
112 }; |
|
113 |
|
114 #endif // SWAUDIOINPUT_H |
|
115 |