bluetoothmgmt/bluetoothclientlib/avlib/avdtpHeaderCompressionCapability.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 <bluetooth/logger.h>
       
    22 #include <bluetoothav.h>
       
    23 #include "gavdpinterface.h"
       
    24 
       
    25 #ifdef __FLOG_ACTIVE
       
    26 _LIT8(KLogComponent, LOG_COMPONENT_AVLIB);
       
    27 #endif
       
    28 
       
    29 #ifdef _DEBUG
       
    30 PANICCATEGORY("headcomp");
       
    31 #endif
       
    32 
       
    33 const TUint8 KBackChannelBitMask= 0x80;
       
    34 const TUint8 KMediaBitMask		= 0x40;
       
    35 const TUint8 KRecoveryBitMask	= 0x20;
       
    36 
       
    37 EXPORT_C TAvdtpHeaderCompressionCapabilities::TAvdtpHeaderCompressionCapabilities()
       
    38 : TAvdtpServiceCapability(EServiceCategoryHeaderCompression, KServiceCatLOSCHeaderCompression)
       
    39 	{
       
    40 	}
       
    41 	
       
    42 EXPORT_C /*virtual*/ TInt TAvdtpHeaderCompressionCapabilities::AsProtocol(RBuf8& aBuffer) const
       
    43 	{
       
    44 	TInt ret = AddHeader(aBuffer);
       
    45 	
       
    46 	if (ret==KErrNone)
       
    47 		{
       
    48 		TUint8 capabilityByte =0; // see fig8.52 AVDTP v1.0
       
    49 		capabilityByte |= BackChannel() ? KBackChannelBitMask : 0;
       
    50 		capabilityByte |= Media() ? KMediaBitMask : 0;
       
    51 		capabilityByte |= Recovery() ? KRecoveryBitMask : 0;
       
    52 		aBuffer.Append(capabilityByte);
       
    53 		}
       
    54 	return ret;	
       
    55 	}
       
    56 
       
    57 /*virtual*/	void TAvdtpHeaderCompressionCapabilities::Parse(const TDesC8& aPtr)
       
    58 	{
       
    59 	ASSERT_DEBUG(aPtr.Length()==1);	// the parse broke if this is not true
       
    60 	iBackChannel = (aPtr[0] & KBackChannelBitMask) ? ETrue : EFalse;
       
    61 	iMedia = (aPtr[0] & KMediaBitMask) ? ETrue : EFalse;
       
    62 	iRecovery = (aPtr[0] & KRecoveryBitMask) ? ETrue : EFalse;
       
    63 	}
       
    64 
       
    65 	
       
    66 EXPORT_C TBool TAvdtpHeaderCompressionCapabilities::Media() const
       
    67 	{
       
    68 	return iMedia;
       
    69 	}
       
    70 	
       
    71 EXPORT_C TBool TAvdtpHeaderCompressionCapabilities::Recovery() const
       
    72 	{
       
    73 	return iRecovery;
       
    74 	}
       
    75 	
       
    76 EXPORT_C TBool TAvdtpHeaderCompressionCapabilities::BackChannel() const
       
    77 	{
       
    78 	return iBackChannel;
       
    79 	}
       
    80 	
       
    81 EXPORT_C void TAvdtpHeaderCompressionCapabilities::SetCapabilities(TBool aMedia,TBool aRecovery,TBool aBackChannel)
       
    82 	{
       
    83 	iMedia=aMedia;
       
    84 	iRecovery=aRecovery;
       
    85 	iBackChannel=aBackChannel;
       
    86 	}