bluetoothapitest/bluetoothsvs/T_BTUserAPI/src/T_NonSBCCodecCapabilitiesData.cpp
changeset 0 29b1cd4cb562
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include "bluetoothav.h"
       
    19 
       
    20 //	User Includes
       
    21 #include "T_AvdtpServiceCapabilityData.h"
       
    22 #include "T_AvdtpMediaCodecCapabilitiesData.h"
       
    23 #include "T_NonSBCCodecCapabilitiesChild.h"
       
    24 #include "T_NonSBCCodecCapabilitiesData.h"
       
    25 #include "T_BTUtil.h"
       
    26 
       
    27 /*@{*/
       
    28 //Parameters
       
    29 _LIT(KMediaCodecType,				"mediacodectype");
       
    30 _LIT(KMediaType,					"mediatype");
       
    31 
       
    32 //Commands
       
    33 _LIT(KCmdnew,						"new");
       
    34 _LIT(KCmdDestructor,				"~"); 
       
    35 
       
    36 //Use of Protected method
       
    37 _LIT(KCmdSetMediaCodecType, 		"SetMediaCodecType");
       
    38 _LIT(KCmdSetMediaType, 				"SetMediaType");
       
    39 
       
    40 //Log
       
    41 _LIT(KLogError,							"Error=%d");
       
    42 _LIT(KLogMissingParameter,				"Missing parameter '%S'");
       
    43 
       
    44 /*@}*/
       
    45 //////////////////////////////////////////////////////////////////////
       
    46 // Construction/Destruction
       
    47 //////////////////////////////////////////////////////////////////////
       
    48 
       
    49 CT_NonSBCCodecCapabilitiesData* CT_NonSBCCodecCapabilitiesData::NewL()
       
    50 	{
       
    51 	CT_NonSBCCodecCapabilitiesData*	ret=new (ELeave) CT_NonSBCCodecCapabilitiesData();
       
    52 	CleanupStack::PushL(ret);
       
    53 	ret->ConstructL();
       
    54 	CleanupStack::Pop(ret);
       
    55 	return ret;
       
    56 	}
       
    57 
       
    58 CT_NonSBCCodecCapabilitiesData::CT_NonSBCCodecCapabilitiesData()
       
    59 :iNonSBCCodecCapabilities(NULL)
       
    60 	{
       
    61 	}
       
    62 
       
    63 void CT_NonSBCCodecCapabilitiesData::ConstructL()
       
    64 	{
       
    65 	}
       
    66 
       
    67 TAvdtpServiceCapability* CT_NonSBCCodecCapabilitiesData::GetAvdtpServiceCapability() const
       
    68 	{
       
    69 	return iNonSBCCodecCapabilities;
       
    70 	}
       
    71 
       
    72 CT_NonSBCCodecCapabilitiesData::~CT_NonSBCCodecCapabilitiesData()
       
    73 	{
       
    74 	DestroyData();
       
    75 	}
       
    76 
       
    77 void CT_NonSBCCodecCapabilitiesData::SetObjectL(TAny* aAny)
       
    78 	{
       
    79 	DestroyData();
       
    80 	iNonSBCCodecCapabilities = static_cast<T_NonSBCCodecCapabilitiesChild*> (aAny);
       
    81 	}
       
    82 
       
    83 void CT_NonSBCCodecCapabilitiesData::DisownObjectL()
       
    84 	{
       
    85 	iNonSBCCodecCapabilities = NULL;
       
    86 	}
       
    87 
       
    88 void CT_NonSBCCodecCapabilitiesData::DestroyData()
       
    89 	{
       
    90 	delete iNonSBCCodecCapabilities;
       
    91 	iNonSBCCodecCapabilities=NULL;	
       
    92 	}
       
    93 
       
    94 
       
    95 TBool CT_NonSBCCodecCapabilitiesData::DoCommandL(const TTEFFunction& aCommand,
       
    96 		const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
       
    97 	{
       
    98 	TBool ret = ETrue;
       
    99 
       
   100 		if ( aCommand==KCmdnew )
       
   101 			{
       
   102 			DoCmdnewL(aSection);
       
   103 			}
       
   104 		else if(aCommand == KCmdSetMediaCodecType)
       
   105 			{
       
   106 			DoCmdSetMediaCodecType(aSection);
       
   107 			}
       
   108 		else if(aCommand == KCmdSetMediaType)
       
   109 			{
       
   110 			DoCmdSetMediaType(aSection);
       
   111 			}
       
   112 		else if ( aCommand==KCmdDestructor )
       
   113 			{
       
   114 			DestroyData();
       
   115 			}
       
   116 		else
       
   117 			{
       
   118 			ret= CT_AvdtpMediaCodecCapabilitiesData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
       
   119 			}
       
   120 
       
   121 	return ret;
       
   122 	}
       
   123 
       
   124 /**
       
   125 Test TNonSBCCodecCapabilities ()
       
   126 */
       
   127 void CT_NonSBCCodecCapabilitiesData::DoCmdnewL(const TDesC& aSection)
       
   128 	{
       
   129 	INFO_PRINTF1(_L("TNonSBCCodecCapabilities Constructor Call"));
       
   130 	DestroyData();
       
   131 	
       
   132 	SymbianBluetoothAV::TBluetoothMediaType mediaType;
       
   133 	if( CT_BTUtil::ReadBluetoothMediaType(*this, aSection, KMediaType, mediaType) )
       
   134 		{
       
   135 		TInt mediaCodecType;
       
   136 		if( GetIntFromConfig(aSection, KMediaCodecType, mediaCodecType))
       
   137 			{
       
   138 			TRAPD(err, iNonSBCCodecCapabilities = new (ELeave) T_NonSBCCodecCapabilitiesChild(mediaType, (TBluetoothMediaCodecType)mediaCodecType));
       
   139 			
       
   140 			if(err != KErrNone)
       
   141 				{
       
   142 				ERR_PRINTF2(KLogError, err);
       
   143 				SetError(err);
       
   144 				}
       
   145 			}
       
   146 		else
       
   147 			{
       
   148 			ERR_PRINTF2(KLogMissingParameter, &KMediaCodecType);
       
   149 			SetBlockResult(EFail);		
       
   150 			}
       
   151 		}
       
   152 	else
       
   153 		{
       
   154 		ERR_PRINTF2(KLogMissingParameter, &KMediaType);
       
   155 		SetBlockResult(EFail);		
       
   156 		}
       
   157 	}
       
   158 
       
   159 /**
       
   160 Test TAvdtpMediaCodecCapabilities::SetMediaCodecType() - protected method
       
   161 */
       
   162 void CT_NonSBCCodecCapabilitiesData::DoCmdSetMediaCodecType(const TDesC& aSection)
       
   163 	{
       
   164 	INFO_PRINTF1(_L("TAvdtpMediaCodecCapabilities::SetMediaCodecType() Call"));
       
   165 
       
   166 	TInt mediaCodecType = 0;
       
   167 	if ( GetIntFromConfig(aSection, KMediaCodecType, mediaCodecType) )
       
   168 		{
       
   169 		iNonSBCCodecCapabilities->SetMediaCodecType((TBluetoothMediaCodecType)mediaCodecType);
       
   170 		}
       
   171 	else
       
   172 		{
       
   173 		ERR_PRINTF2(KLogMissingParameter, &KMediaCodecType);
       
   174 		SetBlockResult(EFail);
       
   175 		}	
       
   176 	}
       
   177 
       
   178 /**
       
   179 Test TAvdtpMediaCodecCapabilities::SetMediaType() - protected method
       
   180 */
       
   181 void CT_NonSBCCodecCapabilitiesData::DoCmdSetMediaType(const TDesC& aSection)
       
   182 	{
       
   183 	INFO_PRINTF1(_L("TAvdtpMediaCodecCapabilities::SetMediaType() Call"));
       
   184 
       
   185 	SymbianBluetoothAV::TBluetoothMediaType mediaType;
       
   186 	if ( CT_BTUtil::ReadBluetoothMediaType(*this, aSection, KMediaType, mediaType) )
       
   187 		{
       
   188 		iNonSBCCodecCapabilities->SetMediaType(mediaType);
       
   189 		}
       
   190 	else
       
   191 		{
       
   192 		ERR_PRINTF2(KLogMissingParameter, &KMediaType);
       
   193 		SetBlockResult(EFail);
       
   194 		}		
       
   195 	}