epoc32/include/mmf/server/mmfdatapathproxy.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/mmf/server/mmfdatapathproxy.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,215 @@
     1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#ifndef __MMFDATAPATHPROXY_H__
    1.20 +#define __MMFDATAPATHPROXY_H__
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +#include <e32std.h>
    1.24 +#include <ecom/ecom.h>
    1.25 +#include <mmf/server/mmfdatapath.h>
    1.26 +#include <mmf/server/mmfsubthreadbase.h>
    1.27 +
    1.28 +#define KMMFDataPathProxyVersion TVersion(8,0,0)
    1.29 +
    1.30 +/**
    1.31 +The amount of time that is allowed for the datapath to close down before the its thread is killed.
    1.32 +*/
    1.33 +#define  KMMFDataPathProxyShutdownTimeout TTimeIntervalMicroSeconds32(10000000)
    1.34 +
    1.35 +
    1.36 +/**
    1.37 +@publishedAll
    1.38 +@released
    1.39 +
    1.40 +Mixin class that the user of the class CMMFDataPathEventMonitor must derive from.
    1.41 +
    1.42 +@since 7.0s
    1.43 +*/
    1.44 +class MMMFDataPathEventMonitorObserver
    1.45 +	{
    1.46 +public:
    1.47 +
    1.48 +	/**
    1.49 +	Handles an event that has been generated by the datapath.
    1.50 +
    1.51 +	Called by CMMFDataPathEventMonitor::RunL().
    1.52 +
    1.53 +	@param  aEvent
    1.54 +	        The event to be handled.
    1.55 +
    1.56 +	@since  7.0s
    1.57 +	*/
    1.58 +	virtual void HandleEvent(const TMMFEvent& aEvent) = 0;
    1.59 +	};
    1.60 +
    1.61 +class RMMFDataPathProxy; //forward reference
    1.62 +
    1.63 +/**
    1.64 +@publishedAll
    1.65 +@released
    1.66 +
    1.67 +Active object utility class that can be used to monitor a datapath that is running in its own
    1.68 +thread for events. If an event occurs, the client will be notified via the
    1.69 +MMMFDataPathEventMonitorObserver interface.
    1.70 +
    1.71 +@since  7.0s
    1.72 +*/
    1.73 +class CMMFDataPathEventMonitor : public CActive
    1.74 +	{
    1.75 +public:
    1.76 +
    1.77 +	IMPORT_C static CMMFDataPathEventMonitor* NewL(MMMFDataPathEventMonitorObserver& aObserver,
    1.78 +		RMMFDataPathProxy& aMMFDataPathProxy);
    1.79 +
    1.80 +	IMPORT_C ~CMMFDataPathEventMonitor();
    1.81 +
    1.82 +	IMPORT_C void Start();
    1.83 +
    1.84 +	IMPORT_C void RunL();
    1.85 +protected:
    1.86 +
    1.87 +	void DoCancel();
    1.88 +private:
    1.89 +
    1.90 +	/**
    1.91 +	Constructs a datapath event monitor object.
    1.92 +
    1.93 +	@param  aObserver
    1.94 +	        A reference to the observer of the active object. The observer will be
    1.95 +	        notified when an event occurs.
    1.96 +	@param  aMMFDataPathProxy
    1.97 +	        A reference to the datapath proxy class.
    1.98 +
    1.99 +	@since  7.0s
   1.100 +	*/
   1.101 +	CMMFDataPathEventMonitor(MMMFDataPathEventMonitorObserver& aObserver, 
   1.102 +		RMMFDataPathProxy& aMMFDataPathProxy);
   1.103 +private:
   1.104 +	MMMFDataPathEventMonitorObserver& iObserver;
   1.105 +	RMMFDataPathProxy& iMMFDataPathProxy;
   1.106 +	TMMFEventPckg iEventPckg;
   1.107 +	};
   1.108 +
   1.109 +/**
   1.110 +@publishedAll
   1.111 +@released
   1.112 +
   1.113 +Proxy class used to create a datapath in a new subthread.
   1.114 +*/
   1.115 +class RMMFDataPathProxy : public RMMFSubThreadBase
   1.116 +
   1.117 +	{
   1.118 +public:
   1.119 +
   1.120 +	/**
   1.121 +	Constuctor.
   1.122 +	*/
   1.123 +	RMMFDataPathProxy() : RMMFSubThreadBase(KMMFDataPathProxyShutdownTimeout) {};
   1.124 +
   1.125 +	IMPORT_C TInt CreateSubThread();
   1.126 +
   1.127 +	IMPORT_C TInt LoadDataPath();
   1.128 +
   1.129 +	IMPORT_C TInt LoadDataPath(TMediaId aMediaId);
   1.130 +
   1.131 +	IMPORT_C TInt LoadDataPath(TUid aCodecUid); 
   1.132 +
   1.133 +	IMPORT_C TInt LoadDataPath(TUid aCodecUid, TMediaId aMediaId);
   1.134 +
   1.135 +	IMPORT_C TInt AddDataSource(MDataSource* aSource);
   1.136 +
   1.137 +	IMPORT_C TInt AddDataSink(MDataSink* aSink);
   1.138 +
   1.139 +	IMPORT_C TInt Prime();
   1.140 +
   1.141 +	IMPORT_C TInt Play();
   1.142 +
   1.143 +	IMPORT_C TInt Pause();
   1.144 +
   1.145 +	IMPORT_C TInt Stop();
   1.146 +
   1.147 +	IMPORT_C TInt GetPosition(TTimeIntervalMicroSeconds& aPosition) const;
   1.148 +
   1.149 +	IMPORT_C TInt SetPosition(const TTimeIntervalMicroSeconds& aPosition);
   1.150 +
   1.151 +	IMPORT_C TInt SetPlayWindow( const TTimeIntervalMicroSeconds& aStart, const TTimeIntervalMicroSeconds& aEnd ) ;
   1.152 +
   1.153 +	IMPORT_C TInt ClearPlayWindow() ;
   1.154 +
   1.155 +	IMPORT_C TInt State( TInt& aState ) ;
   1.156 +
   1.157 +	IMPORT_C void Close();
   1.158 +	};
   1.159 +
   1.160 +/**
   1.161 +@internalComponent
   1.162 + 
   1.163 +The server running in the datapath subthread.
   1.164 +The subthread is owned by the main thread and shares the same heap.
   1.165 +*/
   1.166 +class CMMFDataPathProxyServer : public CMMFSubThreadServer
   1.167 +	{
   1.168 +public:
   1.169 +	static CMMFDataPathProxyServer* NewL();
   1.170 +	~CMMFDataPathProxyServer();
   1.171 +	static TInt StartThread(TAny* aAny);
   1.172 +	static void DoStartThreadL();
   1.173 +private:
   1.174 +	CMmfIpcSession* NewSessionL(const TVersion& aVersion) const;
   1.175 +	CMMFDataPathProxyServer();
   1.176 +	void ConstructL();
   1.177 +	};
   1.178 +
   1.179 +
   1.180 +/**
   1.181 +@internalComponent
   1.182 +
   1.183 +The session used to transmit messages between the main thread and the subthread.
   1.184 +Only one session can be created with a datapath subthread.
   1.185 +Once this session is closed, the subthread will be killed.
   1.186 +*/
   1.187 +class CMMFDataPathProxySession : public CMMFSubThreadSession
   1.188 +	{
   1.189 +public:
   1.190 +	static CMMFDataPathProxySession* NewL();
   1.191 +	~CMMFDataPathProxySession();
   1.192 +	void ServiceL(const RMmfIpcMessage& aMessage);
   1.193 +private:
   1.194 +	CMMFDataPathProxySession();
   1.195 +	TBool LoadDataPathByL(const RMmfIpcMessage& aMessage);
   1.196 +	TBool LoadDataPathByMediaIdL(const RMmfIpcMessage& aMessage);
   1.197 +	TBool LoadDataPathByCodecUidL(const RMmfIpcMessage& aMessage);
   1.198 +	TBool LoadDataPathByMediaIdCodecUidL(const RMmfIpcMessage& aMessage);
   1.199 +	TBool AddDataSourceL(const RMmfIpcMessage& aMessage);
   1.200 +	TBool AddDataSinkL(const RMmfIpcMessage& aMessage);
   1.201 +	TBool PrimeL(const RMmfIpcMessage& aMessage);
   1.202 +	TBool PlayL(const RMmfIpcMessage& aMessage);
   1.203 +	TBool PauseL(const RMmfIpcMessage& aMessage);
   1.204 +	TBool StopL(const RMmfIpcMessage& aMessage);
   1.205 +	TBool GetPositionL(const RMmfIpcMessage& aMessage) const;
   1.206 +	TBool SetPositionL(const RMmfIpcMessage& aMessage);
   1.207 +	TBool SetPlayWindowL(const RMmfIpcMessage& aMessage) ;
   1.208 +	TBool ClearPlayWindowL(const RMmfIpcMessage& aMessage) ;
   1.209 +	TBool StateL(const RMmfIpcMessage& aMessage) ;
   1.210 +
   1.211 +	void CheckDataPathExistsL() const {if (!iDataPath) User::Leave(KErrNotReady);};
   1.212 +private:
   1.213 +	CMMFDataPath* iDataPath;
   1.214 +	};
   1.215 +
   1.216 +
   1.217 +
   1.218 +#endif