0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2004 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: This class is the main interface to the TelephonyAudioRoutingServer.
|
|
15 |
* : Specifically handles TelephonyAudioRoutingManager sessions.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#include <e32math.h>
|
|
22 |
#include <s32mem.h>
|
|
23 |
#include "TelephonyAudioRoutingClientServer.h"
|
|
24 |
#include "TelephonyAudioRoutingManagerSession.h"
|
|
25 |
#include "TelephonyAudioRoutingPolicyRequest.h"
|
|
26 |
|
|
27 |
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
// RTelephonyAudioRoutingManagerSession::RTelephonyAudioRoutingManagerSession
|
|
30 |
// C++ default constructor can NOT contain any code, that
|
|
31 |
// might leave.
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
EXPORT_C RTelephonyAudioRoutingManagerSession::RTelephonyAudioRoutingManagerSession()
|
|
35 |
: RSessionBase(), iConnected(EFalse)
|
|
36 |
{
|
|
37 |
// No implementation required
|
|
38 |
|
|
39 |
}
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// RTelephonyAudioRoutingSession::Connect
|
|
43 |
// Connects a policy client to the server.
|
|
44 |
// (other items were commented in a header).
|
|
45 |
// -----------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
EXPORT_C TInt RTelephonyAudioRoutingManagerSession::Connect(
|
|
48 |
CTelephonyAudioRoutingManager& aAudioRoutingManager,
|
|
49 |
MTelephonyAudioRoutingPolicyObserver& aPolicyObserver)
|
|
50 |
{
|
|
51 |
|
|
52 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::Connect"));
|
|
53 |
|
|
54 |
TInt retry=2;
|
|
55 |
TInt err = KErrGeneral;
|
|
56 |
|
|
57 |
for (;;)
|
|
58 |
{
|
|
59 |
err=CreateSession(KTelAudRtngServName,TVersion(0,0,0)); // RSessionBase::CreateSession
|
|
60 |
|
|
61 |
if (err!=KErrNotFound && err!=KErrServerTerminated && err!=KErrPermissionDenied)
|
|
62 |
break;
|
|
63 |
|
|
64 |
if (--retry==0)
|
|
65 |
break;
|
|
66 |
}
|
|
67 |
|
|
68 |
if ( err == KErrNone )
|
|
69 |
{
|
|
70 |
// Create active object receive handlers and add it to scheduler
|
|
71 |
TRAP(err, StartPolicyRequestHandlersL(aAudioRoutingManager, aPolicyObserver));
|
|
72 |
if ( err == KErrNone )
|
|
73 |
{
|
|
74 |
iConnected = ETrue;
|
|
75 |
}
|
|
76 |
|
|
77 |
SendReceive(ETelAudRtngServInitialize, TIpcArgs());
|
|
78 |
|
|
79 |
}
|
|
80 |
|
|
81 |
return err;
|
|
82 |
|
|
83 |
}
|
|
84 |
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
// RTelephonyAudioRoutingManagerSession::Close
|
|
87 |
// Closes connection to the server.
|
|
88 |
// (other items were commented in a header).
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::Close()
|
|
92 |
{
|
|
93 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::Close"));
|
|
94 |
if ( iConnected )
|
|
95 |
{
|
|
96 |
|
|
97 |
delete iPolicyRequest;
|
|
98 |
RSessionBase::Close();
|
|
99 |
iConnected = EFalse;
|
|
100 |
|
|
101 |
|
|
102 |
}
|
|
103 |
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// RTelephonyAudioRoutingManagerSession::OutputChangeCompleted
|
|
108 |
// Used by policy to notify server that requested output change completed
|
|
109 |
// (other items were commented in a header).
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
//
|
|
112 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::OutputChangeCompleted(
|
|
113 |
CTelephonyAudioRouting::TAudioOutput aOutput,
|
|
114 |
TInt aError)
|
|
115 |
{
|
|
116 |
TPckgBuf<CTelephonyAudioRouting::TAudioOutput> audioOutputPkg;
|
|
117 |
audioOutputPkg() = aOutput;
|
|
118 |
TPckgBuf<TInt> errPkg;
|
|
119 |
errPkg() = aError;
|
|
120 |
|
|
121 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::OutputChangeCompleted to %d"), aOutput);
|
|
122 |
SendReceive(ETelAudRtngServOutputChangeComplete, TIpcArgs(&audioOutputPkg, &errPkg));
|
|
123 |
}
|
|
124 |
|
|
125 |
// -----------------------------------------------------------------------------
|
|
126 |
// RTelephonyAudioRoutingManagerSession::OutputChanged
|
|
127 |
// Used by policy to notify server of audio output changes initiated by policy.
|
|
128 |
// (other items were commented in a header).
|
|
129 |
// -----------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::OutputChanged(
|
|
132 |
CTelephonyAudioRouting::TAudioOutput aOutput)
|
|
133 |
{
|
|
134 |
TPckgBuf<CTelephonyAudioRouting::TAudioOutput> audioOutputPkg;
|
|
135 |
audioOutputPkg() = aOutput;
|
|
136 |
// iAudioOutput = aOutput;
|
|
137 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::OutputChanged to %d"), aOutput);
|
|
138 |
SendReceive(ETelAudRtngServOutputChangedByPolicy, TIpcArgs(&audioOutputPkg));
|
|
139 |
|
|
140 |
}
|
|
141 |
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
// RTelephonyAudioRoutingManagerSession::AvailableOutputsChangedL
|
|
144 |
// Used by policy session to notify server if the available audio output change.
|
|
145 |
// (other items were commented in a header).
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::AvailableOutputsChangedL(
|
|
149 |
const TArray<CTelephonyAudioRouting::TAudioOutput>& aOutputs)
|
|
150 |
{
|
|
151 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::AvailableOutputsChangedL"));
|
|
152 |
TPckgBuf<TInt> numOfOutputs;
|
|
153 |
numOfOutputs()= aOutputs.Count();
|
|
154 |
|
|
155 |
TInt count = aOutputs.Count();
|
|
156 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t AvailableOutputsChangedL: Count = %d "),count);
|
|
157 |
for(TInt i = 0; i < count; i++)
|
|
158 |
{
|
|
159 |
TELAUDRTNG_RDEBUG1(_L("[TELAUDRTNG]\t AvailableOutputsChangedL: aOutputs[i] = %d "),aOutputs[i]);
|
|
160 |
}
|
|
161 |
|
|
162 |
TInt KBufExpandSize8 = 8;//two TInts
|
|
163 |
CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8);
|
|
164 |
CleanupStack::PushL(dataCopyBuffer);
|
|
165 |
RBufWriteStream stream;
|
|
166 |
stream.Open(*dataCopyBuffer);
|
|
167 |
CleanupClosePushL(stream);
|
|
168 |
|
|
169 |
for (TInt i=0;i<aOutputs.Count();i++)
|
|
170 |
{
|
|
171 |
stream.WriteInt16L(aOutputs[i]);
|
|
172 |
}
|
|
173 |
|
|
174 |
TPtr8 ptr = dataCopyBuffer->Ptr(0);
|
|
175 |
|
|
176 |
SendReceive(ETelAudRtngDoAvailableOutputsChanged, TIpcArgs(&numOfOutputs, &ptr));
|
|
177 |
stream.Close();
|
|
178 |
CleanupStack::PopAndDestroy(2);//stream, buf
|
|
179 |
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// RTelephonyAudioRoutingManagerSession::SetPolicySessionIdL
|
|
184 |
// Sets policy session Id.
|
|
185 |
// (other items were commented in a header).
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::SetPolicySessionIdL()
|
|
189 |
{
|
|
190 |
User::LeaveIfError(SendReceive(ETelAudRtngServSetPolicySessionId, TIpcArgs()));
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// RTelephonyAudioRoutingManagerSession::MonitorOutputChangeRequest
|
|
195 |
// Used by policy session to get notification whenever any of the clients sends
|
|
196 |
// a SetOutput request.
|
|
197 |
// (other items were commented in a header).
|
|
198 |
// -----------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::MonitorOutputChangeRequest()
|
|
201 |
{
|
|
202 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::MonitorOutputChangeRequest "));
|
|
203 |
|
|
204 |
iPolicyRequest->Cancel();
|
|
205 |
|
|
206 |
SendReceive(ETelAudRtngServMonitorOutputChange, TIpcArgs(&iAudioOutputPkg), iPolicyRequest->iStatus);
|
|
207 |
iPolicyRequest->SetActive();
|
|
208 |
|
|
209 |
}
|
|
210 |
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
// RTelephonyAudioRoutingManagerSession::CancelRequest
|
|
213 |
// Cancel a previously send request.
|
|
214 |
// (other items were commented in a header).
|
|
215 |
// -----------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
EXPORT_C void RTelephonyAudioRoutingManagerSession::CancelRequest(TTelAudRtngServRqst aRequest)
|
|
218 |
{
|
|
219 |
TELAUDRTNG_RDEBUG(_L("[TELAUDRTNG]\t RTelephonyAudioRoutingManagerSession::CancelRequest "));
|
|
220 |
TPckgBuf<TInt> request;
|
|
221 |
request() = aRequest;
|
|
222 |
SendReceive(ETelAudRtngServCancelRequest, TIpcArgs(&request));
|
|
223 |
}
|
|
224 |
|
|
225 |
// -----------------------------------------------------------------------------
|
|
226 |
// RTelephonyAudioRoutingSession::AudioOutputPkg
|
|
227 |
// Accessor method returns iAudioOutputPkg to caller.
|
|
228 |
// (other items were commented in a header).
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
EXPORT_C TPckgBuf<CTelephonyAudioRouting::TAudioOutput>& RTelephonyAudioRoutingManagerSession::AudioOutputPkg()
|
|
232 |
{
|
|
233 |
return iAudioOutputPkg;
|
|
234 |
}
|
|
235 |
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
// RTelephonyAudioRoutingManagerSession::StartPolicyRequestHandlersL
|
|
238 |
// Start asynchronous request handlers.
|
|
239 |
// (other items were commented in a header).
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
void RTelephonyAudioRoutingManagerSession::StartPolicyRequestHandlersL(
|
|
243 |
CTelephonyAudioRoutingManager& aAudioRoutingManager,
|
|
244 |
MTelephonyAudioRoutingPolicyObserver& aPolicyObserver )
|
|
245 |
{
|
|
246 |
iPolicyRequest = CTelephonyAudioRoutingPolicyRequest::NewL(*this, aPolicyObserver, aAudioRoutingManager, ETelAudRtngServMonitorOutputChange);
|
|
247 |
}
|