|
1 // Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __MMFDATAPATHPROXY_H__ |
|
17 #define __MMFDATAPATHPROXY_H__ |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <e32std.h> |
|
21 #include <ecom/ecom.h> |
|
22 #include <mmf/server/mmfdatapath.h> |
|
23 #include <mmf/server/mmfsubthreadbase.h> |
|
24 |
|
25 #define KMMFDataPathProxyVersion TVersion(8,0,0) |
|
26 |
|
27 /** |
|
28 The amount of time that is allowed for the datapath to close down before the its thread is killed. |
|
29 */ |
|
30 #define KMMFDataPathProxyShutdownTimeout TTimeIntervalMicroSeconds32(10000000) |
|
31 |
|
32 |
|
33 /** |
|
34 @publishedAll |
|
35 @released |
|
36 |
|
37 Mixin class that the user of the class CMMFDataPathEventMonitor must derive from. |
|
38 |
|
39 @since 7.0s |
|
40 */ |
|
41 class MMMFDataPathEventMonitorObserver |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 Handles an event that has been generated by the datapath. |
|
47 |
|
48 Called by CMMFDataPathEventMonitor::RunL(). |
|
49 |
|
50 @param aEvent |
|
51 The event to be handled. |
|
52 |
|
53 @since 7.0s |
|
54 */ |
|
55 virtual void HandleEvent(const TMMFEvent& aEvent) = 0; |
|
56 }; |
|
57 |
|
58 class RMMFDataPathProxy; //forward reference |
|
59 |
|
60 /** |
|
61 @publishedAll |
|
62 @released |
|
63 |
|
64 Active object utility class that can be used to monitor a datapath that is running in its own |
|
65 thread for events. If an event occurs, the client will be notified via the |
|
66 MMMFDataPathEventMonitorObserver interface. |
|
67 |
|
68 @since 7.0s |
|
69 */ |
|
70 class CMMFDataPathEventMonitor : public CActive |
|
71 { |
|
72 public: |
|
73 |
|
74 IMPORT_C static CMMFDataPathEventMonitor* NewL(MMMFDataPathEventMonitorObserver& aObserver, |
|
75 RMMFDataPathProxy& aMMFDataPathProxy); |
|
76 |
|
77 IMPORT_C ~CMMFDataPathEventMonitor(); |
|
78 |
|
79 IMPORT_C void Start(); |
|
80 |
|
81 IMPORT_C void RunL(); |
|
82 protected: |
|
83 |
|
84 void DoCancel(); |
|
85 private: |
|
86 |
|
87 /** |
|
88 Constructs a datapath event monitor object. |
|
89 |
|
90 @param aObserver |
|
91 A reference to the observer of the active object. The observer will be |
|
92 notified when an event occurs. |
|
93 @param aMMFDataPathProxy |
|
94 A reference to the datapath proxy class. |
|
95 |
|
96 @since 7.0s |
|
97 */ |
|
98 CMMFDataPathEventMonitor(MMMFDataPathEventMonitorObserver& aObserver, |
|
99 RMMFDataPathProxy& aMMFDataPathProxy); |
|
100 private: |
|
101 MMMFDataPathEventMonitorObserver& iObserver; |
|
102 RMMFDataPathProxy& iMMFDataPathProxy; |
|
103 TMMFEventPckg iEventPckg; |
|
104 }; |
|
105 |
|
106 /** |
|
107 @publishedAll |
|
108 @released |
|
109 |
|
110 Proxy class used to create a datapath in a new subthread. |
|
111 */ |
|
112 class RMMFDataPathProxy : public RMMFSubThreadBase |
|
113 |
|
114 { |
|
115 public: |
|
116 |
|
117 /** |
|
118 Constuctor. |
|
119 */ |
|
120 RMMFDataPathProxy() : RMMFSubThreadBase(KMMFDataPathProxyShutdownTimeout) {}; |
|
121 |
|
122 IMPORT_C TInt CreateSubThread(); |
|
123 |
|
124 IMPORT_C TInt LoadDataPath(); |
|
125 |
|
126 IMPORT_C TInt LoadDataPath(TMediaId aMediaId); |
|
127 |
|
128 IMPORT_C TInt LoadDataPath(TUid aCodecUid); |
|
129 |
|
130 IMPORT_C TInt LoadDataPath(TUid aCodecUid, TMediaId aMediaId); |
|
131 |
|
132 IMPORT_C TInt AddDataSource(MDataSource* aSource); |
|
133 |
|
134 IMPORT_C TInt AddDataSink(MDataSink* aSink); |
|
135 |
|
136 IMPORT_C TInt Prime(); |
|
137 |
|
138 IMPORT_C TInt Play(); |
|
139 |
|
140 IMPORT_C TInt Pause(); |
|
141 |
|
142 IMPORT_C TInt Stop(); |
|
143 |
|
144 IMPORT_C TInt GetPosition(TTimeIntervalMicroSeconds& aPosition) const; |
|
145 |
|
146 IMPORT_C TInt SetPosition(const TTimeIntervalMicroSeconds& aPosition); |
|
147 |
|
148 IMPORT_C TInt SetPlayWindow( const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd ) ; |
|
149 |
|
150 IMPORT_C TInt ClearPlayWindow() ; |
|
151 |
|
152 IMPORT_C TInt State( TInt& aState ) ; |
|
153 |
|
154 IMPORT_C void Close(); |
|
155 }; |
|
156 |
|
157 /** |
|
158 @internalComponent |
|
159 |
|
160 The server running in the datapath subthread. |
|
161 The subthread is owned by the main thread and shares the same heap. |
|
162 */ |
|
163 class CMMFDataPathProxyServer : public CMMFSubThreadServer |
|
164 { |
|
165 public: |
|
166 static CMMFDataPathProxyServer* NewL(); |
|
167 ~CMMFDataPathProxyServer(); |
|
168 static TInt StartThread(TAny* aAny); |
|
169 static void DoStartThreadL(); |
|
170 private: |
|
171 CMmfIpcSession* NewSessionL(const TVersion& aVersion) const; |
|
172 CMMFDataPathProxyServer(); |
|
173 void ConstructL(); |
|
174 }; |
|
175 |
|
176 |
|
177 /** |
|
178 @internalComponent |
|
179 |
|
180 The session used to transmit messages between the main thread and the subthread. |
|
181 Only one session can be created with a datapath subthread. |
|
182 Once this session is closed, the subthread will be killed. |
|
183 */ |
|
184 class CMMFDataPathProxySession : public CMMFSubThreadSession |
|
185 { |
|
186 public: |
|
187 static CMMFDataPathProxySession* NewL(); |
|
188 ~CMMFDataPathProxySession(); |
|
189 void ServiceL(const RMmfIpcMessage& aMessage); |
|
190 private: |
|
191 CMMFDataPathProxySession(); |
|
192 TBool LoadDataPathByL(const RMmfIpcMessage& aMessage); |
|
193 TBool LoadDataPathByMediaIdL(const RMmfIpcMessage& aMessage); |
|
194 TBool LoadDataPathByCodecUidL(const RMmfIpcMessage& aMessage); |
|
195 TBool LoadDataPathByMediaIdCodecUidL(const RMmfIpcMessage& aMessage); |
|
196 TBool AddDataSourceL(const RMmfIpcMessage& aMessage); |
|
197 TBool AddDataSinkL(const RMmfIpcMessage& aMessage); |
|
198 TBool PrimeL(const RMmfIpcMessage& aMessage); |
|
199 TBool PlayL(const RMmfIpcMessage& aMessage); |
|
200 TBool PauseL(const RMmfIpcMessage& aMessage); |
|
201 TBool StopL(const RMmfIpcMessage& aMessage); |
|
202 TBool GetPositionL(const RMmfIpcMessage& aMessage) const; |
|
203 TBool SetPositionL(const RMmfIpcMessage& aMessage); |
|
204 TBool SetPlayWindowL(const RMmfIpcMessage& aMessage) ; |
|
205 TBool ClearPlayWindowL(const RMmfIpcMessage& aMessage) ; |
|
206 TBool StateL(const RMmfIpcMessage& aMessage) ; |
|
207 |
|
208 void CheckDataPathExistsL() const {if (!iDataPath) User::Leave(KErrNotReady);}; |
|
209 private: |
|
210 CMMFDataPath* iDataPath; |
|
211 }; |
|
212 |
|
213 |
|
214 |
|
215 #endif |