Update contrib.
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef __NGAPOSTPROCHWDEVICE_H__
20 #define __NGAPOSTPROCHWDEVICE_H__
31 #include <mmf/devvideo/videoplayhwdevice.h>
32 #include <mmf/devvideo/devvideostandardcustominterfaces.h>
33 #include <mmf/devvideo/devvideovideosurfacecustominterface.h>
34 #include <graphics/surfacemanager.h> //RSurfaceManager
35 #include <graphics/surface.h> //TSurfaceId
36 #include <mmf/common/mmfvideo.h> //TVideoAspectRatio
38 //#include <mmf/devvideo/devvideosurfacehandlecustominterface.h>
39 #include "devvideosurfacehandlecustominterface.h"
40 #include "postinitializeci.h"
42 #include <mmf/devvideo/devvideoplayratecustominterface.h>
43 #include <surface_hints.h>
44 #include <secureoutputci.h>
45 #include <advancedsecureoutputci.h>
46 #include <graphics/suerror.h>
48 #include "fetchframecustominterface.h"
49 #include "MdfRDebug.h"
50 #include "NGAPostProcHwDevice_UID.hrh"
51 #include "NGAPostProcSessionManagerObserver.h"
54 class CNGAPostProcSessionManager;
55 class CNGAPostProcSurfaceHandler;
56 class CNGAPostProcTimer;
59 class CNGAPostProcHwDevice: public CMMFVideoPostProcHwDevice,
60 public MMmfVideoBufferManagement,
61 public MNGAPostProcSessionManagerObserver,
62 public MMMFVideoSurfaceSupport,
63 public MMmfVideoPropertiesObserver,
64 public MMmfVideoResourceObserver,
65 public MMmfVideoSurfaceHandleControl,
66 public MMmfVideoPropertiesNotifier,
67 public MMmfVideoPlayRateControl,
68 public MMmfVideoSecureOutput,
69 public MMmfAdvancedVideoSecureOutput,
70 public MMmfPostInitializeRequest
74 // === Constructors and destructor ===
76 * Two-phased constructor.
77 * @return pointer to an instance of CMMFVideoPostProcHwDevice
79 static CMMFVideoPostProcHwDevice* NewL();
84 ~CNGAPostProcHwDevice();
88 // === CMMFVideoPostProcHwDevice ===
91 Sets the device input format to an uncompressed video format.
93 @param "aFormat" "The input format to use."
94 @leave "The method will leave if an error occurs. Typical error codes used:
95 * KErrNotSupported - The input format is not supported."
96 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
98 void SetInputFormatL(const TUncompressedVideoFormat& aFormat);
101 Sets the decoder device that will write data to this post-processor. Decoded pictures will be
102 written with WritePictureL() or through a custom interface. After pictures have been processed,
103 they must be returned to the decoder using ReturnPicture().
105 @param "aDevice" "The decoder source plug-in to use."
106 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
108 void SetInputDevice(CMMFVideoDecodeHwDevice* aDevice);
111 Writes an uncompressed video picture to the post-processor. The picture must be returned to the
112 client or source plug-in after it has been used.
114 @param "aPicture" "The picture to write."
115 @leave "This method may leave with one of the system-wide error codes."
116 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
118 void WritePictureL(TVideoPicture* aPicture);
121 Retrieves post-processing information about this hardware device.
122 The device creates a CPostProcessorInfo structure, fills it with correct data, pushes it
123 to the cleanup stack and returns it. The client will delete the object when it is no
126 @return "Post-processor information as a CPostProcessorInfo object.
127 The object is pushed to the cleanup stack, and must be deallocated by the caller."
128 @leave "This method may leave with one of the system-wide error codes.
130 CPostProcessorInfo* PostProcessorInfoLC();
133 Retrieves the list of the output formats that the device supports. The list is ordered in
134 plug-in preference order, with the preferred formats at the beginning of the list. The list
135 can depend on the device source format, and therefore SetSourceFormatL() must be called before
138 @param "aFormats" "An array for the result format list. The array must be created and destroyed by the caller."
139 @leave "This method may leave with one of the system-wide error codes.
140 @pre "This method may only be called before the hwdevice has been initialized using Initialize()."
142 void GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats);
145 Sets the device output format.
147 @param "aFormat" "The format to use."
148 @leave "This method may leave with one of the system-wide error codes.
149 @pre "This method may only be called before the hwdevice has been initialized using Initialize()."
151 void SetOutputFormatL(const TUncompressedVideoFormat &aFormat);
154 Sets the clock source to use for video timing. If no clock source is set. video playback
155 will not be synchronized, but will proceed as fast as possible, depending on input data
156 and output buffer availability.
158 @param "aClock" "The clock source to be used."
159 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
161 void SetClockSource(MMMFClockSource* aClock);
164 Sets the device video output destination. The destination can be the screen (using direct
165 screen access) or memory buffers. By default memory buffers are used. If data is written
166 to another device, this method is ignored, and suitable memory buffers are always used.
168 @param "aScreen" "True if video output destination is the screen, false if memory buffers."
169 @leave "This method may leave with one of the system-wide error codes.
170 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
172 void SetVideoDestScreenL(TBool aScreen);
175 Sets the post-processing types to be used.
177 @param "aPostProcCombination" "The post-processing steps to perform, a bitwise OR of values from TPostProcessType."
178 @leave "This method may leave with one of the system-wide error codes.
179 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
180 If called after initialization, the change must only be committed when CommitL() is called."
182 void SetPostProcessTypesL(TUint32 aPostProcCombination);
185 Sets post-processing options for input (pan-scan) cropping.
187 @param "aRect" "The cropping rectangle to use."
188 @leave "This method may leave with one of the system-wide error codes.
189 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
190 If called after initialization, the change must only be committed when CommitL() is called."
192 void SetInputCropOptionsL(const TRect& aRect);
195 Sets post-processing options for YUV to RGB color space conversion.
196 Specifies the input YUV and output RGB formats to use explicitly. SetSourceFormatL(),
197 SetOutputFormatL(), and SetPostProcessTypesL() must be called before this method is used.
199 @param "aOptions" "The conversion options to use."
200 @param "aYuvFormat" "Conversion source YUV format"
201 @param "aRgbFormat" "Conversion target RGB format"
202 @leave "This method may leave with one of the system-wide error codes.
203 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
204 If called after initialization, the change must only be committed when CommitL() is called."
206 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat,
207 TRgbFormat aRgbFormat);
210 Sets post-processing options for YUV to RGB color space conversion.
211 Uses the device input and output formats. For decoder devices the default YUV format used is
212 the format specified in the input bitstream. SetSourceFormatL(), SetOutputFormatL(), and
213 SetPostProcessTypesL() must be called before this method is used.
215 @param "aOptions" "The conversion options to use."
216 @leave "This method may leave with one of the system-wide error codes.
217 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
218 If called after initialization, the change must only be committed when CommitL() is called."
220 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions);
223 Sets post-processing options for rotation. SetPostProcessTypesL() must be called before
226 @param "aRotationType" "The rotation to perform."
227 @leave "This method may leave with one of the system-wide error codes.
228 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
229 If called after initialization, the change must only be committed when CommitL() is called."
231 void SetRotateOptionsL(TRotationType aRotationType);
234 Sets post-processing options for scaling. SetPostProcessTypesL() must be called before
237 @param "aTargetSize" "Scaling target size. If a fixed scale factor size is used,
238 the new dimensions must be set to width=floor(factor*width),
239 height=floor(factor*height). For example, scaling a
240 QCIF (176x144) picture up by a factor of 4/3 yields a size
242 @param "aAntiAliasFiltering" "True if anti-aliasing filtering should be used.
243 If the post-processor does not support anti-aliased scaling,
244 or supports anti-aliased scaling only, this argument is ignored."
245 @leave "This method may leave with one of the system-wide error codes.
246 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
247 If called after initialization, the change must only be committed when CommitL() is called."
249 void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
252 Sets post-processing options for output cropping. SetPostProcessTypesL() must be called before
255 @param "aRect" "Output cropping area."
256 @leave "This method may leave with one of the system-wide error codes.
257 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
258 If called after initialization, the change must only be committed when CommitL() is called."
260 void SetOutputCropOptionsL(const TRect& aRect);
263 Sets post-processing plug-in specific options. SetPostProcessTypesL() must be called before
266 @param "aOptions" "The options. The format is plug-in specific."
267 @leave "This method may leave with one of the system-wide error codes.
268 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
269 If called after initialization, the change must only be committed when CommitL() is called."
271 void SetPostProcSpecificOptionsL(const TDesC8& aOptions);
274 Initializes the device. This method is asynchronous, the device will call
275 MMFVideoPlayProxy::MdvppInitializeComplete() after initialization has completed. After this
276 method has successfully completed, further configuration changes are not possible except where
282 Commit all changes since the last CommitL(), Revert() or Initialize()
283 to the hardware device. This only applies to methods which can be called both
284 before AND after DevVideoPlay has been initialized.
286 @see SetPostProcessTypesL
287 @see SetInputCropOptionsL
288 @see SetYuvToRgbOptionsL
289 @see SetRotateOptionsL
290 @see SetScaleOptionsL
291 @see SetOutputCropOptionsL
292 @see SetPostProcSpecificOptionsL
294 @leave "The method will leave if an error occurs."
295 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
300 Revert all changes since the last CommitL(), Revert() or Initialize()
301 back to their previous settings. This only applies to methods which can
302 be called both before AND after DevVideoPlay has been initialized.
304 @see SetPostProcessTypesL
305 @see SetInputCropOptionsL
306 @see SetYuvToRgbOptionsL
307 @see SetRotateOptionsL
308 @see SetScaleOptionsL
309 @see SetOutputCropOptionsL
310 @see SetPostProcSpecificOptionsL
312 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
317 Starts writing output directly to the display frame buffer using Direct Screen Access.
319 @param "aVideoRect" "The video output rectangle on screen."
320 @param "aScreenDevice" "The screen device to use. The screen device object must be valid in the current thread."
321 @param "aClipRegion" "Initial clipping region to use."
323 @leave "This method may leave with one of the system-wide error codes.
324 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
326 void StartDirectScreenAccessL(const TRect& aVideoRect,
327 CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion);
330 Sets a new clipping region for Direct Screen Access. After the method returns, no video will
331 be drawn outside of the region. If clipping is not supported, or the clipping region is too
332 complex, either playback will pause or will resume without video display, depending on the
333 current setting of SetPauseOnClipFail(), and the result can be verified with IsPlaying().
334 Clipping can be disabled by setting a new clipping region that includes the whole video window.
336 @param "aRegion" "The new clipping region. After the method returns, no video will be drawn outside the region."
337 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
339 void SetScreenClipRegion(const TRegion& aRegion);
342 Sets whether the system should pause playback when it gets a clipping region it cannot handle,
343 or Direct Screen Access is aborted completely. If not, processing will proceed normally, but no
344 video will be drawn. By default, playback is paused.
346 @param "aPause" "True if playback should be paused when clipping fails, false if not.
347 If playback is not paused, it will be continued without video display."
348 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
350 void SetPauseOnClipFail(TBool aPause);
353 Aborts Direct Screen Access completely, to be called from MAbortDirectScreenAccess::AbortNow()
354 and similar methods. DSA can be resumed by calling StartDirectScreenAccessL().
355 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
357 void AbortDirectScreenAccess();
360 Indicates whether playback is proceeding. This method can be used to check whether playback was
361 paused or not in response to a new clipping region or DSA abort.
363 @return "ETrue if video is still being played (even if not necessarily displayed)."
364 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
369 Re-draws the latest video picture. Only available when DSA is being used. If DSA is aborted or a
370 non-supported clipping region has been set, the request may be ignored.
371 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
377 Starts video playback, including decoding, post-processing, and rendering. Playback will proceed
378 until it has been stopped or paused, or the end of the bitstream is reached.
379 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
384 Stops video playback. No new pictures will be decoded, post-processed, or rendered.
385 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
390 Pauses video playback, including decoding, post-processing, and rendering. No pictures will be
391 decoded, post-processed, or rendered until playback has been resumed.
392 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
397 Resumes video playback after a pause.
398 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
403 Changes to a new decoding and playback position, used for randomly accessing (seeking) the
404 input stream. The position change flushes all input and output buffers. Pre-decoder and
405 post-decoder buffering are handled as if a new bitstream was being decoded. If the device still
406 has buffered pictures that precede the new playback position, they will be discarded. If playback
407 is synchronized to a clock source, the client is responsible for setting the clock source to the
410 @param "aPlaybackPosition" "The new playback position in the video stream."
411 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
413 void SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition);
416 Freezes a picture on the screen. After the picture has been frozen, no new pictures are
417 displayed until the freeze is released with ReleaseFreeze(). If the device output is being
418 written to memory buffers or to another plug-in, instead of the screen, no decoded pictures
419 will be delivered while the freeze is active, and they are simply discarded.
421 @param "aTimestamp" "The presentation timestamp of the picture to freeze. The frozen picture
422 will be the first picture with a timestamp greater than or equal to this
424 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
426 void FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp);
429 Releases a picture frozen with FreezePicture().
431 @param "aTimestamp" "The presentation timestamp of the picture to release. The first picture
432 displayed after the release will be the first picture with a timestamp
433 greater than or equal to this parameter. To release the freeze immediately,
434 set the timestamp to zero."
435 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
437 void ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp);
441 Returns the current playback position, i.e. the timestamp for the most recently displayed or
442 virtually displayed picture. If the device output is written to another device, the most recent
443 output picture is used.
445 @return "Current playback position."
446 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
448 TTimeIntervalMicroSeconds PlaybackPosition();
451 Returns the total amount of memory allocated for uncompressed pictures. This figure only
452 includes the pictures actually allocated by the plug-in itself, so that the total number of
453 bytes allocated in the system can be calculated by taking the sum of the values from all plug-ins.
455 @return "Total number of bytes of memory allocated for uncompressed pictures."
456 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
458 TUint PictureBufferBytes();
461 Reads various counters related to decoded pictures. The counters are reset when Initialize()
462 or this method is called, and thus they only include pictures processed since the last call.
464 Post-processor devices return the number of input pictures in iPicturesDecoded and
465 iTotalPictures. If the decoded pictures are written to another plug-in, they are considered
466 to be "virtually displayed".
468 @param "aCounters" "The counter structure to fill."
469 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
471 void GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters);
475 Sets the computational complexity level to use. If separate complexity levels are not available,
476 the method call is ignored. If the level specified is not available, the results are undefined.
477 Typically the device will either ignore the request or use the nearest suitable level.
479 The complexity level can be changed at any point during playback.
481 @param "aLevel" "The computational complexity level to use. Level zero (0) is the most complex
482 one, with the highest quality. Higher level numbers require less processing
483 and may have lower quality."
484 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
486 void SetComplexityLevel(TUint aLevel);
489 Gets the number of complexity levels available.
491 @return "The number of complexity control levels available, or zero if the information is not
492 available yet. The information may not be available if the number of levels depends on
493 the input data, and enough input data has not been read yet. In that case, using level
495 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
497 TUint NumComplexityLevels();
500 Gets information about a computational complexity level. This method can be called after
501 NumComplexityLevels() has returned a non-zero value - at that point the information is guaranteed
502 to be available. Some hardware device implementations may not be able to provide all values,
503 in that case the values will be approximated.
505 @param "aLevel" "The computational complexity level to query. The level numbers range from zero
506 (the most complex) to NumComplexityLevels()-1."
507 @param "aInfo" "The information structure to fill."
508 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
510 void GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo);
513 Returns a picture back to the device. This method is called by CMMFDevVideoPlay to return pictures
514 from the client (after they have been written with NewPicture()), or by the output device when
515 it has finished using a picture.
517 @param "aPicture" "The picture to return. The device can re-use the memory for the picture."
518 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
520 void ReturnPicture(TVideoPicture* aPicture);
523 Gets a copy of the latest picture sent to output.
525 @param "aPictureData" "Target picture. The memory for the picture must be allocated by the
526 caller, and initialized properly. The data formats must match the snapshot
528 @param "aFormat" "The picture format to use for the snapshot."
530 @return "ETrue if the snapshot was taken, EFalse if a picture is not available. The picture may not
531 be available if decoding has not progressed far enough yet."
533 @leave "The method will leave if an error occurs. Typical error codes used:
534 * KErrNotSupported - The requested data format or picture size is not supported, or the
535 plug-in does not support snapshots."
536 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
538 // TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat) {return EFalse;};
539 TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat);
542 When the snapshot is available, it will be returned to the client using the TimedSnapshotComplete()
543 callback. To cancel a timed snapshot request, use CancelTimedSnapshot(). Only one timed snapshot
544 request can be active at a time.
546 @param "aPictureData" "Target picture. The memory for the picture must be allocated by
547 the caller, and initialized properly. The data formats must match
548 the snapshot format requested. The picture must remain valid until
549 the snapshot has been taken or until the request has been cancelled
550 with CancelTimedSnapshot()."
551 @param "aFormat" "The picture format to use for the snapshot."
552 @param "aPresentationTimestamp" "Presentation timestamp for the picture to copy."
554 @leave "The method will leave if an error occurs. Typical error codes used:
555 * KErrNotSupported - The requested data format or picture size is not supported or
556 the plug-in does not support timed snapshots."
557 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
559 //void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat,
560 // const TTimeIntervalMicroSeconds& aPresentationTimestamp){};
561 void GetTimedSnapshotL(TPictureData*, const TUncompressedVideoFormat&, const TTimeIntervalMicroSeconds&){};
565 When the snapshot is available, it will be returned to the client using the TimedSnapshotComplete()
566 callback. To cancel a timed snapshot request, use CancelTimedSnapshot(). Only one timed snapshot
567 request can be active at a time.
569 @param "aPictureData" "Target picture. The memory for the picture must be allocated by
570 the caller, and initialized properly. The data formats must match
571 the snapshot format requested. The picture must remain valid until
572 the snapshot has been taken or until the request has been cancelled
573 with CancelTimedSnapshot()."
574 @param "aFormat" "The picture format to use for the snapshot."
575 @param "aPictureId" "Picture identifier for the picture to copy."
577 @leave "The method will leave if an error occurs. Typical error codes used:
578 * KErrNotSupported - The requested data format or picture size is not supported or
579 the plug-in does not support timed snapshots."
580 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
582 // void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat,
583 // const TPictureId& aPictureId){};
584 void GetTimedSnapshotL(TPictureData*, const TUncompressedVideoFormat&, const TPictureId& ){};
587 Cancels a timed snapshot request.
588 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
590 void CancelTimedSnapshot(){};
593 Gets a list of the supported snapshot picture formats.
595 @param "aFormats" "An array for the result format list. The array must be created and destroyed by
598 @leave "This method may leave with one of the standard error codes."
599 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
601 void GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>&){};
606 Notifies the hardware device that the end of input data has been reached and no more input data
607 will be written. The hardware device can use this signal to ensure that the remaining data gets
608 processed, without waiting for new data. For example when the data type is not EDuCodedPicture,
609 calling this method is necessary otherwise a hardware device implementation might be looking for
610 the start code for the next picture to ensure it has a complete picture before starting to decode
614 After the remaining data has been processed (and displayed, if applicable), the hardware
615 device must notify the proxy with the MdvppStreamEnd() callback.
617 DevVideo clients are encouraged to call this method, but its use is not mandatory for synchronized
618 processing. For synchronized playback, all video pictures are processed or discarded according to
619 their timestamps, and so the client can easily infer when processing is complete. However, it
620 should be noted that the last picture might not be displayed if this method is not called and the
621 input data type is not EDuCodedPicture.
623 For non-synchronized playback (e.g. file conversion), a client must call this method otherwise it
624 will never find out when the hardware device has finished processing the data.
626 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
631 Retrieves a custom interface to the device.
632 @param "aInterface" "Interface UID, defined with the custom interface."
633 @return "Pointer to the interface implementation, or NULL if the device does not
634 implement the interface requested. The return value must be cast to the
635 correct type by the user."
637 TAny* CustomInterface(TUid aInterface);
639 // === MNGAPostProcSessionManagerObserver ===
641 Set the proxy implementation to be used. Called just after the object is constructed.
642 @param "aProxy" "The proxy to use."
644 void BufferAvailable(TInt aBufId, TInt aStatus);
648 // === MMmfVideoBufferManagement ===
651 * Sets the observer object to use. The observer gets notified
652 * when new buffers are available and when buffers need to be
653 * released back to the media device.
655 * This method can only be called before the media device has
656 * been Initialized with InitializeL().
658 * @param aObserver The observer object to use.
660 void MmvbmSetObserver(MMmfVideoBufferManagementObserver* aObserver);
663 * Enables input buffer management mode. In buffer management mode
664 * the target media device allocates memory for input buffers and
665 * the client can only use input buffers allocated with
668 * This method can only be called before the media device has been
669 * Initialized with InitializeL(). This method must be called if
670 * the client uses MmvbmGetBufferL().
672 * @param aEnable ETrue if input buffer management mode is used.
674 void MmvbmEnable(TBool aEnable);
677 * Sets the buffer options to use. The client can request the
678 * number of input buffers that should be available, but typically
679 * only few (one or two) buffers can be used.
681 * This method can only be called before the media device has been
682 * Initialized with InitializeL().
684 * @param aOptions The buffer options to use, see TBufferOptions.
686 * @leave KErrNotSupported The requested buffer options are not
687 * supported. Typically the client has requested too many input
690 void MmvbmSetBufferOptionsL(const TBufferOptions& aOptions);
693 * Gets the buffer options currently in use.
695 * This method can only be called before the media device has been
696 * Initialized with InitializeL().
698 * @param aOptions Target buffer options data structure.
700 void MmvbmGetBufferOptions(TBufferOptions& aOptions);
703 * Gets a new input picture buffer. The client can then write data
704 * into the buffer and write it back to the media device with
707 * This method can only be called after the media device has been
708 * Initialized with InitializeL(). This method can only be called
709 * in buffer management mode, i.e. if the client has called
710 * MmvbmEnable(ETrue).
712 * Note that target-allocated and client-allocated input buffers
713 * cannot be mixed. In buffer management mode only input buffers
714 * allocated with this method can be sent to the media device.
716 * If a client has retrieved buffers with MmvbmGetBufferL(), it
717 * must be prepated to release them synchronously at any point if
718 * MmmfBufferManagementObserver::MmvbmoReleaseBuffers() is
719 * called. This may happen if the target media device suddenly
720 * loses access to the buffers due to DSA abort, resource
721 * management conflict, or media device destruction.
723 * @param aSize The requested buffer size, in pixels. The buffer
724 * size should match the picture size set at initialisation phase,
725 * or otherwise suitable buffer may not be available. If the size
726 * is smaller than the size set at initialisation phase, the
727 * allocated buffer may be larger than requested.
729 * @return A new input picture buffer. If no free buffers are
730 * available, the return value is NULL.
732 * @leave General The method will leave if an error occurs. Lack
733 * of free buffers is not considered an error.
735 TVideoPicture* MmvbmGetBufferL(const TSize& aSize);
738 * Releases an input buffer back to the media device without using
739 * it. This method is mainly used as a response to a
740 * MmvbmReleaseBuffers() callback.
742 * @param aBuffer The buffer to release.
744 void MmvbmReleaseBuffer(TVideoPicture* aBuffer);
748 // === MMMFVideoSurfaceSupport ===
751 Requests the media device to use graphics surfaces for video rendering.
752 The client must call this method before Initialize() to ensure the media
753 device allocates the right types of resources for rendering.
755 void MmvssUseSurfaces();
758 Sets a new video surface support observer to receive surface management events
759 from the media device.
761 @param aObserver New observer object to use.
763 void MmvssSetObserver(MMMFVideoSurfaceObserver& aObserver);
766 Retrieves surface parameters for a display. The client typically calls this in response
767 to a MmvsoSurfaceCreated() or MmvsoSurfaceParametersUpdated() observer callback.
770 Surface ID for the display.
772 Cropping rectangle within the surface. The crop rectangle identifies the area of
773 the surface that should be shown on the screen.
774 @param aPixelAspectRatio
775 Video picture pixel aspect ratio.
777 @leave KErrNotReady if no surface is available for the display.
780 void MmvssGetSurfaceParametersL(TSurfaceId& aSurfaceId, TRect& aCropRect,
781 TVideoAspectRatio& aPixelAspectRatio);
783 Indicates that the surface is no longer in use and can be destroyed. The client typically calls
784 this in response to MmvsoSurfaceCreated() (while old surface is already in use and the current
785 should be removed) or MmvsoRemoveSurface() observer callback.
787 @param aSurfaceId Surface ID that is no longer in use
789 @leave KErrNotFound if the surface does not exist
791 void MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId);
795 // === MMmfVideoPropertiesObserver ===
798 Decoded video properties updated. The media device implementing the
799 MMmfVideoPropertiesNotifier extension will call this method immediately
800 before outputting a picture with the updated properties.
802 When the extension is used between a decoder and a post-processor media
803 device, the post-processor can associate the changed properties with the
804 correct picture, since the next incoming picture after this call will
805 be the first updated one.
807 When the extension is used between a DevVideoPlay client and a
808 post-processor media device, the client can synchronously reconfigure
809 video display options using SetScaleOptionsL() and related methods. This
810 lets the client reconfigure the display for the correct picture.
812 @param aYuvFormat Updated YUV format parameters. The updated fields are
813 iAspectRatioDenom, iAspectRatioNum, and iCoefficients
814 @param aPictureSize Updated picture size. This size will be the true
815 picture display size, excluding any padding that
818 virtual void MmvpoUpdateVideoProperties(const TYuvFormat& aYuvFormat, const TSize& aPictureSize);
822 // === MMmfVideoResourceObserver ===
825 Indicates that a media device has lost its resources. The client must
826 synchronously pause or stop processing before returning from this method
827 so that the media device can release its resources to the system. If
828 the client does not pause or stop, resource loss will be handled as a
831 The client may start again or resume after receiving a
832 MvroResourcesRestored() callback.
834 @param aMediaDevice UID for the media device that lost resources. The
835 client can use this e.g. to determine whether the
836 decoder or the post-processor lost resources. This
837 is typically not required though since the client
838 must pause DevVideo entirely.
840 virtual void MmvroResourcesLost(TUid aMediaDevice);
843 Indicates that a media device has regained its resources after a
844 previous resource loss. The client can restart or resume processing.
845 This can be done either synchronously or asynchronously.
847 @param aMediaDevice UID for the media device that regained resources.
849 virtual void MmvroResourcesRestored(TUid aMediaDevice);
852 // === MMmfVideoSurfaceHandleControl ===
855 Sets an external surface ID. This should be called as soon as external surface is created.
857 @param aSurfaceID external surface ID.
861 virtual void MmvshcSetSurfaceHandle(const TSurfaceId& aSurfaceHandle);
864 Sets a redraw buffer to be used during resource loss.
866 @param aRedrawBuffer redraw buffer.
869 virtual void MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer);
872 * Creates a surface and maps the surface with the chunk handle passed in.
874 * @param aHandle is the Chunk handle for the data.
875 * @param aSurfaceId returns the surfaceId that was just created
880 virtual TInt MmvshcCreateSurface(const RSurfaceManager::TSurfaceCreationAttributes& aAttributes, TInt aHandle, TSurfaceId& aSurfaceId);
883 // === MMmfVideoPropertiesNotifier ===
885 Sets a new video properties observer. This method can be called at any
886 time after the media device has been instantiated.
888 @param aObserver New observer object.
890 virtual void MmvpnSetObserver(MMmfVideoPropertiesObserver* aObserver);
894 void ReturnPicToDecoder(TVideoPicture* aPic);
895 TInt AttemptToPost();
898 //=== MMdfTrickPlayControl === =
900 * Query the Direction capabilities from the MDF decoders and
904 virtual void MmvprcGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities);
907 * Sets the playback speed. A negative rate means play backward.
911 virtual void MmvprcSetPlayRateL(const TInt aRate);
914 * Gets the playback speed. A negative rate means play backward.
918 virtual TInt MmvprcPlayRateL();
921 * Sets the step frame number in frame step mode
924 virtual void MmvprcStepFrameL(const TInt aStep);
927 * Registers the observer
929 virtual void MmvprcSetObserver(MMmfVideoPlayRateObserver& aObserver);
933 // === MMmfVideoSecureOutput ===
935 * Notifies the media device if the content can only be sent to a
936 * secure output. The device display is typically considered a
937 * secure output, but a high-quality unprotected analog or digital
938 * video output connector is not. By default all content can be
939 * sent to both secure and insecure outputs.
941 * This method can only be called before the media device has been
942 * initialised with InitializeL().
944 * @param aSecure Set to ETrue if the content can only be sent to
945 * a secure output, EFalse if both secure and unsecure outputs can
948 * @leave KErrNotSupported Insecure outputs cannot be
949 * disabled. The client should not play protected content.
951 virtual void MmvsoSetSecureOutputL(TBool aSecure);
954 //=== AdvancedVideoSecureOutput === =
955 virtual void MmavsoSetAllowedOutputL(TUint aAllowedOutputMask);
958 // === MMmfPostInitializeRequest ===
959 virtual void MmpirPostInitializeRequest(MMmfPostInitializeResponse& aResponse);
963 // === CMMFVideoPostProcHwDevice ===
965 Set the proxy implementation to be used. Called just after the object is constructed.
966 @param "aProxy" "The proxy to use."
968 void SetProxy(MMMFDevVideoPlayProxy& aProxy);
973 * Symbian 2nd phase constructor .
978 TInt IsTimeToPost(TVideoPicture* frame, TInt64& delta);
979 TVideoPicture* CreateBuffersL(TInt aBufId);
980 void CreateVBMBuffersL();
981 TInt SetupExternalSurface(const TSurfaceId &aSurfaceID);
982 void ReleaseInputQ();
983 void ReleaseProcessQ();
984 void ReleasePicture(TVideoPicture *pic);
985 void PublishSurfaceCreated();
986 void PublishSurfaceUpdated();
988 void SetSurfaceAttributes(const TSize& aSize, TInt aNumBuf);
989 TInt GetID(TVideoPicture *aPicture);
990 TInt GetExternalBufferID(TVideoPicture *aPicture);
991 TInt RegisterSurface(const TSurfaceId& aSurfaceId);
993 void SetTimer(TInt64 aDelta);
994 TInt ConvertPostProcBuffer(TVideoPicture* pSrc, TVideoPicture* pDest);
995 void AddPictureToVBMQ(TVideoPicture *pic);
996 void AddPictureToColorConversionQ(TVideoPicture *pic);
997 void ResetCountingBuffer();
998 void PicturesSkipped();
999 TVideoPicture* DoColorConvert(TVideoPicture* aPicture);
1002 Adds a picture to the Input queue. Based on the timestamp of the picture,
1003 it is either appeneded at the end of the queue or inserted at the
1004 appropriate position. The queue is arranged in the ascending order.
1005 The ret value indicates if the head of the queue was changed or not.
1007 TInt AddToQ(TVideoPicture* aPicture);
1010 Removes a picture from Input queue based on the playrate.
1011 If the playrate is +ve ie forward playback head will be removed
1012 and if the playrate is -ve ie backward playback tail
1018 Returns a picture from Input queue based on the playrate.
1019 If the playrate is +ve ie forward playback head will be returned
1020 and if the playrate is -ve ie backward playback tail
1023 TVideoPicture* PeekQ();
1026 Adds a surface hint to a video surface. If there is any hint already added,
1027 the surface is updated with the new hint.
1031 #ifdef _DUMP_YUV_FRAMES
1032 void captureYuv(TVideoPicture* aPicture);
1035 TInt SetSourceFormat();
1036 TInt SetSourceRange();
1037 TInt ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow);
1042 // C++ default constructor.
1044 CNGAPostProcHwDevice();
1047 // State of post processor
1067 MMMFDevVideoPlayProxy* iProxy;
1068 CMMFVideoDecodeHwDevice* iInputDecoderDevice;
1069 RArray<TVideoPicture*> iInputQ;
1070 RArray<TVideoPicture*> iProcessQ;
1071 MMMFClockSource* iClockSource;
1072 TTimeIntervalMicroSeconds iCurrentPlaybackPosition;
1074 CNGAPostProcSurfaceHandler* iSurfaceHandler;
1075 CNGAPostProcSessionManager* iSessionManager;
1077 RSurfaceManager::TSurfaceCreationAttributesBuf iAttributes;
1079 RSurfaceManager::TInfoBuf iInfo;
1080 TSurfaceId iSurfaceId;
1081 TBool iIsInputEnded;
1082 CNGAPostProcTimer* iPostingTimer;
1083 CMMFDevVideoPlay::TPictureCounters iPictureCounters;
1084 TBool iFirstPictureUpdated;
1085 TBool iUsingExternalSurface;
1086 TBool iIsColorConversionNeeded;
1087 RArray<TVideoPicture*> iColorConversionQ;
1088 TBool iSurfaceCreatedEventPublished;
1089 TInt iOverflowPictureCounter;
1090 TInt iVideoFrameBufSize;
1091 TBool iResourceLost;
1093 // Flag to indicate that the redraw surface has been created, and
1094 // can be used in a subsequent call ro Redraw()
1095 TBool iRedrawSurfaceInUse;
1097 //-- members for buffer management --
1098 MMmfVideoBufferManagementObserver* iVBMObserver;
1099 TBufferOptions iVBMBufferOptions;
1100 RArray<TVideoPicture*> iVBMBufferReferenceQ;
1101 RArray<TVideoPicture*> iVBMBufferQ;
1103 RArray<TUncompressedVideoFormat> iSupportedInputFormats;
1106 //-- members for Surface Hints --
1107 RSurfaceManager::THintPair iHint;
1111 //-- members for Surface support --
1112 MMMFVideoSurfaceObserver* iVideoSurfaceObserver;
1113 MMmfVideoPropertiesObserver* iVPObserver;
1114 RWsSession iWsSession;
1116 TUint iAspectRatioNum;
1117 TUint iAspectRatioDenom;
1118 //-- members for Trickplay support --
1119 TInt iStepFrameCount;
1121 TBool iKeyFrameMode;
1122 MMmfVideoPlayRateObserver* iFPObserver;
1123 TUint8 iSkippedFramesCountingBuffer[64];
1124 TUint8 iSkippedFramesInLast64Frames;
1125 TUint8 iCurrentPosInFramesCountingBuffer;
1126 TUncompressedVideoFormat iVideoFormat;
1127 //---------- utility variables -------
1128 // Image source format
1129 TUint8 iSourceFormat;
1132 TUint8 iSourceRange;
1134 //-- members for PostInitializeRequest support --
1135 MMmfPostInitializeResponse* iPostInitializeResponse;
1136 TBool iIsExternalChunk;
1143 class CNGAPostProcTimer: public CTimer
1146 static CNGAPostProcTimer* NewL( CNGAPostProcHwDevice& aParent );
1147 ~CNGAPostProcTimer();
1153 CNGAPostProcTimer( CNGAPostProcHwDevice& aParent );
1157 CNGAPostProcHwDevice& iParent;
1160 #endif //__NGAPOSTPROCHWDEVICE_H__