|
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 protocol class |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef AVDTP_H |
|
24 #define AVDTP_H |
|
25 |
|
26 #include <es_prot.h> |
|
27 #include <bt_sock.h> |
|
28 #include <bluetoothav.h> |
|
29 #include "secman.h" |
|
30 #include "notification.h" |
|
31 #include "bt.h" |
|
32 #include "avdtpTransportSession.h" |
|
33 #include "avdtpSEPCache.h" |
|
34 #include "avdtpStream.h" |
|
35 #include "avdtpLocalSEP.h" |
|
36 #include "avdtpAllocators.h" |
|
37 #include <es_prot_internal.h> |
|
38 |
|
39 // Stream and Datagram I/f's are muturally exclusive. You can't have some sockets one |
|
40 // time and some the other -- esock will always give presidence to stream. |
|
41 // don't support graceful close |
|
42 const TUint KAvdtpServiceInfo = KSIInOrder| |
|
43 KSIDatagram| |
|
44 KSICanReconnect; |
|
45 #ifdef _OOM_TEST |
|
46 const TInt KAvdtpIdleTimeout = 1000; |
|
47 #undef __ASSERT_DEBUG |
|
48 #define __ASSERT_DEBUG(c,p) |
|
49 #else |
|
50 const TInt KAvdtpIdleTimeout = 5000000; |
|
51 #endif |
|
52 |
|
53 const TUid KAvdtpUID = {0x100095FE}; |
|
54 |
|
55 class CBTProtocolFamily; |
|
56 class CLinkMgrProtocol; |
|
57 class CBTInquiryMgr; |
|
58 class CTransportChannel; |
|
59 class CSignallingChannel; |
|
60 |
|
61 class CAvdtpSAP; |
|
62 class CLogicalChannelFactory; |
|
63 class CAVStream; |
|
64 class CRemoteSEPCache; |
|
65 class CAVStreamStateFactory; |
|
66 |
|
67 NONSHARABLE_CLASS(CAvdtpProtocol) : public CBluetoothProtocolBase |
|
68 { |
|
69 friend class CAvdtpSAP; |
|
70 |
|
71 public: |
|
72 // export for protocol |
|
73 |
|
74 static CAvdtpProtocol* NewL(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan); |
|
75 static CAvdtpProtocol* NewLC(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan); |
|
76 // From CProtocolBase |
|
77 // Factories |
|
78 CServProviderBase* NewSAPL(TUint aSockType); |
|
79 |
|
80 void Close(); |
|
81 void Open(); |
|
82 void CloseNow(); |
|
83 |
|
84 // From ProtocolManager before all binding. |
|
85 void InitL(TDesC &aTag); |
|
86 // From Protocol Manager - after all binding |
|
87 void StartL(); |
|
88 // From higher protocol |
|
89 void BindL(CProtocolBase* aProtocol, TUint aId); |
|
90 void BindToL(CProtocolBase* aProtocol); // From Protocol Manager |
|
91 |
|
92 // Query functions |
|
93 void Identify(TServerProtocolDesc* aDesc) const; |
|
94 static void ProtocolIdentity(TServerProtocolDesc* aDesc); |
|
95 |
|
96 // bluetooth protocol overridden functions |
|
97 TInt StartProtocolListening(); |
|
98 |
|
99 // Get a factory for the logical channels |
|
100 |
|
101 inline CLogicalChannelFactory& LogicalChannelFactory() const; |
|
102 TInt SetPreauthorisation(const TBTDevAddr& aPreauthoriseAddress, TBool aSetPreauthorisation); |
|
103 |
|
104 void StreamCreated(CAVStream& aStream); |
|
105 CAVStream* FindStream(const TAvdtpSockAddr& aAddr); |
|
106 void RemoveStream(CAVStream& aStream); |
|
107 inline const CAVStreamStateFactory& StreamStateFactory() const; |
|
108 |
|
109 CTransportChannel* GetTransportChannel(const TAvdtpSockAddr& aSockAddr, TBool aUseMux, |
|
110 TTCID aRemotelyAssignedTTCID=KInvalidTCID); |
|
111 CTransportChannel* FindMuxChannel(TTCID aTCID); |
|
112 CSignallingChannel* GetSignallingChannel(const TBTDevAddr& aDevAddr); |
|
113 CSignallingChannel* FindSignallingChannel(const TBTDevAddr& aDevAddr); |
|
114 CSignallingChannel* FindListeningSignallingChannel(); |
|
115 CSignallingChannel* CreateSignallingChannelForListening(); |
|
116 void ConnectSignallingListeners(CSignallingChannel& aConnectedSignallingChannel); |
|
117 CUserPlaneTransportSession* CreateUserPlaneSessionL(CAvdtpSAP& aSAP, |
|
118 CAVStream& aStream, |
|
119 TAvdtpTransportSessionType aType); |
|
120 |
|
121 virtual TInt BearerConnectComplete(const TBTDevAddr& aAddr, CServProviderBase* aSAP); |
|
122 |
|
123 void TransportChannelDown(CTransportChannel& aTransportChannel); |
|
124 void TransportChannelClosing(CTransportChannel& aTransportChannel); |
|
125 |
|
126 void SignallingChannelDown(CSignallingChannel& aSignallingChannel); |
|
127 |
|
128 inline CRemoteSEPCache& RemoteSEPCache() const; |
|
129 inline TSEIDManager& SEIDManager(); |
|
130 |
|
131 // secondary SAP management |
|
132 |
|
133 void AddSecondarySAP(CAvdtpSAP& aSecondarySAP); |
|
134 CAvdtpSAP* GetSecondarySAP(); |
|
135 |
|
136 virtual TInt ControlPlaneMessage(TBTControlPlaneMessage aMessage, TAny* aParam); |
|
137 |
|
138 private: |
|
139 CAvdtpProtocol(CBTSecMan& aSecMan, RBTControlPlane& aControlPlane, CBTCodServiceMan& aCodMan); |
|
140 ~CAvdtpProtocol(); |
|
141 void ConstructL(); |
|
142 |
|
143 CTransportChannel* CreateTransportChannelL(const TBTDevAddr& aAddr, TBool aMuxed); |
|
144 |
|
145 void QueIdleTimerEntry(); |
|
146 void RemoveIdleTimerEntry(); |
|
147 TBool ShouldClose(); |
|
148 static TInt TryToClose(TAny* aProtocol); |
|
149 void DestroySecondarySAPs(); |
|
150 void DoStartAvdtpListeningL(); |
|
151 |
|
152 private: |
|
153 // Singleton objects |
|
154 CLogicalChannelFactory* iLogicalChannelFactory; |
|
155 CAVStreamStateFactory* iStreamStateFactory; |
|
156 |
|
157 CRemoteSEPCache* iRemoteSEPCache; |
|
158 TDeltaTimerEntry iIdleTimerEntry; |
|
159 TBool iIdleEntryQueued; |
|
160 |
|
161 // List of TransportChannels (Direct and Mux) |
|
162 TDblQue<CTransportChannel> iTransportChannels; |
|
163 TDblQue<CTransportChannel> iClosingTransportChannels; |
|
164 |
|
165 TDblQue<CSignallingChannel> iSignallingChannels; |
|
166 // no closing signalling channel tracking as they perform immediate shutdowns |
|
167 |
|
168 TDblQue<CAVStream> iStreams; // to allow for U-plane sessions to find the stream they belong to |
|
169 |
|
170 TSEIDManager iSEIDManager; |
|
171 // Q of SAPs waiting for a transport channel to attach to |
|
172 TSglQue<CAvdtpSAP> iSecondarySAPs; |
|
173 |
|
174 TBool iClosePending; |
|
175 }; |
|
176 |
|
177 |
|
178 inline CLogicalChannelFactory& CAvdtpProtocol::LogicalChannelFactory() const |
|
179 { |
|
180 return *iLogicalChannelFactory; |
|
181 } |
|
182 |
|
183 inline CRemoteSEPCache& CAvdtpProtocol::RemoteSEPCache() const |
|
184 { |
|
185 return *iRemoteSEPCache; |
|
186 } |
|
187 |
|
188 inline TSEIDManager& CAvdtpProtocol::SEIDManager() |
|
189 { |
|
190 return iSEIDManager; |
|
191 } |
|
192 |
|
193 inline const CAVStreamStateFactory& CAvdtpProtocol::StreamStateFactory() const |
|
194 { |
|
195 return *iStreamStateFactory; |
|
196 } |
|
197 |
|
198 |
|
199 #endif |