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