os/mm/mmlibs/mmfw/inc/mmf/server/mmfbuffer.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/server/mmfbuffer.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,258 @@
     1.4 +// Copyright (c) 2002-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 "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.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 +// include\mmf\server\mmfbuffer.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +
    1.22 +#ifndef __MMF_SERVER_BUFFER_H__
    1.23 +#define __MMF_SERVER_BUFFER_H__
    1.24 +
    1.25 +#include <e32base.h>
    1.26 +#include <mmf/server/mmfbuffer.hrh>
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +@publishedAll
    1.31 +@released
    1.32 +
    1.33 +Flag reflecting the current buffer status.
    1.34 +*/
    1.35 +enum TBufferStatus
    1.36 +	{
    1.37 +	/** The buffer is available for use */
    1.38 +	EAvailable,
    1.39 +
    1.40 +	/** The buffer is currently being filled */
    1.41 +	EBeingFilled,
    1.42 +
    1.43 +	/** The buffer is full */
    1.44 +	EFull,
    1.45 +
    1.46 +	/** The buffer is currently being emptied */
    1.47 +	EBeingEmptied,
    1.48 +
    1.49 +	/** The buffer is currently unavailable */
    1.50 +	EUnAvailable
    1.51 +	};
    1.52 +
    1.53 +
    1.54 +/**
    1.55 +@publishedAll
    1.56 +@released
    1.57 +
    1.58 +Abstract representation of a buffer to contain multimedia data.
    1.59 +*/
    1.60 +class CMMFBuffer : public CBase
    1.61 +	{
    1.62 +public:
    1.63 +	IMPORT_C static TBool IsSupportedDataBuffer(TUid aUid);
    1.64 +	IMPORT_C static TBool IsFileServerSafe(TUid aUid);
    1.65 +	/**
    1.66 +	Returns the buffer type.
    1.67 +
    1.68 +	@return The buffer type.
    1.69 +	*/
    1.70 +	TUid Type() const {return iType;};
    1.71 +	/**
    1.72 +	Sets the buffer's status.
    1.73 +
    1.74 +	@param  aStatus
    1.75 +	        The buffer's status.
    1.76 +	*/
    1.77 +	virtual void SetStatus(TBufferStatus aStatus) 
    1.78 +			{iStatus = aStatus; if (iStatus == EAvailable) iPosition = 0;}
    1.79 +	/**
    1.80 +	Returns the buffer's status.
    1.81 +
    1.82 +	@return The buffer's status.
    1.83 +	*/
    1.84 +	TBufferStatus Status() {return iStatus;};
    1.85 +
    1.86 +	/**
    1.87 +	Returns the size of the data in the buffer.
    1.88 +
    1.89 +	This is a virtual function that each derived class must implement.
    1.90 +
    1.91 +	@return The buffer size.
    1.92 +	*/
    1.93 +	virtual TUint BufferSize() const = 0;
    1.94 +
    1.95 +	/**
    1.96 +	Destructor.
    1.97 +	*/
    1.98 +	virtual ~CMMFBuffer() {};
    1.99 +	inline TTimeIntervalMicroSeconds TimeToPlay() const;
   1.100 +	inline void SetTimeToPlay (TTimeIntervalMicroSeconds aTime);
   1.101 +	inline TUint FrameNumber() const;
   1.102 +	inline void SetFrameNumber(TUint aFrame);
   1.103 +	inline void NextFrame();
   1.104 +	inline virtual void SetPosition (TUint aPosition);
   1.105 +	inline virtual TUint Position() const;
   1.106 +	inline virtual TInt RequestSize() const;
   1.107 +	inline void SetLastBuffer(TBool aLastBuffer);
   1.108 +	inline TBool LastBuffer() const;
   1.109 +protected:
   1.110 +	CMMFBuffer(TUid aType): iType(aType), iStatus(EAvailable) {};	
   1.111 +
   1.112 +protected:
   1.113 +	/** 
   1.114 +	The buffer type. 
   1.115 +	*/
   1.116 +	TUid iType;
   1.117 +
   1.118 +	/** 
   1.119 +	The current buffer status.
   1.120 +
   1.121 +	@see enum TBufferStatus
   1.122 +	*/
   1.123 +	TBufferStatus iStatus;
   1.124 +
   1.125 +	/**
   1.126 +	The buffer timestamp, in microseconds. 
   1.127 +	*/
   1.128 +	TTimeIntervalMicroSeconds iTimeToPlay;
   1.129 +
   1.130 +	/** 
   1.131 +	Used to store the current read/write position. Required when the codec and data path
   1.132 +	may have to read and write the buffer in more than one pass.
   1.133 +	*/
   1.134 +	TUint iPosition;
   1.135 +
   1.136 +	/** 
   1.137 +	The frame number.
   1.138 +	*/
   1.139 +	TUint iFrameNumber;
   1.140 +
   1.141 +	/**
   1.142 +	Stores Request size, needed for dynamic buffer length.
   1.143 +	*/
   1.144 +	TInt iRequestSize;
   1.145 +
   1.146 +	/** 
   1.147 +	Indicates if this is the last buffer. ETrue if it is.
   1.148 +	*/
   1.149 +	TBool iLastBuffer; 
   1.150 +	};
   1.151 +
   1.152 +/**
   1.153 +Returns the buffer timestamp, in microseconds.
   1.154 +
   1.155 +@return	The buffer timestamp, in microseconds.
   1.156 +*/
   1.157 +inline TTimeIntervalMicroSeconds CMMFBuffer::TimeToPlay() const
   1.158 +	{
   1.159 +	return iTimeToPlay;
   1.160 +	}
   1.161 +
   1.162 +/**
   1.163 +Sets the buffer timestamp, in microseconds.
   1.164 +
   1.165 +@param  aTime
   1.166 +        The buffer timestamp, in microseconds.
   1.167 +*/
   1.168 +inline void CMMFBuffer::SetTimeToPlay (TTimeIntervalMicroSeconds aTime)
   1.169 +	{
   1.170 +	iTimeToPlay = aTime;
   1.171 +	}
   1.172 +
   1.173 +/**
   1.174 +Returns the frame number.
   1.175 +
   1.176 +@return The frame number.
   1.177 +*/
   1.178 +inline TUint CMMFBuffer::FrameNumber() const
   1.179 +	{
   1.180 +	return iFrameNumber;
   1.181 +	}
   1.182 +
   1.183 +/**
   1.184 +Sets the frame number. This is used for repositioning.
   1.185 +
   1.186 +@param  aFrameNumber
   1.187 +        The frame number.
   1.188 +*/
   1.189 +inline void CMMFBuffer::SetFrameNumber (TUint aFrameNumber)
   1.190 +	{
   1.191 +	iFrameNumber = aFrameNumber;
   1.192 +	}
   1.193 +
   1.194 +/**
   1.195 +Sets the buffer as the next frame.
   1.196 +*/
   1.197 +inline void CMMFBuffer::NextFrame()
   1.198 +	{
   1.199 +	iFrameNumber++;
   1.200 +	}
   1.201 +
   1.202 +
   1.203 +/**
   1.204 +Sets the current buffer read/write position.
   1.205 +Used as read/write position on a buffer where a codec may need
   1.206 +several passes on the same buffer.
   1.207 +
   1.208 +@param  aPosition
   1.209 +        The buffer's number.
   1.210 +*/
   1.211 +inline void CMMFBuffer::SetPosition (TUint aPosition)
   1.212 +	{
   1.213 +	iPosition = aPosition;
   1.214 +	}
   1.215 +
   1.216 +/**
   1.217 +Returns the current buffer read/write position.
   1.218 +Used as read/write position on a buffer where a codec may need
   1.219 +several passes on the same buffer.
   1.220 +
   1.221 +@return The buffer's number.
   1.222 +*/
   1.223 +inline TUint CMMFBuffer::Position() const
   1.224 +	{
   1.225 +	return iPosition;
   1.226 +	}
   1.227 +
   1.228 +/**
   1.229 +Tests whether the buffer is the last buffer.
   1.230 +
   1.231 +@return A boolean indicating if the buffer is the last one. ETrue if it is the last buffer, 
   1.232 +        EFalse otherwise.
   1.233 +*/
   1.234 +inline TBool CMMFBuffer::LastBuffer() const
   1.235 +	{
   1.236 +	return iLastBuffer;
   1.237 +	}
   1.238 +
   1.239 +/**
   1.240 +Sets the buffer as the last buffer.
   1.241 +
   1.242 +@param  aLastBuffer
   1.243 +        A boolean indicating if the buffer is the last buffer. ETrue if it is the last buffer, 
   1.244 +        EFalse otherwise.
   1.245 +*/
   1.246 +inline void CMMFBuffer::SetLastBuffer(TBool aLastBuffer)
   1.247 +	{
   1.248 +	iLastBuffer = aLastBuffer;
   1.249 +	}
   1.250 +
   1.251 +/** 
   1.252 +Returns the size of data processed by sink or data needed by source.
   1.253 +
   1.254 +@return The size of data
   1.255 +*/
   1.256 +inline TInt CMMFBuffer::RequestSize() const
   1.257 +	{
   1.258 +	return iRequestSize;
   1.259 +	}
   1.260 +
   1.261 +#endif