bluetoothmgmt/bluetoothclientlib/avlib/avdtpContentProtectionCapability.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 31 Aug 2010 16:20:16 +0300
branchRCL_3
changeset 23 5b153be919d4
parent 0 29b1cd4cb562
permissions -rw-r--r--
Revision: 201031 Kit: 201035

// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
//

/**
 @file
 @publishedPartner
*/

#include <bluetoothav.h>
#include "gavdpinterface.h"

EXPORT_C TAvdtpContentProtectionCapabilities::TAvdtpContentProtectionCapabilities()
: TAvdtpServiceCapability(EServiceCategoryContentProtection),
KMinContentProtectionLOSC(2)
	{
	}

EXPORT_C TUint16 TAvdtpContentProtectionCapabilities::ContentProtectionType() const
	{
	return iCPType;
	}
	
EXPORT_C void TAvdtpContentProtectionCapabilities::SetContentProtectionType(TUint16 aCPType)
	{
	iCPType = aCPType;
	}
	
EXPORT_C const TDesC8& TAvdtpContentProtectionCapabilities::ContentProtectionData() const
	{
	return iCPData;
	}
	
EXPORT_C void TAvdtpContentProtectionCapabilities::SetContentProtectionData(const TDesC8& aCPData)
	{
	iCPData.Copy(aCPData);
	}
		
EXPORT_C /*virtual*/ TInt TAvdtpContentProtectionCapabilities::AsProtocol(RBuf8& aBuffer) const
	{
	// must set LOSC before adding header
	iLOSC = KMinContentProtectionLOSC + iCPData.Length(); // length of CPType+CPData
	
	TInt ret = AddHeader(aBuffer);
	if (ret == KErrNone)
		{
		aBuffer.Append(reinterpret_cast<const TUint8*>(&iCPType), KMinContentProtectionLOSC);
		aBuffer.Append(iCPData);
		}
	return ret;
	}

EXPORT_C void TAvdtpContentProtectionCapabilities::Parse(const TDesC8& aConfig)
	{
	iCPType = LittleEndian::Get16(aConfig.Ptr());
	iCPData = aConfig.Right(aConfig.Length()-2);
	}