bluetoothappprofiles/avrcp/remconbeareravrcp/src/avrcpsdputils.cpp
changeset 70 f5508c13dfe0
parent 67 16e4b9007960
child 71 083fd884d7dd
equal deleted inserted replaced
67:16e4b9007960 70:f5508c13dfe0
     1 // Copyright (c) 2008-2010 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 #include <bt_sock.h>
       
    17 
       
    18 #include "avrcpsdputils.h"
       
    19 
       
    20 void AvrcpSdpUtils::CreateServiceRecordL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TBool aTarget, TUint16 aProfileVersion)
       
    21 	{
       
    22 	if(!aTarget)
       
    23 		{
       
    24 		// New service record with service class attribute containing
       
    25 		// 0x110e (for A/V Remote Control) 
       
    26 		CSdpAttrValueDES* serviceClassUuids = CSdpAttrValueDES::NewDESL(NULL);
       
    27 		CleanupStack::PushL(serviceClassUuids);
       
    28 		
       
    29 		if(aProfileVersion == AvrcpSdp::KAvrcpProfileVersion13)
       
    30 			{
       
    31 			serviceClassUuids->StartListL()
       
    32 					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID)))
       
    33 			->EndListL();
       
    34 			}
       
    35 		else
       
    36 			{
       
    37 			serviceClassUuids->StartListL()
       
    38 					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlUUID)))
       
    39 					->BuildUUIDL(TUUID(TUint16(KAVRemoteControlControllerUUID)))
       
    40 			->EndListL();
       
    41 			}
       
    42 		
       
    43 		aSdpDatabase.CreateServiceRecordL(*serviceClassUuids, aRecHandle);
       
    44 		CleanupStack::PopAndDestroy(serviceClassUuids);
       
    45 
       
    46 		aSdpDatabase.UpdateAttributeL(aRecHandle,
       
    47 			KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
       
    48 			AvrcpSdp::KAvrcpControllerServiceName
       
    49 			);
       
    50 		}
       
    51 	else
       
    52 		{
       
    53 		// New service record with service class attribute containing
       
    54 		// 0x110c (for A/V Remote Control Target) 
       
    55 		aSdpDatabase.CreateServiceRecordL(KAVRemoteControlTargetUUID, aRecHandle);
       
    56 		
       
    57 		aSdpDatabase.UpdateAttributeL(aRecHandle,
       
    58 			KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName,
       
    59 			AvrcpSdp::KAvrcpTargetServiceName
       
    60 			);
       
    61 		}
       
    62 
       
    63 	aSdpDatabase.UpdateAttributeL(aRecHandle,
       
    64 		KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetProviderName,
       
    65 		AvrcpSdp::KAvrcpProviderName
       
    66 		);
       
    67 	aSdpDatabase.UpdateAttributeL(aRecHandle,
       
    68 		KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription,
       
    69 		AvrcpSdp::KAvrcpServiceDescription
       
    70 		);	
       
    71 	}
       
    72 
       
    73 void AvrcpSdpUtils::UpdateProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProtocolVersion)
       
    74 	{
       
    75 	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
       
    76 	CleanupStack::PushL(attrValDES);
       
    77 	attrValDES->StartListL()
       
    78 		->BuildDESL()->StartListL()
       
    79 			->BuildUUIDL(TUUID(TUint16(KL2CAP)))					// L2CAP
       
    80 			->BuildUintL(TSdpIntBuf<TUint16>(KAVCTP))				// PSM = AVCTP
       
    81 		->EndListL()
       
    82 		->BuildDESL()->StartListL()
       
    83 			->BuildUUIDL(TUUID(TUint16(KAVCTP)))					// AVCTP
       
    84 			->BuildUintL(TSdpIntBuf<TUint16>(aProtocolVersion))
       
    85 		->EndListL()
       
    86 	->EndListL();
       
    87 	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdProtocolDescriptorList, *attrValDES);
       
    88 	CleanupStack::PopAndDestroy(attrValDES);
       
    89 	}
       
    90 
       
    91 void AvrcpSdpUtils::UpdateAdditionalProtocolDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle)
       
    92 	{
       
    93 	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
       
    94 	CleanupStack::PushL(attrValDES);
       
    95 	attrValDES->StartListL()
       
    96 		->BuildDESL()->StartListL()
       
    97 			->BuildUUIDL(TUUID(TUint16(KL2CAP)))				// L2CAP
       
    98 			->BuildUintL(TSdpIntBuf<TUint16>(0x1b))				// PSM = AVCTP_browse
       
    99 		->EndListL()
       
   100 		->BuildDESL()->StartListL()
       
   101 			->BuildUUIDL(TUUID(TUint16(KAVCTP)))					// AVCTP
       
   102 			->BuildUintL(TSdpIntBuf<TUint16>(AvrcpSdp::KAvctpProtocolVersion13))// 0x0103
       
   103 		->EndListL()
       
   104 	->EndListL();
       
   105 	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdAdditionalProtocolDescriptorList, *attrValDES);
       
   106 	CleanupStack::PopAndDestroy(attrValDES);
       
   107 	}
       
   108 
       
   109 void AvrcpSdpUtils::UpdateBrowseListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle)
       
   110 	{
       
   111 	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
       
   112 	CleanupStack::PushL(attrValDES);
       
   113 	attrValDES->StartListL()
       
   114 			  	->BuildUUIDL(TUUID(TUint16(KPublicBrowseGroupUUID)))	 // Public browse group										
       
   115 		      	->EndListL();
       
   116 	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBrowseGroupList, *attrValDES);
       
   117 	CleanupStack::PopAndDestroy(attrValDES);
       
   118 	}
       
   119 
       
   120 void AvrcpSdpUtils::UpdateProfileDescriptorListL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, TUint16 aProfileVersion)
       
   121 	{
       
   122 	CSdpAttrValueDES *attrValDES = CSdpAttrValueDES::NewDESL(0);
       
   123 	CleanupStack::PushL(attrValDES);
       
   124 	attrValDES->StartListL()
       
   125 		->BuildDESL()->StartListL()
       
   126 			//In the profile descriptor list the Control UUID is used 
       
   127 			//for BOTH controller and target
       
   128 			->BuildUUIDL(KAVRemoteControlUUID) 
       
   129 			->BuildUintL(TSdpIntBuf<TUint16>(aProfileVersion))
       
   130 		->EndListL()
       
   131 	->EndListL();
       
   132 	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdBluetoothProfileDescriptorList, *attrValDES);
       
   133 	CleanupStack::PopAndDestroy(attrValDES);
       
   134 	}
       
   135 
       
   136 void AvrcpSdpUtils::UpdateSupportedFeaturesL(RSdpDatabase& aSdpDatabase, TSdpServRecordHandle& aRecHandle, AvrcpSdp::TRecordType aType, TUint16 aFeatures)
       
   137 	{
       
   138 	// Supported Features
       
   139 	// For both target and controller roles if we support that role then
       
   140 	// indicate support for all categories that are available within that
       
   141 	// role.												
       
   142 	CSdpAttrValue* attrVal = NULL;
       
   143 	TSdpIntBuf<TUint16> featureBuf = (aType==AvrcpSdp::ERemoteControl) ? AvrcpSdp::KAvrcpBaseCtFeatures | aFeatures : AvrcpSdp::KAvrcpBaseTgFeatures | aFeatures;
       
   144 	attrVal = CSdpAttrValueUint::NewUintL(featureBuf); 
       
   145 	CleanupStack::PushL(attrVal);
       
   146 	aSdpDatabase.UpdateAttributeL(aRecHandle, KSdpAttrIdSupportedFeatures, *attrVal);
       
   147 	CleanupStack::PopAndDestroy(attrVal);
       
   148 	}