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
37 #include <mmf/devvideo/devvideosurfacehandlecustominterface.h>
38 #include <mmf/devvideo/devvideoplayratecustominterface.h>
39 #include <surface_hints.h>
40 #include <secureoutputci.h>
41 #include <advancedsecureoutputci.h>
42 #include <graphics/suerror.h>
44 #include "fetchframecustominterface.h"
45 #include "MdfRDebug.h"
46 #include "NGAPostProcHwDevice_UID.hrh"
47 #include "NGAPostProcSessionManagerObserver.h"
50 class CNGAPostProcSessionManager;
51 class CNGAPostProcSurfaceHandler;
52 class CNGAPostProcTimer;
55 class CNGAPostProcHwDevice: public CMMFVideoPostProcHwDevice,
56 public MMmfVideoBufferManagement,
57 public MNGAPostProcSessionManagerObserver,
58 public MMMFVideoSurfaceSupport,
59 public MMmfVideoPropertiesObserver,
60 public MMmfVideoResourceObserver,
61 public MMmfVideoSurfaceHandleControl,
62 public MMmfVideoPropertiesNotifier,
63 public MMmfVideoPlayRateControl,
64 public MMmfVideoSecureOutput,
65 public MMmfAdvancedVideoSecureOutput
69 // === Constructors and destructor ===
71 * Two-phased constructor.
72 * @return pointer to an instance of CMMFVideoPostProcHwDevice
74 static CMMFVideoPostProcHwDevice* NewL();
79 ~CNGAPostProcHwDevice();
83 // === CMMFVideoPostProcHwDevice ===
86 Sets the device input format to an uncompressed video format.
88 @param "aFormat" "The input format to use."
89 @leave "The method will leave if an error occurs. Typical error codes used:
90 * KErrNotSupported - The input format is not supported."
91 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
93 void SetInputFormatL(const TUncompressedVideoFormat& aFormat);
96 Sets the decoder device that will write data to this post-processor. Decoded pictures will be
97 written with WritePictureL() or through a custom interface. After pictures have been processed,
98 they must be returned to the decoder using ReturnPicture().
100 @param "aDevice" "The decoder source plug-in to use."
101 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
103 void SetInputDevice(CMMFVideoDecodeHwDevice* aDevice);
106 Writes an uncompressed video picture to the post-processor. The picture must be returned to the
107 client or source plug-in after it has been used.
109 @param "aPicture" "The picture to write."
110 @leave "This method may leave with one of the system-wide error codes."
111 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
113 void WritePictureL(TVideoPicture* aPicture);
116 Retrieves post-processing information about this hardware device.
117 The device creates a CPostProcessorInfo structure, fills it with correct data, pushes it
118 to the cleanup stack and returns it. The client will delete the object when it is no
121 @return "Post-processor information as a CPostProcessorInfo object.
122 The object is pushed to the cleanup stack, and must be deallocated by the caller."
123 @leave "This method may leave with one of the system-wide error codes.
125 CPostProcessorInfo* PostProcessorInfoLC();
128 Retrieves the list of the output formats that the device supports. The list is ordered in
129 plug-in preference order, with the preferred formats at the beginning of the list. The list
130 can depend on the device source format, and therefore SetSourceFormatL() must be called before
133 @param "aFormats" "An array for the result format list. The array must be created and destroyed by the caller."
134 @leave "This method may leave with one of the system-wide error codes.
135 @pre "This method may only be called before the hwdevice has been initialized using Initialize()."
137 void GetOutputFormatListL(RArray<TUncompressedVideoFormat>& aFormats);
140 Sets the device output format.
142 @param "aFormat" "The format to use."
143 @leave "This method may leave with one of the system-wide error codes.
144 @pre "This method may only be called before the hwdevice has been initialized using Initialize()."
146 void SetOutputFormatL(const TUncompressedVideoFormat &aFormat);
149 Sets the clock source to use for video timing. If no clock source is set. video playback
150 will not be synchronized, but will proceed as fast as possible, depending on input data
151 and output buffer availability.
153 @param "aClock" "The clock source to be used."
154 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
156 void SetClockSource(MMMFClockSource* aClock);
159 Sets the device video output destination. The destination can be the screen (using direct
160 screen access) or memory buffers. By default memory buffers are used. If data is written
161 to another device, this method is ignored, and suitable memory buffers are always used.
163 @param "aScreen" "True if video output destination is the screen, false if memory buffers."
164 @leave "This method may leave with one of the system-wide error codes.
165 @pre "This method can only be called before the hwdevice has been initialized with Initialize()."
167 void SetVideoDestScreenL(TBool aScreen);
170 Sets the post-processing types to be used.
172 @param "aPostProcCombination" "The post-processing steps to perform, a bitwise OR of values from TPostProcessType."
173 @leave "This method may leave with one of the system-wide error codes.
174 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
175 If called after initialization, the change must only be committed when CommitL() is called."
177 void SetPostProcessTypesL(TUint32 aPostProcCombination);
180 Sets post-processing options for input (pan-scan) cropping.
182 @param "aRect" "The cropping rectangle to use."
183 @leave "This method may leave with one of the system-wide error codes.
184 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
185 If called after initialization, the change must only be committed when CommitL() is called."
187 void SetInputCropOptionsL(const TRect& aRect);
190 Sets post-processing options for YUV to RGB color space conversion.
191 Specifies the input YUV and output RGB formats to use explicitly. SetSourceFormatL(),
192 SetOutputFormatL(), and SetPostProcessTypesL() must be called before this method is used.
194 @param "aOptions" "The conversion options to use."
195 @param "aYuvFormat" "Conversion source YUV format"
196 @param "aRgbFormat" "Conversion target RGB format"
197 @leave "This method may leave with one of the system-wide error codes.
198 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
199 If called after initialization, the change must only be committed when CommitL() is called."
201 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions, const TYuvFormat& aYuvFormat,
202 TRgbFormat aRgbFormat);
205 Sets post-processing options for YUV to RGB color space conversion.
206 Uses the device input and output formats. For decoder devices the default YUV format used is
207 the format specified in the input bitstream. SetSourceFormatL(), SetOutputFormatL(), and
208 SetPostProcessTypesL() must be called before this method is used.
210 @param "aOptions" "The conversion options to use."
211 @leave "This method may leave with one of the system-wide error codes.
212 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
213 If called after initialization, the change must only be committed when CommitL() is called."
215 void SetYuvToRgbOptionsL(const TYuvToRgbOptions& aOptions);
218 Sets post-processing options for rotation. SetPostProcessTypesL() must be called before
221 @param "aRotationType" "The rotation to perform."
222 @leave "This method may leave with one of the system-wide error codes.
223 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
224 If called after initialization, the change must only be committed when CommitL() is called."
226 void SetRotateOptionsL(TRotationType aRotationType);
229 Sets post-processing options for scaling. SetPostProcessTypesL() must be called before
232 @param "aTargetSize" "Scaling target size. If a fixed scale factor size is used,
233 the new dimensions must be set to width=floor(factor*width),
234 height=floor(factor*height). For example, scaling a
235 QCIF (176x144) picture up by a factor of 4/3 yields a size
237 @param "aAntiAliasFiltering" "True if anti-aliasing filtering should be used.
238 If the post-processor does not support anti-aliased scaling,
239 or supports anti-aliased scaling only, this argument is ignored."
240 @leave "This method may leave with one of the system-wide error codes.
241 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
242 If called after initialization, the change must only be committed when CommitL() is called."
244 void SetScaleOptionsL(const TSize& aTargetSize, TBool aAntiAliasFiltering);
247 Sets post-processing options for output cropping. SetPostProcessTypesL() must be called before
250 @param "aRect" "Output cropping area."
251 @leave "This method may leave with one of the system-wide error codes.
252 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
253 If called after initialization, the change must only be committed when CommitL() is called."
255 void SetOutputCropOptionsL(const TRect& aRect);
258 Sets post-processing plug-in specific options. SetPostProcessTypesL() must be called before
261 @param "aOptions" "The options. The format is plug-in specific."
262 @leave "This method may leave with one of the system-wide error codes.
263 @pre "This method can be called either before or after the hwdevice has been initialized with Initialize().
264 If called after initialization, the change must only be committed when CommitL() is called."
266 void SetPostProcSpecificOptionsL(const TDesC8& aOptions);
269 Initializes the device. This method is asynchronous, the device will call
270 MMFVideoPlayProxy::MdvppInitializeComplete() after initialization has completed. After this
271 method has successfully completed, further configuration changes are not possible except where
277 Commit all changes since the last CommitL(), Revert() or Initialize()
278 to the hardware device. This only applies to methods which can be called both
279 before AND after DevVideoPlay has been initialized.
281 @see SetPostProcessTypesL
282 @see SetInputCropOptionsL
283 @see SetYuvToRgbOptionsL
284 @see SetRotateOptionsL
285 @see SetScaleOptionsL
286 @see SetOutputCropOptionsL
287 @see SetPostProcSpecificOptionsL
289 @leave "The method will leave if an error occurs."
290 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
295 Revert all changes since the last CommitL(), Revert() or Initialize()
296 back to their previous settings. This only applies to methods which can
297 be called both before AND after DevVideoPlay has been initialized.
299 @see SetPostProcessTypesL
300 @see SetInputCropOptionsL
301 @see SetYuvToRgbOptionsL
302 @see SetRotateOptionsL
303 @see SetScaleOptionsL
304 @see SetOutputCropOptionsL
305 @see SetPostProcSpecificOptionsL
307 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
312 Starts writing output directly to the display frame buffer using Direct Screen Access.
314 @param "aVideoRect" "The video output rectangle on screen."
315 @param "aScreenDevice" "The screen device to use. The screen device object must be valid in the current thread."
316 @param "aClipRegion" "Initial clipping region to use."
318 @leave "This method may leave with one of the system-wide error codes.
319 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
321 void StartDirectScreenAccessL(const TRect& aVideoRect,
322 CFbsScreenDevice& aScreenDevice, const TRegion& aClipRegion);
325 Sets a new clipping region for Direct Screen Access. After the method returns, no video will
326 be drawn outside of the region. If clipping is not supported, or the clipping region is too
327 complex, either playback will pause or will resume without video display, depending on the
328 current setting of SetPauseOnClipFail(), and the result can be verified with IsPlaying().
329 Clipping can be disabled by setting a new clipping region that includes the whole video window.
331 @param "aRegion" "The new clipping region. After the method returns, no video will be drawn outside the region."
332 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
334 void SetScreenClipRegion(const TRegion& aRegion);
337 Sets whether the system should pause playback when it gets a clipping region it cannot handle,
338 or Direct Screen Access is aborted completely. If not, processing will proceed normally, but no
339 video will be drawn. By default, playback is paused.
341 @param "aPause" "True if playback should be paused when clipping fails, false if not.
342 If playback is not paused, it will be continued without video display."
343 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
345 void SetPauseOnClipFail(TBool aPause);
348 Aborts Direct Screen Access completely, to be called from MAbortDirectScreenAccess::AbortNow()
349 and similar methods. DSA can be resumed by calling StartDirectScreenAccessL().
350 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
352 void AbortDirectScreenAccess();
355 Indicates whether playback is proceeding. This method can be used to check whether playback was
356 paused or not in response to a new clipping region or DSA abort.
358 @return "ETrue if video is still being played (even if not necessarily displayed)."
359 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
364 Re-draws the latest video picture. Only available when DSA is being used. If DSA is aborted or a
365 non-supported clipping region has been set, the request may be ignored.
366 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
372 Starts video playback, including decoding, post-processing, and rendering. Playback will proceed
373 until it has been stopped or paused, or the end of the bitstream is reached.
374 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
379 Stops video playback. No new pictures will be decoded, post-processed, or rendered.
380 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
385 Pauses video playback, including decoding, post-processing, and rendering. No pictures will be
386 decoded, post-processed, or rendered until playback has been resumed.
387 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
392 Resumes video playback after a pause.
393 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
398 Changes to a new decoding and playback position, used for randomly accessing (seeking) the
399 input stream. The position change flushes all input and output buffers. Pre-decoder and
400 post-decoder buffering are handled as if a new bitstream was being decoded. If the device still
401 has buffered pictures that precede the new playback position, they will be discarded. If playback
402 is synchronized to a clock source, the client is responsible for setting the clock source to the
405 @param "aPlaybackPosition" "The new playback position in the video stream."
406 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
408 void SetPosition(const TTimeIntervalMicroSeconds& aPlaybackPosition);
411 Freezes a picture on the screen. After the picture has been frozen, no new pictures are
412 displayed until the freeze is released with ReleaseFreeze(). If the device output is being
413 written to memory buffers or to another plug-in, instead of the screen, no decoded pictures
414 will be delivered while the freeze is active, and they are simply discarded.
416 @param "aTimestamp" "The presentation timestamp of the picture to freeze. The frozen picture
417 will be the first picture with a timestamp greater than or equal to this
419 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
421 void FreezePicture(const TTimeIntervalMicroSeconds& aTimestamp);
424 Releases a picture frozen with FreezePicture().
426 @param "aTimestamp" "The presentation timestamp of the picture to release. The first picture
427 displayed after the release will be the first picture with a timestamp
428 greater than or equal to this parameter. To release the freeze immediately,
429 set the timestamp to zero."
430 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
432 void ReleaseFreeze(const TTimeIntervalMicroSeconds& aTimestamp);
436 Returns the current playback position, i.e. the timestamp for the most recently displayed or
437 virtually displayed picture. If the device output is written to another device, the most recent
438 output picture is used.
440 @return "Current playback position."
441 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
443 TTimeIntervalMicroSeconds PlaybackPosition();
446 Returns the total amount of memory allocated for uncompressed pictures. This figure only
447 includes the pictures actually allocated by the plug-in itself, so that the total number of
448 bytes allocated in the system can be calculated by taking the sum of the values from all plug-ins.
450 @return "Total number of bytes of memory allocated for uncompressed pictures."
451 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
453 TUint PictureBufferBytes();
456 Reads various counters related to decoded pictures. The counters are reset when Initialize()
457 or this method is called, and thus they only include pictures processed since the last call.
459 Post-processor devices return the number of input pictures in iPicturesDecoded and
460 iTotalPictures. If the decoded pictures are written to another plug-in, they are considered
461 to be "virtually displayed".
463 @param "aCounters" "The counter structure to fill."
464 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
466 void GetPictureCounters(CMMFDevVideoPlay::TPictureCounters& aCounters);
470 Sets the computational complexity level to use. If separate complexity levels are not available,
471 the method call is ignored. If the level specified is not available, the results are undefined.
472 Typically the device will either ignore the request or use the nearest suitable level.
474 The complexity level can be changed at any point during playback.
476 @param "aLevel" "The computational complexity level to use. Level zero (0) is the most complex
477 one, with the highest quality. Higher level numbers require less processing
478 and may have lower quality."
479 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
481 void SetComplexityLevel(TUint aLevel);
484 Gets the number of complexity levels available.
486 @return "The number of complexity control levels available, or zero if the information is not
487 available yet. The information may not be available if the number of levels depends on
488 the input data, and enough input data has not been read yet. In that case, using level
490 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
492 TUint NumComplexityLevels();
495 Gets information about a computational complexity level. This method can be called after
496 NumComplexityLevels() has returned a non-zero value - at that point the information is guaranteed
497 to be available. Some hardware device implementations may not be able to provide all values,
498 in that case the values will be approximated.
500 @param "aLevel" "The computational complexity level to query. The level numbers range from zero
501 (the most complex) to NumComplexityLevels()-1."
502 @param "aInfo" "The information structure to fill."
503 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
505 void GetComplexityLevelInfo(TUint aLevel, CMMFDevVideoPlay::TComplexityLevelInfo& aInfo);
508 Returns a picture back to the device. This method is called by CMMFDevVideoPlay to return pictures
509 from the client (after they have been written with NewPicture()), or by the output device when
510 it has finished using a picture.
512 @param "aPicture" "The picture to return. The device can re-use the memory for the picture."
513 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
515 void ReturnPicture(TVideoPicture* aPicture);
518 Gets a copy of the latest picture sent to output.
520 @param "aPictureData" "Target picture. The memory for the picture must be allocated by the
521 caller, and initialized properly. The data formats must match the snapshot
523 @param "aFormat" "The picture format to use for the snapshot."
525 @return "ETrue if the snapshot was taken, EFalse if a picture is not available. The picture may not
526 be available if decoding has not progressed far enough yet."
528 @leave "The method will leave if an error occurs. Typical error codes used:
529 * KErrNotSupported - The requested data format or picture size is not supported, or the
530 plug-in does not support snapshots."
531 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
533 // TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat) {return EFalse;};
534 TBool GetSnapshotL(TPictureData& aPictureData, const TUncompressedVideoFormat& aFormat);
537 When the snapshot is available, it will be returned to the client using the TimedSnapshotComplete()
538 callback. To cancel a timed snapshot request, use CancelTimedSnapshot(). Only one timed snapshot
539 request can be active at a time.
541 @param "aPictureData" "Target picture. The memory for the picture must be allocated by
542 the caller, and initialized properly. The data formats must match
543 the snapshot format requested. The picture must remain valid until
544 the snapshot has been taken or until the request has been cancelled
545 with CancelTimedSnapshot()."
546 @param "aFormat" "The picture format to use for the snapshot."
547 @param "aPresentationTimestamp" "Presentation timestamp for the picture to copy."
549 @leave "The method will leave if an error occurs. Typical error codes used:
550 * KErrNotSupported - The requested data format or picture size is not supported or
551 the plug-in does not support timed snapshots."
552 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
554 //void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat,
555 // const TTimeIntervalMicroSeconds& aPresentationTimestamp){};
556 void GetTimedSnapshotL(TPictureData*, const TUncompressedVideoFormat&, const TTimeIntervalMicroSeconds&){};
560 When the snapshot is available, it will be returned to the client using the TimedSnapshotComplete()
561 callback. To cancel a timed snapshot request, use CancelTimedSnapshot(). Only one timed snapshot
562 request can be active at a time.
564 @param "aPictureData" "Target picture. The memory for the picture must be allocated by
565 the caller, and initialized properly. The data formats must match
566 the snapshot format requested. The picture must remain valid until
567 the snapshot has been taken or until the request has been cancelled
568 with CancelTimedSnapshot()."
569 @param "aFormat" "The picture format to use for the snapshot."
570 @param "aPictureId" "Picture identifier for the picture to copy."
572 @leave "The method will leave if an error occurs. Typical error codes used:
573 * KErrNotSupported - The requested data format or picture size is not supported or
574 the plug-in does not support timed snapshots."
575 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
577 // void GetTimedSnapshotL(TPictureData* aPictureData, const TUncompressedVideoFormat& aFormat,
578 // const TPictureId& aPictureId){};
579 void GetTimedSnapshotL(TPictureData*, const TUncompressedVideoFormat&, const TPictureId& ){};
582 Cancels a timed snapshot request.
583 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
585 void CancelTimedSnapshot(){};
588 Gets a list of the supported snapshot picture formats.
590 @param "aFormats" "An array for the result format list. The array must be created and destroyed by
593 @leave "This method may leave with one of the standard error codes."
594 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
596 void GetSupportedSnapshotFormatsL(RArray<TUncompressedVideoFormat>&){};
601 Notifies the hardware device that the end of input data has been reached and no more input data
602 will be written. The hardware device can use this signal to ensure that the remaining data gets
603 processed, without waiting for new data. For example when the data type is not EDuCodedPicture,
604 calling this method is necessary otherwise a hardware device implementation might be looking for
605 the start code for the next picture to ensure it has a complete picture before starting to decode
609 After the remaining data has been processed (and displayed, if applicable), the hardware
610 device must notify the proxy with the MdvppStreamEnd() callback.
612 DevVideo clients are encouraged to call this method, but its use is not mandatory for synchronized
613 processing. For synchronized playback, all video pictures are processed or discarded according to
614 their timestamps, and so the client can easily infer when processing is complete. However, it
615 should be noted that the last picture might not be displayed if this method is not called and the
616 input data type is not EDuCodedPicture.
618 For non-synchronized playback (e.g. file conversion), a client must call this method otherwise it
619 will never find out when the hardware device has finished processing the data.
621 @pre "This method can only be called after the hwdevice has been initialized with Initialize()."
626 Retrieves a custom interface to the device.
627 @param "aInterface" "Interface UID, defined with the custom interface."
628 @return "Pointer to the interface implementation, or NULL if the device does not
629 implement the interface requested. The return value must be cast to the
630 correct type by the user."
632 TAny* CustomInterface(TUid aInterface);
634 // === MNGAPostProcSessionManagerObserver ===
636 Set the proxy implementation to be used. Called just after the object is constructed.
637 @param "aProxy" "The proxy to use."
639 void BufferAvailable(TInt aBufId, TInt aStatus);
643 // === MMmfVideoBufferManagement ===
646 * Sets the observer object to use. The observer gets notified
647 * when new buffers are available and when buffers need to be
648 * released back to the media device.
650 * This method can only be called before the media device has
651 * been Initialized with InitializeL().
653 * @param aObserver The observer object to use.
655 void MmvbmSetObserver(MMmfVideoBufferManagementObserver* aObserver);
658 * Enables input buffer management mode. In buffer management mode
659 * the target media device allocates memory for input buffers and
660 * the client can only use input buffers allocated with
663 * This method can only be called before the media device has been
664 * Initialized with InitializeL(). This method must be called if
665 * the client uses MmvbmGetBufferL().
667 * @param aEnable ETrue if input buffer management mode is used.
669 void MmvbmEnable(TBool aEnable);
672 * Sets the buffer options to use. The client can request the
673 * number of input buffers that should be available, but typically
674 * only few (one or two) buffers can be used.
676 * This method can only be called before the media device has been
677 * Initialized with InitializeL().
679 * @param aOptions The buffer options to use, see TBufferOptions.
681 * @leave KErrNotSupported The requested buffer options are not
682 * supported. Typically the client has requested too many input
685 void MmvbmSetBufferOptionsL(const TBufferOptions& aOptions);
688 * Gets the buffer options currently in use.
690 * This method can only be called before the media device has been
691 * Initialized with InitializeL().
693 * @param aOptions Target buffer options data structure.
695 void MmvbmGetBufferOptions(TBufferOptions& aOptions);
698 * Gets a new input picture buffer. The client can then write data
699 * into the buffer and write it back to the media device with
702 * This method can only be called after the media device has been
703 * Initialized with InitializeL(). This method can only be called
704 * in buffer management mode, i.e. if the client has called
705 * MmvbmEnable(ETrue).
707 * Note that target-allocated and client-allocated input buffers
708 * cannot be mixed. In buffer management mode only input buffers
709 * allocated with this method can be sent to the media device.
711 * If a client has retrieved buffers with MmvbmGetBufferL(), it
712 * must be prepated to release them synchronously at any point if
713 * MmmfBufferManagementObserver::MmvbmoReleaseBuffers() is
714 * called. This may happen if the target media device suddenly
715 * loses access to the buffers due to DSA abort, resource
716 * management conflict, or media device destruction.
718 * @param aSize The requested buffer size, in pixels. The buffer
719 * size should match the picture size set at initialisation phase,
720 * or otherwise suitable buffer may not be available. If the size
721 * is smaller than the size set at initialisation phase, the
722 * allocated buffer may be larger than requested.
724 * @return A new input picture buffer. If no free buffers are
725 * available, the return value is NULL.
727 * @leave General The method will leave if an error occurs. Lack
728 * of free buffers is not considered an error.
730 TVideoPicture* MmvbmGetBufferL(const TSize& aSize);
733 * Releases an input buffer back to the media device without using
734 * it. This method is mainly used as a response to a
735 * MmvbmReleaseBuffers() callback.
737 * @param aBuffer The buffer to release.
739 void MmvbmReleaseBuffer(TVideoPicture* aBuffer);
743 // === MMMFVideoSurfaceSupport ===
746 Requests the media device to use graphics surfaces for video rendering.
747 The client must call this method before Initialize() to ensure the media
748 device allocates the right types of resources for rendering.
750 void MmvssUseSurfaces();
753 Sets a new video surface support observer to receive surface management events
754 from the media device.
756 @param aObserver New observer object to use.
758 void MmvssSetObserver(MMMFVideoSurfaceObserver& aObserver);
761 Retrieves surface parameters for a display. The client typically calls this in response
762 to a MmvsoSurfaceCreated() or MmvsoSurfaceParametersUpdated() observer callback.
765 Surface ID for the display.
767 Cropping rectangle within the surface. The crop rectangle identifies the area of
768 the surface that should be shown on the screen.
769 @param aPixelAspectRatio
770 Video picture pixel aspect ratio.
772 @leave KErrNotReady if no surface is available for the display.
775 void MmvssGetSurfaceParametersL(TSurfaceId& aSurfaceId, TRect& aCropRect,
776 TVideoAspectRatio& aPixelAspectRatio);
778 Indicates that the surface is no longer in use and can be destroyed. The client typically calls
779 this in response to MmvsoSurfaceCreated() (while old surface is already in use and the current
780 should be removed) or MmvsoRemoveSurface() observer callback.
782 @param aSurfaceId Surface ID that is no longer in use
784 @leave KErrNotFound if the surface does not exist
786 void MmvssSurfaceRemovedL(const TSurfaceId& aSurfaceId);
790 // === MMmfVideoPropertiesObserver ===
793 Decoded video properties updated. The media device implementing the
794 MMmfVideoPropertiesNotifier extension will call this method immediately
795 before outputting a picture with the updated properties.
797 When the extension is used between a decoder and a post-processor media
798 device, the post-processor can associate the changed properties with the
799 correct picture, since the next incoming picture after this call will
800 be the first updated one.
802 When the extension is used between a DevVideoPlay client and a
803 post-processor media device, the client can synchronously reconfigure
804 video display options using SetScaleOptionsL() and related methods. This
805 lets the client reconfigure the display for the correct picture.
807 @param aYuvFormat Updated YUV format parameters. The updated fields are
808 iAspectRatioDenom, iAspectRatioNum, and iCoefficients
809 @param aPictureSize Updated picture size. This size will be the true
810 picture display size, excluding any padding that
813 virtual void MmvpoUpdateVideoProperties(const TYuvFormat& aYuvFormat, const TSize& aPictureSize);
817 // === MMmfVideoResourceObserver ===
820 Indicates that a media device has lost its resources. The client must
821 synchronously pause or stop processing before returning from this method
822 so that the media device can release its resources to the system. If
823 the client does not pause or stop, resource loss will be handled as a
826 The client may start again or resume after receiving a
827 MvroResourcesRestored() callback.
829 @param aMediaDevice UID for the media device that lost resources. The
830 client can use this e.g. to determine whether the
831 decoder or the post-processor lost resources. This
832 is typically not required though since the client
833 must pause DevVideo entirely.
835 virtual void MmvroResourcesLost(TUid aMediaDevice);
838 Indicates that a media device has regained its resources after a
839 previous resource loss. The client can restart or resume processing.
840 This can be done either synchronously or asynchronously.
842 @param aMediaDevice UID for the media device that regained resources.
844 virtual void MmvroResourcesRestored(TUid aMediaDevice);
847 // === MMmfVideoSurfaceHandleControl ===
850 Sets an external surface ID. This should be called as soon as external surface is created.
852 @param aSurfaceID external surface ID.
856 virtual void MmvshcSetSurfaceHandle(const TSurfaceId& aSurfaceHandle);
859 Sets a redraw buffer to be used during resource loss.
861 @param aRedrawBuffer redraw buffer.
864 virtual void MmvshcRedrawBufferToSurface(TPtrC8& aRedrawBuffer);
866 // === MMmfVideoPropertiesNotifier ===
868 Sets a new video properties observer. This method can be called at any
869 time after the media device has been instantiated.
871 @param aObserver New observer object.
873 virtual void MmvpnSetObserver(MMmfVideoPropertiesObserver* aObserver);
877 void ReturnPicToDecoder(TVideoPicture* aPic);
878 TInt AttemptToPost();
881 //=== MMdfTrickPlayControl === =
883 * Query the Direction capabilities from the MDF decoders and
887 virtual void MmvprcGetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities);
890 * Sets the playback speed. A negative rate means play backward.
894 virtual void MmvprcSetPlayRateL(const TInt aRate);
897 * Gets the playback speed. A negative rate means play backward.
901 virtual TInt MmvprcPlayRateL();
904 * Sets the step frame number in frame step mode
907 virtual void MmvprcStepFrameL(const TInt aStep);
910 * Registers the observer
912 virtual void MmvprcSetObserver(MMmfVideoPlayRateObserver& aObserver);
916 // === MMmfVideoSecureOutput ===
918 * Notifies the media device if the content can only be sent to a
919 * secure output. The device display is typically considered a
920 * secure output, but a high-quality unprotected analog or digital
921 * video output connector is not. By default all content can be
922 * sent to both secure and insecure outputs.
924 * This method can only be called before the media device has been
925 * initialised with InitializeL().
927 * @param aSecure Set to ETrue if the content can only be sent to
928 * a secure output, EFalse if both secure and unsecure outputs can
931 * @leave KErrNotSupported Insecure outputs cannot be
932 * disabled. The client should not play protected content.
934 virtual void MmvsoSetSecureOutputL(TBool aSecure);
937 //=== AdvancedVideoSecureOutput === =
938 virtual void MmavsoSetAllowedOutputL(TUint aAllowedOutputMask);
942 // === CMMFVideoPostProcHwDevice ===
944 Set the proxy implementation to be used. Called just after the object is constructed.
945 @param "aProxy" "The proxy to use."
947 void SetProxy(MMMFDevVideoPlayProxy& aProxy);
952 * Symbian 2nd phase constructor .
957 TInt IsTimeToPost(TVideoPicture* frame, TInt64& delta);
958 TVideoPicture* CreateBuffersL(TInt aBufId);
959 void CreateVBMBuffersL();
960 TInt SetupExternalSurface(const TSurfaceId &aSurfaceID);
961 void ReleaseInputQ();
962 void ReleaseProcessQ();
963 void ReleasePicture(TVideoPicture *pic);
964 void PublishSurfaceCreated();
965 void PublishSurfaceUpdated();
966 TInt SetupSurface(const TSize& aSize);
967 void SetSurfaceAttributes(const TSize& aSize, TInt aNumBuf);
968 TInt GetID(TVideoPicture *aPicture);
969 TInt GetExternalBufferID(TVideoPicture *aPicture);
970 TInt RegisterSurface(const TSurfaceId& aSurfaceId);
972 void SetTimer(TInt64 aDelta);
973 TInt ConvertPostProcBuffer(TVideoPicture* pSrc, TVideoPicture* pDest);
974 void AddPictureToVBMQ(TVideoPicture *pic);
975 void AddPictureToColorConversionQ(TVideoPicture *pic);
976 void ResetCountingBuffer();
977 void PicturesSkipped();
978 TVideoPicture* DoColorConvert(TVideoPicture* aPicture);
981 Adds a picture to the Input queue. Based on the timestamp of the picture,
982 it is either appeneded at the end of the queue or inserted at the
983 appropriate position. The queue is arranged in the ascending order.
984 The ret value indicates if the head of the queue was changed or not.
986 TInt AddToQ(TVideoPicture* aPicture);
989 Removes a picture from Input queue based on the playrate.
990 If the playrate is +ve ie forward playback head will be removed
991 and if the playrate is -ve ie backward playback tail
997 Returns a picture from Input queue based on the playrate.
998 If the playrate is +ve ie forward playback head will be returned
999 and if the playrate is -ve ie backward playback tail
1002 TVideoPicture* PeekQ();
1005 Adds a surface hint to a video surface. If there is any hint already added,
1006 the surface is updated with the new hint.
1010 #ifdef _DUMP_YUV_FRAMES
1011 void captureYuv(TVideoPicture* aPicture);
1014 TInt SetSourceFormat();
1015 TInt SetSourceRange();
1016 TInt ColorConvert(tBaseVideoFrame* aInputFrame, TUint8* aDestPtr, tWndParam* aInputCropWindow, tWndParam* aOutputCropWindow);
1021 // C++ default constructor.
1023 CNGAPostProcHwDevice();
1026 // State of post processor
1046 MMMFDevVideoPlayProxy* iProxy;
1047 CMMFVideoDecodeHwDevice* iInputDecoderDevice;
1048 RArray<TVideoPicture*> iInputQ;
1049 RArray<TVideoPicture*> iProcessQ;
1050 MMMFClockSource* iClockSource;
1051 TTimeIntervalMicroSeconds iCurrentPlaybackPosition;
1053 CNGAPostProcSurfaceHandler* iSurfaceHandler;
1054 CNGAPostProcSessionManager* iSessionManager;
1056 RSurfaceManager::TSurfaceCreationAttributesBuf iAttributes;
1058 RSurfaceManager::TInfoBuf iInfo;
1059 TSurfaceId iSurfaceId;
1060 TBool iIsInputEnded;
1061 CNGAPostProcTimer* iPostingTimer;
1062 CMMFDevVideoPlay::TPictureCounters iPictureCounters;
1063 TBool iFirstPictureUpdated;
1064 TBool iUsingExternalSurface;
1065 TBool iIsColorConversionNeeded;
1066 RArray<TVideoPicture*> iColorConversionQ;
1067 TBool iSurfaceCreatedEventPublished;
1068 TInt iOverflowPictureCounter;
1069 TInt iVideoFrameBufSize;
1070 TBool iResourceLost;
1072 // Flag to indicate that the redraw surface has been created, and
1073 // can be used in a subsequent call ro Redraw()
1074 TBool iRedrawSurfaceInUse;
1076 //-- members for buffer management --
1077 MMmfVideoBufferManagementObserver* iVBMObserver;
1078 TBufferOptions iVBMBufferOptions;
1079 RArray<TVideoPicture*> iVBMBufferReferenceQ;
1080 RArray<TVideoPicture*> iVBMBufferQ;
1082 RArray<TUncompressedVideoFormat> iSupportedInputFormats;
1085 //-- members for Surface Hints --
1086 RSurfaceManager::THintPair iHint;
1090 //-- members for Surface support --
1091 MMMFVideoSurfaceObserver* iVideoSurfaceObserver;
1092 MMmfVideoPropertiesObserver* iVPObserver;
1093 RWsSession iWsSession;
1095 TUint iAspectRatioNum;
1096 TUint iAspectRatioDenom;
1097 //-- members for Trickplay support --
1098 TInt iStepFrameCount;
1100 TBool iKeyFrameMode;
1101 MMmfVideoPlayRateObserver* iFPObserver;
1102 TUint8 iSkippedFramesCountingBuffer[64];
1103 TUint8 iSkippedFramesInLast64Frames;
1104 TUint8 iCurrentPosInFramesCountingBuffer;
1105 TUncompressedVideoFormat iVideoFormat;
1106 //---------- utility variables -------
1107 // Image source format
1108 TUint8 iSourceFormat;
1111 TUint8 iSourceRange;
1118 class CNGAPostProcTimer: public CTimer
1121 static CNGAPostProcTimer* NewL( CNGAPostProcHwDevice& aParent );
1122 ~CNGAPostProcTimer();
1128 CNGAPostProcTimer( CNGAPostProcHwDevice& aParent );
1132 CNGAPostProcHwDevice& iParent;
1135 #endif //__NGAPOSTPROCHWDEVICE_H__