williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@4
|
3 |
* All rights reserved.
|
williamr@4
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@4
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@4
|
8 |
*
|
williamr@4
|
9 |
* Initial Contributors:
|
williamr@4
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@4
|
11 |
*
|
williamr@4
|
12 |
* Contributors:
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
* Description:
|
williamr@4
|
15 |
*
|
williamr@4
|
16 |
*/
|
williamr@4
|
17 |
|
williamr@4
|
18 |
|
williamr@4
|
19 |
|
williamr@4
|
20 |
#ifndef __MMF_HW_DEVICE_H__
|
williamr@4
|
21 |
#define __MMF_HW_DEVICE_H__
|
williamr@4
|
22 |
|
williamr@4
|
23 |
#include <e32base.h>
|
williamr@4
|
24 |
#include <ecom/implementationinformation.h>
|
williamr@4
|
25 |
#include <mmf/common/mmfutilities.h> //TFourCC
|
williamr@4
|
26 |
#include <mmf/server/mmfhwdevicecmds.h>
|
williamr@4
|
27 |
#include <mmf/server/taskconfig.h>
|
williamr@4
|
28 |
|
williamr@4
|
29 |
/**
|
williamr@4
|
30 |
@publishedPartner
|
williamr@4
|
31 |
@released
|
williamr@4
|
32 |
|
williamr@4
|
33 |
The connection type defines what the stream will connect to,
|
williamr@4
|
34 |
either gpp, dsp node, or dsp device.
|
williamr@4
|
35 |
*/
|
williamr@4
|
36 |
typedef enum TConnectionType_tag
|
williamr@4
|
37 |
{
|
williamr@4
|
38 |
/** Gpp
|
williamr@4
|
39 |
*/
|
williamr@4
|
40 |
EConnectionGpp,
|
williamr@4
|
41 |
/** dsp node
|
williamr@4
|
42 |
*/
|
williamr@4
|
43 |
EConnectionTask,
|
williamr@4
|
44 |
/** dsp device
|
williamr@4
|
45 |
*/
|
williamr@4
|
46 |
EConnectionDevice
|
williamr@4
|
47 |
} TConnectionType ;
|
williamr@4
|
48 |
|
williamr@4
|
49 |
/**
|
williamr@4
|
50 |
@publishedPartner
|
williamr@4
|
51 |
@released
|
williamr@4
|
52 |
|
williamr@4
|
53 |
Connection Type
|
williamr@4
|
54 |
*/
|
williamr@4
|
55 |
typedef struct TStreamConnection_tag
|
williamr@4
|
56 |
{
|
williamr@4
|
57 |
/** connection id
|
williamr@4
|
58 |
*/
|
williamr@4
|
59 |
TInt iId ;
|
williamr@4
|
60 |
/** connection type
|
williamr@4
|
61 |
*/
|
williamr@4
|
62 |
TConnectionType iType ;
|
williamr@4
|
63 |
} TStreamConnection;
|
williamr@4
|
64 |
|
williamr@4
|
65 |
const TUint KMaxDeviceNameLength = 128;
|
williamr@4
|
66 |
|
williamr@4
|
67 |
enum TSamplingFreq { ESampFreq8k, ESampFreq11025k, ESampFreq16k, ESampFreq2205k, ESampFreq32k, ESampFreq441k, ESampFreq48k, ESampFreq12k, ESampFreq24k, ESampFreq64k};
|
williamr@4
|
68 |
|
williamr@4
|
69 |
/**
|
williamr@4
|
70 |
@publishedPartner
|
williamr@4
|
71 |
@released
|
williamr@4
|
72 |
|
williamr@4
|
73 |
Type class for stream connection parameters.
|
williamr@4
|
74 |
This structure defines the connection parameters that are required to
|
williamr@4
|
75 |
be filled in by the HwDevice observer. The connection type defines
|
williamr@4
|
76 |
what the stream will connect to, either gpp, dsp node, or dsp device.
|
williamr@4
|
77 |
*/
|
williamr@4
|
78 |
class TConnection
|
williamr@4
|
79 |
{
|
williamr@4
|
80 |
public:
|
williamr@4
|
81 |
/** Connection type.
|
williamr@4
|
82 |
*/
|
williamr@4
|
83 |
TStreamConnection iConnection;
|
williamr@4
|
84 |
/** Name of the device if needed.
|
williamr@4
|
85 |
*/
|
williamr@4
|
86 |
TBuf8<KMaxDeviceNameLength> iDeviceName;
|
williamr@4
|
87 |
};
|
williamr@4
|
88 |
|
williamr@4
|
89 |
// Forward reference
|
williamr@4
|
90 |
class MMMFHwDeviceObserver;
|
williamr@4
|
91 |
|
williamr@4
|
92 |
/**
|
williamr@4
|
93 |
@publishedPartner
|
williamr@4
|
94 |
@released
|
williamr@4
|
95 |
|
williamr@4
|
96 |
Type class for Hardware initialization parameters.
|
williamr@4
|
97 |
The implementation specific initialization attributes are passed in this
|
williamr@4
|
98 |
structure. Elements common to all HwDevices are defined here. These are
|
williamr@4
|
99 |
the pointer to the observer and stream connection identification for the
|
williamr@4
|
100 |
HwDevice.
|
williamr@4
|
101 |
|
williamr@4
|
102 |
These stream connections are defined as follows:
|
williamr@4
|
103 |
- SrcStream is the source data stream to the HwDevice for a decoder/player.
|
williamr@4
|
104 |
- OutStream is the counterpart stream of data out of the HwDevice of
|
williamr@4
|
105 |
processed source data.
|
williamr@4
|
106 |
- InStream is the input stream of data to the HwDevice for an
|
williamr@4
|
107 |
encoder/recorder.
|
williamr@4
|
108 |
- DestStream is the destination data stream of
|
williamr@4
|
109 |
this InStream after it has been processed.
|
williamr@4
|
110 |
|
williamr@4
|
111 |
The last element is a pointer to a buffer of the rest of the initialization
|
williamr@4
|
112 |
data for the HwDevice. This data will vary for different HwDevices.
|
williamr@4
|
113 |
However, the first element is always the number of internal connections (TUint8)
|
williamr@4
|
114 |
required by the HwDevice. Following this, is an element (TUint8) for each of
|
williamr@4
|
115 |
the required connection ID's. The elements following this are only known by
|
williamr@4
|
116 |
the HwDevice.
|
williamr@4
|
117 |
*/
|
williamr@4
|
118 |
class THwDeviceInitParams
|
williamr@4
|
119 |
{
|
williamr@4
|
120 |
public:
|
williamr@4
|
121 |
THwDeviceInitParams() : iHwDeviceInitArgsPtr(0,0){};
|
williamr@4
|
122 |
/** Pointer to an observer.
|
williamr@4
|
123 |
*/
|
williamr@4
|
124 |
MMMFHwDeviceObserver* iHwDeviceObserver;
|
williamr@4
|
125 |
/** Source stream attributes.
|
williamr@4
|
126 |
*/
|
williamr@4
|
127 |
TConnection iSrcStream;
|
williamr@4
|
128 |
/** Destination stream attributes.
|
williamr@4
|
129 |
*/
|
williamr@4
|
130 |
TConnection iDestStream;
|
williamr@4
|
131 |
/** Input stream attributes.
|
williamr@4
|
132 |
*/
|
williamr@4
|
133 |
TConnection iInStream;
|
williamr@4
|
134 |
/** Output stream attributes.
|
williamr@4
|
135 |
*/
|
williamr@4
|
136 |
TConnection iOutStream;
|
williamr@4
|
137 |
/** Pointer to a buffer.
|
williamr@4
|
138 |
*/
|
williamr@4
|
139 |
TPtr8 iHwDeviceInitArgsPtr;
|
williamr@4
|
140 |
};
|
williamr@4
|
141 |
|
williamr@4
|
142 |
|
williamr@4
|
143 |
/**
|
williamr@4
|
144 |
@publishedPartner
|
williamr@4
|
145 |
@released
|
williamr@4
|
146 |
|
williamr@4
|
147 |
The observer class interface for a hardware device listener class.
|
williamr@4
|
148 |
|
williamr@4
|
149 |
MMMFHwDeviceObserver provides a generic interface which should be implemented
|
williamr@4
|
150 |
by the classes that are interested in receiving events from the CMMFHwDevice
|
williamr@4
|
151 |
implementation class.
|
williamr@4
|
152 |
*/
|
williamr@4
|
153 |
class MMMFHwDeviceObserver
|
williamr@4
|
154 |
{
|
williamr@4
|
155 |
public:
|
williamr@4
|
156 |
|
williamr@4
|
157 |
/**
|
williamr@4
|
158 |
Handles CMMFHwDevice object’s data request event.
|
williamr@4
|
159 |
|
williamr@4
|
160 |
This function is called by the CMMFHwDevice implementation class when it
|
williamr@4
|
161 |
needs data for decoding.
|
williamr@4
|
162 |
|
williamr@4
|
163 |
@param aHwDataBuffer
|
williamr@4
|
164 |
The buffer to fill the data.
|
williamr@4
|
165 |
|
williamr@4
|
166 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
167 |
another of the system-wide error codes.
|
williamr@4
|
168 |
*/
|
williamr@4
|
169 |
virtual TInt FillThisHwBuffer(CMMFBuffer& aHwDataBuffer) = 0;
|
williamr@4
|
170 |
|
williamr@4
|
171 |
/**
|
williamr@4
|
172 |
Handles CMMFHwDevice object’s data request event.
|
williamr@4
|
173 |
|
williamr@4
|
174 |
This function is called by the CMMFHwDevice implementation class when it
|
williamr@4
|
175 |
fills encoded data into a buffer.
|
williamr@4
|
176 |
|
williamr@4
|
177 |
@param aHwDataBuffer
|
williamr@4
|
178 |
The buffer with encoded data.
|
williamr@4
|
179 |
|
williamr@4
|
180 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
181 |
another of the system-wide error codes.
|
williamr@4
|
182 |
*/
|
williamr@4
|
183 |
virtual TInt EmptyThisHwBuffer(CMMFBuffer& aHwDataBuffer) = 0;
|
williamr@4
|
184 |
|
williamr@4
|
185 |
/**
|
williamr@4
|
186 |
Handles the CMMFHwDevice object’s message event.
|
williamr@4
|
187 |
|
williamr@4
|
188 |
This function is called by the CMMFHwDevice implementation class when a
|
williamr@4
|
189 |
message is generated and passed back to the observer.
|
williamr@4
|
190 |
|
williamr@4
|
191 |
@param aMessageType
|
williamr@4
|
192 |
The type of message. Defines the contents of aMsg.
|
williamr@4
|
193 |
@param aMsg
|
williamr@4
|
194 |
The message packed in a descriptor.
|
williamr@4
|
195 |
|
williamr@4
|
196 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
197 |
another of the system-wide error codes.
|
williamr@4
|
198 |
*/
|
williamr@4
|
199 |
virtual TInt MsgFromHwDevice(TUid aMessageType, const TDesC8& aMsg)=0;
|
williamr@4
|
200 |
|
williamr@4
|
201 |
/**
|
williamr@4
|
202 |
Called by a CMMFHwDevice derived class when it stops a decoding/encoding task.
|
williamr@4
|
203 |
*/
|
williamr@4
|
204 |
virtual void Stopped() = 0;
|
williamr@4
|
205 |
|
williamr@4
|
206 |
/**
|
williamr@4
|
207 |
Called by a CMMFHwDevice derived class when it stops a decoding/encoding task.
|
williamr@4
|
208 |
*/
|
williamr@4
|
209 |
virtual void Error(TInt aError=KErrNone) = 0;
|
williamr@4
|
210 |
};
|
williamr@4
|
211 |
|
williamr@4
|
212 |
/*
|
williamr@4
|
213 |
*
|
williamr@4
|
214 |
* KMmfUidPluginInterfaceHwDevice
|
williamr@4
|
215 |
*
|
williamr@4
|
216 |
* This UID is the INTERFACE_UID for CMMFHwDevice. It is used to search for hardware device plugins in plugin DLLs.
|
williamr@4
|
217 |
* All hardware device plugin DLLs must include interface_uid = KMmfUidPluginInterfaceHwDevice in their .rss files.
|
williamr@4
|
218 |
*
|
williamr@4
|
219 |
*/
|
williamr@4
|
220 |
|
williamr@4
|
221 |
/**
|
williamr@4
|
222 |
@publishedPartner
|
williamr@4
|
223 |
@released
|
williamr@4
|
224 |
|
williamr@4
|
225 |
ECom plugin class for a hardware device that decodes (plays) source data in a certain
|
williamr@4
|
226 |
FourCC coding type to another FourCC coding type or encodes (records) data from a certain
|
williamr@4
|
227 |
FourCC coding type to a another FourCC coding type.
|
williamr@4
|
228 |
|
williamr@4
|
229 |
The hardware device can be instantiated in 3 different ways:
|
williamr@4
|
230 |
|
williamr@4
|
231 |
1. NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType)
|
williamr@4
|
232 |
|
williamr@4
|
233 |
This instantiate a hardware device that can encode or decode the aSrcDatatype to a aDstDataType.
|
williamr@4
|
234 |
|
williamr@4
|
235 |
2. NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType, const TDesC& aPreferredSupplier)
|
williamr@4
|
236 |
|
williamr@4
|
237 |
This is similar to the above but is used where there may be multiple hardware devices that
|
williamr@4
|
238 |
perform the same conversion. Third party developers may use their own
|
williamr@4
|
239 |
hardware device implementations and can ensure the controller uses their implementation by setting
|
williamr@4
|
240 |
the preferred supplier to themselves.
|
williamr@4
|
241 |
|
williamr@4
|
242 |
3. NewL(TUid aUid)
|
williamr@4
|
243 |
|
williamr@4
|
244 |
This is used to explicitly instantiate a hardware device where the UID is known.
|
williamr@4
|
245 |
|
williamr@4
|
246 |
4. NewL(TFileName aFileName)
|
williamr@4
|
247 |
|
williamr@4
|
248 |
This is used to create an instance of a HwDevice implementation by loading the library
|
williamr@4
|
249 |
|
williamr@4
|
250 |
CMMFHwDevice provides a generic interface that every Hardware Device that decodes and/or encodes has to implement.
|
williamr@4
|
251 |
Based on parameters specified in Start, the device implementation will start decoding or encoding.
|
williamr@4
|
252 |
The source and destination of the decoding/encoding operations should be set up before starting the task by sending
|
williamr@4
|
253 |
THwDeviceInitParams to the Init() function.
|
williamr@4
|
254 |
*/
|
williamr@4
|
255 |
class CMMFHwDevice : public CBase
|
williamr@4
|
256 |
{
|
williamr@4
|
257 |
public:
|
williamr@4
|
258 |
static CMMFHwDevice* NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType);
|
williamr@4
|
259 |
static CMMFHwDevice* NewL(const TFourCC& aSrcDatatype, const TFourCC& aDstDataType, const TDesC& aPreferredSupplier);
|
williamr@4
|
260 |
inline static CMMFHwDevice* NewL(TUid aUid);
|
williamr@4
|
261 |
static CMMFHwDevice* NewL(TFileName aFileName);
|
williamr@4
|
262 |
|
williamr@4
|
263 |
/**
|
williamr@4
|
264 |
Starts Encoding or Decoding task(s) based on the parameter specified.
|
williamr@4
|
265 |
|
williamr@4
|
266 |
@param aFuncCmd
|
williamr@4
|
267 |
The device function specifying the requested service i.e. decode or encode.
|
williamr@4
|
268 |
@param aFlowCmd
|
williamr@4
|
269 |
The device flow directions for the requested service.
|
williamr@4
|
270 |
|
williamr@4
|
271 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
272 |
another of the system-wide error codes.
|
williamr@4
|
273 |
*/
|
williamr@4
|
274 |
virtual TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd) = 0;
|
williamr@4
|
275 |
|
williamr@4
|
276 |
/**
|
williamr@4
|
277 |
Stops the current on-going task.
|
williamr@4
|
278 |
|
williamr@4
|
279 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
280 |
another of the system-wide error codes.
|
williamr@4
|
281 |
*/
|
williamr@4
|
282 |
virtual TInt Stop() = 0;
|
williamr@4
|
283 |
|
williamr@4
|
284 |
/**
|
williamr@4
|
285 |
Temporarily suspends the current task of decoding or encoding.
|
williamr@4
|
286 |
|
williamr@4
|
287 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
288 |
another of the system-wide error codes.
|
williamr@4
|
289 |
*/
|
williamr@4
|
290 |
virtual TInt Pause() = 0;
|
williamr@4
|
291 |
|
williamr@4
|
292 |
/**
|
williamr@4
|
293 |
Initializes the hardware device tasks.
|
williamr@4
|
294 |
|
williamr@4
|
295 |
@param aDevInfo
|
williamr@4
|
296 |
The device initialization parameters.
|
williamr@4
|
297 |
|
williamr@4
|
298 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
299 |
another of the system-wide error codes.
|
williamr@4
|
300 |
*/
|
williamr@4
|
301 |
virtual TInt Init(THwDeviceInitParams& aDevInfo) = 0;
|
williamr@4
|
302 |
|
williamr@4
|
303 |
/**
|
williamr@4
|
304 |
Retrieves a custom interface to the device.
|
williamr@4
|
305 |
|
williamr@4
|
306 |
@param aInterfaceId
|
williamr@4
|
307 |
The interface UID, defined with the custom interface.
|
williamr@4
|
308 |
|
williamr@4
|
309 |
@return A pointer to the interface implementation, or NULL if the device does not
|
williamr@4
|
310 |
implement the interface requested. The return value must be cast to the
|
williamr@4
|
311 |
correct type by the user.
|
williamr@4
|
312 |
*/
|
williamr@4
|
313 |
virtual TAny* CustomInterface(TUid aInterfaceId) = 0;
|
williamr@4
|
314 |
|
williamr@4
|
315 |
/**
|
williamr@4
|
316 |
Call this function to notify hardware device implementation that
|
williamr@4
|
317 |
data is available in aFillBufferPtr for decoding.
|
williamr@4
|
318 |
|
williamr@4
|
319 |
@param aFillBufferPtr
|
williamr@4
|
320 |
The data buffer filled by the observer.
|
williamr@4
|
321 |
|
williamr@4
|
322 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
323 |
another of the system-wide error codes.
|
williamr@4
|
324 |
*/
|
williamr@4
|
325 |
virtual TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr) = 0;
|
williamr@4
|
326 |
|
williamr@4
|
327 |
/**
|
williamr@4
|
328 |
Call this function to notify hardware device implementation that
|
williamr@4
|
329 |
data in aEmptyBufferPtr from encoding is processed.
|
williamr@4
|
330 |
|
williamr@4
|
331 |
@param aEmptyBufferPtr
|
williamr@4
|
332 |
The data buffer processed by the observer.
|
williamr@4
|
333 |
|
williamr@4
|
334 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
335 |
another of the system-wide error codes.
|
williamr@4
|
336 |
*/
|
williamr@4
|
337 |
virtual TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr) = 0;
|
williamr@4
|
338 |
|
williamr@4
|
339 |
/**
|
williamr@4
|
340 |
Used to configure the sample rate and stereo mode of a CMMFHwDevice plugin.
|
williamr@4
|
341 |
|
williamr@4
|
342 |
The configuration of HwDevices is device specific and is not used in any of the reference
|
williamr@4
|
343 |
devices that return KErrNotSupported.
|
williamr@4
|
344 |
|
williamr@4
|
345 |
@param aConfig
|
williamr@4
|
346 |
The device configuration.
|
williamr@4
|
347 |
*/
|
williamr@4
|
348 |
virtual TInt SetConfig(TTaskConfig& aConfig) = 0;
|
williamr@4
|
349 |
|
williamr@4
|
350 |
/**
|
williamr@4
|
351 |
Call this function to stop and then delete a codec. This is used to allow resources to be freed
|
williamr@4
|
352 |
when using a DSP or similar hardware.
|
williamr@4
|
353 |
|
williamr@4
|
354 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
355 |
another of the system-wide error codes.
|
williamr@4
|
356 |
*/
|
williamr@4
|
357 |
virtual TInt StopAndDeleteCodec() = 0;
|
williamr@4
|
358 |
|
williamr@4
|
359 |
/**
|
williamr@4
|
360 |
Call this function to delete a codec.
|
williamr@4
|
361 |
|
williamr@4
|
362 |
This is used to allow resources to be freed when using a DSP or similar hardware.
|
williamr@4
|
363 |
|
williamr@4
|
364 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@4
|
365 |
another of the system-wide error codes.
|
williamr@4
|
366 |
*/
|
williamr@4
|
367 |
virtual TInt DeleteCodec() = 0;
|
williamr@4
|
368 |
|
williamr@4
|
369 |
/**
|
williamr@4
|
370 |
Destructor.
|
williamr@4
|
371 |
|
williamr@4
|
372 |
The destructor is called by ECom framework allowing derived classes
|
williamr@4
|
373 |
to clean up the implementation specific resources.
|
williamr@4
|
374 |
*/
|
williamr@4
|
375 |
inline virtual ~CMMFHwDevice();
|
williamr@4
|
376 |
|
williamr@4
|
377 |
private:
|
williamr@4
|
378 |
static void SelectByPreference( RImplInfoPtrArray& aPlugInArray, const TDesC& aPreferredSupplier ) ;
|
williamr@4
|
379 |
|
williamr@4
|
380 |
protected:
|
williamr@4
|
381 |
/**
|
williamr@4
|
382 |
A pointer to the hardware device observer.
|
williamr@4
|
383 |
*/
|
williamr@4
|
384 |
MMMFHwDeviceObserver* iHwDeviceObserver;
|
williamr@4
|
385 |
|
williamr@4
|
386 |
//Attributes
|
williamr@4
|
387 |
private:
|
williamr@4
|
388 |
TUid iDtor_ID_Key;
|
williamr@4
|
389 |
};
|
williamr@4
|
390 |
|
williamr@4
|
391 |
#include <mmf/server/mmfhwdevice.inl>
|
williamr@4
|
392 |
|
williamr@4
|
393 |
#endif
|
williamr@4
|
394 |
|