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