1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Video/VideoPlayerBody.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,368 @@
1.4 +// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef VIDEOPLAYERBODY_H
1.20 +#define VIDEOPLAYERBODY_H
1.21 +
1.22 +#include <fbs.h>
1.23 +#include <w32std.h>
1.24 +
1.25 +#ifdef SYMBIAN_BUILD_GCE
1.26 +#include <mmf/common/mmfvideosurfacecustomcommands.h>
1.27 +#endif
1.28 +
1.29 +#include <mmf/common/mmfbase.h>
1.30 +#include <mmf/common/mmfcontroller.h>
1.31 +#include <mmf/common/mmfaudio.h>
1.32 +#include <mmf/common/mmfstandardcustomcommands.h>
1.33 +#include <mmf/common/mmfdrmcustomcommands.h>
1.34 +#include <mda/common/base.h>
1.35 +#include <mmf/common/mmfutilities.h>
1.36 +#include <mmf/common/mmfcontrollerframeworkbase.h>
1.37 +#include "mmf/common/mmcaf.h"
1.38 +#include "mmfclientutility.h"
1.39 +
1.40 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.41 +#include "mmfsubtitleutility.h"
1.42 +#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.43 +
1.44 +#ifdef SYMBIAN_BUILD_GCE
1.45 +#include "mediaclientvideodisplaybody.h"
1.46 +#endif
1.47 +
1.48 +class CMMFVideoPlayerCallback;
1.49 +class MMMFDRMCustomCommand;
1.50 +class CVideoPlayerUtility;
1.51 +class MMMFSurfaceEventHandler;
1.52 +#ifdef SYMBIAN_BUILD_GCE
1.53 + class TWindowData;
1.54 + class CMediaClientVideoDisplayBody;
1.55 +#endif // SYMBIAN_BUILD_GCE
1.56 +NONSHARABLE_CLASS( CVideoPlayerUtility::CBody ): public CBase,
1.57 + public MDirectScreenAccess,
1.58 + public MMMFControllerEventMonitorObserver,
1.59 + public MMMFFindAndOpenControllerObserver
1.60 +
1.61 + {
1.62 +
1.63 +public:
1.64 + ~CBody();
1.65 +
1.66 + static CBody* NewL(CVideoPlayerUtility* aParent,
1.67 + MVideoPlayerUtilityObserver& aObserver,
1.68 + TInt aPriority,
1.69 + TInt aPref,
1.70 + RWsSession& aWs,
1.71 + CWsScreenDevice& aScreenDevice,
1.72 + RWindowBase& aWindow,
1.73 + const TRect& aScreenRect,
1.74 + const TRect& aClipRect);
1.75 +
1.76 +#ifdef SYMBIAN_BUILD_GCE
1.77 + static CBody* NewL(CVideoPlayerUtility2* aParent,
1.78 + MVideoPlayerUtilityObserver& aObserver,
1.79 + TInt aPriority,
1.80 + TInt aPref);
1.81 +#endif
1.82 + void OpenFileL(const TDesC& aFileName,TUid aControllerUid = KNullUid);
1.83 + void OpenFileL(const RFile& aFile, TUid aControllerUid = KNullUid);
1.84 +
1.85 +
1.86 + void OpenFileL(const TMMSource& aSource, TUid aControllerUid = KNullUid);
1.87 +
1.88 + void OpenDesL(const TDesC8& aDescriptor,TUid aControllerUid = KNullUid);
1.89 + void OpenUrlL(const TDesC& aUrl, TInt aIapId, const TDesC8& aMimeType=KNullDesC8, TUid aControllerUid = KNullUid);
1.90 +
1.91 + void Prepare();
1.92 +
1.93 + void Close();
1.94 +
1.95 + void Play();
1.96 + void Play(const TTimeIntervalMicroSeconds& aStartPoint, const TTimeIntervalMicroSeconds& aEndPoint);
1.97 + TInt Stop();
1.98 + void PauseL();
1.99 +
1.100 + void SetPriorityL(TInt aPriority, TInt aPref);
1.101 + void PriorityL(TInt& aPriority, TMdaPriorityPreference& aPref) const;
1.102 +
1.103 + void SetDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
1.104 + const TRect& aScreenRect, const TRect& aClipRect);
1.105 +
1.106 + void RegisterForVideoLoadingNotification(MVideoLoadingObserver& aObserver);
1.107 +
1.108 + void GetFrameL(TDisplayMode aDisplayMode, TBool aUseIntentAPI = EFalse, ContentAccess::TIntent aIntent = ContentAccess::EPeek );
1.109 + void RefreshFrameL();
1.110 +
1.111 + TReal32 VideoFrameRateL() const;
1.112 + void VideoFrameSizeL(TSize& aSize) const;
1.113 + const TDesC8& VideoFormatMimeType() const;
1.114 + TInt VideoBitRateL() const;
1.115 +
1.116 + TInt AudioBitRateL() const;
1.117 + TFourCC AudioTypeL() const;
1.118 + TBool AudioEnabledL() const;
1.119 +
1.120 + void SetPositionL(const TTimeIntervalMicroSeconds& aPosition);
1.121 + TTimeIntervalMicroSeconds PositionL() const;
1.122 + TTimeIntervalMicroSeconds DurationL() const;
1.123 +
1.124 + void SetVolumeL(TInt aVolume);
1.125 + TInt Volume() const;
1.126 + TInt MaxVolume() const;
1.127 + void SetBalanceL(TInt aBalance);
1.128 + TInt Balance()const;
1.129 +
1.130 + void SetRotationL(TVideoRotation aRotation);
1.131 + TVideoRotation RotationL() const;
1.132 + void SetScaleFactorL(TReal32 aWidthPercentage, TReal32 aHeightPercentage, TBool aAntiAliasFiltering);
1.133 + void GetScaleFactorL(TReal32& aWidthPercentage, TReal32& aHeightPercentage, TBool& aAntiAliasFiltering) const;
1.134 + void SetCropRegionL(const TRect& aCropRegion);
1.135 + void GetCropRegionL(TRect& aCropRegion) const;
1.136 +
1.137 + TInt NumberOfMetaDataEntriesL() const;
1.138 + CMMFMetaDataEntry* MetaDataEntryL(TInt aIndex) const;
1.139 +
1.140 + void GetVideoLoadingProgressL(TInt& aPercentageProgress);
1.141 + TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom);
1.142 + TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2);
1.143 + void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus);
1.144 + void CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus);
1.145 +
1.146 + void SetVideoFrameRateL(TReal32 aFramesPerSecond);
1.147 + const CMMFControllerImplementationInformation& ControllerImplementationInformationL();
1.148 +
1.149 + MMMFDRMCustomCommand* GetDRMCustomCommand();
1.150 +
1.151 + void StopDirectScreenAccessL();
1.152 + void StartDirectScreenAccessL();
1.153 +
1.154 + TInt RegisterAudioResourceNotification(MMMFAudioResourceNotificationCallback& aCallback, TUid aNotificationEventUid, const TDesC8& aNotificationRegistrationData = KNullDesC8);
1.155 + TInt CancelRegisterAudioResourceNotification(TUid aNotificationEventId);
1.156 + TInt WillResumePlay();
1.157 +
1.158 + TInt SetInitScreenNumber(TInt aScreenNumber);
1.159 +
1.160 + void SetPlayVelocityL(TInt aVelocity);
1.161 + TInt PlayVelocityL() const;
1.162 + void StepFrameL(TInt aStep);
1.163 + void GetPlayRateCapabilitiesL(TVideoPlayRateCapabilities& aCapabilities) const;
1.164 + void SetVideoEnabledL(TBool aVideoEnabled);
1.165 + TBool VideoEnabledL() const;
1.166 + void SetAudioEnabledL(TBool aAudioEnabled);
1.167 + void SetAutoScaleL(TAutoScaleType aScaleType);
1.168 + void SetAutoScaleL(TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
1.169 +
1.170 +#ifdef SYMBIAN_BUILD_GCE
1.171 + void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice,
1.172 + RWindow& aWindow, const TRect& aVideoExtent,
1.173 + const TRect& aWindowClipRect);
1.174 + void AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow);
1.175 + void RemoveDisplayWindow(RWindowBase& aWindow);
1.176 + void SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent);
1.177 + void SetWindowClipRectL(const RWindowBase& aWindow, const TRect& aWindowClipRect);
1.178 +
1.179 + void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType);
1.180 + void SetAutoScaleL(const RWindowBase& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos);
1.181 +
1.182 + void SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation);
1.183 + TVideoRotation RotationL(const RWindowBase& aWindow) const;
1.184 + void SetScaleFactorL(const RWindowBase& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage);
1.185 + void GetScaleFactorL(const RWindowBase& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage) const;
1.186 + void AddDisplayL(TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler);
1.187 + void RemoveDisplay(TInt aDisplay);
1.188 + void ConvertFromRelativeToDisplayToRelativeToWindow(
1.189 + const RWindowBase& aWindow,
1.190 + const TRect& aFromWindowRect,
1.191 + const TRect& aFromClipRect,
1.192 + TRect& aToWindowRect,
1.193 + TRect& aToClipRect);
1.194 + void SetExternalDisplaySwitchingL(TInt aDisplay, TBool aControl);
1.195 +#endif
1.196 +
1.197 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.198 + TBool SubtitlesAvailable();
1.199 + void EnableSubtitlesL();
1.200 + void DisableSubtitles();
1.201 + TArray<TLanguage> SupportedSubtitleLanguagesL();
1.202 + TLanguage SubtitleLanguageL();
1.203 + void SetSubtitleLanguageL(TLanguage aLanguage);
1.204 + void RedrawSubtitle(RWindow& aWindow, const TRect &aRect);
1.205 + static RWindow* FindWindowWithWsHandle(const RPointerArray<CMediaClientVideoDisplayBody>& aDisplays, TInt aWsHandle);
1.206 + TInt EnableSubtitles(CMediaClientVideoDisplayBody& aDisplay);
1.207 + TInt AddSubtitleConfig(CMediaClientVideoDisplayBody::TWindowData& aWindowData);
1.208 + void GetSubtitleConfigFromWindowData(CMediaClientVideoDisplayBody::TWindowData& aWindowData, TMMFSubtitleWindowConfig& aConfig);
1.209 +#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.210 +
1.211 +private:
1.212 + void ConstructL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow,
1.213 + const TRect& aWindowRect, const TRect& aClipRect);
1.214 + CBody(CVideoPlayerUtility* aParent,
1.215 + MVideoPlayerUtilityObserver& aObserver,
1.216 + TInt aScreenNumber,
1.217 + TInt aPriority=EMdaPriorityNormal,
1.218 + TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
1.219 +
1.220 + void CommonConstructL();
1.221 + void SetAndUpdateWindow();
1.222 + void PrepareDSAL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindowBase& aWindow);
1.223 +
1.224 +#ifdef SYMBIAN_BUILD_GCE
1.225 + CBody(CVideoPlayerUtility2* aParent,
1.226 + MVideoPlayerUtilityObserver& aObserver,
1.227 + TInt aPriority=EMdaPriorityNormal,
1.228 + TInt aPref=EMdaPriorityPreferenceTimeAndQuality);
1.229 +
1.230 + void ConstructL();
1.231 + TInt CheckSurfaceSupported();
1.232 + TBool RectContains(const TRect& aLeft, const TRect& aRight);
1.233 + void DoAddDisplayWindowL(RWsSession& aWs, TInt aDisplay, RWindowBase& aWindow,
1.234 + const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
1.235 + void DoUpdateDisplayWindowL(RWsSession& aWs, RWindowBase& aWindow,
1.236 + const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
1.237 + TInt SurfaceCreated();
1.238 + TInt SurfaceParametersChanged();
1.239 + TInt RemoveSurface(TBool aControllerEvent);
1.240 + TInt SetAllBackgroundSurfaces();
1.241 +
1.242 +#endif // SYMBIAN_BUILD_GCE
1.243 +
1.244 + // from MMMFControllerEventMonitorObserver
1.245 + virtual void HandleEvent(const TMMFEvent& aEvent);
1.246 +
1.247 + //from MDirectScreenAccess
1.248 + virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReason);
1.249 + virtual void Restart(RDirectScreenAccess::TTerminationReasons aReason);
1.250 +
1.251 + // from MMMFFindAndOpenControllerObserver
1.252 + virtual void MfaocComplete(
1.253 + TInt& aError,
1.254 + RMMFController* aController,
1.255 + TUid aControllerUid,
1.256 + TMMFMessageDestination* aSourceHandle,
1.257 + TMMFMessageDestination* aSinkHandle);
1.258 +
1.259 +
1.260 + void OpenComplete(TInt aError);
1.261 + void FrameReady(TInt aError);
1.262 + void PlayComplete(TInt aError);
1.263 + void Reset();
1.264 +
1.265 +private:
1.266 + //Source and sink handle info
1.267 + TMMFMessageDestination iSourceHandle;
1.268 + TMMFMessageDestination iSinkHandle;
1.269 +
1.270 + RMMFController iController;
1.271 + RMMFVideoControllerCustomCommands iVideoControllerCustomCommands;
1.272 + RMMFVideoPlayControllerCustomCommands iVideoPlayControllerCustomCommands;
1.273 + RMMFAudioPlayDeviceCustomCommands iAudioPlayDeviceCustomCommands;
1.274 + RMMFAudioRecordDeviceCustomCommands iAudioRecordDeviceCustomCommands;
1.275 + RMMFVideoDRMExtCustomCommands iVideoDRMExtCustomCommands;
1.276 + RMMFDRMCustomCommands iDRMCustomCommands;
1.277 + RMMFVideoPlayControllerExtCustomCommands iVideoPlayControllerExtCustomCommands;
1.278 + RMMFResourceNotificationCustomCommands iNotificationRegistrationCommands;
1.279 + MMMFAudioResourceNotificationCallback* iAudioResourceNotificationCallBack;
1.280 +#ifdef SYMBIAN_BUILD_GCE
1.281 + RMMFVideoPlaySurfaceSupportCustomCommands iVideoPlaySurfaceSupportCustomCommands;
1.282 +#endif
1.283 + //for audio resource notification
1.284 + TUid iArnEventHolder;
1.285 + TBuf8<TMMFAudioConfig::KNotificationDataBufferSize> iNotificationDataHolder;
1.286 +
1.287 + RMMFVideoSetInitScreenCustomCommands iVideoSetInitScreenCustomCommands;
1.288 + MVideoPlayerUtilityObserver& iObserver;
1.289 + CMMFControllerEventMonitor* iControllerEventMonitor;
1.290 + CVideoPlayerUtility::TMMFVideoPlayerState iState;
1.291 + TTimeIntervalMicroSeconds iDuration;
1.292 + TMMFPrioritySettings iPrioritySettings;
1.293 +
1.294 + MVideoLoadingObserver *iVideoLoadingObserver;
1.295 + CDirectScreenAccess * iDirectScreenAccess;
1.296 + HBufC8* iMimeType;
1.297 + CMMFVideoPlayerCallback* iAsyncCallback;
1.298 + CMMFVideoPlayerCallback* iFrameCallback;
1.299 + CMMFControllerImplementationInformation* iControllerImplementationInformation;
1.300 + TUid iControllerUid;
1.301 +
1.302 + CVideoPlayerUtility* iParent;
1.303 + CFbsBitmap* iFrameBitmap;
1.304 + RFbsSession iFbsSession;
1.305 +
1.306 + TRect iWindowRect;
1.307 + TRect iClipRect;
1.308 + TBool iControllerOpen;
1.309 + TBool iFbsSessionConnected;
1.310 +
1.311 + // utility class to find and open a suitable controller asynchronously
1.312 + CMMFFindAndOpenController* iFindAndOpenController;
1.313 +
1.314 + // received a KMMFEventCategoryVideoOpenComplete event
1.315 + TBool iEventOpenReceived;
1.316 +
1.317 + // received a MfaocComplete() callback
1.318 + TBool iCallbackOpenReceived;
1.319 +
1.320 + TInt iOpenError;
1.321 + TInt iScreenNumber;
1.322 +
1.323 + // flag indicating DSA abort in StopDirectScreenAccess() - to be used in SetDisplayWindowL
1.324 + TBool iDirectScreenAccessAbort;
1.325 +
1.326 +#ifdef SYMBIAN_BUILD_GCE
1.327 +
1.328 + TSurfaceId iSurfaceId;
1.329 +
1.330 + //video graphics surface supported
1.331 + TBool iGraphicsSurfaceSupported;
1.332 + TBool iUsingVPU2;
1.333 +
1.334 + // store scale factor
1.335 + TReal32 iGlobalScaleWidth;
1.336 + TReal32 iGlobalScaleHeight;
1.337 + TBool iAntiAliasFiltering;
1.338 + TRect iCropRegion;
1.339 + TVideoRotation iGlobalRotation;
1.340 + TRect iSurfaceCropRect;
1.341 + TVideoAspectRatio iAspectRatio;
1.342 + // for storing window added during NewL,
1.343 + // i.e. DSA
1.344 + RWsSession* iWs;
1.345 + TInt iDisplayId;
1.346 + RWindowBase* iWindow;
1.347 +
1.348 + RPointerArray<CMediaClientVideoDisplayBody> iActiveDisplays;
1.349 +
1.350 + // Autoscale info
1.351 + TAutoScaleType iGlobalAutoScaleType;
1.352 + TInt iGlobalHorizPos;
1.353 + TInt iGlobalVertPos;
1.354 +#endif // SYMBIAN_BUILD_GCE
1.355 +
1.356 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.357 + CMMFSubtitleUtility* iSubtitleUtility;
1.358 +#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.359 +
1.360 + friend class CMMFVideoPlayerCallback;
1.361 + friend class CTestStepUnitMMFVidClient;
1.362 + friend class CTestView;
1.363 + friend class CVideoPlayerUtility;
1.364 +
1.365 +#ifdef SYMBIAN_BUILD_GCE
1.366 + friend class CVideoPlayerUtility2;
1.367 +#endif
1.368 + };
1.369 +
1.370 +
1.371 +#endif // VIDEOPLAYERBODY_H