bluetooth/btstack/avdtp/avdtpSEPCache.h
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 // Defines the avdtp SEP cache which holds details about the capabilities of remote SEPs
       
    15 // these details can then be used later by the stack without having to send a GetCaps
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #ifndef AVDTPSEPCACHE_H
       
    25 #define AVDTPSEPCACHE_H
       
    26 
       
    27 #include <bluetoothav.h>
       
    28 #include <es_mbuf.h>
       
    29 
       
    30 static const TInt KSEPCacheCallbackInterval = 5;	// seconds
       
    31 static const TInt KSEPCacheRecordDeadAge = 4;		// multiples of CBInterval
       
    32 
       
    33 class CCapabilityVisitor;
       
    34 
       
    35 NONSHARABLE_CLASS(CRemoteSEP) : public CBase
       
    36 	{
       
    37 friend class CRemoteSEPCache;
       
    38 public:
       
    39 	~CRemoteSEP();	// RPointerArray deletion
       
    40 private:
       
    41 	static CRemoteSEP* NewL(const TBTDevAddr& aAddr, const TAvdtpSEPInfo& aInfo);
       
    42 	void SetCapabilities(HBufC8* aCapsAsProtocol);
       
    43 	TPtrC8 GetCapabilityL(TAvdtpServiceCategory aCat);
       
    44 	TBool HasCapability(TAvdtpServiceCategory aCat);
       
    45 	inline TAvdtpServiceCategories GetCapabilities() const;
       
    46 	void UpdateInfo(const TAvdtpSEPInfo& aInfo);
       
    47 private:
       
    48 	CRemoteSEP(const TBTDevAddr& aAddr, const TAvdtpSEPInfo& aInfo);
       
    49 	void ConstructL();
       
    50 private:
       
    51 	TBTDevAddr				iRemoteDev;
       
    52 	TAvdtpSEPInfo			iInfo;
       
    53 	RPointerArray<TAvdtpServiceCapability>	iParsedCaps;
       
    54 	HBufC8*					iCapabilitiesBuf;	// the bit of the packet we got, copied out
       
    55 	TAvdtpServiceCategories	iKnownCaps;	
       
    56 	};
       
    57 
       
    58 NONSHARABLE_CLASS(CRemoteSEPCache) : public CBase
       
    59 	{
       
    60 public:
       
    61 	static CRemoteSEPCache* NewL();
       
    62 	TInt AddSEP(const TBTDevAddr& aAddr, const struct TAvdtpSEPInfo& aInfo);
       
    63 	void SetCapabilities(const TBTDevAddr& aAddr, TSEID aSEID, HBufC8* aCapsAsProtocol);
       
    64 	static TInt PerformMaintenanceCallback(TAny*); // maintains the cache;
       
    65 	TBool Exists(const TBTDevAddr& aAddr, TSEID aSEID) const;
       
    66 	TPtrC8 GetCapabilityL(const TBTDevAddr& aAddr, TSEID aSEID, TAvdtpServiceCategory aCat);
       
    67 	TBool HasCapability(const TBTDevAddr& aAddr, TSEID aSEID, TAvdtpServiceCategory aCat);
       
    68 	TAvdtpServiceCategories GetCapabilitiesL(const TBTDevAddr& aAddr, TSEID aSEID) const;
       
    69 	void InvalidateSEPs(const TBTDevAddr& aAddr);
       
    70 	~CRemoteSEPCache();
       
    71 private:
       
    72 	CRemoteSEP* FindSEP(const TBTDevAddr& aAddr, TSEID aSEID) const;
       
    73 private:
       
    74 // async callback to age these things
       
    75 	RPointerArray<CRemoteSEP>	iRemoteSEPs;
       
    76 	};
       
    77 
       
    78 inline TAvdtpServiceCategories  CRemoteSEP::GetCapabilities() const
       
    79 	{
       
    80 	return iKnownCaps;
       
    81 	}
       
    82 
       
    83 #endif //AVDTPSEPCACHE_H