Update contrib.
1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef VIDEOPLAYERBODY_H
17 #define VIDEOPLAYERBODY_H
22 #ifdef SYMBIAN_BUILD_GCE
23 #include <mmf/common/mmfvideosurfacecustomcommands.h>
26 #include <mmf/common/mmfbase.h>
27 #include <mmf/common/mmfcontroller.h>
28 #include <mmf/common/mmfaudio.h>
29 #include <mmf/common/mmfstandardcustomcommands.h>
30 #include <mmf/common/mmfdrmcustomcommands.h>
31 #include <mda/common/base.h>
32 #include <mmf/common/mmfutilities.h>
33 #include <mmf/common/mmfcontrollerframeworkbase.h>
34 #include "mmf/common/mmcaf.h"
35 #include "mmfclientutility.h"
37 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
38 #include "mmfsubtitleutility.h"
39 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
41 #ifdef SYMBIAN_BUILD_GCE
42 #include "mediaclientvideodisplaybody.h"
45 class CMMFVideoPlayerCallback;
46 class MMMFDRMCustomCommand;
47 class CVideoPlayerUtility;
48 class MMMFSurfaceEventHandler;
49 #ifdef SYMBIAN_BUILD_GCE
51 class CMediaClientVideoDisplayBody;
52 #endif // SYMBIAN_BUILD_GCE
53 NONSHARABLE_CLASS( CVideoPlayerUtility::CBody ): public CBase,
54 public MDirectScreenAccess,
55 public MMMFControllerEventMonitorObserver,
56 public MMMFFindAndOpenControllerObserver
63 static CBody* NewL(CVideoPlayerUtility* aParent,
64 MVideoPlayerUtilityObserver& aObserver,
68 CWsScreenDevice& aScreenDevice,
70 const TRect& aScreenRect,
71 const TRect& aClipRect);
73 #ifdef SYMBIAN_BUILD_GCE
74 static CBody* NewL(CVideoPlayerUtility2* aParent,
75 MVideoPlayerUtilityObserver& aObserver,
79 void OpenFileL(const TDesC& aFileName,TUid aControllerUid = KNullUid);
80 void OpenFileL(const RFile& aFile, TUid aControllerUid = KNullUid);
83 void OpenFileL(const TMMSource& aSource, TUid aControllerUid = KNullUid);
85 void OpenDesL(const TDesC8& aDescriptor,TUid aControllerUid = KNullUid);
86 void OpenUrlL(const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType=KNullDesC8, TUid aControllerUid = KNullUid);
93 void Play(const TTimeIntervalMicroSeconds& aStartPoint, const TTimeIntervalMicroSeconds& aEndPoint);
97 void SetPriorityL(TInt aPriority, TInt aPref);
98 void PriorityL(TInt& aPriority, TMdaPriorityPreference& aPref) const;
100 void SetDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
101 const TRect& aScreenRect, const TRect& aClipRect);
103 void RegisterForVideoLoadingNotification(MVideoLoadingObserver& aObserver);
105 void GetFrameL(TDisplayMode aDisplayMode, TBool aUseIntentAPI = EFalse, ContentAccess::TIntent aIntent = ContentAccess::EPeek );
106 void RefreshFrameL();
108 TReal32 VideoFrameRateL() const;
109 void VideoFrameSizeL(TSize& aSize) const;
110 const TDesC8& VideoFormatMimeType() const;
111 TInt VideoBitRateL() const;
113 TInt AudioBitRateL() const;
114 TFourCC AudioTypeL() const;
115 TBool AudioEnabledL() const;
117 void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
118 TTimeIntervalMicroSeconds PositionL() const;
119 TTimeIntervalMicroSeconds DurationL() const;
121 void SetVolumeL(TInt aVolume);
123 TInt MaxVolume() const;
124 void SetBalanceL(TInt aBalance);
127 void SetRotationL(TVideoRotation aRotation);
128 TVideoRotation RotationL() const;
129 void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, TBool aAntiAliasFiltering);
130 void GetScaleFactorL(TReal32& aWidthPercentage, TReal32& aHeightPercentage, TBool& aAntiAliasFiltering) const;
131 void SetCropRegionL(const TRect& aCropRegion);
132 void GetCropRegionL(TRect& aCropRegion) const;
134 TInt NumberOfMetaDataEntriesL() const;
135 CMMFMetaDataEntry* MetaDataEntryL(TInt aIndex) const;
137 void GetVideoLoadingProgressL(TInt& aPercentageProgress);
138 TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
139 TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
140 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
141 void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
143 void SetVideoFrameRateL(TReal32 aFramesPerSecond);
144 const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
146 MMMFDRMCustomCommand* GetDRMCustomCommand();
148 void StopDirectScreenAccessL();
149 void StartDirectScreenAccessL();
151 TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback, TUid aNotificationEventUid, const TDesC8& aNotificationRegistrationData = KNullDesC8);
152 TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
153 TInt WillResumePlay();
155 TInt SetInitScreenNumber(TInt aScreenNumber);
157 void SetPlayVelocityL(TInt aVelocity);
158 TInt PlayVelocityL() const;
159 void StepFrameL(TInt aStep);
160 void GetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities) const;
161 void SetVideoEnabledL(TBool aVideoEnabled);
162 TBool VideoEnabledL() const;
163 void SetAudioEnabledL(TBool aAudioEnabled);
164 void SetAutoScaleL(TAutoScaleType aScaleType);
165 void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
167 #ifdef SYMBIAN_BUILD_GCE
168 void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice,
169 RWindow& aWindow, const TRect& aVideoExtent,
170 const TRect& aWindowClipRect);
171 void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow);
172 void RemoveDisplayWindow(RWindowBase& aWindow);
173 void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent);
174 void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect);
176 void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType);
177 void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
179 void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation);
180 TVideoRotation RotationL(const RWindowBase& aWindow) const;
181 void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage);
182 void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage) const;
183 void AddDisplayL(TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler);
184 void RemoveDisplay(TInt aDisplay);
185 void ConvertFromRelativeToDisplayToRelativeToWindow(
186 const RWindowBase& aWindow,
187 const TRect& aFromWindowRect,
188 const TRect& aFromClipRect,
189 TRect& aToWindowRect,
191 void SetExternalDisplaySwitchingL(TInt aDisplay, TBool aControl);
194 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
195 TBool SubtitlesAvailable();
196 void EnableSubtitlesL();
197 void DisableSubtitles();
198 TArray<TLanguage> SupportedSubtitleLanguagesL();
199 TLanguage SubtitleLanguageL();
200 void SetSubtitleLanguageL(TLanguage aLanguage);
201 void RedrawSubtitle(RWindow& aWindow, const TRect &aRect);
202 static RWindow* FindWindowWithWsHandle(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, TInt aWsHandle);
203 TInt EnableSubtitles(CMediaClientVideoDisplayBody& aDisplay);
204 TInt AddSubtitleConfig(CMediaClientVideoDisplayBody::TWindowData& aWindowData);
205 void GetSubtitleConfigFromWindowData(CMediaClientVideoDisplayBody::TWindowData& aWindowData, TMMFSubtitleWindowConfig& aConfig);
206 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
209 void ConstructL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
210 const TRect& aWindowRect, const TRect& aClipRect);
211 CBody(CVideoPlayerUtility* aParent,
212 MVideoPlayerUtilityObserver& aObserver,
214 TInt aPriority=EMdaPriorityNormal,
215 TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
217 void CommonConstructL();
218 void SetAndUpdateWindow();
219 void PrepareDSAL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow);
221 #ifdef SYMBIAN_BUILD_GCE
222 CBody(CVideoPlayerUtility2* aParent,
223 MVideoPlayerUtilityObserver& aObserver,
224 TInt aPriority=EMdaPriorityNormal,
225 TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
228 TInt CheckSurfaceSupported();
229 TBool RectContains(const TRect& aLeft, const TRect& aRight);
230 void DoAddDisplayWindowL(RWsSession& aWs, TInt aDisplay, RWindowBase& aWindow,
231 const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
232 void DoUpdateDisplayWindowL(RWsSession& aWs, RWindowBase& aWindow,
233 const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
234 TInt SurfaceCreated();
235 TInt SurfaceParametersChanged();
236 TInt RemoveSurface(TBool aControllerEvent);
237 TInt SetAllBackgroundSurfaces();
239 #endif // SYMBIAN_BUILD_GCE
241 // from MMMFControllerEventMonitorObserver
242 virtual void HandleEvent(const TMMFEvent& aEvent);
244 //from MDirectScreenAccess
245 virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
246 virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
248 // from MMMFFindAndOpenControllerObserver
249 virtual void MfaocComplete(
251 RMMFController* aController,
253 TMMFMessageDestination* aSourceHandle,
254 TMMFMessageDestination* aSinkHandle);
257 void OpenComplete(TInt aError);
258 void FrameReady(TInt aError);
259 void PlayComplete(TInt aError);
263 //Source and sink handle info
264 TMMFMessageDestination iSourceHandle;
265 TMMFMessageDestination iSinkHandle;
267 RMMFController iController;
268 RMMFVideoControllerCustomCommands iVideoControllerCustomCommands;
269 RMMFVideoPlayControllerCustomCommands iVideoPlayControllerCustomCommands;
270 RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCustomCommands;
271 RMMFAudioRecordDeviceCustomCommands iAudioRecordDeviceCustomCommands;
272 RMMFVideoDRMExtCustomCommands iVideoDRMExtCustomCommands;
273 RMMFDRMCustomCommands iDRMCustomCommands;
274 RMMFVideoPlayControllerExtCustomCommands iVideoPlayControllerExtCustomCommands;
275 RMMFResourceNotificationCustomCommands iNotificationRegistrationCommands;
276 MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
277 #ifdef SYMBIAN_BUILD_GCE
278 RMMFVideoPlaySurfaceSupportCustomCommands iVideoPlaySurfaceSupportCustomCommands;
280 //for audio resource notification
281 TUid iArnEventHolder;
282 TBuf8<TMMFAudioConfig::KNotificationDataBufferSize> iNotificationDataHolder;
284 RMMFVideoSetInitScreenCustomCommands iVideoSetInitScreenCustomCommands;
285 MVideoPlayerUtilityObserver& iObserver;
286 CMMFControllerEventMonitor* iControllerEventMonitor;
287 CVideoPlayerUtility::TMMFVideoPlayerState iState;
288 TTimeIntervalMicroSeconds iDuration;
289 TMMFPrioritySettings iPrioritySettings;
291 MVideoLoadingObserver *iVideoLoadingObserver;
292 CDirectScreenAccess * iDirectScreenAccess;
294 CMMFVideoPlayerCallback* iAsyncCallback;
295 CMMFVideoPlayerCallback* iFrameCallback;
296 CMMFControllerImplementationInformation* iControllerImplementationInformation;
299 CVideoPlayerUtility* iParent;
300 CFbsBitmap* iFrameBitmap;
301 RFbsSession iFbsSession;
305 TBool iControllerOpen;
306 TBool iFbsSessionConnected;
308 // utility class to find and open a suitable controller asynchronously
309 CMMFFindAndOpenController* iFindAndOpenController;
311 // received a KMMFEventCategoryVideoOpenComplete event
312 TBool iEventOpenReceived;
314 // received a MfaocComplete() callback
315 TBool iCallbackOpenReceived;
320 // flag indicating DSA abort in StopDirectScreenAccess() - to be used in SetDisplayWindowL
321 TBool iDirectScreenAccessAbort;
323 #ifdef SYMBIAN_BUILD_GCE
325 TSurfaceId iSurfaceId;
327 //video graphics surface supported
328 TBool iGraphicsSurfaceSupported;
331 // store scale factor
332 TReal32 iGlobalScaleWidth;
333 TReal32 iGlobalScaleHeight;
334 TBool iAntiAliasFiltering;
336 TVideoRotation iGlobalRotation;
337 TRect iSurfaceCropRect;
338 TVideoAspectRatio iAspectRatio;
339 // for storing window added during NewL,
343 RWindowBase* iWindow;
345 RPointerArray<CMediaClientVideoDisplayBody> iActiveDisplays;
348 TAutoScaleType iGlobalAutoScaleType;
349 TInt iGlobalHorizPos;
351 #endif // SYMBIAN_BUILD_GCE
353 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
354 CMMFSubtitleUtility* iSubtitleUtility;
355 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
357 friend class CMMFVideoPlayerCallback;
358 friend class CTestStepUnitMMFVidClient;
359 friend class CTestView;
360 friend class CVideoPlayerUtility;
362 #ifdef SYMBIAN_BUILD_GCE
363 friend class CVideoPlayerUtility2;
368 #endif // VIDEOPLAYERBODY_H