bluetooth/btstack/avdtp/avdtpsap.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 // Definition of AVDTP SAP
       
    15 // The SAP is really only a conduit to the socket
       
    16 // The sessions implement the meaningful protocol stuff
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23 */
       
    24 
       
    25 
       
    26 #ifndef AVDTPSAP_H
       
    27 #define AVDTPSAP_H
       
    28 
       
    29 #include <bluetoothav.h>
       
    30 #include "BtSap.h"
       
    31 #include "avdtpTransportSession.h"
       
    32 
       
    33 // could have v1 v2 versions of this for MT ESOCK?
       
    34 
       
    35 NONSHARABLE_CLASS(HQueuedAvdtpIndication)
       
    36 	{
       
    37 public:
       
    38 	static HQueuedAvdtpIndication* New(const TDesC8& aIndicationData);
       
    39 	inline TDesC8* Indication() const;
       
    40 	~HQueuedAvdtpIndication();
       
    41 public:
       
    42 	TSglQueLink	iLink;
       
    43 private:
       
    44     void ConstructL(const TDesC8& aIndicationData);
       
    45 private:
       
    46     HBufC8* iBuf;
       
    47 	};
       
    48 
       
    49 inline TDesC8* HQueuedAvdtpIndication::Indication() const
       
    50     {
       
    51     return iBuf;
       
    52     }
       
    53     
       
    54 
       
    55 NONSHARABLE_CLASS(CAvdtpSAP) : public CBluetoothSAP
       
    56 /**
       
    57 
       
    58 */
       
    59 	{
       
    60 friend class CSignallingChannel; // for quing
       
    61 friend class CAvdtpProtocol; // for quing
       
    62 public:
       
    63 	//SAP stuff
       
    64 	static CAvdtpSAP* NewL(CAvdtpProtocol& aProtocol);
       
    65 	~CAvdtpSAP();
       
    66 
       
    67 	virtual TInt SetLocalName(TSockAddr& aAddr); // defines which TransportSession will be created
       
    68 	virtual void LocalName(TSockAddr& anAddr) const;
       
    69 	virtual void RemName(TSockAddr& anAddr) const;
       
    70 	virtual TInt SetRemName(TSockAddr& aAddr);
       
    71 	virtual TInt GetOption(TUint aLevel,TUint aName,TDes8& aOption) const;
       
    72 	virtual void Ioctl(TUint aLevel,TUint aName, TDes8* aOption);
       
    73 	virtual void CancelIoctl(TUint aLevel,TUint aName);
       
    74 	virtual TInt SAPSetOption(TUint aLevel,TUint aName,const TDesC8 &aOption);
       
    75 	virtual void ActiveOpen();
       
    76 	virtual void ActiveOpen(const TDesC8& aConnectionData);
       
    77 	virtual TInt PassiveOpen(TUint aQueSize);
       
    78 	virtual TInt PassiveOpen(TUint aQueSize,const TDesC8& aConnectionData);
       
    79 	virtual void Shutdown(TCloseType aOption);
       
    80 	virtual void Shutdown(TCloseType aOption, const TDesC8& aDisconnectionData);
       
    81 	virtual void AutoBind();
       
    82 	virtual void Start();
       
    83 
       
    84 	virtual TInt Write(RMBufChain& aData, TUint aOptions, TSockAddr* aAddr);
       
    85 	virtual TInt GetData(RMBufChain& aData, TUint aLength, TUint aOptions, TSockAddr* aAddr);
       
    86 	
       
    87 	const TAvdtpSockAddr& SocketAddress() const;
       
    88 
       
    89 	// interface for sessions
       
    90 	void Ready();
       
    91 	void SessionDisconnect();
       
    92 	void Error(TInt aError);
       
    93 	void SendError(TInt aError);
       
    94 	void PacketReceived();
       
    95 	void CanSend();
       
    96 	void ServiceComplete(const TDesC8* aBuf);
       
    97 	void Indication(const TDesC8& aIndicationData);
       
    98 	void NewData(TUint aCount);
       
    99 	void CanClose();
       
   100 	inline void DetachSession();
       
   101 private:
       
   102 	CAvdtpSAP(CAvdtpProtocol& aProtocol);
       
   103 
       
   104 	void ConstructL();
       
   105 	void UpdateSessionL(const TAvdtpSockAddr& aAddr);
       
   106 	void DoIndication(const TDesC8& aIndicationData);
       
   107 
       
   108 	inline void ClearIoctl();
       
   109 private:
       
   110 	CTransportSession*	iSession;
       
   111 	CAvdtpProtocol&		iProtocol;
       
   112 	TBool				iSocketBlocked;
       
   113 	TSglQueLink			iLink; // a couple of classes use this depending on its session 'type'
       
   114 	CAvdtpSAP*			iSecondarySAP; // non-owned (SAPs owned by socket)
       
   115 	TSglQue<HQueuedAvdtpIndication>	iIndicationQueue;
       
   116 	TBool				iIsSecondary; // don'twant secondaries creating secondaries!
       
   117 #ifdef _DEBUG
       
   118 	TBool				iCanSignalDisconnect; // don't want to tell esock disconnect if !connected. copes in urel.
       
   119 #endif
       
   120 	};
       
   121 
       
   122 inline void CAvdtpSAP::DetachSession()
       
   123 	{
       
   124 	iSession = NULL;
       
   125 	}
       
   126 
       
   127 #endif //AVDTPSAP_H