os/mm/mmlibs/mmfw/inc/mmf/server/mmfbuffer.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// include\mmf\server\mmfbuffer.h
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef __MMF_SERVER_BUFFER_H__
sl@0
    20
#define __MMF_SERVER_BUFFER_H__
sl@0
    21
sl@0
    22
#include <e32base.h>
sl@0
    23
#include <mmf/server/mmfbuffer.hrh>
sl@0
    24
sl@0
    25
sl@0
    26
/**
sl@0
    27
@publishedAll
sl@0
    28
@released
sl@0
    29
sl@0
    30
Flag reflecting the current buffer status.
sl@0
    31
*/
sl@0
    32
enum TBufferStatus
sl@0
    33
	{
sl@0
    34
	/** The buffer is available for use */
sl@0
    35
	EAvailable,
sl@0
    36
sl@0
    37
	/** The buffer is currently being filled */
sl@0
    38
	EBeingFilled,
sl@0
    39
sl@0
    40
	/** The buffer is full */
sl@0
    41
	EFull,
sl@0
    42
sl@0
    43
	/** The buffer is currently being emptied */
sl@0
    44
	EBeingEmptied,
sl@0
    45
sl@0
    46
	/** The buffer is currently unavailable */
sl@0
    47
	EUnAvailable
sl@0
    48
	};
sl@0
    49
sl@0
    50
sl@0
    51
/**
sl@0
    52
@publishedAll
sl@0
    53
@released
sl@0
    54
sl@0
    55
Abstract representation of a buffer to contain multimedia data.
sl@0
    56
*/
sl@0
    57
class CMMFBuffer : public CBase
sl@0
    58
	{
sl@0
    59
public:
sl@0
    60
	IMPORT_C static TBool IsSupportedDataBuffer(TUid aUid);
sl@0
    61
	IMPORT_C static TBool IsFileServerSafe(TUid aUid);
sl@0
    62
	/**
sl@0
    63
	Returns the buffer type.
sl@0
    64
sl@0
    65
	@return The buffer type.
sl@0
    66
	*/
sl@0
    67
	TUid Type() const {return iType;};
sl@0
    68
	/**
sl@0
    69
	Sets the buffer's status.
sl@0
    70
sl@0
    71
	@param  aStatus
sl@0
    72
	        The buffer's status.
sl@0
    73
	*/
sl@0
    74
	virtual void SetStatus(TBufferStatus aStatus) 
sl@0
    75
			{iStatus = aStatus; if (iStatus == EAvailable) iPosition = 0;}
sl@0
    76
	/**
sl@0
    77
	Returns the buffer's status.
sl@0
    78
sl@0
    79
	@return The buffer's status.
sl@0
    80
	*/
sl@0
    81
	TBufferStatus Status() {return iStatus;};
sl@0
    82
sl@0
    83
	/**
sl@0
    84
	Returns the size of the data in the buffer.
sl@0
    85
sl@0
    86
	This is a virtual function that each derived class must implement.
sl@0
    87
sl@0
    88
	@return The buffer size.
sl@0
    89
	*/
sl@0
    90
	virtual TUint BufferSize() const = 0;
sl@0
    91
sl@0
    92
	/**
sl@0
    93
	Destructor.
sl@0
    94
	*/
sl@0
    95
	virtual ~CMMFBuffer() {};
sl@0
    96
	inline TTimeIntervalMicroSeconds TimeToPlay() const;
sl@0
    97
	inline void SetTimeToPlay (TTimeIntervalMicroSeconds aTime);
sl@0
    98
	inline TUint FrameNumber() const;
sl@0
    99
	inline void SetFrameNumber(TUint aFrame);
sl@0
   100
	inline void NextFrame();
sl@0
   101
	inline virtual void SetPosition (TUint aPosition);
sl@0
   102
	inline virtual TUint Position() const;
sl@0
   103
	inline virtual TInt RequestSize() const;
sl@0
   104
	inline void SetLastBuffer(TBool aLastBuffer);
sl@0
   105
	inline TBool LastBuffer() const;
sl@0
   106
protected:
sl@0
   107
	CMMFBuffer(TUid aType): iType(aType), iStatus(EAvailable) {};	
sl@0
   108
sl@0
   109
protected:
sl@0
   110
	/** 
sl@0
   111
	The buffer type. 
sl@0
   112
	*/
sl@0
   113
	TUid iType;
sl@0
   114
sl@0
   115
	/** 
sl@0
   116
	The current buffer status.
sl@0
   117
sl@0
   118
	@see enum TBufferStatus
sl@0
   119
	*/
sl@0
   120
	TBufferStatus iStatus;
sl@0
   121
sl@0
   122
	/**
sl@0
   123
	The buffer timestamp, in microseconds. 
sl@0
   124
	*/
sl@0
   125
	TTimeIntervalMicroSeconds iTimeToPlay;
sl@0
   126
sl@0
   127
	/** 
sl@0
   128
	Used to store the current read/write position. Required when the codec and data path
sl@0
   129
	may have to read and write the buffer in more than one pass.
sl@0
   130
	*/
sl@0
   131
	TUint iPosition;
sl@0
   132
sl@0
   133
	/** 
sl@0
   134
	The frame number.
sl@0
   135
	*/
sl@0
   136
	TUint iFrameNumber;
sl@0
   137
sl@0
   138
	/**
sl@0
   139
	Stores Request size, needed for dynamic buffer length.
sl@0
   140
	*/
sl@0
   141
	TInt iRequestSize;
sl@0
   142
sl@0
   143
	/** 
sl@0
   144
	Indicates if this is the last buffer. ETrue if it is.
sl@0
   145
	*/
sl@0
   146
	TBool iLastBuffer; 
sl@0
   147
	};
