1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/ControllerFramework/mmfvideosubtitlecustomcommands.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,454 @@
1.4 +// Copyright (c) 2008-2009 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 "mmfvideosubtitlecustomcommands.h"
1.20 +
1.21 +/**
1.22 +@internalComponent
1.23 +*/
1.24 +enum TMMFSubtitleSupportMessages
1.25 + {
1.26 + EMMFSubtitleSupportAvailable,
1.27 + EMMFSubtitleSupportEnable,
1.28 + EMMFSubtitleSupportDisable,
1.29 + EMMFSubtitleSupportGetLanguageSupportCount,
1.30 + EMMFSubtitleSupportGetLanguageSupportData,
1.31 + EMMFSubtitleSupportSetLanguage,
1.32 + EMMFSubtitleSupportGetLanguage,
1.33 + EMMFSubtitleSupportUpdateSubtitleConfig,
1.34 + EMMFSubtitleSupportAddSubtitleConfig,
1.35 + EMMFSubtitleSupportRemoveSubtitleConfig,
1.36 + EMMFSubtitleSupportGetCrpParameter
1.37 + };
1.38 +
1.39 +/**
1.40 +@internalComponent
1.41 +*/
1.42 +class TCrpParameters
1.43 + {
1.44 +public:
1.45 + TCrpParameters() : iId(TWsGraphicId::EUninitialized) {}
1.46 +
1.47 + TWsGraphicId iId;
1.48 + TRect iCrpRect;
1.49 + };
1.50 +
1.51 +/**
1.52 + * Constructor.
1.53 + *
1.54 + * @param aController The client side controller object to be used by this custom
1.55 + * command interface.
1.56 + */
1.57 +EXPORT_C RMMFVideoPlaySubtitleSupportCustomCommands::RMMFVideoPlaySubtitleSupportCustomCommands(RMMFController& aController)
1.58 + : RMMFCustomCommandsBase(aController, KUidInterfaceMMFVideoPlaySubtitleSupport)
1.59 + {
1.60 + }
1.61 +
1.62 +/**
1.63 + * Adds subtitle configuration data for a window.
1.64 + *
1.65 + * @param aConfig Subtitle configuration data for a window.
1.66 + * @return KErrNone if completed succesfully, otherwise one of the system wide error codes.
1.67 + */
1.68 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::AddSubtitleConfig(const TMMFSubtitleWindowConfig& aConfig)
1.69 + {
1.70 + TPckgBuf<TMMFSubtitleWindowConfig> configPckg(aConfig);
1.71 +
1.72 + return iController.CustomCommandSync(iDestinationPckg,
1.73 + EMMFSubtitleSupportAddSubtitleConfig,
1.74 + configPckg,
1.75 + KNullDesC8);
1.76 + }
1.77 +
1.78 +/**
1.79 + * Removes the subtitle configuration data associated with the given window.
1.80 + *
1.81 + * @param aWindowId Unique identifier of the window associated with the
1.82 + * configuration data being removed.
1.83 + * @return KErrNone if completed succesfully, otherwise one of the system wide error codes.
1.84 + */
1.85 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::RemoveSubtitleConfig(TInt aWindowId)
1.86 + {
1.87 + TPckgBuf<TInt> windowPckg(aWindowId);
1.88 +
1.89 + return iController.CustomCommandSync(iDestinationPckg,
1.90 + EMMFSubtitleSupportRemoveSubtitleConfig,
1.91 + windowPckg,
1.92 + KNullDesC8);
1.93 + }
1.94 +
1.95 +/**
1.96 + * Reconfigures subtitle configuration.
1.97 + *
1.98 + * @param aConfig Subtitle configuration data for a window.
1.99 + * @return KErrNone if completed succesfully, otherwise one of the system wide error codes.
1.100 + */
1.101 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::UpdateSubtitleConfig(const TMMFSubtitleWindowConfig& aConfig)
1.102 + {
1.103 + TPckgBuf<TMMFSubtitleWindowConfig> configPckg(aConfig);
1.104 +
1.105 + return iController.CustomCommandSync(iDestinationPckg,
1.106 + EMMFSubtitleSupportUpdateSubtitleConfig,
1.107 + configPckg,
1.108 + KNullDesC8);
1.109 + }
1.110 +
1.111 +/**
1.112 + * Checks if subtitles are available in the current video stream.
1.113 + *
1.114 + * @param aAvailable When this function returns, this is set to ETrue if the
1.115 + * controller supports subtitle extensions and subtitles are available in the
1.116 + * current video stream.
1.117 + * @return KErrNone if subtitles are supported by the controller; KErrNotSupported
1.118 + * if the controller does not support subtitles; otherwise other system error code.
1.119 + */
1.120 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::GetSubtitlesAvailable(TBool& aAvailable)
1.121 + {
1.122 + TPckgBuf<TBool> avail;
1.123 +
1.124 + TInt err = iController.CustomCommandSync(iDestinationPckg,
1.125 + EMMFSubtitleSupportAvailable,
1.126 + KNullDesC8,
1.127 + KNullDesC8,
1.128 + avail);
1.129 +
1.130 + aAvailable = (KErrNone == err) && avail();
1.131 + return err;
1.132 + }
1.133 +
1.134 +/**
1.135 + * Disables subtitles during video playback.
1.136 + *
1.137 + * @return KErrNone if completed succesfully, otherwise one of the system wide error codes.
1.138 + */
1.139 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::DisableSubtitles()
1.140 + {
1.141 + return iController.CustomCommandSync(iDestinationPckg,
1.142 + EMMFSubtitleSupportDisable,
1.143 + KNullDesC8,
1.144 + KNullDesC8);
1.145 + }
1.146 +
1.147 +/**
1.148 + * Enables subtitles during video playback.
1.149 + *
1.150 + * @return KErrNone if subtitles are supported; KErrNotSupported if
1.151 + * controller does not support subtitles; KErrNotFound if subtitle data
1.152 + * not found; otherwise other system error code.
1.153 + */
1.154 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::EnableSubtitles()
1.155 + {
1.156 + return iController.CustomCommandSync(iDestinationPckg,
1.157 + EMMFSubtitleSupportEnable,
1.158 + KNullDesC8,
1.159 + KNullDesC8);
1.160 + }
1.161 +
1.162 +/**
1.163 + * Gets the CRP parameters associated with a display
1.164 + *
1.165 + * @param aWindowId The window id used in the query.
1.166 + * @param aId Return the CRP id associated with the given display id
1.167 + * @param aCrpRect Return the subtitle region for drawing the CRP
1.168 + *
1.169 + * @return KErrNone on success; system wide error code otherwise.
1.170 + */
1.171 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::GetCrpParameters(TInt aWindowId, TWsGraphicId& aId, TRect& aCrpRect)
1.172 + {
1.173 + TPckgBuf<TInt> windowIdPckg(aWindowId);
1.174 + TPckgBuf<TCrpParameters> parameterPckg;
1.175 +
1.176 + TInt err = iController.CustomCommandSync(iDestinationPckg,
1.177 + EMMFSubtitleSupportGetCrpParameter,
1.178 + windowIdPckg,
1.179 + KNullDesC8,
1.180 + parameterPckg);
1.181 +
1.182 + if (KErrNone == err)
1.183 + {
1.184 + aId = parameterPckg().iId;
1.185 + aCrpRect = parameterPckg().iCrpRect;
1.186 + }
1.187 +
1.188 + return err;
1.189 + }
1.190 +
1.191 +/**
1.192 + * Gets the current subtitle language
1.193 + *
1.194 + * @param aLanguage On return, set the the current language.
1.195 + * @return KErrNone on success. KErrNotSupported when the enabled subtitle does not
1.196 + * contain language information. Otherwise system wide error code.
1.197 + */
1.198 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::GetSubtitleLanguage(TLanguage& aLanguage)
1.199 + {
1.200 + TPckgBuf<TLanguage> languagePckg;
1.201 + TInt err = iController.CustomCommandSync(iDestinationPckg,
1.202 + EMMFSubtitleSupportGetLanguage,
1.203 + KNullDesC8,
1.204 + KNullDesC8,
1.205 + languagePckg);
1.206 +
1.207 + if (KErrNone == err)
1.208 + {
1.209 + aLanguage = languagePckg();
1.210 + }
1.211 +
1.212 + return err;
1.213 + }
1.214 +
1.215 +/**
1.216 + * Gets a list of all available languages.
1.217 + *
1.218 + * @param aAvailable Array of available languages
1.219 + * @leave KErrNotSupported If the current controller does not support subtitles.
1.220 + * @leave KErrNotFound If the controller cannot find subtitle data.
1.221 + * @leave Otherwise leaves with any of the system wide error codes.
1.222 + */
1.223 +EXPORT_C void RMMFVideoPlaySubtitleSupportCustomCommands::GetSupportedSubtitleLanguagesL(RArray<TLanguage>& aSubtitleLanguages)
1.224 + {
1.225 + aSubtitleLanguages.Reset();
1.226 +
1.227 + TPckgBuf<TInt> countPckg;
1.228 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.229 + EMMFSubtitleSupportGetLanguageSupportCount,
1.230 + KNullDesC8,
1.231 + KNullDesC8,
1.232 + countPckg));
1.233 +
1.234 + TInt count = countPckg();
1.235 +
1.236 + if (count > 0)
1.237 + {
1.238 + HBufC8* buf = HBufC8::NewLC(count * sizeof(TLanguage));
1.239 + TPtr8 ptr = buf->Des();
1.240 +
1.241 + User::LeaveIfError(iController.CustomCommandSync(iDestinationPckg,
1.242 + EMMFSubtitleSupportGetLanguageSupportData,
1.243 + KNullDesC8,
1.244 + KNullDesC8,
1.245 + ptr));
1.246 +
1.247 + TPckgBuf<TLanguage> langPckg;
1.248 + RDesReadStream stream(ptr);
1.249 + CleanupClosePushL(stream);
1.250 +
1.251 + for (TInt i = 0; i < count; i++)
1.252 + {
1.253 + stream.ReadL(langPckg);
1.254 + aSubtitleLanguages.AppendL(langPckg());
1.255 + }
1.256 +
1.257 + CleanupStack::PopAndDestroy(2, buf); //stream, buf
1.258 + }
1.259 + }
1.260 +
1.261 +/**
1.262 + * Sets the current subtitle language
1.263 + *
1.264 + * @param aSubtitleLanguage Language to be used for subtitle stream.
1.265 + * @return KErrNone on success. KErrNotSupported when the enabled subtitle
1.266 + * does not contain language information. Otherwise system wide error code.
1.267 + */
1.268 +EXPORT_C TInt RMMFVideoPlaySubtitleSupportCustomCommands::SetSubtitleLanguage(TLanguage aSubtitleLanguage)
1.269 + {
1.270 + TPckgBuf<TLanguage> languagePckg(aSubtitleLanguage);
1.271 +
1.272 + return iController.CustomCommandSync(iDestinationPckg,
1.273 + EMMFSubtitleSupportSetLanguage,
1.274 + languagePckg,
1.275 + KNullDesC8);
1.276 + }
1.277 +
1.278 +/**
1.279 + * Creates a new custom command parser capable of handling subtitle support commands.
1.280 + *
1.281 + * @param aImplementor A reference to the controller plugin that owns this new
1.282 + * object.
1.283 + *
1.284 + * @return A pointer to the object created.
1.285 + */
1.286 +EXPORT_C CMMFVideoPlaySubtitleSupportCustomCommandParser* CMMFVideoPlaySubtitleSupportCustomCommandParser::NewL(
1.287 + MMMFVideoPlaySubtitleSupportCustomCommandImplementor& aImplementor)
1.288 + {
1.289 + return new(ELeave) CMMFVideoPlaySubtitleSupportCustomCommandParser(aImplementor);
1.290 + }
1.291 +
1.292 +CMMFVideoPlaySubtitleSupportCustomCommandParser::CMMFVideoPlaySubtitleSupportCustomCommandParser(MMMFVideoPlaySubtitleSupportCustomCommandImplementor& aImplementor) :
1.293 + CMMFCustomCommandParserBase(KUidInterfaceMMFVideoPlaySubtitleSupport),
1.294 + iImplementor(aImplementor)
1.295 + {
1.296 + }
1.297 +
1.298 +/**
1.299 + * Destructor.
1.300 + */
1.301 +EXPORT_C CMMFVideoPlaySubtitleSupportCustomCommandParser::~CMMFVideoPlaySubtitleSupportCustomCommandParser()
1.302 + {
1.303 + iAvailableLanguages.Close();
1.304 + }
1.305 +
1.306 +/**
1.307 + * Handles a request from the client. Called by the controller framework.
1.308 + *
1.309 + * @param aMessage The message to be handled.
1.310 + */
1.311 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
1.312 + {
1.313 + if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFVideoPlaySubtitleSupport)
1.314 + {
1.315 + TRAPD(error, DoHandleRequestL(aMessage));
1.316 + aMessage.Complete(error);
1.317 + }
1.318 + else
1.319 + {
1.320 + aMessage.Complete(KErrNotSupported);
1.321 + }
1.322 + }
1.323 +
1.324 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
1.325 + {
1.326 + switch (aMessage.Function())
1.327 + {
1.328 + case EMMFSubtitleSupportAvailable:
1.329 + DoGetSubtitlesAvailableL(aMessage);
1.330 + break;
1.331 + case EMMFSubtitleSupportEnable:
1.332 + DoEnableSubtitlesL(aMessage);
1.333 + break;
1.334 + case EMMFSubtitleSupportDisable:
1.335 + DoDisableSubtitlesL(aMessage);
1.336 + break;
1.337 + case EMMFSubtitleSupportGetLanguageSupportCount:
1.338 + DoGetSupportedLanguagesCountL(aMessage);
1.339 + break;
1.340 + case EMMFSubtitleSupportGetLanguageSupportData:
1.341 + DoGetSupportedLanguagesDataL(aMessage);
1.342 + break;
1.343 + case EMMFSubtitleSupportGetLanguage:
1.344 + DoGetSubtitleLanguageL(aMessage);
1.345 + break;
1.346 + case EMMFSubtitleSupportSetLanguage:
1.347 + DoSetSubtitleLanguageL(aMessage);
1.348 + break;
1.349 + case EMMFSubtitleSupportUpdateSubtitleConfig:
1.350 + DoUpdateSubtitleConfigL(aMessage);
1.351 + break;
1.352 + case EMMFSubtitleSupportAddSubtitleConfig:
1.353 + DoAddSubtitleConfigL(aMessage);
1.354 + break;
1.355 + case EMMFSubtitleSupportRemoveSubtitleConfig:
1.356 + DoRemoveSubtitleConfigL(aMessage);
1.357 + break;
1.358 + case EMMFSubtitleSupportGetCrpParameter:
1.359 + DoGetCrpParametersL(aMessage);
1.360 + break;
1.361 + default:
1.362 + User::Leave(KErrNotSupported);
1.363 + break;
1.364 + }
1.365 + }
1.366 +
1.367 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoGetSubtitlesAvailableL(TMMFMessage& aMessage)
1.368 + {
1.369 + TBool avail;
1.370 + iImplementor.MvpsusGetSubtitlesAvailableL(avail);
1.371 + TPckgBuf<TBool> availPckg(avail);
1.372 + aMessage.WriteDataToClientL(availPckg);
1.373 + }
1.374 +
1.375 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoUpdateSubtitleConfigL(TMMFMessage& aMessage)
1.376 + {
1.377 + TPckgBuf<TMMFSubtitleWindowConfig> configPckg;
1.378 + aMessage.ReadData1FromClientL(configPckg);
1.379 + iImplementor.MvpsusUpdateSubtitleConfigL(configPckg());
1.380 + }
1.381 +
1.382 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoAddSubtitleConfigL(TMMFMessage& aMessage)
1.383 + {
1.384 + TPckgBuf<TMMFSubtitleWindowConfig> configPckg;
1.385 + aMessage.ReadData1FromClientL(configPckg);
1.386 + iImplementor.MvpsusAddSubtitleConfigL(configPckg());
1.387 + }
1.388 +
1.389 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoRemoveSubtitleConfigL(TMMFMessage& aMessage)
1.390 + {
1.391 + TPckgBuf<TInt> windowPckg;
1.392 + aMessage.ReadData1FromClientL(windowPckg);
1.393 + iImplementor.MvpsusRemoveSubtitleConfigL(windowPckg());
1.394 + }
1.395 +
1.396 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoDisableSubtitlesL(TMMFMessage& /*aMessage*/)
1.397 + {
1.398 + iImplementor.MvpsusDisableSubtitlesL();
1.399 + }
1.400 +
1.401 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoEnableSubtitlesL(TMMFMessage& /*aMessage*/)
1.402 + {
1.403 + iImplementor.MvpsusEnableSubtitlesL();
1.404 + }
1.405 +
1.406 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoGetSupportedLanguagesDataL(TMMFMessage& aMessage)
1.407 + {
1.408 + HBufC8* buf = HBufC8::NewLC(iAvailableLanguages.Count() * sizeof(TLanguage));
1.409 + TPtr8 ptr = buf->Des();
1.410 + RDesWriteStream stream(ptr);
1.411 + CleanupClosePushL(stream);
1.412 +
1.413 + for (TInt i = 0; i < iAvailableLanguages.Count(); i++)
1.414 + {
1.415 + TPckgBuf<TLanguage> langPckg(iAvailableLanguages[i]);
1.416 + stream.WriteL(langPckg);
1.417 + }
1.418 +
1.419 + stream.CommitL();
1.420 + aMessage.WriteDataToClientL(ptr);
1.421 + CleanupStack::PopAndDestroy(2, buf); // stream, buf
1.422 + }
1.423 +
1.424 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoGetSupportedLanguagesCountL(TMMFMessage& aMessage)
1.425 + {
1.426 + iAvailableLanguages.Reset();
1.427 + iImplementor.MvpsusGetSupportedSubtitleLanguagesL(iAvailableLanguages);
1.428 +
1.429 + TPckgBuf<TInt> countPckg(iAvailableLanguages.Count());
1.430 + aMessage.WriteDataToClientL(countPckg);
1.431 + }
1.432 +
1.433 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoGetSubtitleLanguageL(TMMFMessage& aMessage)
1.434 + {
1.435 + TLanguage lang;
1.436 + iImplementor.MvpsusGetSubtitleLanguageL(lang);
1.437 + TPckgBuf<TLanguage> langPckg(lang);
1.438 + aMessage.WriteDataToClientL(langPckg);
1.439 + }
1.440 +
1.441 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoSetSubtitleLanguageL(TMMFMessage& aMessage)
1.442 + {
1.443 + TPckgBuf<TLanguage> langPckg;
1.444 + aMessage.ReadData1FromClientL(langPckg);
1.445 + iImplementor.MvpsusSetSubtitleLanguageL(langPckg());
1.446 + }
1.447 +
1.448 +void CMMFVideoPlaySubtitleSupportCustomCommandParser::DoGetCrpParametersL(TMMFMessage& aMessage)
1.449 + {
1.450 + TCrpParameters crpParams;
1.451 + TPckgBuf<TInt> displayPckg;
1.452 + aMessage.ReadData1FromClientL(displayPckg);
1.453 + iImplementor.MvpsusGetCrpParametersL(displayPckg(), crpParams.iId, crpParams.iCrpRect);
1.454 +
1.455 + TPckgBuf<TCrpParameters> paramPckg(crpParams);
1.456 + aMessage.WriteDataToClientL(paramPckg);
1.457 + }