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