|
1 /* |
|
2 * Copyright (c) 2005 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: Declaration for CBTSAController class. This class is advertised |
|
15 * to E-com framework (@see proxy.cpp) so that it loads this class when |
|
16 * this plugin gets loaded. That is why this class implements the interface |
|
17 * of the module (currently BT Accessory Server) which loads this plugin. Being |
|
18 * main class, this class constructs other classes and also recieves callbacks, |
|
19 * hence implementing their interfaces. |
|
20 * |
|
21 */ |
|
22 |
|
23 |
|
24 #ifndef BTSACONTROLLER_H |
|
25 #define BTSACONTROLLER_H |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDES |
|
30 |
|
31 // Implement Interface provided by 'BT Accessory Server' component. E-com framework |
|
32 // uses this interface to load this plugin |
|
33 #include <es_sock.h> |
|
34 #include <btaccPlugin.h> |
|
35 #include "btsacdefs.h" |
|
36 #include "btsacStreamerController.h" //MBTAudioAdaptationObserver |
|
37 #include "btsacActiveObserver.h" //MBtsacActiveObserver |
|
38 |
|
39 |
|
40 // CONSTANTS |
|
41 |
|
42 // DATA TYPES |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 class CBtsacState; |
|
46 class CBTSACGavdp; |
|
47 class CBTSACSEPManager; |
|
48 class CBTSACStreamerController; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * |
|
54 * |
|
55 * |
|
56 */ |
|
57 NONSHARABLE_CLASS(CBTSAController) : public CBTAccPlugin, public MBTAudioAdaptationObserver, public MBtsacActiveObserver |
|
58 { |
|
59 public: // Constructors and destructor |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 * After construction the instance is ready to serve requests. |
|
64 * Also starts listening to incoming connections from BT Stereo |
|
65 * audio accessories. |
|
66 */ |
|
67 static CBTSAController* NewL(TPluginParams& aParams); |
|
68 |
|
69 /** |
|
70 * Destructor. |
|
71 * Removes service and security registrations and stops listening to |
|
72 * incoming connections. |
|
73 */ |
|
74 virtual ~CBTSAController(); |
|
75 |
|
76 /** |
|
77 * State transition |
|
78 * |
|
79 * @since S60 v3.1 |
|
80 * @param aState the next state to be entered. |
|
81 */ |
|
82 void ChangeStateL(CBtsacState* aState); |
|
83 |
|
84 public: |
|
85 void ResetRemoteCache(); |
|
86 void InitializeSEPManager(); |
|
87 void CleanSockets(); |
|
88 void StoreAccInfo(); |
|
89 void DeleteAccInfo(); |
|
90 TBool IsAccInfoAvailable(); |
|
91 TInt AbortStream(); |
|
92 |
|
93 void NewAccessory(const TBTDevAddr& aBDAddr); |
|
94 void DisconnectedFromRemote(const TBTDevAddr& aAddr, TInt aError ); |
|
95 void AccessoryOpenedAudio(const TBTDevAddr& aBDAddr); |
|
96 void AccessoryClosedAudio(const TBTDevAddr& aBDAddr); |
|
97 void AccessorySuspendedAudio(const TBTDevAddr& aBDAddr); |
|
98 void CompletePendingRequests(TUint aCompleteReq, TInt aError); |
|
99 |
|
100 void SetRemoteAddr(const TBTDevAddr& aRemoteAddr); |
|
101 TBTDevAddr GetRemoteAddr() const; |
|
102 TBool IsOpenAudioReqFromAccFWPending() const; |
|
103 void SetSEPIndex(TInt aIndex); |
|
104 TInt GetSEPIndex() const; |
|
105 void SetResetAudioInput(TBool aReset); |
|
106 TBool GetResetAudioInput() const; |
|
107 CBtsacActive* GetGavdpErrorActive() const; |
|
108 void GAVDP_Error(TInt aError) ; |
|
109 |
|
110 private: |
|
111 |
|
112 /** |
|
113 * C++ default constructor. |
|
114 */ |
|
115 CBTSAController(TPluginParams& aParams); |
|
116 |
|
117 /** |
|
118 * Symbian 2nd phase constructor. |
|
119 * Starts listening to incoming connections from BT Stereo |
|
120 * audio accessories. |
|
121 * Gets ready to accept requests from clients. |
|
122 */ |
|
123 void ConstructL(/*TPluginParams& aParams*/); |
|
124 |
|
125 public: // From MBTAudioAdaptationObserver |
|
126 |
|
127 virtual void NotifyError(TInt aError); |
|
128 |
|
129 private: // Functions from CBTAccPlugin |
|
130 |
|
131 /** |
|
132 * BT Acc Server learns if plugin supports mono audio or not |
|
133 * while loading the plugin |
|
134 @param None. |
|
135 @return ETrue if plugin supports mono audio, TFalse otherwise. |
|
136 */ |
|
137 virtual TProfiles PluginType(); |
|
138 |
|
139 /** |
|
140 * Called by BT Acc Sever to connect to mono or stereo accessory |
|
141 * @param aAddr Bluetooth Device address of the remote device |
|
142 * @return result of operation |
|
143 */ |
|
144 virtual void ConnectToAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); |
|
145 |
|
146 /** |
|
147 * Called by BT Acc Sever to connect to mono or stereo accessory |
|
148 * @param aAddr Bluetooth Device address of the remote device |
|
149 * @return result of operation |
|
150 */ |
|
151 virtual void CancelConnectToAccessory(const TBTDevAddr& aAddr); |
|
152 |
|
153 /** |
|
154 * Called by BT Acc Sever to connect to mono or stereo accessory |
|
155 * @param aAddr Bluetooth Device address of the remote device |
|
156 * @return result of operation |
|
157 */ |
|
158 virtual void DisconnectAccessory(const TBTDevAddr& aAddr, TRequestStatus& aStatus); |
|
159 |
|
160 /** |
|
161 * Called by BT Acc Sever to open audio link |
|
162 * @param aAddr Bluetooth Device address of the remote device |
|
163 * @return result of operation |
|
164 */ |
|
165 virtual void OpenAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); |
|
166 |
|
167 /** |
|
168 * Called by BT Acc Sever to cancel opening of audio link |
|
169 @param aAddr Bluetooth Device address of the remote device |
|
170 @return result of operation |
|
171 */ |
|
172 void CancelOpenAudioLink(const TBTDevAddr& aAddr ); |
|
173 |
|
174 /** |
|
175 * Called by BT Acc Sever to connect to mono or stereo accessory |
|
176 @param aAddr Bluetooth Device address of the remote device |
|
177 @return result of operation |
|
178 */ |
|
179 void CloseAudioLink(const TBTDevAddr& aAddr, TRequestStatus& aStatus); |
|
180 |
|
181 /** |
|
182 * Called by BT Acc Sever to cancel closing of audio link |
|
183 @param aAddr Bluetooth Device address of the remote device |
|
184 @return |
|
185 */ |
|
186 void CancelCloseAudioLink(const TBTDevAddr& aAddr ); |
|
187 |
|
188 /** |
|
189 * BTAccServer informs BTSAC to start streaming after getting permission |
|
190 * from Acc Fw |
|
191 */ |
|
192 virtual void StartRecording(); |
|
193 |
|
194 /* |
|
195 * Defaults from MBtsacActiveObserver |
|
196 */ |
|
197 /** |
|
198 * Handles the request completion event. |
|
199 * |
|
200 * @since S60 v3.1 |
|
201 * @param aActive the Active Object to which the request is assigned to. |
|
202 */ |
|
203 virtual void RequestCompletedL(CBtsacActive& aActive); |
|
204 |
|
205 /** |
|
206 * Handles the cancellation of an outstanding request. |
|
207 * |
|
208 * @since S60 v3.1 |
|
209 * @param aActive the Active Object to which the request is assigned to. |
|
210 */ |
|
211 virtual void CancelRequest(CBtsacActive& aActive); |
|
212 |
|
213 |
|
214 private: |
|
215 |
|
216 /** |
|
217 * Called by BT Acc Sever to inform plugin that accessory is in use. |
|
218 @param None. |
|
219 @return None. |
|
220 */ |
|
221 virtual void AccInUse(); |
|
222 |
|
223 public: // Data |
|
224 CBTSACGavdp* iGavdp; |
|
225 CBTSACStreamerController* iStreamer; |
|
226 CBTSACSEPManager* iLocalSEPs; |
|
227 CBTSACSEPManager* iRemoteSEPs; |
|
228 RArray<RSocket> iStreamingSockets; |
|
229 |
|
230 private: // Data |
|
231 /** |
|
232 * the current state. |
|
233 */ |
|
234 CBtsacState* iState; |
|
235 |
|
236 /** |
|
237 * AO for handling gavdp errors. |
|
238 */ |
|
239 CBtsacActive* iGavdpErrorActive; |
|
240 |
|
241 TBTDevAddr iRemoteAddr; |
|
242 TInt iSBCSEPIndex; // SBC SEP Index in iRemoteSEPs array |
|
243 TBool iResetAudioInput; |
|
244 TRequestStatus* iConnectStatus; |
|
245 TRequestStatus* iDisconnectStatus; |
|
246 TRequestStatus* iOpenAudioStatus; |
|
247 TRequestStatus* iCloseAudioStatus; |
|
248 RPointerArray<CBTSACSEPManager> iAccDb; // one SEP manager for each accessory |
|
249 }; |
|
250 |
|
251 |
|
252 #endif // BTSAC_CONTROLLER_H |
|
253 |
|
254 // End of File |