1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Video/mmfclientvideoplayer2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,496 @@
1.4 +// Copyright (c) 2007-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 +#include <videoplayer.h>
1.20 +#include <videoplayer2.h>
1.21 +#include "mmfvideocallback.h"
1.22 +#include "VideoPlayerBody.h"
1.23 +
1.24 +/**
1.25 +Creates a new instance of the video player utility. Unlike CVideoPlayerUtility::NewL(),
1.26 +the CVideoPlayerUtility2 factory does not require window handles and other video display
1.27 +information as its arguments. The client can set up rendering later with
1.28 +AddDisplayWindowL(), or optionally use the utility without a window, for example, for metadata
1.29 +query purposes.
1.30 +
1.31 +@param aObserver
1.32 + A client class to receive notifications from the video player.
1.33 +@param aPriority
1.34 + The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and
1.35 + EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request.
1.36 +@param aPref
1.37 + The Priority Preference - an additional audio policy parameter. The suggested default is
1.38 + EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional
1.39 + values may be supported by given phones and/or platforms, but should not be depended upon by
1.40 + portable code.
1.41 +
1.42 +@return A pointer to the new video player utility object.
1.43 +
1.44 +@leave The method will leave if an error occurs. Typical error codes used:
1.45 + * KErrNoMemory if out of memory.
1.46 +
1.47 +Note: The Priority Value and Priority Preference are used primarily when deciding what to do when
1.48 +several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference,
1.49 +the adaptation may consider other parameters such as the SecureId and Capabilities of the client process.
1.50 +Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may
1.51 +vary between different phones. Portable applications are advised not to assume any specific behaviour.
1.52 +
1.53 +*/
1.54 +EXPORT_C CVideoPlayerUtility2* CVideoPlayerUtility2::NewL(MVideoPlayerUtilityObserver& aObserver,
1.55 + TInt aPriority,
1.56 + TInt aPref)
1.57 + {
1.58 + CVideoPlayerUtility2* s = new(ELeave) CVideoPlayerUtility2();
1.59 + CleanupStack::PushL(s);
1.60 + s->iBody = CVideoPlayerUtility::CBody::NewL(s, aObserver, aPriority, aPref);
1.61 + CleanupStack::Pop();
1.62 + return s;
1.63 + }
1.64 +
1.65 +/**
1.66 +Destructor. Closes any open video clips and frees any resources held by the Video Player.
1.67 +*/
1.68 +CVideoPlayerUtility2::~CVideoPlayerUtility2()
1.69 + {
1.70 + }
1.71 +
1.72 +/**
1.73 +Adds a new window for displaying the video picture. Client applications must use this method
1.74 +instead of SetDisplayWindowL() when using CVideoPlayerUtility2.
1.75 +
1.76 +This method can only be called after opening the source is complete and the client has
1.77 +received an MvpuoOpenComplete() callback.
1.78 +
1.79 +@param aWs
1.80 + The window server session for this window.
1.81 +@param aScreenDevice
1.82 + The screen device for the screen that the window is displayed on.
1.83 +@param aWindow
1.84 + The display window.
1.85 +@param aVideoExtent
1.86 + Video extent on the screen, relative to the window. Video picture position within
1.87 + the extent depends on the scaled picture and content alignment or offset. The video
1.88 + extent can be partially or completely outside the window.
1.89 +@param aWindowClipRect
1.90 + Window clipping rectangle, relative to the window. The clipping rectangle specifies
1.91 + the part of the window used for video display. The rectangle must be contained
1.92 + completely within the window.
1.93 +@leave The method will leave if an error occurs. Typical error codes used:
1.94 + * KErrNotReady if the source file, URL, or descriptor has not been opened.
1.95 +*/
1.96 +EXPORT_C void CVideoPlayerUtility2::AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice,
1.97 + RWindow& aWindow, const TRect& aVideoExtent,
1.98 + const TRect& aWindowClipRect)
1.99 + {
1.100 + iBody->AddDisplayWindowL(aWs, aScreenDevice, aWindow, aVideoExtent, aWindowClipRect);
1.101 + }
1.102 +
1.103 +/**
1.104 +A simplified variant of AddDisplayWindowL(). When this variant is used, the video extent and
1.105 +window clipping rectangle default to the whole window.
1.106 +
1.107 +This method can only be called after opening the source is complete and the client has
1.108 +received an MvpuoOpenComplete() callback.
1.109 +
1.110 +@param aWs
1.111 + The window server session for this window.
1.112 +@param aScreenDevice
1.113 + The screen device for the screen that the window is displayed on.
1.114 +@param aWindow
1.115 + The display window.
1.116 +@leave The method will leave if an error occurs. Typical error codes used:
1.117 + * KErrNotReady if the source file, URL, or descriptor has not been opened.
1.118 +*/
1.119 +EXPORT_C void CVideoPlayerUtility2::AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow)
1.120 + {
1.121 + iBody->AddDisplayWindowL(aWs, aScreenDevice, aWindow);
1.122 + }
1.123 +
1.124 +/**
1.125 +Removes a window that is currently being used to display the video picture. The window must
1.126 +have previously been added with AddDisplayWindowL().
1.127 +
1.128 +Note Depending on underlying implementation it may also remove any graphics resources associated
1.129 +with video playback on this window.
1.130 +
1.131 +This method cannot fail. If the window has not been added with AddDisplayWindowL(), the
1.132 +method call will be ignored.
1.133 +
1.134 +@param aWindow
1.135 + The display window.
1.136 +*/
1.137 +EXPORT_C void CVideoPlayerUtility2::RemoveDisplayWindow(RWindow& aWindow)
1.138 + {
1.139 + iBody->RemoveDisplayWindow(aWindow);
1.140 + }
1.141 +
1.142 +/**
1.143 +Sets the video extent on the screen, relative to the window. The extent specifies the area
1.144 +of screen in which the video picture is placed, and may be partially or completely outside of
1.145 +the video window. Video picture position within the extent depends on the picture size and
1.146 +content alignment or offset.
1.147 +
1.148 +This method can only be called after opening the source is complete and the client has
1.149 +received an MvpuoOpenComplete() callback.
1.150 +
1.151 +@param aWindow
1.152 + Window to set video extent for.
1.153 +@param aVideoExtent
1.154 + The new video extent, relative to the video window.
1.155 +@leave The method will leave if an error occurs. Typical error codes used:
1.156 + * KErrNotReady if the source file, URL, or descriptor has not been opened.
1.157 +*/
1.158 +EXPORT_C void CVideoPlayerUtility2::SetVideoExtentL(const RWindow& aWindow, const TRect& aVideoExtent)
1.159 + {
1.160 + iBody->SetVideoExtentL(aWindow, aVideoExtent);
1.161 + }
1.162 +
1.163 +/**
1.164 +Sets the window clipping rectangle, relative to the window. The clipping rectangle specifies
1.165 +the part of the window used to display the video picture and must be fully contained within
1.166 +the window.
1.167 +
1.168 +This method can only be called after opening the source is complete and the client has
1.169 +received an MvpuoOpenComplete() callback.
1.170 +
1.171 +@param aWindow
1.172 + Window to set clipping rectangle for.
1.173 +@param aWindowClipRect
1.174 + The clipping rectangle to use for this window.
1.175 +@leave The method will leave if an error occurs. Typical error codes used:
1.176 + * KErrArgument if the rectangle is not contained within the window.
1.177 + * KErrNotReady if the source file, URL, or descriptor has not been opened.
1.178 +*/
1.179 +EXPORT_C void CVideoPlayerUtility2::SetWindowClipRectL(const RWindow& aWindow, const TRect& aWindowClipRect)
1.180 + {
1.181 + iBody->SetWindowClipRectL(aWindow, aWindowClipRect);
1.182 + }
1.183 +
1.184 +/**
1.185 +Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2.
1.186 +
1.187 +The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL.
1.188 +Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been
1.189 +made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL.
1.190 +
1.191 +@param aWindow Window to set rotation for.
1.192 +@param aRotation The video rotation to use for aWindow.
1.193 +
1.194 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.195 +@leave KErrNotReady if controller hasn't been opened.
1.196 +
1.197 +@see CVideoPlayerUtility::SetRotationL
1.198 +@see TVideoRotation
1.199 +*/
1.200 +
1.201 +EXPORT_C void CVideoPlayerUtility2::SetRotationL(const RWindow& aWindow, TVideoRotation aRotation)
1.202 + {
1.203 + iBody->SetRotationL(aWindow, aRotation);
1.204 + }
1.205 +
1.206 +/**
1.207 +Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2.
1.208 +
1.209 +@param aWindow Window to retrieve rotation for.
1.210 +@return The video rotation.
1.211 +
1.212 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.213 +@leave KErrNotReady if controller hasn't been opened.
1.214 +
1.215 +@see TVideoRotation
1.216 +@see CVideoPlayerUtility2::AddDisplayWindowL
1.217 +*/
1.218 +
1.219 +EXPORT_C TVideoRotation CVideoPlayerUtility2::RotationL(const RWindow& aWindow)
1.220 + {
1.221 + return iBody->RotationL(aWindow);
1.222 + }
1.223 +
1.224 +/**
1.225 +Scales the video image to a specified percentage of its original size within the window.
1.226 +This is the preferred method to use with CVideoPlayerUtility2.
1.227 +Setting scale factor will set auto scale to EAutoScaleNone for the window.
1.228 +
1.229 +The scale factor will replace any scale factor set with CVideoPlayerUtility::SetScaleFactorL.
1.230 +Likewise with setting the scale factor with CVideoPlayerUtility::SetScaleFactorL after a call to CVideoPlayerUtility2::SetScaleFactorL has been
1.231 +made, then the scale factor specified will replace any scale factor set with CVideoPlayerUtility2::SetScaleFactorL.
1.232 +
1.233 +@param aWindow Window to set scale factor for.
1.234 +@param aWidthPercentage
1.235 + The percentage (100 = original size) to be used to scale the width of the video image
1.236 +@param aHeightPercentage
1.237 + The percentage (100 = original size) to be used to scale the height of the video image.
1.238 + If this is not equal to aWidthPercentage then the image may be distorted.
1.239 +
1.240 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.241 +@leave KErrNotReady if controller hasn't been opened.
1.242 +
1.243 +@see CVideoPlayerUtility::SetScaleFactorL
1.244 +*/
1.245 +
1.246 +EXPORT_C void CVideoPlayerUtility2::SetScaleFactorL(const RWindow& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage)
1.247 + {
1.248 + iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
1.249 + }
1.250 +
1.251 +/**
1.252 +Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2.
1.253 +
1.254 +@param aWindow Window to retrieve scale factor for.
1.255 +@param aWidthPercentage
1.256 + On function return, contains the current scaling percentage applied to the width of the
1.257 + video image (100 = original size).
1.258 +@param aHeightPercentage
1.259 + On function return, contains the current scaling percentage applied to the height
1.260 + of the video image (100 = original size).
1.261 +
1.262 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.263 +@leave KErrNotReady if controller hasn't been opened.
1.264 +*/
1.265 +
1.266 +EXPORT_C void CVideoPlayerUtility2::GetScaleFactorL(const RWindow& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage)
1.267 + {
1.268 + iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage);
1.269 + }
1.270 +
1.271 +/**
1.272 +Set video automatic scaling. When automatic scaling is active, the
1.273 +video picture is scaled automatically to match the video extent,
1.274 +based on the scaling type. This variant of SetAutoScaleL() will
1.275 +always center the picture in the extent.
1.276 +
1.277 +This is the preferred method to use with CVideoPlayerUtility2.
1.278 +
1.279 +Calling SetAutoScaleL() will override any scaling factors set with
1.280 +SetScaleFactorL(). Calling SetScaleFactorL() will disable automatic
1.281 +scaling.
1.282 +
1.283 +@see TAutoScaleType, THorizontalAlign, TVerticalAlign
1.284 +
1.285 +@param aWindow Window to set auto scaling options for.
1.286 +@param aScaleType Automatic scaling type
1.287 +
1.288 +@pre The video clip has been opened by the client
1.289 +
1.290 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.291 +@leave KErrNotReady if controller hasn't been opened.
1.292 +*/
1.293 +
1.294 +EXPORT_C void CVideoPlayerUtility2::SetAutoScaleL(const RWindow& aWindow, TAutoScaleType aScaleType)
1.295 + {
1.296 + iBody->SetAutoScaleL(aWindow, aScaleType);
1.297 + }
1.298 +
1.299 +/**
1.300 +Set video automatic scaling. When automatic scaling is active, the
1.301 +video picture is scaled automatically to match the video extent,
1.302 +based on the scaling type, and positioned according to the
1.303 +parameters.
1.304 +
1.305 +This is the preferred method to use with CVideoPlayerUtility2.
1.306 +
1.307 +Calling SetAutoScaleL() will override any scaling factors set with
1.308 +SetScaleFactorL(). Calling SetScaleFactorL() will disable automatic
1.309 +scaling.
1.310 +
1.311 +@see TAutoScaleType, THorizontalAlign, TVerticalAlign
1.312 +
1.313 +@param aWindow Window to set auto scaling options for.
1.314 +@param aScaleType Automatic scaling type
1.315 +@param aHorizPos Video picture horizontal position, relative to the
1.316 + video window. The value can be either a pixel offset
1.317 + (positive or negative) from the top left corner of the
1.318 + window to the top left corner of the picture, or an
1.319 + alignment constant from enum THorizontalAlign.
1.320 +@param aVertPos Video picture vertical position, relative to the
1.321 + video window. The value can be either a pixel offset
1.322 + (positive or negative) from the top left corner of the
1.323 + window to the top left corner of the picture, or an
1.324 + alignment constant from enum TVerticalAlign.
1.325 +
1.326 +@pre The video clip has been opened by the client.
1.327 +
1.328 +@leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2
1.329 +@leave KErrNotReady if controller hasn't been opened.
1.330 +*/
1.331 +
1.332 +EXPORT_C void CVideoPlayerUtility2::SetAutoScaleL(const RWindow& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos)
1.333 + {
1.334 + iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos);
1.335 + }
1.336 +
1.337 +/**
1.338 +Adds the specified display to the list of surface rendering targets.
1.339 +This API can be used in conjunction with AddDisplayWindowL calls.
1.340 +The caller is responsible for handling surface events generated for the specific display.
1.341 +A single graphics surface is created and shared between all windows and displays.
1.342 +Surface registration and de-registration is managed by the MMF framework.
1.343 +
1.344 +@see AddDisplayWindowL
1.345 +
1.346 +@param aWs Window server session.
1.347 +@param aDisplay Display to create graphics surface on.
1.348 +@param aEventHandler Call-back interface for receiving surface specific events.
1.349 +
1.350 +@leave Any of the system wide error codes.
1.351 +@leave KErrNotReady if the source file, URL or descriptor has not been opened.
1.352 +@leave KErrInUse if the display has already been added by a previous AddDisplayL call.
1.353 +*/
1.354 +
1.355 +EXPORT_C void CVideoPlayerUtility2::AddDisplayL(RWsSession& /* aWs */, TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler)
1.356 + {
1.357 + iBody->AddDisplayL(aDisplay, aEventHandler);
1.358 + }
1.359 +
1.360 +/**
1.361 +Removes the specified display from the list of surface rendering targets.
1.362 +
1.363 +@param aDisplay Display id of display to remove
1.364 +*/
1.365 +
1.366 +EXPORT_C void CVideoPlayerUtility2::RemoveDisplay(TInt aDisplay)
1.367 + {
1.368 + iBody->RemoveDisplay(aDisplay);
1.369 + }
1.370 +
1.371 +/**
1.372 +When enabled sets automatic switching of surface to/from external display when it is connected/disconnected from the device.
1.373 +
1.374 +Automatic switching is enabled by default, but only if the client thread that created this utility has an Active Scheduler
1.375 +installed and the device supports external display switching.
1.376 +
1.377 +To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady.
1.378 +
1.379 +@param aControl
1.380 + ETrue to enable. EFalse to disable.
1.381 +@param aDisplay
1.382 + Display id of display to enable external switching for.
1.383 +@leave KErrNotSupported Device does not support external displays
1.384 +@leave KErrNotReady CActiveScheduler is not installed
1.385 +*/
1.386 +EXPORT_C void CVideoPlayerUtility2::SetExternalDisplaySwitchingL(TInt aDisplay, TBool aControl)
1.387 + {
1.388 + iBody->SetExternalDisplaySwitchingL(aDisplay, aControl);
1.389 + }
1.390 +
1.391 +#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
1.392 +/**
1.393 +Check to see if subtitles are available with the current video stream and controller.
1.394 +
1.395 +@return ETrue if subtitles can be enabled,
1.396 + EFalse if subtitles are not available with the current video stream or video clip has not been opened
1.397 +*/
1.398 +EXPORT_C TBool CVideoPlayerUtility2::SubtitlesAvailable()
1.399 + {
1.400 + return iBody->SubtitlesAvailable();
1.401 + }
1.402 +
1.403 +/**
1.404 +Enable subtitles with the current video stream.
1.405 +
1.406 +@pre The video clip has been opened by the client and SubtitlesAvailable() return ETrue.
1.407 +
1.408 +@leave KErrNotReady if the video source file, URL, or descriptor has not been opened,
1.409 + or no window has been added to CVideoPlayerUtility2.
1.410 +@leave KErrNotSupported if underlying video player controller does not support subtitles.
1.411 +@leave KErrNotFound if the opened video source has no associated subtitle data.
1.412 +@leave KErrInUse if subtitle is already enabled.
1.413 +@leave Otherwise leaves with any of the system wide error codes.
1.414 +
1.415 +@panic MMFVideoPlayUtil 1 In debug mode, if the video source file, URL, or descriptor has not been opened.
1.416 +@panic MMFVideoPlayUtil 2 In debug mode, if subtitle is not supported or not available.
1.417 +@panic MMFVideoPlayUtil 3 In debug mode, if no display window has been added.
1.418 +*/
1.419 +EXPORT_C void CVideoPlayerUtility2::EnableSubtitlesL()
1.420 + {
1.421 + iBody->EnableSubtitlesL();
1.422 + }
1.423 +
1.424 +/**
1.425 +Disable subtitles.
1.426 +*/
1.427 +EXPORT_C void CVideoPlayerUtility2::DisableSubtitles()
1.428 + {
1.429 + iBody->DisableSubtitles();
1.430 + }
1.431 +
1.432 +/**
1.433 +Get the current subtitle language.
1.434 +
1.435 +@pre Subtitle has been enabled.
1.436 +@return The current subtitle language, or ELangNone if no language information is available
1.437 +
1.438 +@leave KErrNotReady if subtitle has not been enabled.
1.439 +@leave Otherwise leaves with any of the system wide error codes.
1.440 +
1.441 +@panic MMFVideoPlayUtil 4 In debug mode, if subtitle has not been enabled.
1.442 +*/
1.443 +EXPORT_C TLanguage CVideoPlayerUtility2::SubtitleLanguageL()
1.444 + {
1.445 + return iBody->SubtitleLanguageL();
1.446 + }
1.447 +
1.448 +/**
1.449 +Return the subtitle languages available.
1.450 +
1.451 +@pre Subtitles have been enabled.
1.452 +@return A array of the currently available languages, or an empty array if
1.453 + subtitle source does not contain any language information. Array is valid
1.454 + until subtitles are disabled.
1.455 +
1.456 +@leave KErrNotReady if subtitles have not been enabled.
1.457 +@leave Otherwise leaves with any of the system wide error codes.
1.458 +
1.459 +@panic MMFVideoPlayUtil 4 In debug mode, if subtitles have not been enabled.
1.460 +*/
1.461 +EXPORT_C TArray<TLanguage> CVideoPlayerUtility2::SupportedSubtitleLanguagesL()
1.462 + {
1.463 + return iBody->SupportedSubtitleLanguagesL();
1.464 + }
1.465 +
1.466 +/**
1.467 +Set the current subtitle language.
1.468 +
1.469 +@see CVideoPlayerUtility2::GetSupportedSubtitleLanguagesL()
1.470 +
1.471 +@pre Subtitles have been enabled.
1.472 +@pre GetSupportedSubtitleLanguagesL() return a non empty array
1.473 +
1.474 +@param aLanguage Language to be used for subtitle stream.
1.475 +
1.476 +@leave KErrNotReady if subtitles have not been enabled.
1.477 +@leave KErrNotSupported if subtitle language is not supported
1.478 +@leave Otherwise leaves with any of the system wide error codes.
1.479 +
1.480 +@panic MMFVideoPlayUtil 4 In debug mode, if subtitles have not been enabled.
1.481 +@panic MMFVideoPlayUtil 5 In debug mode, if subtitle language is not supported.
1.482 +*/
1.483 +EXPORT_C void CVideoPlayerUtility2::SetSubtitleLanguageL(TLanguage aLanguage)
1.484 + {
1.485 + iBody->SetSubtitleLanguageL(aLanguage);
1.486 + }
1.487 +
1.488 +/**
1.489 +To be called when the video window is asked to redraw. E.g. For cone control, when CCoeControl::Draw() is called.
1.490 +
1.491 +@param aWindow Handle to the video window to be redrawn.
1.492 +@param aRect The region of the control to be redrawn from aRect in CCodControl::Draw().
1.493 +*/
1.494 +EXPORT_C void CVideoPlayerUtility2::RedrawSubtitle(RWindow& aWindow, const TRect &aRect)
1.495 + {
1.496 + iBody->RedrawSubtitle(aWindow, aRect);
1.497 + }
1.498 +
1.499 +#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT