os/mm/devsound/sounddevbt/src/RoutingSoundDevice/MMFBtRoutingSoundDevice.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __MMFBTROUTINGSOUNDDEVICE_H__
    17 #define __MMFBTROUTINGSOUNDDEVICE_H__
    18 
    19 #include <e32base.h>
    20 #include <mmf/common/mmfutilities.h>
    21 #include <mmf/server/sounddevice.h>
    22 
    23 #include <mdasound.h>
    24 
    25 #include "A2dpBTHeadsetAudioIfClient.h"
    26 #include "MmfBtRoutingPrioritySettings.h"
    27 
    28 /**
    29  * TRange - primarily used to store bounds for a range of sample rates.
    30  * @internalComponent
    31  */
    32 class TRange
    33 	{
    34 public:
    35 	TUint iLow;
    36 	TUint iHigh;
    37 	};
    38 
    39 /**
    40  *  Routing sound play device
    41  *  @internalComponent
    42  */
    43 class CRoutingSoundPlayDevice : public CBase
    44 	{ 
    45 public:	
    46 	IMPORT_C static CRoutingSoundPlayDevice* NewL();
    47 	~CRoutingSoundPlayDevice();
    48 	
    49 	IMPORT_C void Initialize(TUid aDeviceUid,
    50 							const TDesC8& aDeviceConfig,
    51 							TRequestStatus& aStatus);
    52 	IMPORT_C void CancelInitialize(TUid aDeviceUid);
    53 	IMPORT_C void OpenDevice(TUid aDeviceUid, TRequestStatus& aStatus);
    54 	IMPORT_C void CancelOpenDevice(TUid aDeviceUid);
    55 	IMPORT_C void CloseDevice(TUid aDeviceUid, TRequestStatus& aStatus);
    56 	IMPORT_C TInt GetSupportedSampleRates(RArray<TUint>& aSupportedDiscreteRates, RArray<TRange>& aSupportedRateRanges);
    57 	IMPORT_C TInt GetSupportedChannels(RArray<TUint>& aSupportedChannels, TMMFStereoSupport& aStereoSupport);
    58 	IMPORT_C TInt GetSupportedDataTypes(RArray<TFourCC>& aSupportedDataTypes);
    59 	IMPORT_C TInt SetDataType(const TFourCC& aDataType);
    60 	IMPORT_C TInt SetSampleRate(TUint aSampleRate);
    61 	IMPORT_C TInt SetChannels(TUint aChannels, TMMFStereoSupport aStereoSupport);
    62 	IMPORT_C TInt SetBufferSize(TUint aBufferSize);
    63 	IMPORT_C void FlushBuffer();
    64 	IMPORT_C void NotifyError(TRequestStatus& aStatus);
    65 	IMPORT_C void CancelNotifyError();	
    66 	IMPORT_C TUint Volume() const;
    67 	IMPORT_C TInt SetVolume(TUint aVolume);
    68 	IMPORT_C void PlayData(const TDesC8& aData, TRequestStatus& aStatus);
    69 	IMPORT_C void CancelPlayData();
    70 	IMPORT_C TUint BytesPlayed();
    71 	IMPORT_C TInt ResetBytesPlayed();
    72 	IMPORT_C TInt PauseBuffer();
    73 	IMPORT_C TInt ResumePlaying();
    74 	IMPORT_C TInt Handle() const;
    75 protected:	
    76 	CRoutingSoundPlayDevice();
    77 	void ConstructL();
    78 private:
    79 	RMdaDevSound iSpeakerDevice;
    80 	RA2dpBTHeadsetAudioInterface iBTDevice;
    81 	TUid iDeviceUid;
    82 	TBTDevAddr iBTAddress;
    83 	TUint iSampleRate;
    84 	TUint iChannels;
    85 	TMMFStereoSupport iStereoSupport;
    86 	TUint iBufferSize;
    87 
    88 	TRequestStatus* iInitializeStatus;
    89 	TRequestStatus* iOpenDeviceStatus;
    90 	TRequestStatus* iCloseDeviceStatus;
    91 	};
    92 
    93 
    94 
    95 /**
    96  *  Routing sound record device
    97  *  @internalComponent
    98  */
    99 class CRoutingSoundRecordDevice : public CBase
   100 	{
   101 public:
   102 	IMPORT_C static CRoutingSoundRecordDevice* NewL();
   103 	IMPORT_C ~CRoutingSoundRecordDevice();
   104 	
   105 	IMPORT_C void Initialize(TUid aDeviceUid,
   106 							const TDesC8& aDeviceConfig,
   107 							TRequestStatus& aStatus);
   108 	IMPORT_C void CancelInitialize(TUid aDeviceUid);
   109 	IMPORT_C void OpenDevice(TUid aDeviceUid, TRequestStatus& aStatus);
   110 	IMPORT_C void CancelOpenDevice(TUid aDeviceUid);
   111 	IMPORT_C void CloseDevice(TUid aDeviceUid, TRequestStatus& aStatus);
   112 	IMPORT_C TInt GetSupportedSampleRates(RArray<TUint>& aSupportedDiscreteRates, RArray<TRange>& aSupportedRateRanges);
   113 	IMPORT_C TInt GetSupportedChannels(RArray<TUint>& aSupportedChannels, TMMFStereoSupport& aStereoSupport);
   114 	IMPORT_C TInt SetSampleRate(TUint aSampleRate);
   115 	IMPORT_C TInt SetChannels(TUint aChannels, TMMFStereoSupport aStereoSupport);
   116 	IMPORT_C TInt SetBufferSize(TUint aBufferSize);
   117 	IMPORT_C void FlushBuffer();
   118 	IMPORT_C void NotifyError(TRequestStatus& aStatus);
   119 	IMPORT_C void CancelNotifyError();
   120 	IMPORT_C TUint Gain() const;
   121 	IMPORT_C TInt SetGain(TUint aGain);
   122 	IMPORT_C void RecordData(TDes8& aData, TRequestStatus& aStatus);
   123 	IMPORT_C void CancelRecordData();
   124 	IMPORT_C TUint BytesRecorded();
   125 	IMPORT_C TInt Handle() const;
   126 	
   127 protected:
   128 	void ConstructL();
   129 	CRoutingSoundRecordDevice();
   130 private:
   131 	// although the microphone is the only device for now, there may be
   132 	// a BT microphone in the future, so keep the device uid
   133 	RMdaDevSound iInputDevice;
   134 	TUid iDeviceUid;
   135 	TUint iSampleRate;
   136 	TUint iChannels;
   137 	TMMFStereoSupport iStereoSupport;
   138 	TUint iBufferSize;
   139 
   140 	TRequestStatus* iOpenDeviceStatus;	
   141 	};
   142 
   143 
   144 #endif // __MMFBTROUTINGSOUNDDEVICE_H__
   145