60
|
1 |
/*
|
|
2 |
* Component Name: Headset Simulator
|
|
3 |
* Author: Comarch S.A.
|
|
4 |
* Version: 1.0
|
|
5 |
* Copyright (c) 2010 Comarch S.A.
|
|
6 |
*
|
|
7 |
* This Software is submitted by Comarch S.A. to Symbian Foundation Limited on
|
|
8 |
* the basis of the Member Contribution Agreement entered between Comarch S.A.
|
|
9 |
* and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be
|
|
10 |
* used only in accordance with the terms and conditions of the Agreement.
|
|
11 |
* Any other usage, duplication or redistribution of this Software is not
|
|
12 |
* allowed without written permission of Comarch S.A.
|
|
13 |
*
|
|
14 |
*/
|
|
15 |
|
|
16 |
#ifndef HSAUDIOSERVER_H_
|
|
17 |
#define HSAUDIOSERVER_H_
|
|
18 |
|
|
19 |
#include <e32std.h>
|
|
20 |
#include <bt_sock.h>
|
|
21 |
|
|
22 |
/** Buffer size */
|
|
23 |
const TInt KHsSynchronousBufferLength = 128;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* @brief Server for SCO connections
|
|
27 |
*/
|
|
28 |
class CHsAudioServer : public CBase, public MBluetoothSynchronousLinkNotifier
|
|
29 |
{
|
|
30 |
public:
|
|
31 |
/**
|
|
32 |
* Two-phase constructor
|
|
33 |
* @param aSocketServ socket server session
|
|
34 |
* @param aPullAudio denotes if audio should be pulled
|
|
35 |
* @return instance of class
|
|
36 |
*/
|
|
37 |
static CHsAudioServer* NewL( RSocketServ& aSocketServ, TBool aPullAudio );
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Two-phase constructor
|
|
41 |
* @param aSocketServ socket server session
|
|
42 |
* @param aPullAudio denotes if audio should be pulled
|
|
43 |
* @return instance of class
|
|
44 |
*/
|
|
45 |
static CHsAudioServer* NewLC( RSocketServ& aSocketServ, TBool aPullAudio );
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Destructor
|
|
49 |
*/
|
|
50 |
~CHsAudioServer();
|
|
51 |
|
|
52 |
public:
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Prepares audio server for incoming connections
|
|
56 |
*/
|
|
57 |
void ListenL();
|
|
58 |
|
|
59 |
/**
|
|
60 |
* Connects audio server to the specified device
|
|
61 |
*
|
|
62 |
* @param aAddr device's bluetooth address
|
|
63 |
*/
|
|
64 |
void ConnectL( const TBTDevAddr &aAddr );
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Closes current connections and prepares the server for the new one
|
|
68 |
*/
|
|
69 |
void Disconnect();
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Turns off audio server
|
|
73 |
*/
|
|
74 |
void Shutdown();
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Method allows to accept \ reject SCO connection establishment
|
|
78 |
*
|
|
79 |
* @param aPullAudio ETrue if SCO connection is supposed to be accepted
|
|
80 |
*/
|
|
81 |
void SetPullAudio( TBool aPullAudio );
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Checks if client is connected
|
|
85 |
*
|
|
86 |
* @return ETrue if client connected
|
|
87 |
*/
|
|
88 |
TBool IsConnected();
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Checks if server is ready for incoming requests
|
|
92 |
*
|
|
93 |
* @return ETrue if server is ready
|
|
94 |
*/
|
|
95 |
TBool IsListen();
|
|
96 |
|
|
97 |
private:
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Constructor for performing 1st stage construction
|
|
101 |
*
|
|
102 |
* @param aSocketServ socket server session
|
|
103 |
* @param aPullAudio denotes if audio should be pulled
|
|
104 |
*/
|
|
105 |
CHsAudioServer( RSocketServ& aSocketServ, TBool aPullAudio );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Constructor for performing 2nd stage construction
|
|
109 |
*/
|
|
110 |
void ConstructL();
|
|
111 |
|
|
112 |
private:
|
|
113 |
// Methods derived from MBluetoothSynchronousLinkNotifier
|
|
114 |
|
|
115 |
void HandleSetupConnectionCompleteL( TInt aErr );
|
|
116 |
|
|
117 |
void HandleDisconnectionCompleteL( TInt aErr );
|
|
118 |
|
|
119 |
void HandleAcceptConnectionCompleteL( TInt aErr );
|
|
120 |
|
|
121 |
void HandleSendCompleteL( TInt aErr );
|
|
122 |
|
|
123 |
void HandleReceiveCompleteL( TInt aErr );
|
|
124 |
|
|
125 |
private:
|
|
126 |
|
|
127 |
/** Session of socket server */
|
|
128 |
RSocketServ& iSServ;
|
|
129 |
|
|
130 |
/** SCO socket */
|
|
131 |
CBluetoothSynchronousLink* iSCOSocket;
|
|
132 |
|
|
133 |
/** Buffer for received data */
|
|
134 |
TBuf8 <KHsSynchronousBufferLength> iReceiveBuffer;
|
|
135 |
|
|
136 |
/** Buffer for data to be send */
|
|
137 |
TBuf8 <KHsSynchronousBufferLength> iSendBuffer;
|
|
138 |
|
|
139 |
/** Types of accepted SCO packets */
|
|
140 |
TBTSyncPackets iAcceptedPackets;
|
|
141 |
|
|
142 |
/** DevAddr of connected device */
|
|
143 |
TBTDevAddr iAddr;
|
|
144 |
|
|
145 |
/** Denotes if server is ready for incoming connections */
|
|
146 |
TBool iListening;
|
|
147 |
|
|
148 |
/** Denotes if client is connected */
|
|
149 |
TBool iConnected;
|
|
150 |
|
|
151 |
/** Denotes if audio should be transferred */
|
|
152 |
TBool iPullAudio;
|
|
153 |
};
|
|
154 |
|
|
155 |
#endif /* HSAUDIOSERVER_H_ */
|