|
1 /* |
|
2 * Copyright (c) 2009 Aricent and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "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 * Aricent - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Declares plugin class for Mpeg4SP/H263 encoder HwDevice. This class inherits |
|
16 * from CMMFVideoEncodeHwDevice and implements the pure virtual functions.The |
|
17 * class also contains implementation specific private methods. |
|
18 * |
|
19 */ |
|
20 |
|
21 #ifndef ARIMP4SPENCHWDEVICEIMPL_H |
|
22 #define ARIMP4SPENCHWDEVICEIMPL_H |
|
23 |
|
24 //System Includes |
|
25 #include <Implementationproxy.h> |
|
26 #include <f32file.h> |
|
27 #include <e32const.h> |
|
28 #include <e32base.h> |
|
29 #include <Videorecordhwdevice.h> |
|
30 |
|
31 //User Includes |
|
32 #include "arivideoenccommon.h" |
|
33 #include "aristatemachine.h" |
|
34 #include "aribaseengine.h" |
|
35 #include "arimp4spencwrapper.h" |
|
36 //#include "arimp4spenchwdevice.h" |
|
37 #include "arimp4spenchwdeviceuids.hrh" |
|
38 #include "ariprint.h" |
|
39 |
|
40 // Forward declarations |
|
41 |
|
42 /** |
|
43 * This class is part of Aricent's Mpeg4-sp/H263 encoder HwDevice plugin used |
|
44 * for encoding yuv420 input to Mpeg4-sp/H263 content. |
|
45 * Provides implementation for standard MDF HwDevice plugin APIs as well as |
|
46 * private functions used internal to this class for .This class also |
|
47 * implements callback APIs from MProcessEngineObserver which are called |
|
48 * from CBaseEngine. |
|
49 */ |
|
50 class CAriMp4spencHwDeviceImpl: public CMMFVideoEncodeHwDevice, |
|
51 public MProcessEngineObserver |
|
52 { |
|
53 |
|
54 public: |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * @return pointer to an instance of CAriMp4spencHwDeviceImpl |
|
58 * @leave "The method will leave if an error occurs" |
|
59 */ |
|
60 static CAriMp4spencHwDeviceImpl* NewL(); |
|
61 |
|
62 /**> Destructor */ |
|
63 ~CAriMp4spencHwDeviceImpl(); |
|
64 |
|
65 public: |
|
66 /** |
|
67 * From CMMFVideoHwDevice |
|
68 * The function retrieves a custom interface to the HwDevice. |
|
69 * @param aInterface |
|
70 * UID of the interface to be retrieved. It is defined with the custom |
|
71 * interface |
|
72 * @return returns pointer to the interface |
|
73 */ |
|
74 TAny* CustomInterface( TUid aInterface ); |
|
75 |
|
76 public: |
|
77 /** |
|
78 * From CMMFVideoEncodeHwDevice |
|
79 * The function retrieves information about the video encoder |
|
80 * @return "returns pointer to the object with encoder information" |
|
81 * @leave "The method will leave if an error occurs" |
|
82 */ |
|
83 CVideoEncoderInfo* VideoEncoderInfoLC(); |
|
84 |
|
85 /** |
|
86 * From CMMFVideoEncodeHwDevice |
|
87 * The function sets the encoder output format. |
|
88 * @param aFormat |
|
89 * UID of the interface to be retrieved. It is defined with the custom |
|
90 * interface |
|
91 * @param aDataUnitType |
|
92 * The type of output coded data units |
|
93 * @param aDataEncapsulation |
|
94 * Data encapsulation type for output encoded data units |
|
95 * @param aSegmentationAllowed |
|
96 * Indicates if segmentation is allowed or not |
|
97 * @leave "The method will leave if an error occurs" |
|
98 */ |
|
99 void SetOutputFormatL( const CCompressedVideoFormat& aFormat, |
|
100 TVideoDataUnitType aDataUnitType, |
|
101 TVideoDataUnitEncapsulation aDataEncapsulation, |
|
102 TBool aSegmentationAllowed=EFalse ); |
|
103 |
|
104 /** |
|
105 * From CMMFVideoEncodeHwDevice |
|
106 * The function sets the pre-processor hwdevice that will write data to |
|
107 * this encoder. |
|
108 * @param aDevice |
|
109 * Pre-processor device that will write to this encoder |
|
110 */ |
|
111 void SetInputDevice( CMMFVideoPreProcHwDevice* aDevice ); |
|
112 |
|
113 /** |
|
114 * From CMMFVideoEncodeHwDevice |
|
115 * The function sets the number of bit-rate scalability layers to use. |
|
116 * @param aNumLayers |
|
117 * The number of bit-rate scalability layers to use |
|
118 * @leave "The method will leave if an error occurs" |
|
119 */ |
|
120 void SetNumBitrateLayersL( TUint aNumLayers ); |
|
121 |
|
122 /** |
|
123 * From CMMFVideoEncodeHwDevice |
|
124 * The function sets the scalability type for a bit-rate scalability layer |
|
125 * @param aLayer |
|
126 * The layer number |
|
127 * @param aScalabilityType |
|
128 * Layer scalability type |
|
129 * @leave "The method will leave if an error occurs" |
|
130 */ |
|
131 void SetScalabilityLayerTypeL( TUint aLayer, |
|
132 TScalabilityType aScalabilityType); |
|
133 |
|
134 /** |
|
135 * From CMMFVideoEncodeHwDevice |
|
136 * The function sets the reference picture options to be used for all |
|
137 * scalability layers |
|
138 * @param aMaxReferencePictures |
|
139 * Maximum number of reference pictures to be used |
|
140 * @param aMaxPictureOrderDelay |
|
141 * The maximum picture order delay, in number of pictures. |
|
142 */ |
|
143 void SetGlobalReferenceOptions( TUint aMaxReferencePictures, |
|
144 TUint aMaxPictureOrderDelay ); |
|
145 |
|
146 /** |
|
147 * From CMMFVideoEncodeHwDevice |
|
148 * The function sets the reference picture options to be used for a |
|
149 * particular scalability layer |
|
150 * @param aLayer |
|
151 * The layer number |
|
152 * @param aMaxReferencePictures |
|
153 * Maximum number of reference pictures to be used for this layer |
|
154 * @param aMaxPictureOrderDelay |
|
155 * The maximum picture order delay for this layer, in number of |
|
156 * pictures. |
|
157 */ |
|
158 void SetLayerReferenceOptions( TUint aLayer,TUint aMaxReferencePictures, |
|
159 TUint aMaxPictureOrderDelay ); |
|
160 |
|
161 /** |
|
162 * From CMMFVideoEncodeHwDevice |
|
163 * The function sets the encoder buffering options |
|
164 * @param aOptions |
|
165 * Buffering options to be used |
|
166 * @leave "The method will leave if an error occurs" |
|
167 */ |
|
168 void SetBufferOptionsL( const TEncoderBufferOptions& aOptions ); |
|
169 |
|
170 /** |
|
171 * From CMMFVideoEncodeHwDevice |
|
172 * The function sets the encoder output rectangle |
|
173 * @param aRect |
|
174 * Output rectangle to be used |
|
175 * @leave "The method will leave if an error occurs" |
|
176 */ |
|
177 void SetOutputRectL( const TRect& aRect ); |
|
178 |
|
179 /** |
|
180 * From CMMFVideoEncodeHwDevice |
|
181 * The function notifies the encoder whether bit errors or packets losses |
|
182 * can be expected in the video transmission |
|
183 * @param aBitErrors |
|
184 * Boolean to indicate if bit errors can be expected |
|
185 * @param aPacketLosses |
|
186 * Boolean to indicate if packet losses can be expected |
|
187 */ |
|
188 void SetErrorsExpected( TBool aBitErrors, TBool aPacketLosses ); |
|
189 |
|
190 /** |
|
191 * From CMMFVideoEncodeHwDevice |
|
192 * The function sets the minimum random access rate to be used |
|
193 * @param aRate |
|
194 * The minimum random access rate |
|
195 */ |
|
196 void SetMinRandomAccessRate( TReal aRate ); |
|
197 |
|
198 /** |
|
199 * From CMMFVideoEncodeHwDevice |
|
200 * The function sets the coding standard specific options to be used. |
|
201 * @param aOptions |
|
202 * Coding standard specific options to be used |
|
203 * @leave "The method will leave if an error occurs" |
|
204 */ |
|
205 void SetCodingStandardSpecificOptionsL( const TDesC8& aOptions ); |
|
206 |
|
207 /** |
|
208 * From CMMFVideoEncodeHwDevice |
|
209 * The function sets the implementation specific options to be used |
|
210 * @param aOptions |
|
211 * Implementation specific options to be used. |
|
212 * @leave "The method will leave if an error occurs" |
|
213 */ |
|
214 void SetImplementationSpecificEncoderOptionsL( const TDesC8& aOptions ); |
|
215 |
|
216 /** |
|
217 * From CMMFVideoEncodeHwDevice |
|
218 * The function returns coding-standard specific initialization output |
|
219 * from the encoder |
|
220 * @return Returns the pointer to buffer holding coding-standard specific |
|
221 * initialization output |
|
222 * @leave "The method will leave if an error occurs" |
|
223 */ |
|
224 HBufC8* CodingStandardSpecificInitOutputLC(); |
|
225 |
|
226 /** |
|
227 * From CMMFVideoEncodeHwDevice |
|
228 * The function gets the implementation specific initialization output from |
|
229 * the encoder |
|
230 * @return Returns the pointer to buffer holding implementation specific |
|
231 * initialization output |
|
232 * @leave "The method will leave if an error occurs" |
|
233 */ |
|
234 HBufC8* ImplementationSpecificInitOutputLC(); |
|
235 |
|
236 /** |
|
237 * From CMMFVideoEncodeHwDevice |
|
238 * The function the number of unequal error protection levels. |
|
239 * @param aNumLevels |
|
240 * The number of unequal error protection levels to be used |
|
241 * @param aSeparateBuffers |
|
242 * Boolean indicating whether each unequal error protection level of a |
|
243 * coded data unit shall be encapsulated in its own output buffer |
|
244 * @leave "The method will leave if an error occurs" |
|
245 */ |
|
246 void SetErrorProtectionLevelsL( TUint aNumLevels, |
|
247 TBool aSeparateBuffers ); |
|
248 |
|
249 /** |
|
250 * From CMMFVideoEncodeHwDevice |
|
251 * The function the number of unequal error protection levels. |
|
252 * @param aNumLevels |
|
253 * The number of unequal error protection levels to be used |
|
254 * @param aSeparateBuffers |
|
255 * Boolean indicating whether each unequal error protection level of a |
|
256 * coded data unit shall be encapsulated in its own output buffer |
|
257 * @param aStrength |
|
258 * Forward error control strength for this error protection level |
|
259 * @leave "The method will leave if an error occurs" |
|
260 */ |
|
261 void SetErrorProtectionLevelL( TUint aLevel, TUint aBitrate, |
|
262 TUint aStrength ); |
|
263 |
|
264 /** |
|
265 * From CMMFVideoEncodeHwDevice |
|
266 * The function sets the expected or prevailing channel conditions for an |
|
267 * unequal error protection |
|
268 * level in terms of expected packet loss rate. |
|
269 * @param aLevel |
|
270 * Error protection level number |
|
271 * @param aLossRate |
|
272 * Packet loss rate, in number of packets lost per second. |
|
273 * @param aLossBurstLength |
|
274 * Expected average packet loss burst length |
|
275 */ |
|
276 void SetChannelPacketLossRate( TUint aLevel, TReal aLossRate, |
|
277 TTimeIntervalMicroSeconds32 aLossBurstLength ); |
|
278 |
|
279 |
|
280 /** |
|
281 * From CMMFVideoEncodeHwDevice |
|
282 * The function sets the expected or prevailing channel conditions for an |
|
283 * unequal error |
|
284 * protection level, in terms of expected bit error rate |
|
285 * @param aLevel |
|
286 * Error protection level number |
|
287 * @param aErrorRate |
|
288 * Expected bit error rate |
|
289 * @param aStdDeviation |
|
290 * Expected bit error rate standard deviation |
|
291 */ |
|
292 void SetChannelBitErrorRate( TUint aLevel, TReal aErrorRate, |
|
293 TReal aStdDeviation ); |
|
294 |
|
295 /** |
|
296 * From CMMFVideoEncodeHwDevice |
|
297 * The function sets the segment size. To be used only for packet mode |
|
298 * @param aLayer |
|
299 * Layer number |
|
300 * @param aSizeBytes |
|
301 * Segment size in bytes |
|
302 * @param aSizeMacroblocks |
|
303 * Size of the macro blocks |
|
304 */ |
|
305 void SetSegmentTargetSize( TUint aLayer, TUint aSizeBytes, |
|
306 TUint aSizeMacroblocks ); |
|
307 |
|
308 /** |
|
309 * From CMMFVideoEncodeHwDevice |
|
310 * The function sets the bit-rate control options for a layer |
|
311 * @param aLayer |
|
312 * Bit-rate scalability layer number |
|
313 * @param aOptions |
|
314 * Bit-rate control options to be used |
|
315 */ |
|
316 void SetRateControlOptions( TUint aLayer, |
|
317 const TRateControlOptions& aOptions ); |
|
318 |
|
319 |
|
320 /** |
|
321 * From CMMFVideoEncodeHwDevice |
|
322 * The function sets the in-layer scalability options for a layer |
|
323 * @param aLayer |
|
324 * Bit-rate scalability layer number |
|
325 * @param aNumSteps |
|
326 * The number of in-layer scalability steps to use |
|
327 * @param aScalabilityType |
|
328 * Bit-rate share for each scalability step |
|
329 * @param aBitrateShare |
|
330 * Picture rate share for each scalability step |
|
331 * @param aPictureShare |
|
332 * The scalability type to use |
|
333 * @leave "The method will leave if an error occurs" |
|
334 */ |
|
335 void SetInLayerScalabilityL( TUint aLayer,TUint aNumSteps, |
|
336 TInLayerScalabilityType aScalabilityType, |
|
337 const TArray<TUint>& aBitrateShare, |
|
338 const TArray<TUint>& aPictureShare ); |
|
339 |
|
340 /** |
|
341 * From CMMFVideoEncodeHwDevice |
|
342 * The function sets the segment size. To be used only for packet mode |
|
343 * @param aLayer |
|
344 * Layer number |
|
345 * @param aPeriod |
|
346 * The number of in-layer scalability steps to use |
|
347 */ |
|
348 void SetLayerPromotionPointPeriod( TUint aLayer, TUint aPeriod ); |
|
349 |
|
350 |
|
351 /** |
|
352 * From CMMFVideoEncodeHwDevice |
|
353 * The function gets the coding-standard specific settings output from the |
|
354 * encoder |
|
355 * @return Returns the pointer to buffer holding coding-standard specific |
|
356 * settings output |
|
357 * @leave "The method will leave if an error occurs" |
|
358 */ |
|
359 HBufC8* CodingStandardSpecificSettingsOutputLC(); |
|
360 |
|
361 /** |
|
362 * From CMMFVideoEncodeHwDevice |
|
363 * The function gets the Implementation specific settings output from the |
|
364 * encoder |
|
365 * @return Returns the pointer to buffer holding Implementation specific |
|
366 * settings output |
|
367 * @leave "The method will leave if an error occurs" |
|
368 */ |
|
369 HBufC8* ImplementationSpecificSettingsOutputLC(); |
|
370 |
|
371 /** |
|
372 * From CMMFVideoEncodeHwDevice |
|
373 * The function requests the encoder to send supplemental information in |
|
374 * the bit stream |
|
375 * @param aData |
|
376 * Supplemental information data to send |
|
377 * @leave "The method will leave if an error occurs" |
|
378 */ |
|
379 void SendSupplementalInfoL( const TDesC8& aData ); |
|
380 |
|
381 /** |
|
382 * From CMMFVideoEncodeHwDevice |
|
383 * The function requests the encoder to send supplemental information in |
|
384 * the bit stream |
|
385 * @param aData |
|
386 * Supplemental information data to send |
|
387 * @param aTimestamp |
|
388 * Timestamp for the picture in which the supplemental information |
|
389 * should be included |
|
390 * @leave "The method will leave if an error occurs" |
|
391 */ |
|
392 void SendSupplementalInfoL( const TDesC8& aData, |
|
393 const TTimeIntervalMicroSeconds& aTimestamp ); |
|
394 |
|
395 /** |
|
396 * From CMMFVideoEncodeHwDevice |
|
397 * The function requests the encoder to cancel the current supplemental |
|
398 * information send request |
|
399 */ |
|
400 void CancelSupplementalInfo(); |
|
401 |
|
402 /** |
|
403 * From CMMFVideoEncodeHwDevice |
|
404 * The function gets the current output buffer status |
|
405 * @param aNumFreeBuffers |
|
406 * Target for the number of free output buffers |
|
407 * @param aTotalFreeBytes |
|
408 * Target for the total free buffer size in bytes |
|
409 */ |
|
410 void GetOutputBufferStatus( TUint& aNumFreeBuffers, |
|
411 TUint& aTotalFreeBytes ); |
|
412 |
|
413 /** |
|
414 * From CMMFVideoEncodeHwDevice |
|
415 * The function returns a used output buffer back to the encoder |
|
416 * @param aBuffer |
|
417 * The buffer to be returned |
|
418 */ |
|
419 void ReturnBuffer( TVideoOutputBuffer* aBuffer ); |
|
420 |
|
421 /** |
|
422 * From CMMFVideoEncodeHwDevice |
|
423 * The function notifies the encoder that a picture loss has occurred |
|
424 * without specifying the lost picture. |
|
425 */ |
|
426 void PictureLoss(); |
|
427 |
|
428 |
|
429 /** |
|
430 * From CMMFVideoEncodeHwDevice |
|
431 * The function notifies the encoder that a picture loss has occurred |
|
432 * @param aPictures |
|
433 * Picture identifiers of lost pictures |
|
434 */ |
|
435 void PictureLoss( const TArray<TPictureId>& aPictures ); |
|
436 |
|
437 /** |
|
438 * From CMMFVideoEncodeHwDevice |
|
439 * The function notify the encoder that slice loss has occurred, giving |
|
440 * the details of the macroblocks and the picture to which they belong |
|
441 * @param aFirstMacroblock |
|
442 * The first lost macroblock. |
|
443 * @param aNumMacroblocks |
|
444 * The number of macroblocks in the lost slice |
|
445 * @param aPicture |
|
446 * The picture identified for the picture where the slice was lost |
|
447 */ |
|
448 void SliceLoss( TUint aFirstMacroblock, TUint aNumMacroblocks, |
|
449 const TPictureId& aPicture ); |
|
450 |
|
451 /** |
|
452 * From CMMFVideoEncodeHwDevice |
|
453 * The function requests the encoder to use reference picture selection |
|
454 * @param aSelectionData |
|
455 * The reference picture selection request message |
|
456 */ |
|
457 void ReferencePictureSelection( const TDesC8& aSelectionData ); |
|
458 |
|
459 |
|
460 public: |
|
461 |
|
462 /** |
|
463 * From CMMFVideoRecordHwDevice |
|
464 * The function initializes the encoder HwDevice with the configuration |
|
465 * settings and reserve |
|
466 * the hardware resources required |
|
467 */ |
|
468 void Initialize(); |
|
469 |
|
470 /** |
|
471 * From CMMFVideoRecordHwDevice |
|
472 * The function commits all changes since the last CommitL(), Revert() or |
|
473 * Initialize() to the hardware device |
|
474 * @leave "The method will leave if an error occurs" |
|
475 */ |
|
476 void CommitL(); |
|
477 |
|
478 /** |
|
479 * From CMMFVideoRecordHwDevice |
|
480 * The function reverts all changes since the last CommitL(), Revert() or |
|
481 * Initialize() |
|
482 * back to their previous settings. |
|
483 */ |
|
484 void Revert(); |
|
485 |
|
486 /** |
|
487 * From CMMFVideoRecordHwDevice |
|
488 * The function writes an uncompressed input picture |
|
489 * @param aPicture |
|
490 * The picture to write |
|
491 * @leave "The method will leave if an error occurs" |
|
492 */ |
|
493 void WritePictureL( TVideoPicture* aPicture ); |
|
494 |
|
495 /** |
|
496 * From CMMFVideoRecordHwDevice |
|
497 * The function notifies the hardware device that the end of input data |
|
498 * has been reached. |
|
499 */ |
|
500 void InputEnd(); |
|
501 |
|
502 /** |
|
503 * From CMMFVideoRecordHwDevice |
|
504 * The function starts recording video. |
|
505 */ |
|
506 void Start(); |
|
507 |
|
508 static TInt TimerCallBack( TAny* aPtr ); |
|
509 |
|
510 /** |
|
511 * From CMMFVideoRecordHwDevice |
|
512 * The function stops recording video |
|
513 */ |
|
514 void Stop(); |
|
515 |
|
516 /** |
|
517 * From CMMFVideoRecordHwDevice |
|
518 * The function pauses video recording. |
|
519 */ |
|
520 void Pause(); |
|
521 |
|
522 |
|
523 /** |
|
524 * From CMMFVideoRecordHwDevice |
|
525 * The function resumes video recording after a pause. |
|
526 */ |
|
527 void Resume(); |
|
528 |
|
529 |
|
530 /** |
|
531 * From CMMFVideoRecordHwDevice |
|
532 * The function freezes the input picture |
|
533 */ |
|
534 void Freeze(); |
|
535 |
|
536 |
|
537 /** |
|
538 * From CMMFVideoRecordHwDevice |
|
539 * The function releases a frozen input picture. |
|
540 */ |
|
541 void ReleaseFreeze(); |
|
542 |
|
543 |
|
544 /** |
|
545 * From CMMFVideoRecordHwDevice |
|
546 * The function returns the current recording position |
|
547 * @return Returns the current recording position |
|
548 */ |
|
549 TTimeIntervalMicroSeconds RecordingPosition(); |
|
550 |
|
551 |
|
552 /** |
|
553 * From CMMFVideoRecordHwDevice |
|
554 * The function reads various counters related to processed video pictures |
|
555 * @param aCounters |
|
556 * The counter structure to fill |
|
557 */ |
|
558 void GetPictureCounters( CMMFDevVideoRecord:: |
|
559 TPictureCounters& aCounters ); |
|
560 |
|
561 /** |
|
562 * From CMMFVideoRecordHwDevice |
|
563 * The function reads the frame stabilisation output picture position |
|
564 * @param aRect |
|
565 * Output rect which holds frame stabilisation output |
|
566 */ |
|
567 void GetFrameStabilisationOutput( TRect& aRect ); |
|
568 |
|
569 /** |
|
570 * From CMMFVideoRecordHwDevice |
|
571 * The function retrieves the number of complexity control levels |
|
572 * available for this hardware device |
|
573 * @return Returns the number of complexity level |
|
574 */ |
|
575 TUint NumComplexityLevels(); |
|
576 |
|
577 |
|
578 /** |
|
579 * From CMMFVideoRecordHwDevice |
|
580 * The function sets the complexity level to use for video processing in a |
|
581 * hardware device |
|
582 * @param aLevel |
|
583 * The computational complexity level to use. |
|
584 */ |
|
585 void SetComplexityLevel( TUint aLevel ); |
|
586 |
|
587 /** |
|
588 * From CMMFVideoRecordHwDevice |
|
589 * The function gets the information about the pre-processing capabilities |
|
590 * of the encoder hwdevice |
|
591 * @return Returns the pointer to object holding preprocessor info |
|
592 * @leave "The method will leave if an error occurs" |
|
593 */ |
|
594 CPreProcessorInfo* PreProcessorInfoLC(); |
|
595 |
|
596 /** |
|
597 * From CMMFVideoRecordHwDevice |
|
598 * The function sets the hardware device input format |
|
599 * @param aFormat |
|
600 * The input format to use |
|
601 * @param aPictureSize |
|
602 * The input picture size in pixels |
|
603 * @leave "The method will leave if an error occurs" |
|
604 */ |
|
605 void SetInputFormatL( const TUncompressedVideoFormat& aFormat, |
|
606 const TSize& aPictureSize ); |
|
607 |
|
608 /** |
|
609 * From CMMFVideoRecordHwDevice |
|
610 * The function sets the data source to be a camera |
|
611 * @param aCameraHandle |
|
612 * Camera handle to be used |
|
613 * @param aPictureRate |
|
614 * Video capture frame rate |
|
615 * @leave "The method will leave if an error occurs" |
|
616 */ |
|
617 void SetSourceCameraL( TInt aCameraHandle, TReal aPictureRate ); |
|
618 |
|
619 /** |
|
620 * From CMMFVideoRecordHwDevice |
|
621 * The function sets the data source to be memory buffers |
|
622 * @param aMaxPictureRate |
|
623 * The maximum picture rate for input pictures. |
|
624 * @param aConstantPictureRate |
|
625 * Flag indicating if picture rate is constant or not |
|
626 * @param aProcessRealtime |
|
627 * Flag indicating real time processing should be done or not |
|
628 * @leave "The method will leave if an error occurs" |
|
629 */ |
|
630 void SetSourceMemoryL( TReal aMaxPictureRate, TBool aConstantPictureRate, |
|
631 TBool aProcessRealtime ); |
|
632 |
|
633 /** |
|
634 * From CMMFVideoRecordHwDevice |
|
635 * The function enables synchronized encoding and set the clock source to |
|
636 * use for synchronization. |
|
637 * @param aClock |
|
638 * Clock source to be used. |
|
639 */ |
|
640 void SetClockSource( MMMFClockSource* aClock ); |
|
641 |
|
642 /** |
|
643 * From CMMFVideoRecordHwDevice |
|
644 * The function sets pre-processing options for RGB to YUV color space |
|
645 * conversion |
|
646 * @param aRange |
|
647 * Input RGB data range |
|
648 * @param aOutputFormat |
|
649 * Conversion output YUV format |
|
650 * @leave "The method will leave if an error occurs" |
|
651 */ |
|
652 void SetRgbToYuvOptionsL( TRgbRange aRange, |
|
653 const TYuvFormat& aOutputFormat); |
|
654 |
|
655 /** |
|
656 * From CMMFVideoRecordHwDevice |
|
657 * The function sets pre-processing options for YUV to YUV data format |
|
658 * conversion |
|
659 * @param aRange |
|
660 * Conversion input format |
|
661 * @param aOutputFormat |
|
662 * Conversion output YUV format |
|
663 * @leave "The method will leave if an error occurs" |
|
664 */ |
|
665 void SetYuvToYuvOptionsL( const TYuvFormat& aInputFormat, |
|
666 const TYuvFormat& aOutputFormat ); |
|
667 |
|
668 /** |
|
669 * From CMMFVideoRecordHwDevice |
|
670 * The function sets the pre-processing types to be used |
|
671 * @param aPreProcessTypes |
|
672 * The pre-processing steps to perform, a bitwise OR of values from |
|
673 * TPrePostProcessType |
|
674 * @leave "The method will leave if an error occurs" |
|
675 */ |
|
676 void SetPreProcessTypesL( TUint32 aPreProcessTypes ); |
|
677 |
|
678 /** |
|
679 * From CMMFVideoRecordHwDevice |
|
680 * The function sets pre-processing options for rotation |
|
681 * @param aRotationType |
|
682 * The rotation to perform |
|
683 * @leave "The method will leave if an error occurs" |
|
684 */ |
|
685 void SetRotateOptionsL( TRotationType aRotationType ); |
|
686 |
|
687 /** |
|
688 * From CMMFVideoRecordHwDevice |
|
689 * The function sets pre-processing options for scaling. |
|
690 * @param aTargetSize |
|
691 * Target picture size. |
|
692 * @param aAntiAliasFiltering |
|
693 * True if anti-aliasing filtering should be used |
|
694 * @leave "The method will leave if an error occurs" |
|
695 */ |
|
696 void SetScaleOptionsL( const TSize& aTargetSize, |
|
697 TBool aAntiAliasFiltering ); |
|
698 |
|
699 |
|
700 /** |
|
701 * From CMMFVideoRecordHwDevice |
|
702 * The function sets pre-processing options for input cropping. |
|
703 * @param aRect |
|
704 * The input cropping rectangle specifying the area of the picture to |
|
705 * use |
|
706 * @leave "The method will leave if an error occurs" |
|
707 */ |
|
708 void SetInputCropOptionsL( const TRect& aRect ); |
|
709 |
|
710 /** |
|
711 * From CMMFVideoRecordHwDevice |
|
712 * The function sets pre-processing options for output cropping. |
|
713 * @param aRect |
|
714 * The output cropping rectangle specifying the area of the picture to |
|
715 * use |
|
716 * @leave "The method will leave if an error occurs" |
|
717 */ |
|
718 void SetOutputCropOptionsL( const TRect& aRect ); |
|
719 |
|
720 /** |
|
721 * From CMMFVideoRecordHwDevice |
|
722 * The function sets pre-processing options for output padding |
|
723 * @param aOutputSize |
|
724 * The padded output picture size. |
|
725 * @param aPicturePos |
|
726 * The position for the original picture in the new padded picture. |
|
727 * @leave "The method will leave if an error occurs" |
|
728 */ |
|
729 void SetOutputPadOptionsL( const TSize& aOutputSize, |
|
730 const TPoint& aPicturePos ); |
|
731 |
|
732 /** |
|
733 * From CMMFVideoRecordHwDevice |
|
734 * The function sets color enhancement pre-processing options. |
|
735 * @param aOptions |
|
736 * Color enchancement options |
|
737 * @leave "The method will leave if an error occurs" |
|
738 */ |
|
739 void SetColorEnhancementOptionsL( |
|
740 const TColorEnhancementOptions& aOptions); |
|
741 |
|
742 /** |
|
743 * From CMMFVideoRecordHwDevice |
|
744 * The function sets frame stabilisation options |
|
745 * @param aOutputSize |
|
746 * Output picture size. |
|
747 * @param aFrameStabilisation |
|
748 * True if frame stabilisation should be used |
|
749 * @leave "The method will leave if an error occurs" |
|
750 */ |
|
751 void SetFrameStabilisationOptionsL( const TSize& aOutputSize, |
|
752 TBool aFrameStabilisation ); |
|
753 |
|
754 /** |
|
755 * From CMMFVideoRecordHwDevice |
|
756 * The function sets custom implementation-specific pre-processing options |
|
757 * @param aOptions |
|
758 * Post-processing options |
|
759 * @leave "The method will leave if an error occurs" |
|
760 */ |
|
761 void SetCustomPreProcessOptionsL( const TDesC8& aOptions ); |
|
762 |
|
763 |
|
764 /** |
|
765 * From CMMFVideoEncodeHwDevice |
|
766 * The function sets the proxy implementation to be used |
|
767 * @param aProxy |
|
768 * The proxy to use |
|
769 */ |
|
770 void SetProxy( MMMFDevVideoRecordProxy& aProxy ); |
|
771 |
|
772 |
|
773 |
|
774 public: |
|
775 |
|
776 /** |
|
777 * From MProcessEngineObserver |
|
778 * The function is a callback to indicate the input buffer is consumed |
|
779 * @param aInp |
|
780 * Pointer to the input picture that has been processed |
|
781 * @param aError |
|
782 * Error code returned by process engine |
|
783 * @return error value |
|
784 */ |
|
785 TInt InputBufferConsumed( TAny* aInp, TInt aError); |
|
786 |
|
787 /** |
|
788 * From MProcessEngineObserver |
|
789 * The function is a callback to indicate the output buffer is ready |
|
790 * @param aOup |
|
791 * Pointer to the output picture that has been processed |
|
792 * @param aError |
|
793 * Error code returned by process engine |
|
794 * @return error value |
|
795 */ |
|
796 TInt OutputBufferReady( TAny* aOup, TInt aError ); |
|
797 |
|
798 /** |
|
799 * From MProcessEngineObserver |
|
800 * The function indicates to hwdevice that process engine has finished |
|
801 * with the processing of command requested by hwdevice |
|
802 * @param aCmd |
|
803 * Command that has been processed by process engine |
|
804 * @param aCmdData |
|
805 * Pointer to command data that has been processed by process engine |
|
806 * @param aError |
|
807 * Error code corresponding to the command |
|
808 */ |
|
809 void CommandProcessed( TInt aCmd, TAny* aCmdData, TInt aError ); |
|
810 |
|
811 /** |
|
812 * From CMMFVideoEncodeHwDevice |
|
813 * The function indicates to hwdevice that process engine has met with an |
|
814 * unrecoverable error during its processing |
|
815 * @param aError |
|
816 * The fatal error code |
|
817 */ |
|
818 void FatalErrorFromProcessEngine( TInt aError ); |
|
819 |
|
820 private: |
|
821 |
|
822 /** |
|
823 * The function is the default constructor for class |
|
824 * CAriMp4spencHwDeviceImpl |
|
825 */ |
|
826 CAriMp4spencHwDeviceImpl(); |
|
827 |
|
828 /** |
|
829 * Symbian 2 phase constructor |
|
830 */ |
|
831 void ConstructL(); |
|
832 |
|
833 /** |
|
834 * Updates the time periodically i.e gets the clock source values from |
|
835 * client |
|
836 * @return returns system wide error code on error |
|
837 */ |
|
838 TInt UpdateTime(); |
|
839 |
|
840 /** |
|
841 * Creates coded Output buffers for the hw device. |
|
842 * @param aSize |
|
843 * Size of buffers to be created |
|
844 */ |
|
845 void CreateCodedOutputBuffersL( TUint aSize ); |
|
846 |
|
847 |
|
848 /** |
|
849 * Creates Internal buffers in segment mode, to hold the complete |
|
850 * encoded frame returned from the codec |
|
851 * @param aSize |
|
852 * Size of buffers to be created |
|
853 */ |
|
854 void CreateInternalOutputBuffersL( TUint aBufferSize ); |
|
855 |
|
856 /** |
|
857 * Creates packet offset info buffers |
|
858 * @param aSize |
|
859 * Size of buffers to be created |
|
860 */ |
|
861 void CreatePacketOffsetLengthInfoBuffersL( TUint aSize ); |
|
862 |
|
863 /** |
|
864 * Decides whether this input picture can be encoded or not |
|
865 * @param aPicture |
|
866 * Pointer to the input picture |
|
867 */ |
|
868 TBool CanEncode( TVideoPicture *aPicture ); |
|
869 |
|
870 /** |
|
871 * Input picture is not processed, returned back to client |
|
872 * @param aPicture |
|
873 * Pointer to the input picture |
|
874 */ |
|
875 void SkipInputPicture( TVideoPicture *aPicture ); |
|
876 |
|
877 |
|
878 /** |
|
879 * Checks whether this input picture is coded as i-frame or not |
|
880 * @param aPicture |
|
881 * Pointer to the input picture |
|
882 */ |
|
883 TBool IsForcedIFrameRequired( TVideoPicture* aPicture ); |
|
884 |
|
885 /** |
|
886 * Fills one segment data from the internal buffer to output buffer |
|
887 * @param aOutBuf |
|
888 * Destination buffer to hold the packet |
|
889 * @param aSrcBuf |
|
890 * Buffer which contains encoder output frame |
|
891 */ |
|
892 void FillVideoSegment( TVideoOutputBuffer* aOutBuf, |
|
893 TVideoOutputBuffer* aSrcBuf ); |
|
894 |
|
895 |
|
896 /** |
|
897 * Initializes the members of the output coded buffers created |
|
898 * @param aOutputBuffer |
|
899 * Output buffer for which members are to be initialized |
|
900 */ |
|
901 void InitializeOuputCodedBuffer( TVideoOutputBuffer& aOutputBuffer ); |
|
902 |
|
903 /** |
|
904 * Checks if the specified input format is supported or not |
|
905 * @param aFormat |
|
906 * Input format to be checked |
|
907 * @return Returns True if input format is supported else false |
|
908 */ |
|
909 TBool CheckInputFormat( const TUncompressedVideoFormat& aFormat ); |
|
910 |
|
911 /** |
|
912 * Notifies the client that the hw device has encountered with error |
|
913 * @param aError |
|
914 * Error code indicating type of fatal error |
|
915 */ |
|
916 void ClientFatalError ( TInt aError ); |
|
917 |
|
918 private: |
|
919 |
|
920 /** |
|
921 * Handle to proxy i.e observer |
|
922 */ |
|
923 MMMFDevVideoRecordProxy* iMMFDevVideoRecordProxy; |
|
924 |
|
925 /** |
|
926 * Handle to preprocessor hw device |
|
927 */ |
|
928 CMMFVideoPreProcHwDevice* iInputDevice; |
|
929 |
|
930 /** |
|
931 * Reference to clock source if client |
|
932 */ |
|
933 MMMFClockSource* iClockSource; |
|
934 |
|
935 /** |
|
936 * Flag to indicate whether the buffer is returned to inputdevice |
|
937 */ |
|
938 TBool iInputBufReturnToPreProc; |
|
939 |
|
940 /** |
|
941 * Hold the parameters that are required after initialize |
|
942 */ |
|
943 TMpeg4H263EncoderInitParams iCurSetMpeg4H263HWParams; |
|
944 |
|
945 /** |
|
946 * Hold all the parameters before initialize |
|
947 */ |
|
948 TMpeg4H263EncoderInitParams iSetMpeg4H263HWParams; |
|
949 |
|
950 /** |
|
951 * pointer to state machine object |
|
952 */ |
|
953 CStateMachine* iEncStateMac; |
|
954 |
|
955 /** |
|
956 * All levels information is stored |
|
957 */ |
|
958 RArray<TInt> iLevels; |
|
959 |
|
960 /** |
|
961 * Supported Input format information |
|
962 */ |
|
963 RArray<TUncompressedVideoFormat> iSupportedInputFormats; |
|
964 |
|
965 /** |
|
966 * Supported output formats information |
|
967 */ |
|
968 RArray<CCompressedVideoFormat*> iSupportedOutputFormats; |
|
969 |
|
970 /** |
|
971 * All supported data unit types |
|
972 */ |
|
973 TUint32 iSupportedDataUnitTypes; |
|
974 |
|
975 /** |
|
976 * All supported data unit encapsulation |
|
977 */ |
|
978 TUint32 iSupportedDataUnitEncapsulations; |
|
979 |
|
980 /** |
|
981 * Timer for updates |
|
982 */ |
|
983 CPeriodic* iPeriodicTimer; |
|
984 |
|
985 /** |
|
986 * Stores tha value when clock is paused |
|
987 */ |
|
988 TInt64 iClockTimeWhenPaused; |
|
989 |
|
990 /** |
|
991 * Polling interval to be used |
|
992 */ |
|
993 TTimeIntervalMicroSeconds32 iPollingInterval; |
|
994 |
|
995 /** |
|
996 * Codec Reference |
|
997 */ |
|
998 CAriMp4spencWrapper* iCodec; |
|
999 |
|
1000 /** |
|
1001 * Pointer to base process engine object |
|
1002 */ |
|
1003 CBaseEngine* iEngine; |
|
1004 |
|
1005 /** |
|
1006 * Output Free buffers can be segment or coded buffers |
|
1007 */ |
|
1008 TVideoOutputBuffer* iOutputBuffers; |
|
1009 |
|
1010 /** |
|
1011 * Output buffer queue |
|
1012 */ |
|
1013 RPointerArray<TVideoOutputBuffer> iOutputFreeBufferQueue; |
|
1014 |
|
1015 /** |
|
1016 * Output buffer size of the coded picture |
|
1017 */ |
|
1018 TInt iOutputBufferSize; |
|
1019 |
|
1020 |
|
1021 /** |
|
1022 * Pause offset i.e offset between pause and resume |
|
1023 */ |
|
1024 TInt64 iPauseOffset; |
|
1025 |
|
1026 /** |
|
1027 * Total time deviation from client clock source |
|
1028 */ |
|
1029 TInt64 iTotalTime; |
|
1030 |
|
1031 /** |
|
1032 * Last encoded picture time stamp |
|
1033 */ |
|
1034 TInt64 iLastEncodedPictureTimestamp; |
|
1035 |
|
1036 /** |
|
1037 * Indicates picture loss |
|
1038 */ |
|
1039 TBool iPictureLoss; |
|
1040 |
|
1041 /** |
|
1042 * Indicates input end called |
|
1043 */ |
|
1044 TBool iInputEndCalled; |
|
1045 |
|
1046 /** |
|
1047 * Picture Counters |
|
1048 */ |
|
1049 CMMFDevVideoRecord::TPictureCounters iPictureCounters; |
|
1050 |
|
1051 /** |
|
1052 * Indicates whether HwDevice is frozen by calling Freeze () |
|
1053 */ |
|
1054 TBool iFrozen; |
|
1055 |
|
1056 /** |
|
1057 * Current postion in the coded frame in packet mode |
|
1058 */ |
|
1059 TUint iTotalLengthFilledSoFarInPacketMode; |
|
1060 |
|
1061 /** |
|
1062 * Total Output buffer Length of the coded picture in packet mode |
|
1063 */ |
|
1064 TUint iTotalOutputBufferLengthInPacketMode; |
|
1065 |
|
1066 /** |
|
1067 * Pointer to current offset position within a frame - used in packet mode |
|
1068 * only |
|
1069 */ |
|
1070 TUint* iPacketOffSetCurrentPosition; |
|
1071 |
|
1072 /** |
|
1073 * Holds offsets and length information array |
|
1074 */ |
|
1075 TUint** iPacketOffSetAndLengthInfoBuffers; |
|
1076 |
|
1077 /** |
|
1078 * Free buffer queue for packet offset information |
|
1079 */ |
|
1080 RPointerArray<TUint> iFreeBufferQueueForPacketOffsetInfo; |
|
1081 |
|
1082 /** |
|
1083 * Filled buffer queue for packet offset information |
|
1084 */ |
|
1085 RPointerArray<TUint> iFilledBufferQueueForPacketOffsetInfo; |
|
1086 |
|
1087 /** |
|
1088 * Temporary output buffers |
|
1089 */ |
|
1090 TVideoOutputBuffer* iInternalOutputBuffers; |
|
1091 |
|
1092 /** |
|
1093 * Holds temporary o/p buffers |
|
1094 */ |
|
1095 RPointerArray<TVideoOutputBuffer> iInternalOutputBufferQueue; |
|
1096 |
|
1097 /** |
|
1098 * Indicates if all the packets in a frame are sent to above layer or not |
|
1099 */ |
|
1100 TBool iPacketsPending; |
|
1101 |
|
1102 /** |
|
1103 * Stores config data |
|
1104 */ |
|
1105 HBufC8* iConfigData; |
|
1106 |
|
1107 /** |
|
1108 * Stores value of max no of buffers |
|
1109 */ |
|
1110 TUint iMaxNumOfPackets; |
|
1111 |
|
1112 /** |
|
1113 * Buffer to store packet length info |
|
1114 */ |
|
1115 TPtr8* iPacketOffsetBuf; |
|
1116 }; |
|
1117 |
|
1118 #endif //ARIMP4SPENCHWDEVICEIMPL_H |