1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/src/Client/Audio/mmfclientaudioconverter.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1782 @@
1.4 +// Copyright (c) 2002-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 <e32std.h>
1.20 +#include <mmf/common/mmffourcc.h>
1.21 +#include <mmf/common/mmfpaniccodes.h>
1.22 +#include <mmfformatimplementationuids.hrh>
1.23 +
1.24 +#include "mmfclientaudioconverter.h"
1.25 +
1.26 +// declared in the recorder module
1.27 +void Panic(TInt aPanicCode);
1.28 +
1.29 +//CMdaAudioConvertUtility
1.30 +
1.31 +
1.32 +/**
1.33 +Returns the current utility state.
1.34 +
1.35 +@return The state of the audio sample data. See CMdaAudioClipUtility::TState.
1.36 +
1.37 +@since 5.0
1.38 +*/
1.39 +CMdaAudioClipUtility::TState CMdaAudioConvertUtility::State()
1.40 + {
1.41 + ASSERT(iProperties);
1.42 + return iProperties->State();
1.43 + }
1.44 +
1.45 +/**
1.46 +Closes the current audio clip.
1.47 +
1.48 +@since 5.0
1.49 +*/
1.50 +void CMdaAudioConvertUtility::Close()
1.51 + {
1.52 + ASSERT(iProperties);
1.53 + iProperties->Close();
1.54 + }
1.55 +
1.56 +/**
1.57 +This function is mapped to ConvertL(). ConvertL() should be used instead.
1.58 +
1.59 +@see ConvertL()
1.60 +
1.61 +@since 5.0
1.62 +*/
1.63 +void CMdaAudioConvertUtility::PlayL()
1.64 + {
1.65 + ASSERT(iProperties);
1.66 + iProperties->PlayL();
1.67 + }
1.68 +
1.69 +/**
1.70 +This function is mapped to ConvertL. ConvertL() should be used instead.
1.71 +
1.72 +@since 5.0
1.73 +*/
1.74 +void CMdaAudioConvertUtility::RecordL()
1.75 + {
1.76 + ASSERT(iProperties);
1.77 + iProperties->RecordL();
1.78 + }
1.79 +
1.80 +/**
1.81 +Stops the current operation (playback/recording/conversion).
1.82 +
1.83 +When conversion has been stopped, successfully or otherwise, the client is notified by
1.84 +MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
1.85 +providing it with state change information and error codes.
1.86 +
1.87 +@since 5.0
1.88 +*/
1.89 +void CMdaAudioConvertUtility::Stop()
1.90 + {
1.91 + ASSERT(iProperties);
1.92 + iProperties->Stop();
1.93 + }
1.94 +
1.95 +/**
1.96 +Crops the current clip from the current position. The remainder of the clip is discarded.
1.97 +
1.98 +The effects of the function cannot be undone. The function is synchronous and can leave if there is
1.99 +a problem. The leave code depends on the configuration.
1.100 +
1.101 +@since 5.0
1.102 +*/
1.103 +void CMdaAudioConvertUtility::CropL()
1.104 + {
1.105 + ASSERT(iProperties);
1.106 + iProperties->CropL(ETrue);
1.107 + }
1.108 +
1.109 +/**
1.110 +Sets the current position in the audio clip.
1.111 +
1.112 +A subsequent call to ConvertL() starts conversion from this new position.
1.113 +
1.114 +@param aPosition
1.115 + The position in the audio clip, in microseconds.
1.116 +
1.117 +@since 5.0
1.118 +*/
1.119 +void CMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition)
1.120 + {
1.121 + ASSERT(iProperties);
1.122 + iProperties->SetPosition(aPosition);
1.123 + }
1.124 +
1.125 +/**
1.126 +Returns the current position in the audio clip. The position is defined in terms of a time interval
1.127 +measured from the beginning of the audio sample data.
1.128 +
1.129 +@return The current position in the audio clip, in microseconds.
1.130 +
1.131 +@since 5.0
1.132 +*/
1.133 +const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Position()
1.134 + {
1.135 + ASSERT(iProperties);
1.136 + return iProperties->Position();
1.137 + }
1.138 +
1.139 +/**
1.140 +Returns the amount of recording time available to the current clip.
1.141 +
1.142 +@return The recording time available measured in microseconds.
1.143 +
1.144 +@since 5.0
1.145 +*/
1.146 +const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::RecordTimeAvailable()
1.147 + {
1.148 + ASSERT(iProperties);
1.149 + return iProperties->RecordTimeAvailable();
1.150 + }
1.151 +
1.152 +/**
1.153 +Returns the duration of the audio clip.
1.154 +
1.155 +@return The duration in microseconds.
1.156 +
1.157 +@since 5.0
1.158 +*/
1.159 +const TTimeIntervalMicroSeconds& CMdaAudioConvertUtility::Duration()
1.160 + {
1.161 + ASSERT(iProperties);
1.162 + return iProperties->Duration();
1.163 + }
1.164 +
1.165 +/**
1.166 +Sets a window for playback.
1.167 +
1.168 +The window is defined in terms of a start and end time. A subsequent call to ConvertL() results
1.169 +in just the data within the window being converted.
1.170 +
1.171 +@param aStart
1.172 + The position in the clip to start playback, in microseconds. This must be any value from zero
1.173 + to aEnd. If this value is less than zero or greater than aEnd, this function raises
1.174 + EMMFMediaClientPanicServerCommunicationProblem panic in debug version.
1.175 +@param aEnd
1.176 + The position in the clip to end playback, in microseconds. This must be any value from aStart
1.177 + to the value returned by Duration(). If this value is greater than the value returned by
1.178 + Duration() or less than aStart, this function raises EMMFMediaClientPanicServerCommunicationProblem panic in debug version.
1.179 +
1.180 +@since 5.0
1.181 +*/
1.182 +void CMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd)
1.183 + {
1.184 + ASSERT(iProperties);
1.185 + iProperties->SetPlayWindow(aStart, aEnd);
1.186 + }
1.187 +
1.188 +/**
1.189 +Clears the playback window.
1.190 +
1.191 +Playback returns to playing the entire clip. A subsequent call to ConvertL() results in the entire
1.192 +source audio being converted.
1.193 +
1.194 +@since 5.0
1.195 +*/
1.196 +void CMdaAudioConvertUtility::ClearPlayWindow()
1.197 + {
1.198 + ASSERT(iProperties);
1.199 + iProperties->ClearPlayWindow();
1.200 + }
1.201 +
1.202 +/**
1.203 +Sets the number of repetitions for playback. This is unsupported for CMdaConvertUtility as there is
1.204 +no playback facility. It is provided only for binary compatibility.
1.205 +
1.206 +@param aRepeatNumberOfTimes
1.207 + The number of times to repeat the audio clip, after the first playback. If this is set to
1.208 + KMdaRepeatForever, then the audio sample, together with the trailing silence, is repeated
1.209 + indefinitely. If this is set to zero, then the audio sample is not repeated.
1.210 +@param aTrailingSilence
1.211 + A delay to wait before each repetition.
1.212 +
1.213 +@since 5.0
1.214 +*/
1.215 +void CMdaAudioConvertUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
1.216 + {
1.217 + ASSERT(iProperties);
1.218 + iProperties->SetRepeats(aRepeatNumberOfTimes, aTrailingSilence);
1.219 + }
1.220 +
1.221 +/**
1.222 +Sets the maximum size of an audio clip.
1.223 +
1.224 +This function is provided so that applications such as recorders and converters can limit the amount
1.225 +of file storage/memory that should be allocated.
1.226 +
1.227 +@param aMaxWriteLength
1.228 + The maximum size of the audio clip, in bytes. If the default value is used, there is no
1.229 + maximum file size.
1.230 +
1.231 +@since 7.0
1.232 +*/
1.233 +void CMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength /* = KMdaClipLocationMaxWriteLengthNone*/)
1.234 + {
1.235 + ASSERT(iProperties);
1.236 + iProperties->SetMaxWriteLength(aMaxWriteLength);
1.237 + }
1.238 +
1.239 +/**
1.240 +Crops the audio clip from the start of the file to the current position. The audio data
1.241 +prior to the current position is discarded.
1.242 +
1.243 +The effects of the function cannot be undone.
1.244 +
1.245 +The function is synchronous and can leave if there is a problem. The leave code depends on the
1.246 +configuration.
1.247 +
1.248 +@since 7.0s
1.249 +*/
1.250 +void CMdaAudioConvertUtility::CropFromBeginningL()
1.251 + {
1.252 + ASSERT(iProperties);
1.253 + iProperties->CropL(EFalse);
1.254 + }
1.255 +
1.256 +/**
1.257 +Constructs and initialises a new instance of the audio converter for converting audio sample data
1.258 +from one format to another.
1.259 +
1.260 +The function leaves if the audio converter object cannot be created.
1.261 +
1.262 +@param aObserver
1.263 + The class to receive state change events from converter.
1.264 +@param aServer
1.265 + No longer used, should be NULL.
1.266 +@param aPriority
1.267 + The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and
1.268 + EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request.
1.269 +@param aPref
1.270 + The Priority Preference - an additional audio policy parameter. The suggested default is
1.271 + EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional
1.272 + values may be supported by given phones and/or platforms, but should not be depended upon by
1.273 + portable code.
1.274 +
1.275 +@return A pointer to a new instance of CMdaAudioConvertUtility.
1.276 +
1.277 +@since 5.0
1.278 +
1.279 +Note: The Priority Value and Priority Preference are used primarily when deciding what to do when
1.280 +several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference,
1.281 +the adaptation may consider other parameters such as the SecureId and Capabilities of the client process.
1.282 +Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may
1.283 +vary between different phones. Portable applications are advised not to assume any specific behaviour.
1.284 +*/
1.285 +EXPORT_C CMdaAudioConvertUtility* CMdaAudioConvertUtility::NewL(MMdaObjectStateChangeObserver& aObserver,
1.286 + CMdaServer* /*aServer*/,
1.287 + TInt aPriority,
1.288 + TInt aPref)
1.289 + {
1.290 + CMdaAudioConvertUtility* self = new(ELeave) CMdaAudioConvertUtility();
1.291 + CleanupStack::PushL(self);
1.292 + self->iProperties = new(ELeave) CMMFMdaAudioConvertUtility(self, aObserver);
1.293 + self->iProperties->ConstructL(aPriority, aPref);
1.294 + CleanupStack::Pop(self);
1.295 + return self;
1.296 + }
1.297 +
1.298 +/**
1.299 +Destructor.
1.300 +
1.301 +Closes the audio clip and frees resources.
1.302 +
1.303 +@since 5.0
1.304 +*/
1.305 +CMdaAudioConvertUtility::~CMdaAudioConvertUtility()
1.306 + {
1.307 + delete iProperties;
1.308 + }
1.309 +
1.310 +/**
1.311 +Ensures that any subsequent calls to OpenXYZ() will create controllers that
1.312 +share a heap.
1.313 +
1.314 +The default behaviour is that for each converter utility a controller with its own heap
1.315 +is created. Each heap uses a chunk, so using this function avoids situations where
1.316 +the number of chunks per process is limited.
1.317 +The default behaviour is generally to be preferred, and should give lower overall
1.318 +memory usage. However, if many controllers are to be created for a particular thread,
1.319 +then this function should be used to prevent running out of heaps or chunks.
1.320 +
1.321 +@since 9.2
1.322 +*/
1.323 +EXPORT_C void CMdaAudioConvertUtility::UseSharedHeap()
1.324 + {
1.325 + ASSERT(iProperties);
1.326 + iProperties->UseSharedHeap();
1.327 + }
1.328 +
1.329 +/**
1.330 +Opens source and target files (both of which must already exist) so that audio sample data can be
1.331 +extracted from the source file, converted and appended to the target file.
1.332 +
1.333 +When opening is complete, successfully or otherwise, the client is notified by
1.334 +MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
1.335 +providing it with state change information and error codes.
1.336 +
1.337 +@param aPrimaryFile
1.338 + The full path and filename of a file containing audio sample data to be converted.
1.339 +@param aSecondaryFile
1.340 + The full path and filename of a file to which converted data is appended.
1.341 +
1.342 +@since 5.0
1.343 +*/
1.344 +void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile)
1.345 + {
1.346 + ASSERT(iProperties);
1.347 + iProperties->OpenL(aPrimaryFile, aSecondaryFile);
1.348 + }
1.349 +
1.350 +/**
1.351 +Opens an existing audio file so that audio sample data can be extracted from it, converted and
1.352 +placed into the target audio object.
1.353 +
1.354 +When opening is complete, successfully or otherwise, the client is notified by
1.355 +MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
1.356 +providing it with state change information and error codes.
1.357 +
1.358 +@param aPrimaryFile
1.359 + The full path and filename of a file containing audio sample data to be converted.
1.360 +@param aLocation
1.361 + The target location for the audio data. This is normally a file (TMdaFileClipLocation) or a
1.362 + descriptor (TMdaDesClipLocation).
1.363 +@param aFormat
1.364 + The audio format for the target audio object.
1.365 +@param aArg1
1.366 + The codec to use for the target audio object.
1.367 +@param aArg2
1.368 + The audio settings for the target audio object.
1.369 +
1.370 +@since 5.0
1.371 +*/
1.372 +void CMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, TMdaClipLocation* aLocation, TMdaClipFormat* aFormat,
1.373 + TMdaPackage* aArg1 /*= NULL*/, TMdaPackage* aArg2 /*= NULL*/)
1.374 + {
1.375 + ASSERT(iProperties);
1.376 + iProperties->OpenL(aPrimaryFile, aLocation, aFormat, aArg1, aArg2);
1.377 + }
1.378 +
1.379 +/**
1.380 +Opens an audio clip for conversion.
1.381 +
1.382 +@param aPriLocation
1.383 + The source location for audio data. This is normally a file (TMdaFileClipLocation) or a
1.384 + descriptor (TMdaDesClipLocation).
1.385 +@param aSecLocation
1.386 + The target location for audio data. This is normally a file (TMdaFileClipLocation) or a
1.387 + descriptor (TMdaDesClipLocation).
1.388 +@param aPriFormat
1.389 + The audio format of the source audio object.
1.390 +@param aSecFormat
1.391 + The audio format for the target audio object.
1.392 +@param aPriArg1
1.393 + The codec used by the source audio object.
1.394 +@param aPriArg2
1.395 + The audio settings of the source audio object.
1.396 +@param aSecArg1
1.397 + The codec to be used for the target audio object.
1.398 +@param aSecArg2
1.399 + The audio settings for the target audio object.
1.400 +
1.401 +@since 5.0
1.402 +*/
1.403 +void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation,
1.404 + TMdaClipFormat* aPriFormat, TMdaClipFormat* aSecFormat,
1.405 + TMdaPackage* aPriArg1 /*= NULL*/, TMdaPackage* aPriArg2 /*= NULL*/,
1.406 + TMdaPackage* aSecArg1 /*= NULL*/, TMdaPackage* aSecArg2 /*= NULL*/)
1.407 + {
1.408 + ASSERT(iProperties);
1.409 + iProperties->OpenL(aPriLocation, aSecLocation, aPriFormat, aSecFormat, aPriArg1, aPriArg2, aSecArg1, aSecArg2);
1.410 + }
1.411 +
1.412 +// New functions for 7.0s
1.413 +/**
1.414 +Opens source and target audio objects and specifies controller and audio format and codec
1.415 +information.
1.416 +
1.417 +When opening is complete, successfully or otherwise, the client is notified by
1.418 +MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
1.419 +providing it with state change information and error codes.
1.420 +
1.421 +@param aPriLocation
1.422 + The source location for audio data. This is normally a file (TMdaFileClipLocation) or a
1.423 + descriptor (TMdaDesClipLocation).
1.424 +@param aSecLocation
1.425 + The destination location for the converted audio data. This is normally a file
1.426 + (TMdaFileClipLocation) or a descriptor (TMdaDesClipLocation).
1.427 +@param aControllerUid
1.428 + The UID of the controller to used for conversion.
1.429 +@param aDestFormatUid
1.430 + The UID of the destination format.
1.431 +@param aDestDataType
1.432 + The audio codec to use for the destination data sink.
1.433 +
1.434 +@since 7.0s
1.435 +*/
1.436 +EXPORT_C void CMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation, TUid aControllerUid,
1.437 + TUid aDestFormatUid, TFourCC aDestDataType)
1.438 + {
1.439 + ASSERT(iProperties);
1.440 + iProperties->OpenL(aPriLocation, aSecLocation, aControllerUid, aDestFormatUid, aDestDataType);
1.441 + }
1.442 +
1.443 +/**
1.444 +Returns a list of the supported data types for the conversion destination.
1.445 +
1.446 +@param aSupportedDestinationDataTypes
1.447 + A list of four character codes, representing the supported data
1.448 + encodings for the conversion destination.
1.449 +
1.450 +@since 7.0s
1.451 +*/
1.452 +EXPORT_C void CMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDestinationDataTypes)
1.453 + {
1.454 + ASSERT(iProperties);
1.455 + iProperties->GetSupportedDestinationDataTypesL(aSupportedDestinationDataTypes);
1.456 + }
1.457 +
1.458 +/**
1.459 +Sets the data type of the destination audio clip.
1.460 +
1.461 +@param aCodec
1.462 + The four character code, representing the encoding of the destination audio clip
1.463 +
1.464 +@since 7.0s
1.465 +*/
1.466 +EXPORT_C void CMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aCodec)
1.467 + {
1.468 + ASSERT(iProperties);
1.469 + iProperties->SetDestinationDataTypeL(aCodec);
1.470 + }
1.471 +
1.472 +/**
1.473 +Returns the data type of the destination audio clip.
1.474 +
1.475 +@return The four character code, representing the encoding of the destination audio clip.
1.476 +
1.477 +@since 7.0s
1.478 +*/
1.479 +EXPORT_C TFourCC CMdaAudioConvertUtility::DestinationDataTypeL()
1.480 + {
1.481 + ASSERT(iProperties);
1.482 + return iProperties->DestinationDataTypeL();
1.483 + }
1.484 +
1.485 +/**
1.486 +Returns the data type of the source audio clip.
1.487 +
1.488 +@return The four character code, representing the encoding of the source audio clip.
1.489 +
1.490 +@since 7.0s
1.491 +*/
1.492 +EXPORT_C TFourCC CMdaAudioConvertUtility::SourceDataTypeL()
1.493 + {
1.494 + ASSERT(iProperties);
1.495 + return iProperties->SourceDataTypeL();
1.496 + }
1.497 +
1.498 +/**
1.499 +Sets the bit rate of the destination audio clip.
1.500 +
1.501 +The bit rate must be one of the supported bit rates of the audio target. Use
1.502 +GetSupportedConversionBitRatesL() to retrieve a list of supported bit rates.
1.503 +
1.504 +@param aBitRate
1.505 + The destination bit rate in bits/second.
1.506 +
1.507 +@since 7.0s
1.508 +*/
1.509 +EXPORT_C void CMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate)
1.510 + {
1.511 + ASSERT(iProperties);
1.512 + iProperties->SetDestinationBitRateL(aBitRate);
1.513 + }
1.514 +
1.515 +/**
1.516 +Returns the bit rate of the destination audio clip.
1.517 +
1.518 +@return The destination bit rate in bits/second.
1.519 +
1.520 +@since 7.0s
1.521 +*/
1.522 +EXPORT_C TUint CMdaAudioConvertUtility::DestinationBitRateL()
1.523 + {
1.524 + ASSERT(iProperties);
1.525 + return iProperties->DestinationBitRateL();
1.526 + }
1.527 +
1.528 +/**
1.529 +Gets a list of the supported bit rates for the conversion destination.
1.530 +
1.531 +@param aSupportedBitRates
1.532 + The list of bit rates supported for the conversion destination.
1.533 +
1.534 +@since 7.0s
1.535 +*/
1.536 +EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates)
1.537 + {
1.538 + ASSERT(iProperties);
1.539 + iProperties->GetSupportedConversionBitRatesL(aSupportedBitRates);
1.540 + }
1.541 +
1.542 +/**
1.543 +Returns the bit rate of the source audio clip.
1.544 +
1.545 +@return The source bit rate in bits/second.
1.546 +
1.547 +@since 7.0s
1.548 +*/
1.549 +EXPORT_C TInt CMdaAudioConvertUtility::SourceBitRateL()
1.550 + {
1.551 + ASSERT(iProperties);
1.552 + return iProperties->SourceBitRateL();
1.553 + }
1.554 +
1.555 +/**
1.556 +Sets the sample rate for the conversion destination.
1.557 +
1.558 +The sample rate must be one of the supported sample rates of the audio target. Use
1.559 +GetSupportedConversionSampleRatesL() to retrieve a list of supported sample rates.
1.560 +This function should not be used if the audio clip already exists; that is, in the
1.561 +"Open and Append" scenario, when the function's behaviour is undefined.
1.562 +
1.563 +@param aSampleRate
1.564 + The sample rate of the conversion destination in samples per second.
1.565 +
1.566 +@since 7.0s
1.567 +*/
1.568 +EXPORT_C void CMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate)
1.569 + {
1.570 + ASSERT(iProperties);
1.571 + iProperties->SetDestinationSampleRateL(aSampleRate);
1.572 + }
1.573 +
1.574 +/**
1.575 +Returns the sample rate of the conversion destination.
1.576 +
1.577 +@return The sample rate of the conversion destination in samples per second.
1.578 +
1.579 +@since 7.0s
1.580 +*/
1.581 +EXPORT_C TUint CMdaAudioConvertUtility::DestinationSampleRateL()
1.582 + {
1.583 + ASSERT(iProperties);
1.584 + return iProperties->DestinationSampleRateL();
1.585 + }
1.586 +
1.587 +/**
1.588 +Gets a list of supported conversion sample rates. This is a list of the sample rates that
1.589 +the conversion destination can take.
1.590 +
1.591 +@param aSupportedSampleRates
1.592 + A list of the sample rates that are supported for the conversion.
1.593 +
1.594 +@since 7.0s
1.595 +*/
1.596 +EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray<TUint>& aSupportedSampleRates)
1.597 + {
1.598 + ASSERT(iProperties);
1.599 + iProperties->GetSupportedConversionSampleRatesL(aSupportedSampleRates);
1.600 + }
1.601 +
1.602 +/**
1.603 +Returns the sample rate of the source audio clip.
1.604 +
1.605 +@return The source sample rate in samples/second.
1.606 +
1.607 +@since 7.0s
1.608 +*/
1.609 +EXPORT_C TUint CMdaAudioConvertUtility::SourceSampleRateL()
1.610 + {
1.611 + ASSERT(iProperties);
1.612 + return iProperties->SourceSampleRateL();
1.613 + }
1.614 +
1.615 +/**
1.616 +Sets the format of the destination audio clip.
1.617 +
1.618 +The UID (aFormatUid) corresponds to the UID of the destination format to use.
1.619 +
1.620 +@param aFormatUid
1.621 + The UID of the destination format.
1.622 +
1.623 +@since 7.0s
1.624 +*/
1.625 +EXPORT_C void CMdaAudioConvertUtility::SetDestinationFormatL(TUid aFormatUid)
1.626 + {
1.627 + ASSERT(iProperties);
1.628 + iProperties->SetDestinationFormatL(aFormatUid);
1.629 + }
1.630 +
1.631 +/**
1.632 +Returns the format of the destination audio clip.
1.633 +
1.634 +@return The UID of the destination format.
1.635 +
1.636 +@since 7.0s
1.637 +*/
1.638 +EXPORT_C TUid CMdaAudioConvertUtility::DestinationFormatL()
1.639 + {
1.640 + ASSERT(iProperties);
1.641 + return iProperties->DestinationFormatL();
1.642 + }
1.643 +
1.644 +/**
1.645 +Returns the format of the source audio clip.
1.646 +
1.647 +@return The UID of the source format.
1.648 +
1.649 +@since 7.0s
1.650 +*/
1.651 +EXPORT_C TUid CMdaAudioConvertUtility::SourceFormatL()
1.652 + {
1.653 + ASSERT(iProperties);
1.654 + return iProperties->SourceFormatL();
1.655 + }
1.656 +
1.657 +/**
1.658 +Sets the number of channels the destination audio clip contains.
1.659 +
1.660 +The number of channels must be one of the values returned by
1.661 +GetSupportedConversionNumberOfChannelsL().
1.662 +
1.663 +@param aNumberOfChannels
1.664 + The number of channels.
1.665 +
1.666 +@since 7.0s
1.667 +*/
1.668 +EXPORT_C void CMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels)
1.669 + {
1.670 + ASSERT(iProperties);
1.671 + iProperties->SetDestinationNumberOfChannelsL(aNumberOfChannels);
1.672 + }
1.673 +
1.674 +/**
1.675 +Returns the number of channels the destination audio clip contains.
1.676 +
1.677 +@return The number of channels.
1.678 +
1.679 +@since 7.0s
1.680 +*/
1.681 +EXPORT_C TUint CMdaAudioConvertUtility::DestinationNumberOfChannelsL()
1.682 + {
1.683 + ASSERT(iProperties);
1.684 + return iProperties->DestinationNumberOfChannelsL();
1.685 + }
1.686 +
1.687 +/**
1.688 +Returns a list of the supported number of channels for conversion.
1.689 +
1.690 +For example, 1 for mono, 2 for stereo and so on.
1.691 +
1.692 +@param aSupportedNumChannels
1.693 + A list of the number of channels supported for the conversion destination.
1.694 +
1.695 +@since 7.0s
1.696 +*/
1.697 +EXPORT_C void CMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray<TUint>& aSupportedNumChannels)
1.698 + {
1.699 + ASSERT(iProperties);
1.700 + iProperties->GetSupportedConversionNumberOfChannelsL(aSupportedNumChannels);
1.701 + }
1.702 +
1.703 +/**
1.704 +Returns the number of channels used by the conversion source.
1.705 +
1.706 +@return The number of channels.
1.707 +
1.708 +@since 7.0s
1.709 +*/
1.710 +EXPORT_C TUint CMdaAudioConvertUtility::SourceNumberOfChannelsL()
1.711 + {
1.712 + ASSERT(iProperties);
1.713 + return iProperties->SourceNumberOfChannelsL();
1.714 + }
1.715 +/**
1.716 +Performs the conversion from the source audio format to the destination.
1.717 +
1.718 +When conversion is complete, successfully or otherwise, the client is notified by
1.719 +MMdaObjectStateChangeObserver::MoscoStateChangeEvent(). The callback is initiated by this function
1.720 +providing it with state change information and error codes.
1.721 +
1.722 +@since 7.0s
1.723 +*/
1.724 +EXPORT_C void CMdaAudioConvertUtility::ConvertL()
1.725 + {
1.726 + ASSERT(iProperties);
1.727 + iProperties->ConvertL();
1.728 + }
1.729 +
1.730 +/**
1.731 +Returns the controller implementation information associated with the current controller.
1.732 +
1.733 +@return The controller implementation structure associated with the controller
1.734 +
1.735 +@since 7.0s
1.736 +*/
1.737 +EXPORT_C const CMMFControllerImplementationInformation& CMdaAudioConvertUtility::ControllerImplementationInformationL()
1.738 + {
1.739 + ASSERT(iProperties);
1.740 + return iProperties->ControllerImplementationInformationL();
1.741 + }
1.742 +
1.743 +/**
1.744 +Sends a synchronous custom command to the controller.
1.745 +
1.746 +@param aDestination
1.747 + The destination of the message, consisting of the UID of the interface of this message.
1.748 +@param aFunction
1.749 + The function number to indicate which function is to be called
1.750 + on the interface defined in the aDestination parameter.
1.751 +@param aDataTo1
1.752 + A reference to the first chunk of data to be copied to the controller
1.753 + framework. The exact contents of the data are dependent on the
1.754 + interface being called. Can be KNullDesC8.
1.755 +@param aDataTo2
1.756 + A reference to the second chunk of data to be copied to the controller
1.757 + framework. The exact contents of the data are dependent on the
1.758 + interface being called. Can be KNullDesC8.
1.759 +@param aDataFrom
1.760 + A reference to an area of memory to which the controller framework will
1.761 + write any data to be passed back to the client. Can't be KNullDesC8.
1.762 +
1.763 +@return The result of the request. Exact range of values is dependent on the interface.
1.764 +
1.765 +@since 7.0s
1.766 +*/
1.767 +EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom)
1.768 + {
1.769 + ASSERT(iProperties);
1.770 + return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom);
1.771 + }
1.772 +
1.773 +/**
1.774 +Sends a synchronous custom command to the controller.
1.775 +
1.776 +@param aDestination
1.777 + The destination of the message, consisting of the UID of the interface of this message.
1.778 +@param aFunction
1.779 + The function number to indicate which function is to be called on the interface defined in
1.780 + the aDestination parameter.
1.781 +@param aDataTo1
1.782 + A reference to the first chunk of data to be copied to the controllert framework. The exact
1.783 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.784 +@param aDataTo2
1.785 + A reference to the second chunk of data to be copied to the controller framework. The exact
1.786 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.787 +
1.788 +@return The result of the request. The exact range of values is dependent on the interface.
1.789 +
1.790 +@since 7.0s
1.791 +*/
1.792 +EXPORT_C TInt CMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2)
1.793 + {
1.794 + ASSERT(iProperties);
1.795 + return iProperties->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2);
1.796 + }
1.797 +
1.798 +/**
1.799 +Send a asynchronous custom command to the controller.
1.800 +
1.801 +Note: This method will return immediately. The RunL of the active object owning the
1.802 +aStatus parameter will be called when the command is completed by the controller framework.
1.803 +
1.804 +@param aDestination
1.805 + The destination of the message, consisting of the UID of the interface of this message.
1.806 +@param aFunction
1.807 + The function number to indicate which function is to be called on the interface defined in
1.808 + the aDestination parameter.
1.809 +@param aDataTo1
1.810 + A reference to the first chunk of data to be copied to the controller framework. The exact
1.811 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.812 +@param aDataTo2
1.813 + A reference to the second chunk of data to be copied to the controller framework. The exact
1.814 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.815 +@param aDataFrom
1.816 + A reference to an area of memory to which the controller framework will write any data to be
1.817 + passed back to the client. Can't be KNullDesC8.
1.818 +@param aStatus
1.819 + The TRequestStatus of an active object. This will contain the result of the request on
1.820 + completion. The exact range of result values is dependent on the interface.
1.821 +@since 7.0s
1.822 +*/
1.823 +EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus)
1.824 + {
1.825 + ASSERT(iProperties);
1.826 + iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus);
1.827 + }
1.828 +
1.829 +/**
1.830 +Send a asynchronous custom command to the controller.
1.831 +
1.832 +Note: This method will return immediately. The RunL of the active object owning the
1.833 +aStatus parameter will be called when the command is completed by the controller framework.
1.834 +
1.835 +@param aDestination
1.836 + The destination of the message, consisting of the UID of the interface of this message.
1.837 +@param aFunction
1.838 + The function number to indicate which function is to be called on the interface defined in
1.839 + the aDestination parameter.
1.840 +@param aDataTo1
1.841 + A reference to the first chunk of data to be copied to the controller framework. The exact
1.842 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.843 +@param aDataTo2
1.844 + A reference to the second chunk of data to be copied to the controller framework. The exact
1.845 + contents of the data are dependent on the interface being called. Can be KNullDesC8.
1.846 +@param aStatus
1.847 + The TRequestStatus of an active object. This will contain the result of the request on
1.848 + completion. The exact range of result values is dependent on the interface.
1.849 +
1.850 +@since 7.0s
1.851 +*/
1.852 +EXPORT_C void CMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus)
1.853 + {
1.854 + ASSERT(iProperties);
1.855 + iProperties->CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus);
1.856 + }
1.857 +
1.858 +/**
1.859 +Set the priority of the controller's sub thread.
1.860 +
1.861 +This can be used to increase the responsiveness of the audio plugin to minimise
1.862 +any lag in processing. This function should be used with care as it may have knock-on
1.863 +effects elsewhere in the system.
1.864 +
1.865 +@param aPriority
1.866 + The TThreadPriority that the thread should run under. The default is EPriorityNormal.
1.867 +@return TInt
1.868 + A standard error code: KErrNone if successful, KErrNotReady if the thread does not have a
1.869 + valid handle.
1.870 +*/
1.871 +EXPORT_C TInt CMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const
1.872 + {
1.873 + ASSERT(iProperties);
1.874 + return iProperties->SetThreadPriority(aThreadPriority);
1.875 + }
1.876 +
1.877 +
1.878 +/******************************************************************************/
1.879 +
1.880 +
1.881 +CMMFMdaAudioConvertUtility::CMMFMdaAudioConvertUtility(CMdaAudioConvertUtility* aParent,
1.882 + MMdaObjectStateChangeObserver& aCallback) :
1.883 + iCallback(aCallback),
1.884 + iAudioControllerCustomCommands(iController),
1.885 + iAudioPlayControllerCustomCommands(iController),
1.886 + iAudioRecordControllerCustomCommands(iController),
1.887 + iParent(aParent),
1.888 + iHasCropped(EFalse),
1.889 + iCroppedDuration(0)
1.890 + {
1.891 + iConvertStart = TTimeIntervalMicroSeconds(0);
1.892 + iConvertEnd = TTimeIntervalMicroSeconds(0);
1.893 + iConvertWindowSet = EFalse;
1.894 + }
1.895 +
1.896 +void CMMFMdaAudioConvertUtility::ConstructL(TInt /*aPriority*/, TInt /*aPref*/)
1.897 + {
1.898 + iControllerEventMonitor = CMMFControllerEventMonitor::NewL(*this, iController);
1.899 + iAsyncCallback = CMMFMdaObjectStateChangeObserverCallback::NewL(iCallback);
1.900 + User::LeaveIfError(iMediaIds.Append(KUidMediaTypeAudio));
1.901 + iFindAndOpenController = CMMFFindAndOpenController::NewL(*this);
1.902 + iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings);
1.903 + iFindAndOpenController->ConfigureController(iController, *iControllerEventMonitor, CMMFFindAndOpenController::EConvert);
1.904 + }
1.905 +
1.906 +CMMFMdaAudioConvertUtility::~CMMFMdaAudioConvertUtility()
1.907 + {
1.908 + delete iControllerImplementationInformation;
1.909 + delete iAsyncCallback;
1.910 + delete iFindAndOpenController;
1.911 + delete iControllerEventMonitor;
1.912 + iMediaIds.Close();
1.913 + iController.Close();
1.914 + }
1.915 +
1.916 +void CMMFMdaAudioConvertUtility::UseSharedHeap()
1.917 + {
1.918 + iFindAndOpenController->UseSharedHeap();
1.919 + }
1.920 +
1.921 +void CMMFMdaAudioConvertUtility::MfaocComplete(
1.922 + TInt& aError,
1.923 + RMMFController* /*aController*/,
1.924 + TUid aControllerUid,
1.925 + TMMFMessageDestination* /*aSourceHandle*/,
1.926 + TMMFMessageDestination* /*aSinkHandle*/)
1.927 + {
1.928 + TInt oldState = iState;
1.929 +
1.930 + if (aError == KErrNone)
1.931 + {
1.932 + iControllerUid = aControllerUid;
1.933 + aError = ControllerOpen();
1.934 + if (iFindAndOpenController)
1.935 + {
1.936 + iFindAndOpenController->Close();
1.937 + }
1.938 + }
1.939 +
1.940 + iAsyncCallback->CallBack(iParent, oldState, iState, aError);
1.941 + }
1.942 +
1.943 +void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation,
1.944 + TMdaClipLocation* aSecLocation,
1.945 + TMdaClipFormat* aPriFormat,
1.946 + TMdaClipFormat* aSecFormat,
1.947 + TMdaPackage* aPriArg1 /*= NULL*/,
1.948 + TMdaPackage* aPriArg2 /*= NULL*/,
1.949 + TMdaPackage* aSecArg1 /*= NULL*/,
1.950 + TMdaPackage* aSecArg2 /*= NULL*/)
1.951 + {
1.952 + __ASSERT_ALWAYS((aPriLocation && aSecLocation && aPriFormat && aSecFormat), User::Leave(KErrArgument));
1.953 +
1.954 + __ASSERT_ALWAYS((((aPriLocation->Uid() == KUidMdaFileResLoc) || (aPriLocation->Uid() == KUidMdaDesResLoc) || (aPriLocation->Uid() == KUidMdaUrlResLoc)) &&
1.955 + ((aSecLocation->Uid() == KUidMdaFileResLoc) || (aSecLocation->Uid() == KUidMdaDesResLoc) || (aSecLocation->Uid() == KUidMdaUrlResLoc))),
1.956 + User::Leave(KErrNotSupported));
1.957 +
1.958 + __ASSERT_ALWAYS(((aPriFormat->Uid() != KNullUid) && (aSecFormat->Uid() != KNullUid)), User::Leave(KErrNotSupported));
1.959 +
1.960 + Reset();
1.961 +
1.962 + //Do aPriArg2 & aSecArg2 contain the correct package type
1.963 + if(aPriArg2)
1.964 + {
1.965 + TMdaPackage* pckg = aPriArg2;
1.966 + if(pckg->Uid() != KUidMdaMediaTypeAudio)
1.967 + User::Leave(KErrNotSupported);
1.968 +
1.969 + TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aPriArg2;
1.970 + iSourceSampleRate = audioSettings.iSampleRate;
1.971 + iSourceChannels = audioSettings.iChannels;
1.972 + }
1.973 +
1.974 + if(aSecArg2)
1.975 + {
1.976 + TMdaPackage* pckg = aSecArg2;
1.977 + if(pckg->Uid() != KUidMdaMediaTypeAudio)
1.978 + User::Leave(KErrNotSupported);
1.979 + TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aSecArg2;
1.980 + iSinkSampleRate = audioSettings.iSampleRate;
1.981 + iSinkChannels = audioSettings.iChannels;
1.982 + }
1.983 +
1.984 +
1.985 + //Do aPriArg1 & aSecArg1 contain supported FourCC types
1.986 + iSourceDataType = KMMFFourCCCodeNULL;
1.987 + if (aPriArg1)
1.988 + {
1.989 + iSourceDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aPriArg1);
1.990 + if(iSourceDataType == KMMFFourCCCodeNULL)
1.991 + User::Leave(KErrNotSupported);
1.992 + }
1.993 +
1.994 + iSinkDataType = KMMFFourCCCodeNULL;
1.995 + if (aSecArg1)
1.996 + {
1.997 + iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aSecArg1);
1.998 + if(iSinkDataType == KMMFFourCCCodeNULL)
1.999 + User::Leave(KErrNotSupported);
1.1000 + }
1.1001 +
1.1002 +
1.1003 +
1.1004 + TInt err = KErrNone;
1.1005 +
1.1006 + iSourceFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMRead(aPriFormat->Uid());
1.1007 + //If a new formatter plugin has been added, use the supplied read format implementation ID
1.1008 + if (iSourceFormatUid == KNullUid)
1.1009 + iSourceFormatUid = aPriFormat->Uid();
1.1010 +
1.1011 + iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aSecFormat->Uid());
1.1012 + //If a new formatter plugin has been added, use the supplied write format implementation ID
1.1013 + if (iSinkFormatUid == KNullUid)
1.1014 + iSinkFormatUid = aSecFormat->Uid();
1.1015 +
1.1016 + TRAP(err, ConfigureSourceSinkL(aPriLocation, aSecLocation));
1.1017 +
1.1018 + if (!err)
1.1019 + iFindAndOpenController->OpenByFormatUid(iSourceFormatUid, iSinkFormatUid);
1.1020 +
1.1021 + if (err)
1.1022 + {
1.1023 + TInt oldState = State();
1.1024 + iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1.1025 + return;
1.1026 + }
1.1027 + }
1.1028 +
1.1029 +
1.1030 +
1.1031 +
1.1032 +void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile, const TDesC& aSecondaryFile)
1.1033 + {
1.1034 + Reset();
1.1035 +
1.1036 + iFindAndOpenController->ConfigureSourceSink(
1.1037 + CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, CMMFFindAndOpenController::GetConfigFile(aPrimaryFile)),
1.1038 + CMMFFindAndOpenController::TSourceSink(KUidMmfFileSink, CMMFFindAndOpenController::GetConfigFile(aSecondaryFile)));
1.1039 +
1.1040 + TMMFileSource tfs(aPrimaryFile);
1.1041 + iFindAndOpenController->OpenByFileSource(tfs, aSecondaryFile);
1.1042 + }
1.1043 +
1.1044 +void CMMFMdaAudioConvertUtility::OpenL(const TDesC& aPrimaryFile,
1.1045 + TMdaClipLocation* aLocation, // Normally file or descriptor
1.1046 + TMdaClipFormat* aFormat, // Data format
1.1047 + TMdaPackage* aArg1, // Normally codec to use
1.1048 + TMdaPackage* aArg2) // Normally audio settings
1.1049 + {
1.1050 + __ASSERT_ALWAYS(aLocation && aFormat, User::Leave(KErrArgument));
1.1051 +
1.1052 + Reset();
1.1053 +
1.1054 + // convert from the old parameters
1.1055 + if (aFormat)
1.1056 + {
1.1057 + iSinkFormatUid = CMMFClientUtility::ConvertMdaFormatUidToECOMWrite(aFormat->Uid());
1.1058 +
1.1059 + //If a new formatter plugin has been added, use the supplied format ID
1.1060 + if (iSinkFormatUid == KNullUid)
1.1061 + iSinkFormatUid = aFormat->Uid();
1.1062 + }
1.1063 +
1.1064 + if (aArg1)
1.1065 + iSinkDataType = CMMFClientUtility::ConvertMdaCodecToFourCC(*aArg1);
1.1066 +
1.1067 + if (aArg2)
1.1068 + {//have audio settings
1.1069 + TMdaAudioDataSettings audioSettings = *(TMdaAudioDataSettings*)aArg2; //shoud check arg2 are data settings
1.1070 + iSinkSampleRate = audioSettings.iSampleRate;
1.1071 + iSinkChannels = audioSettings.iChannels;
1.1072 + }
1.1073 +
1.1074 +
1.1075 +
1.1076 + TMMFFileConfig sourceCfg;
1.1077 + sourceCfg().iPath = aPrimaryFile;
1.1078 +
1.1079 + TMMFDescriptorConfig dstDesCfg;
1.1080 + TMMFFileConfig dstFileCfg;
1.1081 + CBufFlat* dstCfgBuffer = NULL;
1.1082 + CMMFUrlParams* dstURLCfg = NULL;
1.1083 + TUid dstUid = KNullUid;
1.1084 + TPtrC8 dstCfg(NULL, 0);
1.1085 +
1.1086 + TInt err = KErrNone;
1.1087 +
1.1088 + if (aLocation->Uid() == KUidMdaFileResLoc)
1.1089 + {//sink clip location is a file
1.1090 + TDesC& fileName = ((TMdaFileClipLocation*)aLocation)->iName;
1.1091 + dstFileCfg().iPath = fileName;
1.1092 + dstCfg.Set(dstFileCfg);
1.1093 + dstUid = KUidMmfFileSink;
1.1094 + }
1.1095 + else if (aLocation->Uid() == KUidMdaDesResLoc)
1.1096 + {//sink clip is a descriptor - pass down descriptor & thread id
1.1097 + TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aLocation;
1.1098 + dstDesCfg().iDes = desLoc->iDes;
1.1099 + dstDesCfg().iDesThreadId = desLoc->iThreadId;
1.1100 + dstCfg.Set(dstDesCfg);
1.1101 + dstUid = KUidMmfDescriptorSink;
1.1102 + }
1.1103 + else if (aLocation->Uid() == KUidMdaUrlResLoc)
1.1104 + {
1.1105 + TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aLocation;
1.1106 + dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId);
1.1107 + dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC();
1.1108 + dstCfg.Set(dstCfgBuffer->Ptr(0));
1.1109 + dstUid = KUidMmfUrlSink;
1.1110 + }
1.1111 + else
1.1112 + err = KErrNotSupported;
1.1113 +
1.1114 + if (!err)
1.1115 + {
1.1116 + iFindAndOpenController->ConfigureSourceSink(
1.1117 + CMMFFindAndOpenController::TSourceSink(KUidMmfFileSource, sourceCfg),
1.1118 + CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg));
1.1119 +
1.1120 + TMMFileSource tfs(aPrimaryFile);
1.1121 + iFindAndOpenController->OpenByFileSource(tfs);
1.1122 + }
1.1123 +
1.1124 +
1.1125 +
1.1126 + if (dstCfgBuffer)
1.1127 + CleanupStack::PopAndDestroy(dstCfgBuffer);
1.1128 + if (dstURLCfg)
1.1129 + CleanupStack::PopAndDestroy(dstURLCfg);
1.1130 +
1.1131 +
1.1132 + if (err)
1.1133 + {
1.1134 + TInt oldState = State();
1.1135 + iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1.1136 + return;
1.1137 + }
1.1138 + }
1.1139 +
1.1140 +void CMMFMdaAudioConvertUtility::OpenL(TMdaClipLocation* aPriLocation,
1.1141 + TMdaClipLocation* aSecLocation,
1.1142 + TUid aControllerUid, // the controller to use
1.1143 + TUid aDestFormatUid,
1.1144 + TFourCC aDestDataType)
1.1145 + {
1.1146 + __ASSERT_ALWAYS(aPriLocation && aSecLocation, User::Leave(KErrArgument));
1.1147 +
1.1148 + Reset();
1.1149 +
1.1150 +
1.1151 + // Configure the destination format and data type
1.1152 + if (aDestFormatUid != KNullUid)
1.1153 + iSinkFormatUid = aDestFormatUid;
1.1154 +
1.1155 + if (aDestDataType != KMMFFourCCCodeNULL)
1.1156 + iSinkDataType = aDestDataType;
1.1157 +
1.1158 + TRAPD(err, ConfigureSourceSinkL(aPriLocation, aSecLocation));
1.1159 + if (!err)
1.1160 + iFindAndOpenController->OpenByControllerUid(aControllerUid);
1.1161 +
1.1162 +
1.1163 + if (err)
1.1164 + {
1.1165 + TInt oldState = State();
1.1166 + iAsyncCallback->CallBack(iParent, oldState, oldState, err);
1.1167 + return;
1.1168 + }
1.1169 + }
1.1170 +
1.1171 +
1.1172 +void CMMFMdaAudioConvertUtility::HandleEvent(const TMMFEvent& aEvent)
1.1173 + {
1.1174 + //When converting, state is EPlaying, ERecording is never used
1.1175 + if (aEvent.iEventType==KMMFEventCategoryPlaybackComplete || aEvent.iEventType==KMMFErrorCategoryControllerGeneralError)
1.1176 + {
1.1177 + TInt oldState = iState;
1.1178 + iState = CMdaAudioClipUtility::EOpen;
1.1179 +
1.1180 + //if we weren't converting, don't advise Client.
1.1181 + if(oldState == CMdaAudioClipUtility::EPlaying)
1.1182 + iCallback.MoscoStateChangeEvent(iParent, CMdaAudioClipUtility::EPlaying, iState, aEvent.iErrorCode);
1.1183 + }
1.1184 + }
1.1185 +
1.1186 +void CMMFMdaAudioConvertUtility::PlayL()
1.1187 + {
1.1188 + // N.B. ConvertL should be used in preference to PlayL
1.1189 + ConvertL();
1.1190 + }
1.1191 +
1.1192 +void CMMFMdaAudioConvertUtility::RecordL()
1.1193 + {
1.1194 + // N.B. ConvertL should be used in preference to RecordL
1.1195 + ConvertL();
1.1196 + }
1.1197 +
1.1198 +void CMMFMdaAudioConvertUtility::ConvertL()
1.1199 + {
1.1200 + if (iState == CMdaAudioClipUtility::EOpen)
1.1201 + {
1.1202 + TInt err;
1.1203 + err = iController.Prime();
1.1204 + if (err==KErrNone)
1.1205 + {
1.1206 + err=iController.SetPosition(iPosition);
1.1207 + if (!err && iConvertWindowSet)
1.1208 + err = iAudioPlayControllerCustomCommands.SetPlaybackWindow(iConvertStart, iConvertEnd);
1.1209 + if (err==KErrNone)
1.1210 + err = iController.Play();
1.1211 + }
1.1212 +
1.1213 + TInt oldState = iState;
1.1214 + if (!err)
1.1215 + iState = CMdaAudioClipUtility::EPlaying;
1.1216 +
1.1217 + iAsyncCallback->CallBack(iParent, oldState, iState, err);
1.1218 + }
1.1219 + else
1.1220 + iAsyncCallback->CallBack(iParent, iState, iState, KErrNotReady);
1.1221 + }
1.1222 +
1.1223 +void CMMFMdaAudioConvertUtility::Stop()
1.1224 + {
1.1225 + TInt err = iController.Pause();
1.1226 + TInt oldState = iState;
1.1227 + if (!err)
1.1228 + iState = CMdaAudioClipUtility::EOpen;
1.1229 + iAsyncCallback->CallBack(iParent, oldState, iState, err);
1.1230 + }
1.1231 +
1.1232 +void CMMFMdaAudioConvertUtility::CropL(TBool aCropToEnd)
1.1233 + {
1.1234 + // if we are busy converting, or we have not opened the file, return KErrNotReady
1.1235 + if (iState!=CMdaAudioClipUtility::EOpen)
1.1236 + User::Leave(KErrNotReady);
1.1237 +
1.1238 + // check that cropping position is valid if clip has been cropped before
1.1239 + if (iHasCropped && iPosition > iCroppedDuration)
1.1240 + {
1.1241 + User::Leave(KErrArgument);
1.1242 + }
1.1243 +
1.1244 + TInt err = iController.Prime();
1.1245 + if (!err)
1.1246 + {
1.1247 +
1.1248 + if (!err)
1.1249 + err = iController.SetPosition(iPosition);
1.1250 +
1.1251 + err = iAudioRecordControllerCustomCommands.Crop(aCropToEnd);
1.1252 + // try to stop controller regardless of whether any of the above commands failed
1.1253 + iController.Stop();
1.1254 + // save the duration of the cropped clip because
1.1255 + // Duration() returns length of the original clip only
1.1256 + // this is used to prevent a subsequent crop, beyond the end of the
1.1257 + // already cropped clip.
1.1258 + if (err == KErrNone)
1.1259 + {
1.1260 + iHasCropped = ETrue;
1.1261 + if (aCropToEnd)
1.1262 + iCroppedDuration = iPosition;
1.1263 + else
1.1264 + iCroppedDuration = TTimeIntervalMicroSeconds(iDuration.Int64() - iPosition.Int64());
1.1265 + }
1.1266 + }
1.1267 + User::LeaveIfError(err);
1.1268 + }
1.1269 +
1.1270 +void CMMFMdaAudioConvertUtility::SetPosition(const TTimeIntervalMicroSeconds& aPosition)
1.1271 + {
1.1272 + iPosition = aPosition;
1.1273 +
1.1274 + // Clip the position if aPosition is greater than the duration, or less then 0
1.1275 + const TTimeIntervalMicroSeconds duration = Duration();
1.1276 + if (iPosition > duration)
1.1277 + iPosition = duration;
1.1278 + else if (iPosition < TTimeIntervalMicroSeconds(0))
1.1279 + iPosition = 0;
1.1280 +
1.1281 + if (iState==CMdaAudioClipUtility::EPlaying)
1.1282 + iController.SetPosition(iPosition);
1.1283 + }
1.1284 +
1.1285 +const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Position()
1.1286 + {
1.1287 + if (iState==CMdaAudioClipUtility::EPlaying)
1.1288 + {
1.1289 + TInt err = iController.GetPosition(iPositionTemp);
1.1290 + if (err==KErrNone)
1.1291 + return iPositionTemp;
1.1292 + }
1.1293 + return iPosition;
1.1294 + }
1.1295 +
1.1296 +const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::RecordTimeAvailable()
1.1297 + {
1.1298 +#ifdef _DEBUG
1.1299 + TInt error =
1.1300 +#endif
1.1301 + iAudioRecordControllerCustomCommands.GetRecordTimeAvailable(iRecordTimeAvailable);
1.1302 + __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1.1303 + return iRecordTimeAvailable;
1.1304 + }
1.1305 +
1.1306 +const TTimeIntervalMicroSeconds& CMMFMdaAudioConvertUtility::Duration()
1.1307 + {
1.1308 + TInt err = iController.GetDuration(iDuration);
1.1309 + if (err)
1.1310 + iDuration = 0;
1.1311 + return iDuration;
1.1312 + }
1.1313 +
1.1314 +void CMMFMdaAudioConvertUtility::SetMaxWriteLength(TInt aMaxWriteLength)
1.1315 + {
1.1316 + iAudioRecordControllerCustomCommands.SetMaxFileSize(aMaxWriteLength);
1.1317 + }
1.1318 +
1.1319 +
1.1320 +void CMMFMdaAudioConvertUtility::SetPlayWindow(const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd)
1.1321 + {
1.1322 + if (aStart >= TTimeIntervalMicroSeconds(0) &&
1.1323 + aStart < iDuration &&
1.1324 + aStart <= aEnd &&
1.1325 + aEnd <= iDuration )
1.1326 + {
1.1327 + iConvertStart = aStart;
1.1328 + iConvertEnd = aEnd;
1.1329 + iConvertWindowSet = ETrue;
1.1330 +
1.1331 + if (iState==CMdaAudioClipUtility::EPlaying)
1.1332 + {
1.1333 +#ifdef _DEBUG
1.1334 + TInt error =
1.1335 +#endif
1.1336 + iAudioPlayControllerCustomCommands.SetPlaybackWindow(aStart, aEnd);
1.1337 + __ASSERT_DEBUG(error==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1.1338 + }
1.1339 + }
1.1340 + else
1.1341 + {
1.1342 + __ASSERT_DEBUG(EFalse, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1.1343 + }
1.1344 + }
1.1345 +
1.1346 +void CMMFMdaAudioConvertUtility::ClearPlayWindow()
1.1347 + {
1.1348 + iConvertWindowSet = EFalse;
1.1349 +#ifdef _DEBUG
1.1350 + TInt err =
1.1351 +#endif //_DEBUG
1.1352 + iAudioPlayControllerCustomCommands.DeletePlaybackWindow();
1.1353 + __ASSERT_DEBUG(err==KErrNone, Panic(EMMFMediaClientPanicServerCommunicationProblem));
1.1354 + }
1.1355 +
1.1356 +void CMMFMdaAudioConvertUtility::SetRepeats(TInt /*aRepeatNumberOfTimes*/, const TTimeIntervalMicroSeconds& /*aTrailingSilence*/)
1.1357 + {
1.1358 + // This doesn't really make sense for the converter.
1.1359 + }
1.1360 +
1.1361 +void CMMFMdaAudioConvertUtility::SetPriority(TInt aPriority, TInt aPref)
1.1362 + {
1.1363 + iPrioritySettings.iPref = aPref;
1.1364 + iPrioritySettings.iPriority = aPriority;
1.1365 + iFindAndOpenController->Configure(iMediaIds[0], iPrioritySettings);
1.1366 + iController.SetPrioritySettings(iPrioritySettings);
1.1367 + }
1.1368 +
1.1369 +
1.1370 +void CMMFMdaAudioConvertUtility::Close()
1.1371 + {
1.1372 + iControllerEventMonitor->Cancel();
1.1373 + iController.Close();
1.1374 +
1.1375 + if (iFindAndOpenController)
1.1376 + iFindAndOpenController->Close();
1.1377 +
1.1378 + iHasCropped = EFalse;
1.1379 + iCroppedDuration = 0;
1.1380 + iState = CMdaAudioClipUtility::ENotReady;
1.1381 + if(iControllerImplementationInformation)
1.1382 + {
1.1383 + delete iControllerImplementationInformation;
1.1384 + iControllerImplementationInformation = NULL;
1.1385 + }
1.1386 + iControllerUid = KNullUid;
1.1387 + }
1.1388 +
1.1389 +void CMMFMdaAudioConvertUtility::CropL(const TTimeIntervalMicroSeconds &aCropBegin,
1.1390 + const TTimeIntervalMicroSeconds &aCropEnd)
1.1391 + {
1.1392 + // if we are busy converting, or we have not opened the file, return KErrNotReady
1.1393 + if (iState!=CMdaAudioClipUtility::EOpen)
1.1394 + User::Leave(KErrNotReady);
1.1395 +
1.1396 + // check that cropping positions are valid if clip has been cropped before
1.1397 + if (iHasCropped && aCropEnd > iCroppedDuration)
1.1398 + {
1.1399 + User::Leave(KErrArgument);
1.1400 + }
1.1401 +
1.1402 + TInt err = iController.Prime();
1.1403 + if (!err)
1.1404 + {
1.1405 + err =iController.SetPosition(aCropEnd);
1.1406 + if (!err)
1.1407 + err = iAudioRecordControllerCustomCommands.Crop(ETrue);
1.1408 + if (!err)
1.1409 + {
1.1410 + //remember the cropping, store the cropped length
1.1411 + iHasCropped = ETrue;
1.1412 + iCroppedDuration = aCropEnd;
1.1413 + err = iController.SetPosition(aCropBegin);
1.1414 + }
1.1415 + if (!err)
1.1416 + err = iAudioRecordControllerCustomCommands.Crop(EFalse);
1.1417 + if (!err) // store the new cropped length
1.1418 + iCroppedDuration = TTimeIntervalMicroSeconds(aCropEnd.Int64() - aCropBegin.Int64());
1.1419 +
1.1420 + // try to stop controller regardless of whether any of the above commands failed
1.1421 + iController.Stop();
1.1422 + }
1.1423 + User::LeaveIfError(err);
1.1424 + }
1.1425 +
1.1426 +CMdaAudioClipUtility::TState CMMFMdaAudioConvertUtility::State()
1.1427 + {
1.1428 + return iState;
1.1429 + }
1.1430 +
1.1431 +void CMMFMdaAudioConvertUtility::GetSupportedDestinationDataTypesL(RArray<TFourCC>& aSupportedDataTypes)
1.1432 + {
1.1433 + iAudioControllerCustomCommands.GetSupportedSinkDataTypesL(aSupportedDataTypes);
1.1434 + }
1.1435 +
1.1436 +void CMMFMdaAudioConvertUtility::SetSourceDataTypeL(TFourCC aDataType)
1.1437 + {
1.1438 + User::LeaveIfError(iAudioControllerCustomCommands.SetSourceDataType(aDataType));
1.1439 + }
1.1440 +
1.1441 +void CMMFMdaAudioConvertUtility::SetDestinationDataTypeL(TFourCC aDataType)
1.1442 + {
1.1443 + User::LeaveIfError(iAudioControllerCustomCommands.SetSinkDataType(aDataType));
1.1444 + }
1.1445 +
1.1446 +TFourCC CMMFMdaAudioConvertUtility::DestinationDataTypeL()
1.1447 + {
1.1448 + TFourCC dataType;
1.1449 + User::LeaveIfError(iAudioControllerCustomCommands.GetSinkDataType(dataType));
1.1450 + return dataType;
1.1451 + }
1.1452 +
1.1453 +TFourCC CMMFMdaAudioConvertUtility::SourceDataTypeL()
1.1454 + {
1.1455 + TFourCC dataType;
1.1456 + User::LeaveIfError(iAudioControllerCustomCommands.GetSourceDataType(dataType));
1.1457 + return dataType;
1.1458 + }
1.1459 +
1.1460 +
1.1461 +void CMMFMdaAudioConvertUtility::SetDestinationBitRateL(TUint aBitRate)
1.1462 + {
1.1463 + User::LeaveIfError(iAudioControllerCustomCommands.SetSinkBitRate(aBitRate));
1.1464 + }
1.1465 +
1.1466 +void CMMFMdaAudioConvertUtility::SetSourceSampleRateL(TUint aSampleRate)
1.1467 + {
1.1468 + User::LeaveIfError(iController.Stop());
1.1469 + User::LeaveIfError(iAudioControllerCustomCommands.SetSourceSampleRate(aSampleRate));
1.1470 + }
1.1471 +
1.1472 +void CMMFMdaAudioConvertUtility::SetDestinationSampleRateL(TUint aSampleRate)
1.1473 + {
1.1474 + User::LeaveIfError(iController.Stop());
1.1475 + User::LeaveIfError(iAudioControllerCustomCommands.SetSinkSampleRate(aSampleRate));
1.1476 + }
1.1477 +
1.1478 +void CMMFMdaAudioConvertUtility::SetSourceFormatL(TUid aRecordFormat)
1.1479 + {
1.1480 + User::LeaveIfError(iAudioControllerCustomCommands.SetSourceFormat(aRecordFormat));
1.1481 + }
1.1482 +
1.1483 +void CMMFMdaAudioConvertUtility::SetDestinationFormatL(TUid aRecordFormat)
1.1484 + {
1.1485 + User::LeaveIfError(iAudioControllerCustomCommands.SetSinkFormat(aRecordFormat));
1.1486 + }
1.1487 +
1.1488 +void CMMFMdaAudioConvertUtility::SetSourceNumberOfChannelsL(TUint aNumberOfChannels)
1.1489 + {
1.1490 + User::LeaveIfError(iAudioControllerCustomCommands.SetSourceNumChannels(aNumberOfChannels));
1.1491 + }
1.1492 +
1.1493 +void CMMFMdaAudioConvertUtility::SetDestinationNumberOfChannelsL(TUint aNumberOfChannels)
1.1494 + {
1.1495 + User::LeaveIfError(iAudioControllerCustomCommands.SetSinkNumChannels(aNumberOfChannels));
1.1496 + }
1.1497 +
1.1498 +TUint CMMFMdaAudioConvertUtility::DestinationBitRateL()
1.1499 + {
1.1500 + TUint bitRate;
1.1501 + User::LeaveIfError(iAudioControllerCustomCommands.GetSinkBitRate(bitRate));
1.1502 + return bitRate;
1.1503 + }
1.1504 +
1.1505 +TUint CMMFMdaAudioConvertUtility::DestinationSampleRateL()
1.1506 + {
1.1507 + TUint sampleRate;
1.1508 + User::LeaveIfError(iAudioControllerCustomCommands.GetSinkSampleRate(sampleRate));
1.1509 + return sampleRate;
1.1510 + }
1.1511 +
1.1512 +TUid CMMFMdaAudioConvertUtility::DestinationFormatL()
1.1513 + {
1.1514 + TUid format;
1.1515 + User::LeaveIfError(iAudioControllerCustomCommands.GetSinkFormat(format));
1.1516 + return format;
1.1517 + }
1.1518 +
1.1519 +TUint CMMFMdaAudioConvertUtility::DestinationNumberOfChannelsL()
1.1520 + {
1.1521 + TUint numChannels;
1.1522 + User::LeaveIfError(iAudioControllerCustomCommands.GetSinkNumChannels(numChannels));
1.1523 + return numChannels;
1.1524 + }
1.1525 +
1.1526 +TUint CMMFMdaAudioConvertUtility::SourceBitRateL()
1.1527 + {
1.1528 + TUint bitRate;
1.1529 + User::LeaveIfError(iAudioControllerCustomCommands.GetSourceBitRate(bitRate));
1.1530 + return bitRate;
1.1531 + }
1.1532 +
1.1533 +TUint CMMFMdaAudioConvertUtility::SourceSampleRateL()
1.1534 + {
1.1535 + TUint sampleRate;
1.1536 + User::LeaveIfError(iAudioControllerCustomCommands.GetSourceSampleRate(sampleRate));
1.1537 + return sampleRate;
1.1538 + }
1.1539 +
1.1540 +TUid CMMFMdaAudioConvertUtility::SourceFormatL()
1.1541 + {
1.1542 + TUid format;
1.1543 + User::LeaveIfError(iAudioControllerCustomCommands.GetSourceFormat(format));
1.1544 + return format;
1.1545 + }
1.1546 +
1.1547 +TUint CMMFMdaAudioConvertUtility::SourceNumberOfChannelsL()
1.1548 + {
1.1549 + TUint numChannels;
1.1550 + User::LeaveIfError(iAudioControllerCustomCommands.GetSourceNumChannels(numChannels));
1.1551 + return numChannels;
1.1552 + }
1.1553 +
1.1554 +
1.1555 +void CMMFMdaAudioConvertUtility::GetSupportedConversionBitRatesL(RArray<TUint>& aSupportedBitRates)
1.1556 + {
1.1557 + iAudioControllerCustomCommands.GetSupportedSinkBitRatesL(aSupportedBitRates);
1.1558 + }
1.1559 +
1.1560 +void CMMFMdaAudioConvertUtility::GetSupportedConversionSampleRatesL(RArray<TUint>& aSupportedSampleRates)
1.1561 + {
1.1562 + User::LeaveIfError(iController.Prime());
1.1563 + iAudioControllerCustomCommands.GetSupportedSinkSampleRatesL(aSupportedSampleRates);
1.1564 + User::LeaveIfError(iController.Stop());
1.1565 + }
1.1566 +
1.1567 +void CMMFMdaAudioConvertUtility::GetSupportedConversionNumberOfChannelsL(RArray<TUint>& aSupportedNumChannels)
1.1568 + {
1.1569 + iAudioControllerCustomCommands.GetSupportedSinkNumChannelsL(aSupportedNumChannels);
1.1570 + }
1.1571 +
1.1572 +CMdaAudioConvertUtility* CMMFMdaAudioConvertUtility::Parent() const
1.1573 + {
1.1574 + ASSERT(iParent);
1.1575 + return static_cast<CMdaAudioConvertUtility*>(iParent);
1.1576 + }
1.1577 +
1.1578 +TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom)
1.1579 + {
1.1580 + return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom);
1.1581 + }
1.1582 +
1.1583 +TInt CMMFMdaAudioConvertUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2)
1.1584 + {
1.1585 + return iController.CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2);
1.1586 + }
1.1587 +
1.1588 +void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TDes8& aDataFrom, TRequestStatus& aStatus)
1.1589 + {
1.1590 + iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aDataFrom, aStatus);
1.1591 + }
1.1592 +
1.1593 +void CMMFMdaAudioConvertUtility::CustomCommandAsync(const TMMFMessageDestinationPckg& aDestination, TInt aFunction, const TDesC8& aDataTo1, const TDesC8& aDataTo2, TRequestStatus& aStatus)
1.1594 + {
1.1595 + iController.CustomCommandAsync(aDestination, aFunction, aDataTo1, aDataTo2, aStatus);
1.1596 + }
1.1597 +
1.1598 +const CMMFControllerImplementationInformation& CMMFMdaAudioConvertUtility::ControllerImplementationInformationL()
1.1599 + {
1.1600 + if (!iControllerImplementationInformation)
1.1601 + {
1.1602 + if (iControllerUid==KNullUid)
1.1603 + User::Leave(KErrNotReady);
1.1604 + iControllerImplementationInformation = CMMFControllerImplementationInformation::NewL(iControllerUid);
1.1605 + }
1.1606 + return *iControllerImplementationInformation;
1.1607 + }
1.1608 +
1.1609 +
1.1610 +void CMMFMdaAudioConvertUtility::Reset()
1.1611 + {
1.1612 + // Make sure any existing controller is closed.
1.1613 + Close();
1.1614 +
1.1615 + iSourceFormatUid = KNullUid;
1.1616 + iSinkFormatUid = KNullUid;
1.1617 + iSourceDataType = KMMFFourCCCodeNULL;
1.1618 + iSinkDataType = KMMFFourCCCodeNULL;
1.1619 + iSourceSampleRate = 0;
1.1620 + iSinkSampleRate = 0;
1.1621 + iSourceChannels = 0;
1.1622 + iSinkChannels = 0;
1.1623 + }
1.1624 +
1.1625 +
1.1626 +TInt CMMFMdaAudioConvertUtility::ControllerOpen()
1.1627 + {
1.1628 + TInt err = KErrNone;
1.1629 +
1.1630 + if(iSourceFormatUid != KNullUid)
1.1631 + TRAP(err, SetSourceFormatL(iSourceFormatUid));
1.1632 +
1.1633 + if(!err && iSinkFormatUid != KNullUid)
1.1634 + TRAP(err, SetDestinationFormatL(iSinkFormatUid));
1.1635 +
1.1636 + if(!err && iSourceDataType != KMMFFourCCCodeNULL)
1.1637 + {
1.1638 + TRAP(err, SetSourceDataTypeL(iSourceDataType));
1.1639 + }
1.1640 +
1.1641 + if(!err && iSinkDataType != KMMFFourCCCodeNULL)
1.1642 + {
1.1643 + TRAP(err, SetDestinationDataTypeL(iSinkDataType));
1.1644 + }
1.1645 +
1.1646 + // set the audio data settings ie sample rate & channels
1.1647 + if (!err && iSourceSampleRate != 0)
1.1648 + {
1.1649 + TRAP(err, SetSourceSampleRateL(iSourceSampleRate));
1.1650 + }
1.1651 +
1.1652 + if (!err && iSourceChannels != 0)
1.1653 + {
1.1654 + TRAP(err, SetSourceNumberOfChannelsL(iSourceChannels));
1.1655 + }
1.1656 +
1.1657 + if (!err && iSinkSampleRate != 0)
1.1658 + {
1.1659 + TRAP(err, SetDestinationSampleRateL(iSinkSampleRate));
1.1660 + }
1.1661 +
1.1662 + if (!err && iSinkChannels != 0)
1.1663 + {
1.1664 + TRAP(err, SetDestinationNumberOfChannelsL(iSinkChannels));
1.1665 + }
1.1666 +
1.1667 + //get the clip duration
1.1668 + if (!err)
1.1669 + {
1.1670 + iDuration = TTimeIntervalMicroSeconds(0);
1.1671 + err = iController.GetDuration(iDuration);
1.1672 + }
1.1673 +
1.1674 + if (err)
1.1675 + Close();
1.1676 + else
1.1677 + iState = CMdaAudioClipUtility::EOpen;
1.1678 +
1.1679 + return err;
1.1680 + }
1.1681 +
1.1682 +
1.1683 +void CMMFMdaAudioConvertUtility::ConfigureSourceSinkL(TMdaClipLocation* aPriLocation, TMdaClipLocation* aSecLocation)
1.1684 + {
1.1685 + TMMFDescriptorConfig srcDesCfg;
1.1686 + TMMFFileConfig srcFileCfg;
1.1687 + CBufFlat* srcCfgBuffer = NULL;
1.1688 + CMMFUrlParams* srcURLCfg = NULL;
1.1689 + TPtrC8 sourceCfg;
1.1690 + TUid sourceUid = KNullUid;
1.1691 +
1.1692 + TMMFDescriptorConfig dstDesCfg;
1.1693 + TMMFFileConfig dstFileCfg;
1.1694 + CBufFlat* dstCfgBuffer = NULL;
1.1695 + CMMFUrlParams* dstURLCfg = NULL;
1.1696 + TPtrC8 dstCfg;
1.1697 + TUid dstUid = KNullUid;
1.1698 +
1.1699 + TInt err = KErrNone;
1.1700 +
1.1701 + // setup the source config info
1.1702 + if (aPriLocation->Uid() == KUidMdaFileResLoc)
1.1703 + {//sink clip location is a file
1.1704 + TDesC& fileName = ((TMdaFileClipLocation*)aPriLocation)->iName;
1.1705 + srcFileCfg().iPath = fileName;
1.1706 + sourceCfg.Set(srcFileCfg);
1.1707 + sourceUid = KUidMmfFileSource;
1.1708 + }
1.1709 + else if (aPriLocation->Uid() == KUidMdaDesResLoc)
1.1710 + {//sink clip is a descriptor - pass down descriptor & thread id
1.1711 + TMdaDesClipLocation* srcLoc = (TMdaDesClipLocation*)aPriLocation;
1.1712 + srcDesCfg().iDes = srcLoc->iDes;
1.1713 + srcDesCfg().iDesThreadId = srcLoc->iThreadId;
1.1714 + sourceCfg.Set(srcDesCfg);
1.1715 + sourceUid = KUidMmfDescriptorSource;
1.1716 + }
1.1717 + else if (aPriLocation->Uid() == KUidMdaUrlResLoc)
1.1718 + {
1.1719 + TMdaUrlClipLocation* srcLoc = (TMdaUrlClipLocation*)aPriLocation;
1.1720 + srcURLCfg = CMMFUrlParams::NewLC(srcLoc->iUrl, srcLoc->iIapId);
1.1721 + srcCfgBuffer = srcURLCfg->ExternalizeToCBufFlatLC();
1.1722 + sourceCfg.Set(srcCfgBuffer->Ptr(0));
1.1723 + sourceUid = KUidMmfUrlSource;
1.1724 + }
1.1725 + else
1.1726 + {
1.1727 + err = KErrNotSupported;
1.1728 + }
1.1729 +
1.1730 + if (!err)
1.1731 + {
1.1732 + if (aSecLocation->Uid() == KUidMdaFileResLoc)
1.1733 + {//sink clip location is a file
1.1734 + TDesC& fileName = ((TMdaFileClipLocation*)aSecLocation)->iName;
1.1735 + dstFileCfg().iPath = fileName;
1.1736 + dstCfg.Set(dstFileCfg);
1.1737 + dstUid = KUidMmfFileSink;
1.1738 + }
1.1739 + else if (aSecLocation->Uid() == KUidMdaDesResLoc)
1.1740 + {//sink clip is a descriptor - pass down descriptor & thread id
1.1741 + TMdaDesClipLocation* desLoc = (TMdaDesClipLocation*)aSecLocation;
1.1742 + dstDesCfg().iDes = desLoc->iDes;
1.1743 + dstDesCfg().iDesThreadId = desLoc->iThreadId;
1.1744 + dstCfg.Set(dstDesCfg);
1.1745 + dstUid = KUidMmfDescriptorSink;
1.1746 + }
1.1747 + else if (aSecLocation->Uid() == KUidMdaUrlResLoc)
1.1748 + {
1.1749 + TMdaUrlClipLocation* desLoc = (TMdaUrlClipLocation*)aSecLocation;
1.1750 + dstURLCfg = CMMFUrlParams::NewLC(desLoc->iUrl, desLoc->iIapId);
1.1751 + dstCfgBuffer = dstURLCfg->ExternalizeToCBufFlatLC();
1.1752 + dstCfg.Set(dstCfgBuffer->Ptr(0));
1.1753 + dstUid = KUidMmfUrlSink;
1.1754 + }
1.1755 + else
1.1756 + {
1.1757 + err = KErrNotSupported;
1.1758 + }
1.1759 + }
1.1760 +
1.1761 + if (!err)
1.1762 + {
1.1763 + iFindAndOpenController->ConfigureSourceSink(
1.1764 + CMMFFindAndOpenController::TSourceSink(sourceUid, sourceCfg),
1.1765 + CMMFFindAndOpenController::TSourceSink(dstUid, dstCfg));
1.1766 + }
1.1767 +
1.1768 + if (dstCfgBuffer)
1.1769 + CleanupStack::PopAndDestroy(2); //dstCfgBuffer, dstURLCfg
1.1770 + if (srcCfgBuffer)
1.1771 + CleanupStack::PopAndDestroy(2); //srcCfgBuffer, srcURLCfg
1.1772 +
1.1773 + User::LeaveIfError(err);
1.1774 + }
1.1775 +
1.1776 +
1.1777 +TInt CMMFMdaAudioConvertUtility::SetThreadPriority(const TThreadPriority& aThreadPriority) const
1.1778 + {
1.1779 + return iController.SetThreadPriority(aThreadPriority);
1.1780 + }
1.1781 +
1.1782 +
1.1783 +
1.1784 +
1.1785 +