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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMFDATAPATHPROXY_H__
17 #define __MMFDATAPATHPROXY_H__
21 #include <ecom/ecom.h>
22 #include <mmf/server/mmfdatapath.h>
23 #include <mmf/server/mmfsubthreadbase.h>
25 #define KMMFDataPathProxyVersion TVersion(8,0,0)
28 The amount of time that is allowed for the datapath to close down before the its thread is killed.
30 #define KMMFDataPathProxyShutdownTimeout TTimeIntervalMicroSeconds32(10000000)
37 Mixin class that the user of the class CMMFDataPathEventMonitor must derive from.
41 class MMMFDataPathEventMonitorObserver
46 Handles an event that has been generated by the datapath.
48 Called by CMMFDataPathEventMonitor::RunL().
51 The event to be handled.
55 virtual void HandleEvent(const TMMFEvent& aEvent) = 0;
58 class RMMFDataPathProxy; //forward reference
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.
70 class CMMFDataPathEventMonitor : public CActive
74 IMPORT_C static CMMFDataPathEventMonitor* NewL(MMMFDataPathEventMonitorObserver& aObserver,
75 RMMFDataPathProxy& aMMFDataPathProxy);
77 IMPORT_C ~CMMFDataPathEventMonitor();
79 IMPORT_C void Start();
88 Constructs a datapath event monitor object.
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.
98 CMMFDataPathEventMonitor(MMMFDataPathEventMonitorObserver& aObserver,
99 RMMFDataPathProxy& aMMFDataPathProxy);
101 MMMFDataPathEventMonitorObserver& iObserver;
102 RMMFDataPathProxy& iMMFDataPathProxy;
103 TMMFEventPckg iEventPckg;
110 Proxy class used to create a datapath in a new subthread.
112 class RMMFDataPathProxy : public RMMFSubThreadBase
120 RMMFDataPathProxy() : RMMFSubThreadBase(KMMFDataPathProxyShutdownTimeout) {};
122 IMPORT_C TInt CreateSubThread();
124 IMPORT_C TInt LoadDataPath();
126 IMPORT_C TInt LoadDataPath(TMediaId aMediaId);
128 IMPORT_C TInt LoadDataPath(TUid aCodecUid);
130 IMPORT_C TInt LoadDataPath(TUid aCodecUid, TMediaId aMediaId);
132 IMPORT_C TInt AddDataSource(MDataSource* aSource);
134 IMPORT_C TInt AddDataSink(MDataSink* aSink);
136 IMPORT_C TInt Prime();
138 IMPORT_C TInt Play();
140 IMPORT_C TInt Pause();
142 IMPORT_C TInt Stop();
144 IMPORT_C TInt GetPosition(TTimeIntervalMicroSeconds& aPosition) const;
146 IMPORT_C TInt SetPosition(const TTimeIntervalMicroSeconds& aPosition);
148 IMPORT_C TInt SetPlayWindow( const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd ) ;
150 IMPORT_C TInt ClearPlayWindow() ;
152 IMPORT_C TInt State( TInt& aState ) ;
154 IMPORT_C void Close();
160 The server running in the datapath subthread.
161 The subthread is owned by the main thread and shares the same heap.
163 class CMMFDataPathProxyServer : public CMMFSubThreadServer
166 static CMMFDataPathProxyServer* NewL();
167 ~CMMFDataPathProxyServer();
168 static TInt StartThread(TAny* aAny);
169 static void DoStartThreadL();
171 CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
172 CMMFDataPathProxyServer();
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.
184 class CMMFDataPathProxySession : public CMMFSubThreadSession
187 static CMMFDataPathProxySession* NewL();
188 ~CMMFDataPathProxySession();
189 void ServiceL(const RMmfIpcMessage& aMessage);
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) ;
208 void CheckDataPathExistsL() const {if (!iDataPath) User::Leave(KErrNotReady);};
210 CMMFDataPath* iDataPath;