sl@0
   148
sl@0
   149
/**
sl@0
   150
Returns the buffer timestamp, in microseconds.
sl@0
   151
sl@0
   152
@return	The buffer timestamp, in microseconds.
sl@0
   153
*/
sl@0
   154
inline TTimeIntervalMicroSeconds CMMFBuffer::TimeToPlay() const
sl@0
   155
	{
sl@0
   156
	return iTimeToPlay;
sl@0
   157
	}
sl@0
   158
sl@0
   159
/**
sl@0
   160
Sets the buffer timestamp, in microseconds.
sl@0
   161
sl@0
   162
@param  aTime
sl@0
   163
        The buffer timestamp, in microseconds.
sl@0
   164
*/
sl@0
   165
inline void CMMFBuffer::SetTimeToPlay (TTimeIntervalMicroSeconds aTime)
sl@0
   166
	{
sl@0
   167
	iTimeToPlay = aTime;
sl@0
   168
	}
sl@0
   169
sl@0
   170
/**
sl@0
   171
Returns the frame number.
sl@0
   172
sl@0
   173
@return The frame number.
sl@0
   174
*/
sl@0
   175
inline TUint CMMFBuffer::FrameNumber() const
sl@0
   176
	{
sl@0
   177
	return iFrameNumber;
sl@0
   178
	}
sl@0
   179
sl@0
   180
/**
sl@0
   181
Sets the frame number. This is used for repositioning.
sl@0
   182
sl@0
   183
@param  aFrameNumber
sl@0
   184
        The frame number.
sl@0
   185
*/
sl@0
   186
inline void CMMFBuffer::SetFrameNumber (TUint aFrameNumber)
sl@0
   187
	{
sl@0
   188
	iFrameNumber = aFrameNumber;
sl@0
   189
	}
sl@0
   190
sl@0
   191
/**
sl@0
   192
Sets the buffer as the next frame.
sl@0
   193
*/
sl@0
   194
inline void CMMFBuffer::NextFrame()
sl@0
   195
	{
sl@0
   196
	iFrameNumber++;
sl@0
   197
	}
sl@0
   198
sl@0
   199
sl@0
   200
/**
sl@0
   201
Sets the current buffer read/write position.
sl@0
   202
Used as read/write position on a buffer where a codec may need
sl@0
   203
several passes on the same buffer.
sl@0
   204
sl@0
   205
@param  aPosition
sl@0
   206
        The buffer's number.
sl@0
   207
*/
sl@0
   208
inline void CMMFBuffer::SetPosition (TUint aPosition)
sl@0
   209
	{
sl@0
   210
	iPosition = aPosition;
sl@0
   211
	}
sl@0
   212
sl@0
   213
/**
sl@0
   214
Returns the current buffer read/write position.
sl@0
   215
Used as read/write position on a buffer where a codec may need
sl@0
   216
several passes on the same buffer.
sl@0
   217
sl@0
   218
@return The buffer's number.
sl@0
   219
*/
sl@0
   220
inline TUint CMMFBuffer::Position() const
sl@0
   221
	{
sl@0
   222
	return iPosition;
sl@0
   223
	}
sl@0
   224
sl@0
   225
/**
sl@0
   226
Tests whether the buffer is the last buffer.
sl@0
   227
sl@0
   228
@return A boolean indicating if the buffer is the last one. ETrue if it is the last buffer, 
sl@0
   229
        EFalse otherwise.
sl@0
   230
*/
sl@0
   231
inline TBool CMMFBuffer::LastBuffer() const
sl@0
   232
	{
sl@0
   233
	return iLastBuffer;
sl@0
   234
	}
sl@0
   235
sl@0
   236
/**
sl@0
   237
Sets the buffer as the last buffer.
sl@0
   238
sl@0
   239
@param  aLastBuffer
sl@0
   240
        A boolean indicating if the buffer is the last buffer. ETrue if it is the last buffer, 
sl@0
   241
        EFalse otherwise.
sl@0
   242
*/
sl@0
   243
inline void CMMFBuffer::SetLastBuffer(TBool aLastBuffer)
sl@0
   244
	{
sl@0
   245
	iLastBuffer = aLastBuffer;
sl@0
   246
	}
sl@0
   247
sl@0
   248
/** 
sl@0
   249
Returns the size of data processed by sink or data needed by source.
sl@0
   250
sl@0
   251
@return The size of data
sl@0
   252
*/
sl@0
   253
inline TInt CMMFBuffer::RequestSize() const
sl@0
   254
	{
sl@0
   255
	return iRequestSize;
sl@0
   256
	}
sl@0
   257
sl@0
   258
#endif