bluetoothmgmt/bluetoothclientlib/avlib/avdtpSBCCodecCapability.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 // Copyright (c) 2003-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 /**
       
    17  @file
       
    18  @publishedPartner
       
    19 */
       
    20 
       
    21 #include <bluetoothav.h>
       
    22 #include "gavdpinterface.h"
       
    23 #include "avdtpSBCCodecCapability.h"
       
    24 
       
    25 /**
       
    26 Default constructor for SBC codec details
       
    27 */
       
    28 EXPORT_C TSBCCodecCapabilities::TSBCCodecCapabilities()
       
    29 : TAvdtpMediaCodecCapabilities(SymbianBluetoothAV::EAvdtpMediaTypeAudio,
       
    30 								SymbianBluetoothAV::EAudioCodecSBC,
       
    31 								KServiceCatLOSCSBCCodec)
       
    32 	{
       
    33 	}
       
    34 
       
    35 /**
       
    36 @internalTechnology
       
    37 */	
       
    38 EXPORT_C /*virtual*/ TInt TSBCCodecCapabilities::AsProtocol(RBuf8& aBuffer) const
       
    39 	{
       
    40 	using namespace SymbianBluetoothAV;
       
    41 
       
    42 	TInt ret = AddHeader(aBuffer);
       
    43 	if (ret == KErrNone)
       
    44 		{		
       
    45 		aBuffer.Append(static_cast<TChar>(iMediaType));
       
    46 		aBuffer.Append(static_cast<TChar>(iMediaCodecType));
       
    47 
       
    48 		TUint8 octet = (iSamplingFrequencies << KSBCIESampFreqOffset) |
       
    49 					   (iChannelModes & KSBCIEChModeMask);
       
    50 		
       
    51 		aBuffer.Append(static_cast<TChar>(octet));
       
    52 		
       
    53 		octet = (iBlockLengths << KSBCIEBlockLenOffset) |
       
    54 			    ((iSubbands & KSBCIESubbandsMask) << KSBCIESubbandsOffset) |
       
    55 			    (iAllocationMethod & KSBCIEAllocMethMask);
       
    56 		
       
    57 		aBuffer.Append(static_cast<TChar>(octet));
       
    58 		
       
    59 		aBuffer.Append(static_cast<TChar>(iMinimumBitpoolValue));
       
    60 		aBuffer.Append(static_cast<TChar>(iMaximumBitpoolValue));
       
    61 		}
       
    62 		
       
    63 	return ret;
       
    64 
       
    65 	}
       
    66 	
       
    67 /**
       
    68 @internalTechnology
       
    69 */	
       
    70 EXPORT_C /*virtual*/ void TSBCCodecCapabilities::Parse(const TDesC8& aPtr)
       
    71 	{
       
    72 	TInt ptrLength = aPtr.Length();
       
    73 #ifdef _DEBUG
       
    74 	_LIT(KSBCCodecCapabilitiesPanic, "SBCConfigPanic");
       
    75 #endif
       
    76 	__ASSERT_DEBUG(ptrLength>=6, User::Panic(KSBCCodecCapabilitiesPanic, 0));
       
    77 	
       
    78 	// parse the media type and codec type via base-class
       
    79 	TAvdtpMediaCodecCapabilities::Parse(aPtr);
       
    80 	
       
    81 	iSamplingFrequencies = 0;
       
    82 	iChannelModes = 0;
       
    83 	iBlockLengths = 0;
       
    84 	iSubbands = 0;
       
    85 	iAllocationMethod = 0;
       
    86 	iMinimumBitpoolValue = 0;
       
    87 	iMaximumBitpoolValue = 0;
       
    88 	
       
    89 	//set the values according to the length of the package
       
    90 	switch(ptrLength) {
       
    91 		case 6:
       
    92 			iMaximumBitpoolValue = static_cast<TInt>(aPtr[5]);
       
    93 		
       
    94 		case 5:
       
    95 			iMinimumBitpoolValue = static_cast<TInt>(aPtr[4]);
       
    96 		
       
    97 		case 4:
       
    98 			iBlockLengths = static_cast<TSBCBlockLengthBitmask>(aPtr[3]>>KSBCIEBlockLenOffset);
       
    99 			iSubbands = static_cast<TSBCSubbandsBitmask>((aPtr[3]>>KSBCIESubbandsOffset)&KSBCIESubbandsMask);
       
   100 			iAllocationMethod = static_cast<TSBCAllocationMethodBitmask>(aPtr[3]&KSBCIEAllocMethMask);
       
   101 		
       
   102 		case 3:
       
   103 			iSamplingFrequencies = static_cast<TSBCSamplingFrequencyBitmask>(aPtr[2]>>KSBCIESampFreqOffset);
       
   104 			iChannelModes = static_cast<TSBCChannelModeBitmask>(aPtr[2]&KSBCIEChModeMask);
       
   105 		
       
   106 		default:
       
   107 			break;
       
   108 		}
       
   109 	}
       
   110 	
       
   111 /**
       
   112 Get the SBC sampling frequencies
       
   113 @return bitmask of supported sampling frequencies
       
   114 */	
       
   115 EXPORT_C TSBCSamplingFrequencyBitmask TSBCCodecCapabilities::SamplingFrequencies() const
       
   116 	{
       
   117 	return iSamplingFrequencies;
       
   118 	}
       
   119 
       
   120 /**
       
   121 Set the SBC sampling frequencies
       
   122 @param aSampFreq bitmask of supported sampling frequencies
       
   123 */	
       
   124 EXPORT_C void TSBCCodecCapabilities::SetSamplingFrequencies(TSBCSamplingFrequencyBitmask aSampFreq)
       
   125 	{
       
   126 	iSamplingFrequencies = aSampFreq;
       
   127 	}
       
   128 	
       
   129 /**
       
   130 Get the SBC channel modes
       
   131 @return bitmask of supported channel modes
       
   132 */	
       
   133 EXPORT_C TSBCChannelModeBitmask TSBCCodecCapabilities::ChannelModes() const
       
   134 	{
       
   135 	return iChannelModes;
       
   136 	}
       
   137 	
       
   138 /**
       
   139 Set the SBC channel modes
       
   140 @param aChModes bitmask of supported channel modes
       
   141 */	
       
   142 EXPORT_C void TSBCCodecCapabilities::SetChannelModes(TSBCChannelModeBitmask aChModes)
       
   143 	{
       
   144 	iChannelModes = aChModes;
       
   145 	}
       
   146 	
       
   147 /**
       
   148 Get the SBC block lengths
       
   149 @return bitmask of supported block lengths
       
   150 */	
       
   151 EXPORT_C TSBCBlockLengthBitmask TSBCCodecCapabilities::BlockLengths() const
       
   152 	{
       
   153 	return iBlockLengths;
       
   154 	}
       
   155 	
       
   156 /**
       
   157 Set the SBC block lengths
       
   158 @param aBlockLens bitmask of supported block lengths
       
   159 */	
       
   160 EXPORT_C void TSBCCodecCapabilities::SetBlockLengths(TSBCBlockLengthBitmask aBlockLens)
       
   161 	{
       
   162 	iBlockLengths=aBlockLens;
       
   163 	}
       
   164 	
       
   165 /**
       
   166 Get the SBC subbands
       
   167 @return bitmask of supported subbands
       
   168 */	
       
   169 EXPORT_C TSBCSubbandsBitmask TSBCCodecCapabilities::Subbands() const
       
   170 	{
       
   171 	return iSubbands;
       
   172 	}
       
   173 	
       
   174 /**
       
   175 Set the SBC subbands
       
   176 @param aSubbands bitmask of supported subbands
       
   177 */	
       
   178 EXPORT_C void TSBCCodecCapabilities::SetSubbands(TSBCSubbandsBitmask aSubbands)
       
   179 	{
       
   180 	iSubbands = aSubbands;
       
   181 	}
       
   182 	
       
   183 /**
       
   184 Get the SBC allocation methods
       
   185 @return bitmask of supported allocation methods
       
   186 */	
       
   187 EXPORT_C TSBCAllocationMethodBitmask TSBCCodecCapabilities::AllocationMethods() const
       
   188 	{
       
   189 	return iAllocationMethod;
       
   190 	}
       
   191 	
       
   192 /**
       
   193 Set the SBC allocation methods
       
   194 @param aAllocMeths of supported allocation methods
       
   195 */	
       
   196 EXPORT_C void TSBCCodecCapabilities::SetAllocationMethods(TSBCAllocationMethodBitmask aAllocMeths)
       
   197 	{
       
   198 	iAllocationMethod = aAllocMeths;
       
   199 	}
       
   200 	
       
   201 /**
       
   202 Get the SBC minimum bitpool value
       
   203 @return minimum bitpool value
       
   204 */	
       
   205 EXPORT_C TInt TSBCCodecCapabilities::MinBitpoolValue() const
       
   206 	{
       
   207 	return iMinimumBitpoolValue;
       
   208 	}
       
   209 	
       
   210 /**
       
   211 Set the SBC minimum bitpool value
       
   212 @param aMinBP minimum bitpool value
       
   213 */	
       
   214 EXPORT_C void TSBCCodecCapabilities::SetMinBitpoolValue(TInt aMinBP)
       
   215 	{
       
   216 	iMinimumBitpoolValue = aMinBP;
       
   217 	}
       
   218 	
       
   219 /**
       
   220 Get the SBC maximum bitpool value
       
   221 @return maximum bitpool value
       
   222 */	
       
   223 EXPORT_C TInt TSBCCodecCapabilities::MaxBitpoolValue() const
       
   224 	{
       
   225 	return iMaximumBitpoolValue;
       
   226 	}
       
   227 	
       
   228 /**
       
   229 Set the SBC maximum bitpool value
       
   230 @param aMaxBP maximum bitpool value
       
   231 */	
       
   232 EXPORT_C void TSBCCodecCapabilities::SetMaxBitpoolValue(TInt aMaxBP)
       
   233 	{
       
   234 	iMaximumBitpoolValue = aMaxBP;
       
   235 	}
       
   236