|
1 // Copyright (c) 2007-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 // |
|
15 |
|
16 #include <ecom/implementationproxy.h> |
|
17 #include <ecom/implementationproxy.h> |
|
18 #include <ecom/ecom.h> |
|
19 |
|
20 #include "gettimestampsci.h" |
|
21 |
|
22 class TPositionTimestamp |
|
23 { |
|
24 public: |
|
25 TTimeIntervalMicroSeconds iBufferPosition; |
|
26 TTime iTimestamp; |
|
27 }; |
|
28 |
|
29 // MUX // |
|
30 /*****************************************************************************/ |
|
31 |
|
32 TInt CMMFGetTimestampsMux::OpenInterface(TUid /*aInterfaceId*/) |
|
33 { |
|
34 // attempt to open the interface link with the |
|
35 // remote slave device |
|
36 iRemoteHandle = -1; |
|
37 TUid slaveId = {KMmfUidCustomInterfaceGetTimestampsDeMux}; |
|
38 |
|
39 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8); |
|
40 if (handle >= 0) |
|
41 { |
|
42 iRemoteHandle = handle; |
|
43 } |
|
44 |
|
45 return iRemoteHandle; |
|
46 } |
|
47 |
|
48 /*****************************************************************************/ |
|
49 void CMMFGetTimestampsMux::Release() |
|
50 { |
|
51 // close the slave device if it exists |
|
52 if (iRemoteHandle > 0) |
|
53 { |
|
54 // we assume the slave is closed correctly |
|
55 iUtility->CloseSlave(iRemoteHandle); |
|
56 } |
|
57 |
|
58 TUid key = iDestructorKey; |
|
59 delete this; |
|
60 |
|
61 // tell ECom to destroy us |
|
62 REComSession::DestroyedImplementation(key); |
|
63 } |
|
64 |
|
65 /*****************************************************************************/ |
|
66 void CMMFGetTimestampsMux::PassDestructorKey(TUid aDestructorKey) |
|
67 { |
|
68 // store the destructor key |
|
69 iDestructorKey = aDestructorKey; |
|
70 } |
|
71 |
|
72 /*****************************************************************************/ |
|
73 void CMMFGetTimestampsMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility) |
|
74 { |
|
75 // store a pointer to the utility |
|
76 iUtility = aCustomUtility; |
|
77 } |
|
78 |
|
79 /*****************************************************************************/ |
|
80 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFGetTimestampsMux::NewL() |
|
81 { |
|
82 CMMFGetTimestampsMux* self = new (ELeave) CMMFGetTimestampsMux; |
|
83 return self; |
|
84 } |
|
85 |
|
86 /*****************************************************************************/ |
|
87 TAny* CMMFGetTimestampsMux::CustomInterface(TUid /*aInterfaceId*/) |
|
88 { |
|
89 MMMFGetTimestamps* interface = this; |
|
90 return interface; |
|
91 } |
|
92 |
|
93 /*****************************************************************************/ |
|
94 CMMFGetTimestampsMux::CMMFGetTimestampsMux() : |
|
95 iRemoteHandle(-1) |
|
96 { |
|
97 } |
|
98 |
|
99 /*****************************************************************************/ |
|
100 CMMFGetTimestampsMux::~CMMFGetTimestampsMux() |
|
101 { |
|
102 } |
|
103 |
|
104 /*****************************************************************************/ |
|
105 // from MMMFGetTimestamps |
|
106 TInt CMMFGetTimestampsMux::MmgtSetRecordSystemTimestampsEnabled(TBool aEnable) |
|
107 { |
|
108 if (iRemoteHandle > 0) |
|
109 { |
|
110 // send the enable flag in the sync command |
|
111 TPckgBuf<TBool> flag(aEnable); |
|
112 |
|
113 // any return code other than zero is an error |
|
114 return iUtility->SendSlaveSyncCommand(iRemoteHandle, EMMFDevSoundCIGetTimestampsEnable, flag); |
|
115 } |
|
116 else |
|
117 { |
|
118 return KErrNotReady; |
|
119 } |
|
120 } |
|
121 |
|
122 TInt CMMFGetTimestampsMux::MmgtGetSystemTimestampForBuffer(const TTimeIntervalMicroSeconds& aBufferPosition, |
|
123 TTime& aTimestamp) const |
|
124 { |
|
125 TInt err = KErrNotReady; |
|
126 if (iRemoteHandle > 0) |
|
127 { |
|
128 // send the position and timestamp in the sync command |
|
129 TPositionTimestamp value; |
|
130 value.iBufferPosition = aBufferPosition; |
|
131 value.iTimestamp = aTimestamp; |
|
132 TPckgBuf<TPositionTimestamp> pckgBuffer(value); |
|
133 |
|
134 // any return code other than zero is an error |
|
135 err = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, EMMFDevSoundCIGetTimestampsForBuffer, |
|
136 pckgBuffer, pckgBuffer); |
|
137 aTimestamp = pckgBuffer().iTimestamp; |
|
138 } |
|
139 |
|
140 return err; |
|
141 } |
|
142 |
|
143 |
|
144 |
|
145 // DEMUX // |
|
146 /*****************************************************************************/ |
|
147 TInt CMMFGetTimestampsDeMux::OpenInterface(TUid /*aInterfaceId*/) |
|
148 { |
|
149 return KErrNone; |
|
150 } |
|
151 |
|
152 /*****************************************************************************/ |
|
153 void CMMFGetTimestampsDeMux::Release() |
|
154 { |
|
155 TUid key = iDestructorKey; |
|
156 |
|
157 delete this; |
|
158 |
|
159 // tell ECom to destroy us |
|
160 REComSession::DestroyedImplementation(key); |
|
161 } |
|
162 |
|
163 /*****************************************************************************/ |
|
164 void CMMFGetTimestampsDeMux::PassDestructorKey(TUid aDestructorKey) |
|
165 { |
|
166 // store the destructor key |
|
167 iDestructorKey = aDestructorKey; |
|
168 } |
|
169 |
|
170 /*****************************************************************************/ |
|
171 void CMMFGetTimestampsDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget) |
|
172 { |
|
173 iTarget = aTarget; |
|
174 } |
|
175 |
|
176 /*****************************************************************************/ |
|
177 void CMMFGetTimestampsDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility) |
|
178 { |
|
179 // store a pointer to the utility |
|
180 iUtility = aCustomUtility; |
|
181 } |
|
182 |
|
183 /*****************************************************************************/ |
|
184 void CMMFGetTimestampsDeMux::RefreshL() |
|
185 { |
|
186 // refetch the play back status custom interface if we already have a target |
|
187 if (iTarget) |
|
188 { |
|
189 MMMFGetTimestamps* ptr = NULL; |
|
190 |
|
191 ptr = static_cast <MMMFGetTimestamps*> (iTarget->CustomInterface(KUidGetTimestamps)); |
|
192 |
|
193 if (!ptr) |
|
194 { |
|
195 iInterfaceGetTimestamps = NULL; |
|
196 User::Leave(KErrNotSupported); |
|
197 } |
|
198 else |
|
199 { |
|
200 iInterfaceGetTimestamps = ptr; |
|
201 } |
|
202 } |
|
203 } |
|
204 |
|
205 /*****************************************************************************/ |
|
206 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFGetTimestampsDeMux::NewL() |
|
207 { |
|
208 CMMFGetTimestampsDeMux* self = new (ELeave) CMMFGetTimestampsDeMux; |
|
209 return self; |
|
210 } |
|
211 |
|
212 /*****************************************************************************/ |
|
213 CMMFGetTimestampsDeMux::CMMFGetTimestampsDeMux() |
|
214 { |
|
215 } |
|
216 |
|
217 /*****************************************************************************/ |
|
218 CMMFGetTimestampsDeMux::~CMMFGetTimestampsDeMux() |
|
219 { |
|
220 } |
|
221 |
|
222 /*****************************************************************************/ |
|
223 TInt CMMFGetTimestampsDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/) |
|
224 { |
|
225 // fetch the Playback status Hw Device custom interface |
|
226 MMMFGetTimestamps* ptr = NULL; |
|
227 |
|
228 ptr = static_cast<MMMFGetTimestamps*> (iTarget->CustomInterface(KUidGetTimestamps)); |
|
229 |
|
230 if (!ptr) |
|
231 { |
|
232 iInterfaceGetTimestamps = NULL; |
|
233 User::Leave(KErrNotSupported); |
|
234 } |
|
235 else |
|
236 { |
|
237 iInterfaceGetTimestamps = ptr; |
|
238 } |
|
239 return KErrNone; |
|
240 } |
|
241 |
|
242 /*****************************************************************************/ |
|
243 void CMMFGetTimestampsDeMux::DoCloseSlaveL(TInt /*aHandle*/) |
|
244 { |
|
245 // nothing to do |
|
246 } |
|
247 |
|
248 /*****************************************************************************/ |
|
249 // original RMessage is supplied so that remote demux plugin can extract necessary details |
|
250 // using DeMux utility |
|
251 TInt CMMFGetTimestampsDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) |
|
252 { |
|
253 TMMFDevSoundCIMessageData data; |
|
254 |
|
255 TInt retVal = KErrNone; |
|
256 |
|
257 // decode message |
|
258 iUtility->GetSyncMessageDataL(aMessage, data); |
|
259 |
|
260 switch (data.iCommand) |
|
261 { |
|
262 case EMMFDevSoundCIGetTimestampsEnable: |
|
263 { |
|
264 TPckgBuf<TBool> flag; |
|
265 iUtility->ReadFromInputDesL(aMessage, &flag); |
|
266 retVal = DoMmgtSetRecordSystemTimestampsEnabled(flag()); |
|
267 break; |
|
268 } |
|
269 default: |
|
270 { |
|
271 User::Leave(KErrNotSupported); |
|
272 } |
|
273 } |
|
274 return retVal; |
|
275 } |
|
276 |
|
277 /*****************************************************************************/ |
|
278 TInt CMMFGetTimestampsDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) |
|
279 { |
|
280 TMMFDevSoundCIMessageData data; |
|
281 |
|
282 TInt retVal = KErrNone; |
|
283 |
|
284 // decode message |
|
285 iUtility->GetSyncMessageDataL(aMessage, data); |
|
286 |
|
287 switch (data.iCommand) |
|
288 { |
|
289 case EMMFDevSoundCIGetTimestampsForBuffer: |
|
290 { |
|
291 TPckgBuf<TPositionTimestamp> value; |
|
292 iUtility->ReadFromInputDesL(aMessage, &value); |
|
293 retVal = DoMmgtGetSystemTimestampForBuffer(value().iBufferPosition, value().iTimestamp); |
|
294 iUtility->WriteToOutputDesL(aMessage, value); |
|
295 break; |
|
296 } |
|
297 default: |
|
298 { |
|
299 User::Leave(KErrNotSupported); |
|
300 } |
|
301 } |
|
302 return retVal; |
|
303 } |
|
304 |
|
305 /*****************************************************************************/ |
|
306 void CMMFGetTimestampsDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/) |
|
307 { |
|
308 // not used in this interface |
|
309 } |
|
310 |
|
311 /*****************************************************************************/ |
|
312 void CMMFGetTimestampsDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/) |
|
313 { |
|
314 // not used in this interface |
|
315 } |
|
316 |
|
317 /*****************************************************************************/ |
|
318 // Get Timestamp custom interface implementation |
|
319 TInt CMMFGetTimestampsDeMux::DoMmgtSetRecordSystemTimestampsEnabled(TBool aEnable) |
|
320 { |
|
321 if (!iInterfaceGetTimestamps) |
|
322 { |
|
323 return KErrNotReady; |
|
324 } |
|
325 else |
|
326 { |
|
327 return iInterfaceGetTimestamps->MmgtSetRecordSystemTimestampsEnabled(aEnable); |
|
328 } |
|
329 } |
|
330 |
|
331 TInt CMMFGetTimestampsDeMux::DoMmgtGetSystemTimestampForBuffer(const TTimeIntervalMicroSeconds& aBufferPosition, |
|
332 TTime& aTimestamp) |
|
333 { |
|
334 if (!iInterfaceGetTimestamps) |
|
335 { |
|
336 return KErrNotReady; |
|
337 } |
|
338 else |
|
339 { |
|
340 return iInterfaceGetTimestamps->MmgtGetSystemTimestampForBuffer(aBufferPosition, aTimestamp); |
|
341 } |
|
342 } |
|
343 /*****************************************************************************/ |
|
344 // |
|
345 // ImplementationTable |
|
346 // |
|
347 |
|
348 const TImplementationProxy ImplementationTable[] = |
|
349 { |
|
350 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGetTimestampsMux, CMMFGetTimestampsMux::NewL), |
|
351 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGetTimestampsDeMux, CMMFGetTimestampsDeMux::NewL), |
|
352 }; |
|
353 |
|
354 /*****************************************************************************/ |
|
355 // |
|
356 // ImplementationGroupProxy |
|
357 // |
|
358 // |
|
359 |
|
360 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
361 { |
|
362 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
363 |
|
364 return ImplementationTable; |
|
365 } |
|
366 |
|
367 |