1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #ifndef __MDA_COMMON_AUDIO_H__
19 #define __MDA_COMMON_AUDIO_H__
21 // Standard EPOC32 includes
24 // Public Media Server includes
25 #include <mda/common/base.h>
26 #include <mda/common/resource.h>
27 //#include <mda/common/controller.h>
28 #include <mda/common/audio.hrh>
29 #include <mda/common/audiostream.hrh>
31 MDA_UID(KUidMdaPrioritySettings)
32 MDA_UID(KUidMdaMediaTypeAudio) // Audio data type Uid
33 MDA_UID(KUidMdaLocalSoundDevice) // Local audio stream location
34 MDA_UID(KUidMdaClipLocationMaxWriteLength)
35 MDA_UID(KUidMdaTelephonySoundDevice) // Telephony audio stream location
36 MDA_UID(KUidMdaClientPCMSoundDevice) // Client PCM audio stream location
37 MDA_UID(KUidMdaToneGeneratorDevice) // Tone Generator Device
38 MDA_UID(KUidMdaClipFormatWav) // Wav Audio Clip Format Uid
40 MDA_UID(KUidMdaAudioOutputStreamDevice) // Output Stream Device
42 MDA_UID(KUidMdaWavCodec) // Wav Codec Type Uid
43 MDA_UID(KUidMdaWavPcmCodec) // Wav Codec Uids
44 MDA_UID(KUidMdaWavAlawCodec)
45 MDA_UID(KUidMdaWavMulawCodec)
46 MDA_UID(KUidMdaWavImaAdpcmCodec)
49 MDA_UID(KUidMdaClipFormatAu) // Sun/Next "Au" Audio Clip format Uid
50 MDA_UID(KUidMdaAuCodec) // Sun/Next "Au" Audio Codec Type Uid
51 MDA_UID(KUidMdaAuMulawCodec) // Sun/Next "Au" Audio Codec Uids
52 MDA_UID(KUidMdaAu8PcmCodec)
53 MDA_UID(KUidMdaAu16PcmCodec)
54 MDA_UID(KUidMdaAuAlawCodec)
56 MDA_UID(KUidMdaClipFormatRawAudio) // Raw Audio Clip format Uid
57 MDA_UID(KUidMdaRawAudioCodec) // Raw Audio Codec Type Uid
58 MDA_UID(KUidMdaRawAudioMulawCodec)
59 MDA_UID(KUidMdaRawAudioAlawCodec)
60 MDA_UID(KUidMdaRawAudioS8PcmCodec) // Signed 8bit
61 MDA_UID(KUidMdaRawAudioU8PcmCodec) // Unsigned 8bit
62 MDA_UID(KUidMdaRawAudioSL16PcmCodec) // Signed little-endian 16bit
63 MDA_UID(KUidMdaRawAudioSB16PcmCodec) // Signed big-endian 16bit
64 MDA_UID(KUidMdaRawAudioUL16PcmCodec) // Unsigned little-endian 16bit
65 MDA_UID(KUidMdaRawAudioUB16PcmCodec) // Unsigned big-endian 16bit
67 MDA_UID(KUidMdaTelephonyStateQuery) // Telephony state query
68 MDA_UID(KUidMdaAudioStreamVolumeRamp) // Audio stream volume ramp
70 MDA_UID(KUidMdaDataTypeSettings)
72 MDA_UID(KUidMdaClipFormatRawAmr) // AMR Audio Clip Format Uid
73 MDA_UID(KUidMdaRawAmrCodec) // AMR Codec Type Uid
78 const TInt KMdaClipLocationMaxWriteLengthNone = -1;
86 Generic Audio Parameters
88 class TMdaPrioritySettings : public TMdaPackage
91 inline TMdaPrioritySettings();
94 Absolute priority of a client of the MMF Server.
96 Used by the policy server to determine which client should gain access to the sound device.
98 The priority which should be an integer in the range -100 to +100.
102 The priority preference that expresses the nature of the priority that can be none,
103 time (or speed), quality or both time and quality.
105 Values are known to the adaptation and will be iterpreted accordingly.
117 Base class for specific data type config packages
119 class TMdaDatatypeSettings : public TMdaPackage
122 inline TMdaDatatypeSettings(TUid aUid,TInt aDerivedSize);
125 inline TMdaDatatypeSettings::TMdaDatatypeSettings(TUid aUid,TInt aDerivedSize) :
126 TMdaPackage(KUidMdaDataTypeSettings,aUid,aDerivedSize) {}
132 The settings for audio data played through the media server.
134 These can be the settings for an audio clip, for streamed audio data, or can be the capabilities
135 of the sound device. The sample rate and number of channels apply to the audio sample, the maximum
136 volume applies to the output device and the volume setting can apply to either, depending on the
137 device. An object of this class is a public data member of class CMdaAudioType and also can be
138 passed to CMdaAudioOutputStream::Open().
142 @see CMdaAudioOutputStream::Open()
144 class TMdaAudioDataSettings : public TMdaDatatypeSettings
148 Audio capabilities, which include the sample rate and number of channels. The iCaps
149 member is a combination of these flags.
154 // Sampled audio capabilities
156 /** If specified, the sample rate iSampleRate is the only one supported. If not
157 specified, multiple sample rates may be supported.
159 ESampleRateFixed = 0x00000001,
161 /** If specified, all sample rates between the minimum and the maximum are supported.
163 ESampleRateAnyInRange = 0x00000002,
165 /** The audio sample supports a sample rate of 8.000KHz.
167 ESampleRate8000Hz = 0x00000010,
169 /** The audio sample supports a sample rate of 11.025KHz.
171 ESampleRate11025Hz = 0x00000040,
173 /** The audio sample supports a sample rate of 12.000KHz.
175 ESampleRate12000Hz = 0x00000080,
177 /** The audio sample supports a sample rate of 16.000KHz.
179 ESampleRate16000Hz = 0x00000100,
181 /** The audio sample supports a sample rate of 22.000KHz.
183 ESampleRate22050Hz = 0x00000400,
185 /** The audio sample supports a sample rate of 24.000KHz.
187 ESampleRate24000Hz = 0x00000800,
189 /** The audio sample supports a sample rate of 32.000KHz.
191 ESampleRate32000Hz = 0x00001000,
193 /** The audio sample supports a sample rate of 44.100KHz.
195 ESampleRate44100Hz = 0x00004000,
197 /** The audio sample supports a sample rate of 48.000KHz.
199 ESampleRate48000Hz = 0x00010000,
201 /** The audio sample supports a sample rate of 96.000KHz.
203 ESampleRate96000Hz = 0x00020000,
205 /** The audio sample supports a sample rate of 64.000KHz.
207 ESampleRate64000Hz = 0x00040000,
209 // Channel related - applies to sampled
211 /** The audio sample supports mono.
213 EChannelsMono = 0x02000000,
215 /** The audio sample supports stereo.
217 EChannelsStereo = 0x04000000,
221 ERoutingControl = 0x08000000,
223 /** True if data flow is synchronised with real time (e.g. stream)
225 ERealTime = 0x10000000
228 /** Mutually exclusive flags that specify whether audio data is sent to the local device (speakers)
229 or the network (phone line) or both. The iFlags member uses these flags.
234 /** The sound data is only sent to the network.
236 ENoLocalRouting = 0x00000001,
238 /** The sound data is only sent to the local device.
240 ENoNetworkRouting = 0x00000002
243 inline TMdaAudioDataSettings();
244 inline void Query(); // Call this when you just want to have caps and maxvolume filled
246 // Fixed values - must be queried
249 Specifies the capabilities of the audio sample. Its value is a combination of the flags
250 contained in the TAudioCaps enum.
255 The maximum volume of the audio device.
257 TInt iMaxVolume; // One means fixed volume (zero not valid)
261 The sample rate of the audio sample.
266 The number of channels for the audio sample.
271 The volume. Whether this applies to the audio device or to the audio sample is device-dependent.
276 The flags. Its value can be either of the flags contained in the TAudioFlags enum.
281 // Wav Config Packages
287 The format for .wav audio clips.
289 An object of this type can be passed to CMdaAudioRecorderUtility::OpenL() or CMdaAudioConvertUtility::OpenL().
291 class TMdaWavClipFormat : public TMdaClipFormat
294 inline TMdaWavClipFormat();
301 The base class for codecs used by .wav audio files.
303 An object derived from this class can be used to specify the compression algorithm to use when recording or
304 converting a .wav audio clip. When playing back a .wav clip, the codec is not specified: the media server
305 identifies the correct one to use.
307 class TMdaWavCodec : public TMdaPackage
310 inline TMdaWavCodec(); // Unknown type
312 inline TMdaWavCodec(TUid aUid,TInt aDerivedSize);
319 The codec for uncompressed 8 or 16 bit PCM .wav format sound data.
321 This codec copies the data unchanged from source to destination.
323 class TMdaPcmWavCodec : public TMdaWavCodec
328 Indicates whether the sound is sampled using 8 or 16 bits.
332 /** The sound is sampled using 8 bits.
336 /** The sound is sampled using 16 bits.
341 inline TMdaPcmWavCodec(TBits aBits=E16BitPcm);
344 Indicates whether the sound is sampled using 8 or 16 bits.
353 The codec for .wav audio data compressed using the A-Law algorithm.
355 class TMdaAlawWavCodec : public TMdaWavCodec
358 inline TMdaAlawWavCodec();
365 The codec for .wav audio data compressed using the mu-law algorithm.
367 class TMdaMulawWavCodec : public TMdaWavCodec
370 inline TMdaMulawWavCodec();
377 The codec for .wav audio data compressed using the IMA-ADPCM algorithm.
379 class TMdaImaAdpcmWavCodec : public TMdaWavCodec
382 inline TMdaImaAdpcmWavCodec();
386 // Sun/NeXT "Au" Config Packages
391 The format for .au audio clips.
393 An object of this type can be passed to CMdaAudioRecorderUtility::OpenL() or CMdaAudioConvertUtility::OpenL().
395 class TMdaAuClipFormat : public TMdaClipFormat
398 inline TMdaAuClipFormat();
405 The base class for codecs used by .au audio files.
407 An object derived from this class can be used to specify the compression algorithm to use when recording
408 or converting a .au audio clip (whose format is TMdaAuClipFormat). When playing back a .au clip, the
409 codec is not specified: the media server identifies the correct one to use.
411 class TMdaAuCodec : public TMdaPackage
414 inline TMdaAuCodec(); // Unknown type
416 inline TMdaAuCodec(TUid aUid,TInt aDerivedSize);
423 The codec for 8 bit PCM .au audio data.
425 class TMdaPcm8BitAuCodec : public TMdaAuCodec
428 inline TMdaPcm8BitAuCodec();
435 The codec for 16 bit PCM .au audio data.
437 class TMdaPcm16BitAuCodec : public TMdaAuCodec
440 inline TMdaPcm16BitAuCodec();
447 The codec for .au audio data compressed using the A-Law algorithm.
449 class TMdaAlawAuCodec : public TMdaAuCodec
452 inline TMdaAlawAuCodec();
459 The codec for .au audio data compressed using the mu-law algorithm.
461 class TMdaMulawAuCodec : public TMdaAuCodec
464 inline TMdaMulawAuCodec();
467 // Raw Audio Config Packages
472 Audio format for raw audio clips.
474 An object of this type can be passed to CMdaAudioRecorderUtility::OpenL() or CMdaAudioConvertUtility::OpenL().
476 class TMdaRawAudioClipFormat : public TMdaClipFormat
479 inline TMdaRawAudioClipFormat();
486 The base class for raw audio codecs.
488 An object derived from this class can be used to specify the algorithm to use when opening a
489 raw audio clip (whose format is TMdaRawAudioClipFormat).
491 Raw audio clips are have no header information, so that when opening one, the user must supply
492 a codec and a package containing the settings appropriate for the data in the clip.
494 @see TMdaRawAudioClipFormat
495 @see CMdaAudioConvertUtility::OpenL()
496 @see CMdaAudioRecorderUtility::OpenL()
498 class TMdaRawAudioCodec : public TMdaPackage
501 inline TMdaRawAudioCodec(); // Unknown type
503 inline TMdaRawAudioCodec(TUid aUid,TInt aDerivedSize);
510 The codec for raw audio data compressed using the mu-law algorithm.
512 class TMdaMulawRawAudioCodec : public TMdaRawAudioCodec
515 inline TMdaMulawRawAudioCodec();
522 The codec for raw audio data compressed using the A-Law algorithm.
524 class TMdaAlawRawAudioCodec : public TMdaRawAudioCodec
527 inline TMdaAlawRawAudioCodec();
534 The codec for signed 8 bit PCM raw audio data.
536 class TMdaS8PcmRawAudioCodec : public TMdaRawAudioCodec
539 inline TMdaS8PcmRawAudioCodec();
546 The codec for unsigned 8 bit PCM raw audio data.
548 class TMdaU8PcmRawAudioCodec : public TMdaRawAudioCodec
551 inline TMdaU8PcmRawAudioCodec();
558 The codec for signed little-endian 16 bit PCM raw audio data.
560 class TMdaSL16RawAudioCodec : public TMdaRawAudioCodec
563 inline TMdaSL16RawAudioCodec();
570 The codec for signed big-endian 16 bit PCM raw audio data.
572 class TMdaSB16RawAudioCodec : public TMdaRawAudioCodec
575 inline TMdaSB16RawAudioCodec();
582 The codec for unsigned little-endian 16 bit PCM raw audio data.
584 class TMdaUL16RawAudioCodec : public TMdaRawAudioCodec
587 inline TMdaUL16RawAudioCodec();
594 The codec for unsigned big-endian 16 bit PCM raw audio data.
596 class TMdaUB16RawAudioCodec : public TMdaRawAudioCodec
599 inline TMdaUB16RawAudioCodec();
606 Local Audio Stream Device
607 Control local microphone/speaker audio stream
608 May not function during telephone call
610 class TMdaLocalAudioDevice : public TMdaStreamDevice
613 inline TMdaLocalAudioDevice();
620 Telephony Audio Stream Device
621 Control telephony microphone+downlink/speaker+uplink audio stream
622 Only functional during telephone call
624 class TMdaTelephonyAudioDevice : public TMdaStreamDevice
627 inline TMdaTelephonyAudioDevice();
634 This class is used in a ResourceConfig on a telephony port
635 to determine the current state of telephony
637 class TMdaTelephonyStateQuery : public TMdaPackage
640 inline TMdaTelephonyStateQuery();
642 TBool iIsTelephonyActive;
649 Client PCM Audio Stream Device
650 Used to configure a 16bit PCM audio stream to/from client
652 class TMdaClientPCMAudioDevice : public TMdaStreamDevice
655 inline TMdaClientPCMAudioDevice();
663 Volume ramping control on audio stream devices
665 class TMdaAudioStreamVolumeRamp : public TMdaPackage
668 inline TMdaAudioStreamVolumeRamp();
670 TTimeIntervalMicroSeconds iDuration;
677 Default constructor. The member data is not initialised.
679 inline TMdaAudioDataSettings::TMdaAudioDataSettings() :
680 TMdaDatatypeSettings(KUidMdaMediaTypeAudio,sizeof(TMdaAudioDataSettings))
682 Mem::FillZ(&iSampleRate,sizeof(TInt)*4);
686 Sets the number of channels, the sample rate and the volume to KMdaUnknown (–1). Call this function when you
687 only want to have the iCaps and iMaxVolume members filled.
689 inline void TMdaAudioDataSettings::Query()
691 iChannels = KMdaUnknown;
692 iSampleRate = KMdaUnknown;
693 iVolume = KMdaUnknown;
694 }// Call this when you just want to have caps and maxvolume filled
697 The default constructor initialises the object so that it can be identified by the media server.
699 inline TMdaWavClipFormat::TMdaWavClipFormat() :
700 TMdaClipFormat(KUidMdaClipFormatWav,sizeof(TMdaWavClipFormat)) {}
703 The default constructor initialises the package so that it can be identified by the media server.
705 inline TMdaWavCodec::TMdaWavCodec() :
706 TMdaPackage(KUidMdaWavCodec,KNullUid,sizeof(TMdaWavCodec)) {}
708 inline TMdaWavCodec::TMdaWavCodec(TUid aUid, TInt aDerivedSize) :
709 TMdaPackage(KUidMdaWavCodec,aUid,aDerivedSize) {}
712 Constructs the package with a flag that indicates whether the sound is sampled using 8 or 16 bits.
715 Indicates whether the sound is sampled using 8 or 16 bits.
717 inline TMdaPcmWavCodec::TMdaPcmWavCodec(TBits aBits) :
718 TMdaWavCodec(KUidMdaWavPcmCodec,sizeof(TMdaPcmWavCodec)), iBits(aBits) {}
721 The default constructor initialises the package so that it can be identified by the media server.
723 inline TMdaAlawWavCodec::TMdaAlawWavCodec() :
724 TMdaWavCodec(KUidMdaWavAlawCodec,sizeof(TMdaAlawWavCodec)) {}
727 The default constructor initialises the object so that it can be identified by the media server.
729 inline TMdaMulawWavCodec::TMdaMulawWavCodec() :
730 TMdaWavCodec(KUidMdaWavMulawCodec,sizeof(TMdaMulawWavCodec)) {}
733 The default constructor initialises the package so that it can be identified by the media server.
735 inline TMdaImaAdpcmWavCodec::TMdaImaAdpcmWavCodec() :
736 TMdaWavCodec(KUidMdaWavImaAdpcmCodec,sizeof(TMdaImaAdpcmWavCodec)) {}
739 The default constructor initialises the object so that it can be identified by the media server.
741 inline TMdaAuClipFormat::TMdaAuClipFormat() :
742 TMdaClipFormat(KUidMdaClipFormatAu,sizeof(TMdaAuClipFormat)) {}
745 The default constructor initialises the package so that it can be identified by the media server.
747 inline TMdaAuCodec::TMdaAuCodec() :
748 TMdaPackage(KUidMdaAuCodec,KNullUid,sizeof(TMdaAuCodec)) {}
750 inline TMdaAuCodec::TMdaAuCodec(TUid aUid,TInt aDerivedSize) :
751 TMdaPackage(KUidMdaAuCodec,aUid,aDerivedSize) {}
754 The default constructor initialises the package so that it can be identified by the media server.
756 inline TMdaPcm16BitAuCodec::TMdaPcm16BitAuCodec() :
757 TMdaAuCodec(KUidMdaAu16PcmCodec,sizeof(TMdaPcm16BitAuCodec)) {}
760 The default constructor initialises the package so that it can be identified by the media server.
762 inline TMdaPcm8BitAuCodec::TMdaPcm8BitAuCodec() :
763 TMdaAuCodec(KUidMdaAu8PcmCodec,sizeof(TMdaPcm8BitAuCodec)) {}
766 The default constructor initialises the package so that it can be identified by the media server.
768 inline TMdaAlawAuCodec::TMdaAlawAuCodec() :
769 TMdaAuCodec(KUidMdaAuAlawCodec,sizeof(TMdaAlawAuCodec)) {}
772 The default constructor initialises the object so that it can be identified by the media server.
774 inline TMdaMulawAuCodec::TMdaMulawAuCodec() :
775 TMdaAuCodec(KUidMdaAuMulawCodec,sizeof(TMdaMulawAuCodec)) {}
778 The default constructor initialises the object so that it can be identified by the media server.
780 inline TMdaRawAudioClipFormat::TMdaRawAudioClipFormat() :
781 TMdaClipFormat(KUidMdaClipFormatRawAudio,sizeof(TMdaRawAudioClipFormat)) {}
784 The default constructor initialises the package so that it can be identified by the media server.
786 inline TMdaRawAudioCodec::TMdaRawAudioCodec() :
787 TMdaPackage(KUidMdaRawAudioCodec,KNullUid,sizeof(TMdaRawAudioCodec)) {}
789 inline TMdaRawAudioCodec::TMdaRawAudioCodec(TUid aUid,TInt aDerivedSize) :
790 TMdaPackage(KUidMdaRawAudioCodec,aUid,aDerivedSize) {}
793 The default constructor initialises the object so that it can be identified by the media server.
795 inline TMdaMulawRawAudioCodec::TMdaMulawRawAudioCodec() :
796 TMdaRawAudioCodec(KUidMdaRawAudioMulawCodec,sizeof(TMdaMulawRawAudioCodec)) {}
799 The default constructor initialises the package so that it can be identified by the media server.
801 inline TMdaAlawRawAudioCodec::TMdaAlawRawAudioCodec() :
802 TMdaRawAudioCodec(KUidMdaRawAudioAlawCodec,sizeof(TMdaAlawRawAudioCodec)) {}
805 The default constructor initialises the package so that it can be identified by the media server.
807 inline TMdaS8PcmRawAudioCodec::TMdaS8PcmRawAudioCodec() :
808 TMdaRawAudioCodec(KUidMdaRawAudioS8PcmCodec,sizeof(TMdaS8PcmRawAudioCodec)) {}
811 The default constructor initialises the package so that it can be identified by the media server.
813 inline TMdaU8PcmRawAudioCodec::TMdaU8PcmRawAudioCodec() :
814 TMdaRawAudioCodec(KUidMdaRawAudioU8PcmCodec,sizeof(TMdaU8PcmRawAudioCodec)) {}
817 The default constructor initialises the package so that it can be identified by the media server.
819 inline TMdaSL16RawAudioCodec::TMdaSL16RawAudioCodec() :
820 TMdaRawAudioCodec(KUidMdaRawAudioSL16PcmCodec,sizeof(TMdaSL16RawAudioCodec)) {}
823 The default constructor initialises the package so that it can be identified by the media server.
825 inline TMdaSB16RawAudioCodec::TMdaSB16RawAudioCodec() :
826 TMdaRawAudioCodec(KUidMdaRawAudioSB16PcmCodec,sizeof(TMdaSB16RawAudioCodec)) {}
829 The default constructor initialises the package so that it can be identified by the media server.
831 inline TMdaUL16RawAudioCodec::TMdaUL16RawAudioCodec() :
832 TMdaRawAudioCodec(KUidMdaRawAudioUL16PcmCodec,sizeof(TMdaUL16RawAudioCodec)) {}
835 The default constructor initialises the package so that it can be identified by the media server.
837 inline TMdaUB16RawAudioCodec::TMdaUB16RawAudioCodec() :
838 TMdaRawAudioCodec(KUidMdaRawAudioUB16PcmCodec,sizeof(TMdaUB16RawAudioCodec)) {}
840 inline TMdaLocalAudioDevice::TMdaLocalAudioDevice() :
841 TMdaStreamDevice(KUidMdaLocalSoundDevice,sizeof(TMdaLocalAudioDevice)) {}
843 inline TMdaTelephonyAudioDevice::TMdaTelephonyAudioDevice() :
844 TMdaStreamDevice(KUidMdaTelephonySoundDevice,sizeof(TMdaTelephonyAudioDevice)) {}
846 inline TMdaClientPCMAudioDevice::TMdaClientPCMAudioDevice() :
847 TMdaStreamDevice(KUidMdaClientPCMSoundDevice,sizeof(TMdaClientPCMAudioDevice)) {}
849 inline TMdaAudioStreamVolumeRamp::TMdaAudioStreamVolumeRamp() :
850 TMdaPackage(KUidMdaAudioStreamVolumeRamp,KUidMdaAudioStreamVolumeRamp,sizeof(TMdaAudioStreamVolumeRamp)) {}
852 inline TMdaTelephonyStateQuery::TMdaTelephonyStateQuery() :
853 TMdaPackage(KUidMdaTelephonySoundDevice,KUidMdaTelephonyStateQuery,sizeof(TMdaTelephonyStateQuery)) {}
855 inline TMdaPrioritySettings::TMdaPrioritySettings() :
856 TMdaPackage(KUidMdaPrioritySettings,KUidMdaPrioritySettings,sizeof(TMdaPrioritySettings)) {}