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 |
// include\mmf\server\mmfdatasink.h
|
williamr@2
|
15 |
//
|
williamr@2
|
16 |
//
|
williamr@2
|
17 |
|
williamr@2
|
18 |
#ifndef __MMF_SERVER_DATASINK_H__
|
williamr@2
|
19 |
#define __MMF_SERVER_DATASINK_H__
|
williamr@2
|
20 |
|
williamr@2
|
21 |
#include <e32base.h>
|
williamr@2
|
22 |
#include <mmf/server/mmfdatasourcesink.hrh>
|
williamr@2
|
23 |
#include <mmf/common/mmfutilities.h>
|
williamr@2
|
24 |
#include <ecom/ecom.h>
|
williamr@2
|
25 |
#include <mmf/common/mmfbase.h>
|
williamr@2
|
26 |
#include <mmf/common/mmfcontrollerframework.h>
|
williamr@2
|
27 |
|
williamr@2
|
28 |
//
|
williamr@2
|
29 |
// MDataSink mixim
|
williamr@2
|
30 |
//
|
williamr@2
|
31 |
|
williamr@2
|
32 |
class TFourCC;
|
williamr@2
|
33 |
class TMediaId;
|
williamr@2
|
34 |
class CMMFBuffer;
|
williamr@2
|
35 |
class MDataSource;
|
williamr@2
|
36 |
class MAsyncEventHandler;
|
williamr@2
|
37 |
|
williamr@2
|
38 |
/**
|
williamr@2
|
39 |
@publishedAll
|
williamr@2
|
40 |
@released
|
williamr@2
|
41 |
|
williamr@2
|
42 |
Abstract class representing a data sink.
|
williamr@2
|
43 |
*/
|
williamr@2
|
44 |
class MDataSink
|
williamr@2
|
45 |
{
|
williamr@2
|
46 |
public:
|
williamr@2
|
47 |
|
williamr@2
|
48 |
static inline MDataSink* NewSinkL( TUid aImplementationUid, const TDesC8& aInitData ) ;
|
williamr@2
|
49 |
|
williamr@2
|
50 |
/**
|
williamr@2
|
51 |
Destructor.
|
williamr@2
|
52 |
*/
|
williamr@2
|
53 |
virtual ~MDataSink() {REComSession::DestroyedImplementation(iDtor_ID_Key);};
|
williamr@2
|
54 |
|
williamr@2
|
55 |
/**
|
williamr@2
|
56 |
Returns the UID identifying the type of data sink.
|
williamr@2
|
57 |
|
williamr@2
|
58 |
@return The UID identifying the type of data sink
|
williamr@2
|
59 |
*/
|
williamr@2
|
60 |
virtual TUid DataSinkType() const {return iDataSinkType;};
|
williamr@2
|
61 |
|
williamr@2
|
62 |
/**
|
williamr@2
|
63 |
Returns the data type as a fourCC code of the data sink.
|
williamr@2
|
64 |
|
williamr@2
|
65 |
This is a pure virtual function that each derrived class must implement.
|
williamr@2
|
66 |
|
williamr@2
|
67 |
@param aMediaId
|
williamr@2
|
68 |
This identifies the type of media eg. audio or video and the stream ID.
|
williamr@2
|
69 |
This parameter is required in cases where the sink can accept data
|
williamr@2
|
70 |
of more than one media type and/or multiple streams of data.
|
williamr@2
|
71 |
|
williamr@2
|
72 |
@return The fourCC code identifying the sink datatype for the specified aMediaId.
|
williamr@2
|
73 |
*/
|
williamr@2
|
74 |
virtual TFourCC SinkDataTypeCode(TMediaId aMediaId) = 0;
|
williamr@2
|
75 |
|
williamr@2
|
76 |
inline virtual TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId);
|
williamr@2
|
77 |
|
williamr@2
|
78 |
/**
|
williamr@2
|
79 |
Method called by a MDataSource to request the data sink to empty aBuffer of data.
|
williamr@2
|
80 |
|
williamr@2
|
81 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
82 |
This method is used when a data sink is passively waiting for requests from a supplier ie.
|
williamr@2
|
83 |
a data source to empty a buffer. The data sink must call the BufferEmptiedL member on aSupplier
|
williamr@2
|
84 |
when it has emptied the buffer of it's data. The data sink can either make this callback
|
williamr@2
|
85 |
synchronously or asynchronously.
|
williamr@2
|
86 |
|
williamr@2
|
87 |
@param aBuffer
|
williamr@2
|
88 |
The full buffer that needs emptying of it's data.
|
williamr@2
|
89 |
@param aSupplier
|
williamr@2
|
90 |
The data source that supplied the data. The data sink needs this to make the
|
williamr@2
|
91 |
BufferEmptiedL callback on aSupplier to indicate to the data source that the data sink
|
williamr@2
|
92 |
has finished with the buffer.
|
williamr@2
|
93 |
@param aMediaId
|
williamr@2
|
94 |
This identifies the type of media eg. audio or video and the stream ID.
|
williamr@2
|
95 |
This parameter is required in cases where the source can supply data
|
williamr@2
|
96 |
of more than one media type and/or multiple streams of data.
|
williamr@2
|
97 |
*/
|
williamr@2
|
98 |
virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId)=0;
|
williamr@2
|
99 |
|
williamr@2
|
100 |
/**
|
williamr@2
|
101 |
Function called by a data source to pass back a filled buffer to the sink.
|
williamr@2
|
102 |
|
williamr@2
|
103 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
104 |
This method is used as the callback when the data sink actively requests a supplier ie. a
|
williamr@2
|
105 |
data source to fill a buffer by calling the data sources FillBufferL. When the data sink gets
|
williamr@2
|
106 |
this callback it knows that the buffer has been filled and is ready to be emptied.
|
williamr@2
|
107 |
|
williamr@2
|
108 |
@param aBuffer
|
williamr@2
|
109 |
The buffer that has been filled by a data source and is now available for processing.
|
williamr@2
|
110 |
*/
|
williamr@2
|
111 |
virtual void BufferFilledL(CMMFBuffer* aBuffer)=0;
|
williamr@2
|
112 |
|
williamr@2
|
113 |
/**
|
williamr@2
|
114 |
@deprecated
|
williamr@2
|
115 |
|
williamr@2
|
116 |
Function to indicate whether the data sink can create a buffer.
|
williamr@2
|
117 |
|
williamr@2
|
118 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
119 |
|
williamr@2
|
120 |
@return A boolean indicating if the data sink can create a buffer. ETrue if it can otherwise
|
williamr@2
|
121 |
EFalse.
|
williamr@2
|
122 |
*/
|
williamr@2
|
123 |
virtual TBool CanCreateSinkBuffer()=0;
|
williamr@2
|
124 |
|
williamr@2
|
125 |
/**
|
williamr@2
|
126 |
Returns a buffer created by the data sink.
|
williamr@2
|
127 |
|
williamr@2
|
128 |
This is a pure virtual function that each derived class must implement.
|
williamr@2
|
129 |
|
williamr@2
|
130 |
@param aMediaId
|
williamr@2
|
131 |
This identifies the type of media eg. audio or video and the stream ID.
|
williamr@2
|
132 |
This parameter is required in cases where the source can supply data
|
williamr@2
|
133 |
of more than one media type and/or multiple streams of data.
|
williamr@2
|
134 |
|
williamr@2
|
135 |
@param aReference
|
williamr@2
|
136 |
This must be written to by the method to indicate whether the created buffer is
|
williamr@2
|
137 |
a 'reference' buffer. A 'reference' buffer is a buffer that is owned by the sink
|
williamr@2
|
138 |
and should be used in preference to the source buffer provided the source buffer
|
williamr@2
|
139 |
is also not a reference buffer.
|
williamr@2
|
140 |
|
williamr@2
|
141 |
@return The created buffer.
|
williamr@2
|
142 |
*/
|
williamr@2
|
143 |
virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference)=0;
|
williamr@2
|
144 |
|
williamr@2
|
145 |
inline virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler);
|
williamr@2
|
146 |
|
williamr@2
|
147 |
/**
|
williamr@2
|
148 |
Function to 'logoff' the data sink from the same thread that sink consumes data in.
|
williamr@2
|
149 |
|
williamr@2
|
150 |
This method may be required as the thread that the data sink is deleted in may not be
|
williamr@2
|
151 |
the same thread that the data transfer took place in. Therefore any thread specific
|
williamr@2
|
152 |
releasing of resources needs to be performed in the SinkThreadLogoff rather than in the
|
williamr@2
|
153 |
destructor.
|
williamr@2
|
154 |
|
williamr@2
|
155 |
This is a virtual function that a derrived data sink can implement if any thread specific
|
williamr@2
|
156 |
releasing of resources is required.
|
williamr@2
|
157 |
*/
|
williamr@2
|
158 |
virtual void SinkThreadLogoff() {};
|
williamr@2
|
159 |
|
williamr@2
|
160 |
inline virtual void NegotiateL(MDataSource& aDataSource);
|
williamr@2
|
161 |
|
williamr@2
|
162 |
/**
|
williamr@2
|
163 |
Function to 'prime' the data sink.
|
williamr@2
|
164 |
|
williamr@2
|
165 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
166 |
any data sink specific 'priming' is required.
|
williamr@2
|
167 |
*/
|
williamr@2
|
168 |
virtual void SinkPrimeL() {};
|
williamr@2
|
169 |
|
williamr@2
|
170 |
/**
|
williamr@2
|
171 |
Function 'play' the data sink.
|
williamr@2
|
172 |
|
williamr@2
|
173 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
174 |
any data sink specific action is required prior to 'playing' ie. the start of data transfer.
|
williamr@2
|
175 |
*/
|
williamr@2
|
176 |
virtual void SinkPlayL() {};
|
williamr@2
|
177 |
|
williamr@2
|
178 |
/**
|
williamr@2
|
179 |
Function to 'pause' the data sink.
|
williamr@2
|
180 |
|
williamr@2
|
181 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
182 |
any data sink specific action is required to 'pause'.
|
williamr@2
|
183 |
*/
|
williamr@2
|
184 |
virtual void SinkPauseL() {};
|
williamr@2
|
185 |
|
williamr@2
|
186 |
/**
|
williamr@2
|
187 |
Function to 'stop' the data sink.
|
williamr@2
|
188 |
|
williamr@2
|
189 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
190 |
any data sink specific action is required to 'stop'
|
williamr@2
|
191 |
*/
|
williamr@2
|
192 |
virtual void SinkStopL() {};
|
williamr@2
|
193 |
|
williamr@2
|
194 |
inline virtual void SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
|
williamr@2
|
195 |
|
williamr@2
|
196 |
/**
|
williamr@2
|
197 |
Calls a sink specific custom command.
|
williamr@2
|
198 |
|
williamr@2
|
199 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
200 |
it implements any custom commands.
|
williamr@2
|
201 |
|
williamr@2
|
202 |
@param aMessage
|
williamr@2
|
203 |
The message specifying the custom command.
|
williamr@2
|
204 |
*/
|
williamr@2
|
205 |
virtual void SinkCustomCommand(TMMFMessage& aMessage) {aMessage.Complete(KErrNotSupported);};
|
williamr@2
|
206 |
|
williamr@2
|
207 |
protected:
|
williamr@2
|
208 |
/**
|
williamr@2
|
209 |
Performs any sink construction dependant on the sink construction
|
williamr@2
|
210 |
initialisation data aInitData.
|
williamr@2
|
211 |
|
williamr@2
|
212 |
This is a pure virtual function that a derrived data sink must implement
|
williamr@2
|
213 |
|
williamr@2
|
214 |
@param aInitData
|
williamr@2
|
215 |
The sink specific initialisation data required for sink construction.
|
williamr@2
|
216 |
*/
|
williamr@2
|
217 |
virtual void ConstructSinkL( const TDesC8& aInitData ) = 0;
|
williamr@2
|
218 |
|
williamr@2
|
219 |
/**
|
williamr@2
|
220 |
Protected constructor.
|
williamr@2
|
221 |
|
williamr@2
|
222 |
@param aType
|
williamr@2
|
223 |
The source type UID.
|
williamr@2
|
224 |
*/
|
williamr@2
|
225 |
MDataSink(TUid aType): iDataSinkType(aType) {}
|
williamr@2
|
226 |
|
williamr@2
|
227 |
private:
|
williamr@2
|
228 |
TUid iDataSinkType;
|
williamr@2
|
229 |
TUid iDtor_ID_Key;
|
williamr@2
|
230 |
};
|
williamr@2
|
231 |
|
williamr@2
|
232 |
/**
|
williamr@2
|
233 |
Instantiates a new data sink.
|
williamr@2
|
234 |
|
williamr@2
|
235 |
@param aImplementationUid
|
williamr@2
|
236 |
The UID identifying the data sink to be instantiated.
|
williamr@2
|
237 |
@param aInitData
|
williamr@2
|
238 |
The sink specific initialisation data required for sink construction.
|
williamr@2
|
239 |
|
williamr@2
|
240 |
@return A pointer to the instantiated data sink.
|
williamr@2
|
241 |
*/
|
williamr@2
|
242 |
inline MDataSink* MDataSink::NewSinkL( TUid aImplementationUid, const TDesC8& aInitData )
|
williamr@2
|
243 |
{
|
williamr@2
|
244 |
MDataSink* retPtr = REINTERPRET_CAST( MDataSink*, REComSession::CreateImplementationL( aImplementationUid,
|
williamr@2
|
245 |
_FOFF(MDataSink, iDtor_ID_Key) ) ) ;
|
williamr@2
|
246 |
CleanupDeletePushL(retPtr);
|
williamr@2
|
247 |
retPtr->ConstructSinkL( aInitData ) ;
|
williamr@2
|
248 |
|
williamr@2
|
249 |
CleanupStack::Pop(retPtr);
|
williamr@2
|
250 |
return retPtr ;
|
williamr@2
|
251 |
}
|
williamr@2
|
252 |
|
williamr@2
|
253 |
/**
|
williamr@2
|
254 |
Sets the data type as a fourCC code for the data sink.
|
williamr@2
|
255 |
|
williamr@2
|
256 |
This is a virtual function that each derived class can implement if the data sink supports
|
williamr@2
|
257 |
the ability to have its data type set.
|
williamr@2
|
258 |
|
williamr@2
|
259 |
@param aSinkFourCC
|
williamr@2
|
260 |
This specifies the data type as a fourCC code to set the sink to.
|
williamr@2
|
261 |
@param aMediaId
|
williamr@2
|
262 |
This identifies the type of media eg. audio or video and the stream ID.
|
williamr@2
|
263 |
This parameter is required in cases where the source can supply data
|
williamr@2
|
264 |
of more than one media type and/or multiple streams of data.
|
williamr@2
|
265 |
|
williamr@2
|
266 |
@return KErrNone if successful, KErrNotSupported if the sink does not support having
|
williamr@2
|
267 |
it's data type set, otherwise a system wide error code.
|
williamr@2
|
268 |
*/
|
williamr@2
|
269 |
inline TInt MDataSink::SetSinkDataTypeCode(TFourCC /*aSinkFourCC*/, TMediaId /*aMediaId*/)
|
williamr@2
|
270 |
{
|
williamr@2
|
271 |
return KErrNotSupported;
|
williamr@2
|
272 |
}
|
williamr@2
|
273 |
|
williamr@2
|
274 |
/**
|
williamr@2
|
275 |
Function to 'logon' the data sink to the same thread that sink will be consuming data in.
|
williamr@2
|
276 |
|
williamr@2
|
277 |
This method may be required as the thread that the data sink was created in is not always
|
williamr@2
|
278 |
the same thread that the data transfer will take place in. Therefore any thread specific
|
williamr@2
|
279 |
initialisation needs to be performed in the SinkThreadLogon rather than in the creation
|
williamr@2
|
280 |
of the data sink.
|
williamr@2
|
281 |
|
williamr@2
|
282 |
This is a virtual function that a derrived data sink can implement if any thread specific
|
williamr@2
|
283 |
initialisation is required and/or the data sink can create any asynchronous events.
|
williamr@2
|
284 |
|
williamr@2
|
285 |
@param aEventHandler
|
williamr@2
|
286 |
This is an MAsyncEventHandler to handle asynchronous events that occur during the
|
williamr@2
|
287 |
transfer of multimedia data. The event handler must be in the same thread as the data
|
williamr@2
|
288 |
transfer thread - hence the reason it is passed in the SinkThreadLogon as opposed to
|
williamr@2
|
289 |
say the constructor.
|
williamr@2
|
290 |
|
williamr@2
|
291 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
williamr@2
|
292 |
another of the system-wide error codes.
|
williamr@2
|
293 |
*/
|
williamr@2
|
294 |
inline TInt MDataSink::SinkThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
|
williamr@2
|
295 |
{
|
williamr@2
|
296 |
return KErrNone;
|
williamr@2
|
297 |
}
|
williamr@2
|
298 |
|
williamr@2
|
299 |
/**
|
williamr@2
|
300 |
@deprecated
|
williamr@2
|
301 |
|
williamr@2
|
302 |
Allows the data sink to negotiate with a data source.
|
williamr@2
|
303 |
|
williamr@2
|
304 |
This method is required in cases where the settings of data sink are dependant on those of a
|
williamr@2
|
305 |
data source. This is a virtual function that a derrived data sink can implement.
|
williamr@2
|
306 |
|
williamr@2
|
307 |
@param aDataSource
|
williamr@2
|
308 |
The data source whose settings can affect the data sink.
|
williamr@2
|
309 |
*/
|
williamr@2
|
310 |
inline void MDataSink::NegotiateL(MDataSource& /*aDataSource*/)
|
williamr@2
|
311 |
{
|
williamr@2
|
312 |
}
|
williamr@2
|
313 |
|
williamr@2
|
314 |
/**
|
williamr@2
|
315 |
Sets the sink priority settings.
|
williamr@2
|
316 |
|
williamr@2
|
317 |
This is a virtual function that a derrived data sink can implement if
|
williamr@2
|
318 |
a priority mechanism is required to arbitrate between multiple clients
|
williamr@2
|
319 |
trying to access the same resource.
|
williamr@2
|
320 |
|
williamr@2
|
321 |
@param aPrioritySettings
|
williamr@2
|
322 |
The sink priority settings.
|
williamr@2
|
323 |
|
williamr@2
|
324 |
@capability MultimediaDD
|
williamr@2
|
325 |
A process requesting or using this method that has MultimediaDD capability will
|
williamr@2
|
326 |
always have precedence over a process that does not have MultimediaDD.
|
williamr@2
|
327 |
*/
|
williamr@2
|
328 |
inline void MDataSink::SetSinkPrioritySettings(const TMMFPrioritySettings& /*aPrioritySettings*/)
|
williamr@2
|
329 |
{
|
williamr@2
|
330 |
}
|
williamr@2
|
331 |
|
williamr@2
|
332 |
/**
|
williamr@2
|
333 |
This function is used by TCleanupItem objects to perform
|
williamr@2
|
334 |
a SinkStopL() when leaving functions exist, ususally between SinkPrimeL-SinkStopL pairs.
|
williamr@2
|
335 |
|
williamr@2
|
336 |
@param aSink
|
williamr@2
|
337 |
The data sink to be stopped.
|
williamr@2
|
338 |
*/
|
williamr@2
|
339 |
inline static void DoDataSinkStop(TAny* aSink)
|
williamr@2
|
340 |
{
|
williamr@2
|
341 |
MDataSink* sink = STATIC_CAST(MDataSink*, aSink);
|
williamr@2
|
342 |
// we don't want this function to leave because no leaving functions are supposed
|
williamr@2
|
343 |
// to be used as argument to the TCleanupItem objects. Hence we catch the error but
|
williamr@2
|
344 |
// we do nothing with it.
|
williamr@2
|
345 |
TRAP_IGNORE(sink->SinkStopL());
|
williamr@2
|
346 |
}
|
williamr@2
|
347 |
|
williamr@2
|
348 |
/**
|
williamr@2
|
349 |
This method is used by TCleanupItem objects to perform a SinkThreadLogoff().
|
williamr@2
|
350 |
|
williamr@2
|
351 |
@param aSink
|
williamr@2
|
352 |
The data sink to be logged off.
|
williamr@2
|
353 |
*/
|
williamr@2
|
354 |
inline static void DoDataSinkThreadLogoff(TAny* aSink)
|
williamr@2
|
355 |
{
|
williamr@2
|
356 |
MDataSink* sink = STATIC_CAST(MDataSink*, aSink);
|
williamr@2
|
357 |
sink->SinkThreadLogoff();
|
williamr@2
|
358 |
}
|
williamr@2
|
359 |
|
williamr@2
|
360 |
|
williamr@2
|
361 |
#endif
|