|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef MCECODEC_H |
|
22 #define MCECODEC_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include <mcedefs.h> |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class RReadStream; |
|
30 class RWriteStream; |
|
31 class CMceComCodec; |
|
32 |
|
33 class CMceMediaStream; |
|
34 class TMceEvent; |
|
35 class TMceMediaId; |
|
36 class TMceFactory; |
|
37 class MMceComSerializationContext; |
|
38 |
|
39 // DATA TYPES |
|
40 typedef TUint TMceCodecType; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * Base class for codecs. |
|
46 * |
|
47 * It defines setters and getters for generic codec attributes. |
|
48 * |
|
49 * In some systems certain device resources cannot be shared. For example |
|
50 * speaker of the device might not be able to play simultaneously several |
|
51 * differently encoded audio streams. Or only one client at the time |
|
52 * could use the camera of the device. Codec states can be used to overcome |
|
53 * situations where single codec would occupy some resource for excessive |
|
54 * period of time or permanently. |
|
55 * |
|
56 * Codec can be in one of the three states: |
|
57 * |
|
58 * When codec is in state EEnabled, resources, associated with the codec, |
|
59 * are reserved for the codec and in some cases cannot be used by other |
|
60 * software components. Precondition for reserving resources for the codec |
|
61 * is that associated device resource (e.g. speaker sink of downlink or |
|
62 * camera source of uplink) is also enabled. |
|
63 * |
|
64 * When codec is in state EStandby, resources are not reserved for the codec |
|
65 * and therefore can be used by other software components. If the stream |
|
66 * (uplink or downlink), into which this codec is attached, encounters data |
|
67 * encoded with the codec, codec in state EStandby is tried to be enabled. |
|
68 * If enabling succeeds, codec state changes to EEnabled and associated |
|
69 * resources are reserved. |
|
70 * |
|
71 * When codec is in state EDisabled, resources are not reserved for the codec |
|
72 * and are not even tried to be reserved. |
|
73 * |
|
74 * @lib mceclient.lib |
|
75 */ |
|
76 class CMceCodec : public CBase |
|
77 { |
|
78 |
|
79 public: // Codec states |
|
80 |
|
81 enum TState |
|
82 { |
|
83 EDisabled, |
|
84 EStandby, |
|
85 EEnabled |
|
86 }; |
|
87 |
|
88 public: // Constructors and destructor |
|
89 |
|
90 /** |
|
91 * Destructor. |
|
92 */ |
|
93 virtual ~CMceCodec(); |
|
94 |
|
95 public: // New functions |
|
96 |
|
97 /** |
|
98 * Sets bitrate used with codec for encoding. |
|
99 * @param aBitrate bitrate value for encoding |
|
100 * @return KErrNotSupported if codec doesn't support bitrate |
|
101 * value issued |
|
102 */ |
|
103 virtual TInt SetBitrate( TUint aBitrate ) = 0; |
|
104 |
|
105 /** |
|
106 * Sets bitrates allowed with codec. Allowed bitrates are copied |
|
107 * automatically to same codec of opposite direction stream if streams |
|
108 * are bound. |
|
109 * @param aBitrates allowed bitrate values |
|
110 * @return KErrNotSupported if codec doesn't support bitrate |
|
111 * values issued |
|
112 */ |
|
113 virtual TInt SetAllowedBitrates( TUint aBitrates ) = 0; |
|
114 |
|
115 /** |
|
116 * Sets the codec specific mode. Codec mode is copied |
|
117 * automatically to same codec of opposite direction stream if streams |
|
118 * are bound. |
|
119 * @param aCodecMode mode of the codec |
|
120 * @return KErrNotSupported if codec doesnt' support codec mode |
|
121 * value issued |
|
122 */ |
|
123 virtual TInt SetCodecMode( TUint aCodecMode ) = 0; |
|
124 |
|
125 /** |
|
126 * Sets the payload type. |
|
127 * @param aPayloadType type identifier of the payload |
|
128 * @return KErrNotSupported if codec doesn't support payload type issued |
|
129 */ |
|
130 virtual TInt SetPayloadType( TUint8 aPayloadType ) = 0; |
|
131 |
|
132 |
|
133 public: // New functions |
|
134 |
|
135 /** |
|
136 * Sets the state of the codec. |
|
137 * @param aState desired codec state |
|
138 */ |
|
139 IMPORT_C void SetStateL( CMceCodec::TState aState ); |
|
140 |
|
141 /** |
|
142 * Sets the timer period in seconds from starting of inactivity |
|
143 * to automatically changing to state CMceCodec::EStandby . |
|
144 * @param aTimerValue timer period in seconds |
|
145 */ |
|
146 IMPORT_C void SetStandByTimerL( TUint32 aTimerValue ); |
|
147 |
|
148 /** |
|
149 * Sets MMF priority value for the codec. |
|
150 * @param aPriority priority of the codec |
|
151 */ |
|
152 IMPORT_C void SetMMFPriorityL( TInt aPriority ); |
|
153 |
|
154 /** |
|
155 * Sets MMF priority preference value for the codec. |
|
156 * @param aPriorityPreference priority preference of the codec |
|
157 */ |
|
158 IMPORT_C void SetMMFPriorityPreferenceL( TInt aPriorityPreference ); |
|
159 |
|
160 /** |
|
161 * Set keep alive packets send timer value. |
|
162 * @param aTimerValue timer value in ms for keep alive packets |
|
163 * @return One of the standard system-wide error codes. |
|
164 */ |
|
165 IMPORT_C void SetKeepAliveTimerL( TUint8 aTimerValue ); |
|
166 |
|
167 /** |
|
168 * Set keep alive packets payload type. |
|
169 * @param aKeepAlivePT payload type for keep alive packets |
|
170 * @return One of the standard system-wide error codes. |
|
171 */ |
|
172 IMPORT_C void SetKeepAlivePayloadTypeL( TUint8 aKeepAlivePT ); |
|
173 |
|
174 /** |
|
175 * Set keep alive packets payload data. |
|
176 * @param aData payload data for keep alive packets |
|
177 * @return One of the standard system-wide error codes. |
|
178 */ |
|
179 IMPORT_C void SetKeepAliveDataL( const TDesC8& aData ); |
|
180 |
|
181 public: // Getters |
|
182 |
|
183 /** |
|
184 * Gets the state of the codec |
|
185 * @return state of the codec |
|
186 */ |
|
187 IMPORT_C CMceCodec::TState State() const; |
|
188 |
|
189 /** |
|
190 * Type of the codec |
|
191 * @return codec type |
|
192 */ |
|
193 IMPORT_C TMceCodecType Type() const; |
|
194 |
|
195 /** |
|
196 * Gets codec fourCC. |
|
197 * @return fourCC value |
|
198 */ |
|
199 IMPORT_C TUint32 FourCC() const; |
|
200 |
|
201 /** |
|
202 * Gets current bitrate. |
|
203 * @return bitrate value |
|
204 */ |
|
205 IMPORT_C TUint Bitrate() const; |
|
206 |
|
207 /** |
|
208 * Gets allowed bitrate values. |
|
209 * @return bitrate values |
|
210 */ |
|
211 IMPORT_C TUint AllowedBitrates() const; |
|
212 |
|
213 /** |
|
214 * Gets current frame size of the codec. |
|
215 * @return size of single frame used by the codec |
|
216 */ |
|
217 IMPORT_C TUint FrameSize() const; |
|
218 |
|
219 /** |
|
220 * Gets the codec mode. |
|
221 * @return codec mode |
|
222 */ |
|
223 IMPORT_C TUint CodecMode() const; |
|
224 |
|
225 /** |
|
226 * Gets the payload type identifier. |
|
227 * @return payload type used |
|
228 */ |
|
229 IMPORT_C TUint8 PayloadType() const; |
|
230 |
|
231 /** |
|
232 * Gets the sdp name. |
|
233 * @return sdp name of the codec |
|
234 */ |
|
235 IMPORT_C const TDesC8& SdpName() const; |
|
236 |
|
237 /** |
|
238 * Gets MMF priority |
|
239 * @return MMF priority |
|
240 */ |
|
241 IMPORT_C TInt MMFPriority() const; |
|
242 |
|
243 /** |
|
244 * Gets MMF priority preference |
|
245 * @return current MMFPriorityPreference |
|
246 */ |
|
247 IMPORT_C TInt MMFPriorityPreference() const; |
|
248 |
|
249 /** |
|
250 * Gets keep alive packets send timer value. |
|
251 * @return keep alive packets send timer value (ms). |
|
252 */ |
|
253 IMPORT_C TUint8 KeepAliveTimer() const; |
|
254 |
|
255 /** |
|
256 * Gets keep alive packets payload type. |
|
257 * @return keep alive packets payload type. |
|
258 */ |
|
259 IMPORT_C TUint8 KeepAlivePayloadType() const; |
|
260 |
|
261 /** |
|
262 * Gets keep alive packets payload data. |
|
263 * @return keep alive packets payload data. |
|
264 */ |
|
265 IMPORT_C const TDesC8& KeepAliveData() const; |
|
266 |
|
267 public: // Preference manipulation |
|
268 |
|
269 /** |
|
270 * Gets the preference value. |
|
271 * @return preference value of the codec |
|
272 */ |
|
273 IMPORT_C TInt Preference() const; |
|
274 |
|
275 /** |
|
276 * Sets the preference value used in media negotiation. |
|
277 * Codec with preference value 0 is considered as the most preferenced |
|
278 * codec. Preference of codecs with the same preference value is |
|
279 * determined by order they were added to the stream. |
|
280 * @param aPreference preference value of the codec |
|
281 */ |
|
282 IMPORT_C void SetPreferenceL( TInt aPeference ); |
|
283 |
|
284 |
|
285 public: // Internal |
|
286 |
|
287 /** |
|
288 * Media id of the codec. |
|
289 * @return media id |
|
290 */ |
|
291 TMceMediaId Id() const; |
|
292 |
|
293 /** |
|
294 * Initializes the codec. |
|
295 * @param aParent the parent |
|
296 */ |
|
297 virtual void InitializeL( CMceMediaStream& aParent ); |
|
298 |
|
299 /** |
|
300 * Gets the base factory. |
|
301 * @return factory |
|
302 */ |
|
303 TMceFactory BaseFactory(); |
|
304 |
|
305 /** |
|
306 * Gets the flat data |
|
307 * @return flat data |
|
308 */ |
|
309 CMceComCodec* FlatData(); |
|
310 |
|
311 /** |
|
312 * Attaches stream to codec, preliminary intialization. |
|
313 */ |
|
314 void Attach( CMceMediaStream& aParent ); |
|
315 |
|
316 |
|
317 public: // from MMceComSerializableMedia |
|
318 |
|
319 |
|
320 /** |
|
321 * Returns serialization id |
|
322 * @return serialization id |
|
323 */ |
|
324 TUint64 SerializationId() const; |
|
325 |
|
326 /** |
|
327 * Internalizes flat data |
|
328 * @param aReadStream read stream |
|
329 */ |
|
330 void InternalizeFlatL( RReadStream& aReadStream ); |
|
331 |
|
332 /** |
|
333 * Externalizes flat data |
|
334 * @param aWriteStream write stream |
|
335 */ |
|
336 void ExternalizeFlatL( RWriteStream& aWriteStream ); |
|
337 |
|
338 /** |
|
339 * Internalizes |
|
340 * @param aSerCtx context for serialization |
|
341 */ |
|
342 virtual void InternalizeL( MMceComSerializationContext& aSerCtx ); |
|
343 |
|
344 /** |
|
345 * Externalizes |
|
346 * @param aSerCtx context for serialization |
|
347 */ |
|
348 virtual void ExternalizeL( MMceComSerializationContext& aSerCtx ); |
|
349 |
|
350 |
|
351 |
|
352 public: // Event handling |
|
353 |
|
354 /** |
|
355 * Traversal event handler. |
|
356 * @param aEvent the event |
|
357 * @return status; if event was consumed or not or object needs update |
|
358 */ |
|
359 virtual TInt EventReceivedL( TMceEvent& aEvent ); |
|
360 |
|
361 /** |
|
362 * Called after update. |
|
363 */ |
|
364 virtual void Updated(); |
|
365 |
|
366 protected: // New functions |
|
367 |
|
368 /** |
|
369 * Sets the sdp name. |
|
370 * @param aSdpName sdp name for the codec |
|
371 */ |
|
372 virtual void SetSdpNameL( const TDesC8& aSdpName ) = 0; |
|
373 |
|
374 /** |
|
375 * C++ default constructor. |
|
376 */ |
|
377 CMceCodec(); |
|
378 |
|
379 /** |
|
380 * Second-phase constructor. |
|
381 * @param aFlatData flat data container |
|
382 */ |
|
383 void ConstructL( CMceComCodec* aFlatData ); |
|
384 |
|
385 protected: // Data |
|
386 |
|
387 /** |
|
388 * Flat data container. |
|
389 */ |
|
390 CMceComCodec* iFlatData; |
|
391 |
|
392 /** |
|
393 * Codec type. |
|
394 */ |
|
395 TMceCodecType iType; |
|
396 |
|
397 protected: // NOT owned data |
|
398 |
|
399 /** |
|
400 * Parent stream, not owned. |
|
401 */ |
|
402 CMceMediaStream* iStream; |
|
403 |
|
404 private: // Reserved for future use |
|
405 |
|
406 TAny* iReserved; |
|
407 |
|
408 //for testing |
|
409 |
|
410 MCE_UNIT_TEST_DEFS |
|
411 }; |
|
412 |
|
413 |
|
414 #endif |
|
415 |
|
416 // End of File |