bluetooth/btstack/avdtp/avdtpTransportChannel.h
changeset 0 29b1cd4cb562
child 22 786b94c6f0a4
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 transport channel base class
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21 */
       
    22 
       
    23 #ifndef AVDTPTRANSPORTCHANNEL_H
       
    24 #define AVDTPTRANSPORTCHANNEL_H
       
    25 
       
    26 #include <bt_sock.h>
       
    27 #include "avdtpAllocators.h"
       
    28 #include "avdtpLogicalChannelFactory.h"
       
    29 #include "avdtpTransportSession.h"
       
    30 
       
    31 #ifdef _DEBUG
       
    32 _LIT(KAVDTPTransportChannel, "AVDTP_TransportChannel");
       
    33 #define DEBUG_UNEXPECTED_L2CAP_EVENT User::Panic(KAVDTPTransportChannel, 0);
       
    34 #else
       
    35 #define DEBUG_UNEXPECTED_L2CAP_EVENT
       
    36 #endif
       
    37 
       
    38 class CAvdtpProtocol;
       
    39 class CTransportSession;
       
    40 class TAvdtpSockAddr;
       
    41 
       
    42 typedef TUint32 TAvdtpAdaptationServices;
       
    43 const TUint32 KFragmentationService = 0x01;
       
    44 
       
    45 /**
       
    46 Base class for Direct and Mux channels	
       
    47 Derivers must implement certain send-related methods
       
    48 */
       
    49 NONSHARABLE_CLASS(CTransportChannel) : public CBase, public MSocketNotify
       
    50 	{
       
    51 friend class CAvdtpProtocol;
       
    52 public:
       
    53 	static CTransportChannel* NewDirectChannelL(CAvdtpProtocol& aParent,
       
    54 								   const TBTDevAddr& aAddr);
       
    55 	static CTransportChannel* NewMuxChannelL(CAvdtpProtocol& aProtocol,
       
    56 							  const TBTDevAddr& aRemoteDevice,
       
    57 							  TTCID aRemotelyAssignedTCID/*=KInvalidTCID*/);
       
    58 	virtual ~CTransportChannel();
       
    59 
       
    60 // management path
       
    61 	virtual void DetachTransportSession(CUserPlaneTransportSession& aSession, TAvdtpTransportSessionType aType)=0;
       
    62 	virtual TInt AttachTransportSession(CUserPlaneTransportSession& aSession, TAvdtpTransportSessionType aType)=0;
       
    63 	virtual TBool CouldAttachSession(const TAvdtpSockAddr& aAddr)=0;
       
    64 	virtual TTCID TCID() const=0;
       
    65 	inline const TBTDevAddr& RemoteAddress() const;
       
    66 	virtual CServProviderBase* ObtainSAP()=0;
       
    67 
       
    68 // send path
       
    69 	virtual TUint SendPacket(TTSID aTSID, RMBufChain& aPacket)=0;
       
    70 	virtual TInt MaxPacketSize(TInt& aMTU); // default is just whatever l2cap is
       
    71 // receive path
       
    72 	virtual void TransportSessionBlocked(TAvdtpTransportSessionType aSession, TBool aBlocked)=0;
       
    73 	
       
    74 // interface for stream
       
    75 	virtual void LogicalChannelComplete(TLogicalChannelRecord aLogicalChannelRecord, TInt aErr);
       
    76 	void AllowServices(TAvdtpAdaptationServices aServices);
       
    77 	inline TBool IsConnected() const;
       
    78 	
       
    79 	// MSocketNotify stuff that is never used
       
    80 	// (still virtual though - so implementors *can* implement!)
       
    81 	void Bearer(const TDesC8&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    82 	void NoBearer(const TDesC8&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    83 	void Disconnect(TDesC8&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    84 	void CanClose(const TDesC8&, TDelete) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    85 	void ConnectComplete() {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    86 	void ConnectComplete(const TDesC8&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    87     void ConnectComplete(CServProviderBase&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    88 	void ConnectComplete(CServProviderBase&,const TDesC8&) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    89 	TInt SetOption(TUint aLevel, TUint aName, const TDesC8 &aOption);
       
    90 	// MSocketNotify stuff that the base class can sort out
       
    91 	// no ioctl-forwarding supported yet
       
    92 	// if implemented this base class can handle the ioctlcomplete
       
    93 	void IoctlComplete(TDesC8*) {DEBUG_UNEXPECTED_L2CAP_EVENT};
       
    94 	void CanClose(TDelete aDelete=EDelete);
       
    95 
       
    96 	virtual TInt MaxReceivePacketSize(TInt& aMTU); // default is just whatever l2cap is		
       
    97 	
       
    98 protected:
       
    99 	CTransportChannel(CAvdtpProtocol& aParent, const TBTDevAddr& aAddr);
       
   100 	void ConstructL();
       
   101 	void CloseLogicalChannel();
       
   102 	inline CAvdtpProtocol& Protocol() const;
       
   103 
       
   104 protected:
       
   105 	RTCID				iTCID;
       
   106 	CServProviderBase*	iLogicalChannel;
       
   107 	TDblQueLink			iProtocolQLink;
       
   108 	TBool				iLogicalChannelBlocked;
       
   109 	TAvdtpAdaptationServices iAllowedServices;
       
   110 private:
       
   111 	CAvdtpProtocol&		iProtocol;
       
   112 	TBTDevAddr			iRemoteDevice;
       
   113 	};
       
   114 	
       
   115 inline CAvdtpProtocol& CTransportChannel::Protocol() const
       
   116 	{
       
   117 	return iProtocol;
       
   118 	}
       
   119 	
       
   120 inline const TBTDevAddr& CTransportChannel::RemoteAddress() const
       
   121 	{
       
   122 	return iRemoteDevice;
       
   123 	}
       
   124 	
       
   125 inline TBool CTransportChannel::IsConnected() const
       
   126 	{
       
   127 	return (iLogicalChannel!=NULL);
       
   128 	}
       
   129 
       
   130 #endif //AVDTPTRANSPORTCHANNEL_H