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