sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // include\mmf\server\mmfbuffer.h sl@0: // sl@0: // sl@0: sl@0: sl@0: #ifndef __MMF_SERVER_BUFFER_H__ sl@0: #define __MMF_SERVER_BUFFER_H__ sl@0: sl@0: #include <e32base.h> sl@0: #include <mmf/server/mmfbuffer.hrh> sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Flag reflecting the current buffer status. sl@0: */ sl@0: enum TBufferStatus sl@0: { sl@0: /** The buffer is available for use */ sl@0: EAvailable, sl@0: sl@0: /** The buffer is currently being filled */ sl@0: EBeingFilled, sl@0: sl@0: /** The buffer is full */ sl@0: EFull, sl@0: sl@0: /** The buffer is currently being emptied */ sl@0: EBeingEmptied, sl@0: sl@0: /** The buffer is currently unavailable */ sl@0: EUnAvailable sl@0: }; sl@0: sl@0: sl@0: /** sl@0: @publishedAll sl@0: @released sl@0: sl@0: Abstract representation of a buffer to contain multimedia data. sl@0: */ sl@0: class CMMFBuffer : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static TBool IsSupportedDataBuffer(TUid aUid); sl@0: IMPORT_C static TBool IsFileServerSafe(TUid aUid); sl@0: /** sl@0: Returns the buffer type. sl@0: sl@0: @return The buffer type. sl@0: */ sl@0: TUid Type() const {return iType;}; sl@0: /** sl@0: Sets the buffer's status. sl@0: sl@0: @param aStatus sl@0: The buffer's status. sl@0: */ sl@0: virtual void SetStatus(TBufferStatus aStatus) sl@0: {iStatus = aStatus; if (iStatus == EAvailable) iPosition = 0;} sl@0: /** sl@0: Returns the buffer's status. sl@0: sl@0: @return The buffer's status. sl@0: */ sl@0: TBufferStatus Status() {return iStatus;}; sl@0: sl@0: /** sl@0: Returns the size of the data in the buffer. sl@0: sl@0: This is a virtual function that each derived class must implement. sl@0: sl@0: @return The buffer size. sl@0: */ sl@0: virtual TUint BufferSize() const = 0; sl@0: sl@0: /** sl@0: Destructor. sl@0: */ sl@0: virtual ~CMMFBuffer() {}; sl@0: inline TTimeIntervalMicroSeconds TimeToPlay() const; sl@0: inline void SetTimeToPlay (TTimeIntervalMicroSeconds aTime); sl@0: inline TUint FrameNumber() const; sl@0: inline void SetFrameNumber(TUint aFrame); sl@0: inline void NextFrame(); sl@0: inline virtual void SetPosition (TUint aPosition); sl@0: inline virtual TUint Position() const; sl@0: inline virtual TInt RequestSize() const; sl@0: inline void SetLastBuffer(TBool aLastBuffer); sl@0: inline TBool LastBuffer() const; sl@0: protected: sl@0: CMMFBuffer(TUid aType): iType(aType), iStatus(EAvailable) {}; sl@0: sl@0: protected: sl@0: /** sl@0: The buffer type. sl@0: */ sl@0: TUid iType; sl@0: sl@0: /** sl@0: The current buffer status. sl@0: sl@0: @see enum TBufferStatus sl@0: */ sl@0: TBufferStatus iStatus; sl@0: sl@0: /** sl@0: The buffer timestamp, in microseconds. sl@0: */ sl@0: TTimeIntervalMicroSeconds iTimeToPlay; sl@0: sl@0: /** sl@0: Used to store the current read/write position. Required when the codec and data path sl@0: may have to read and write the buffer in more than one pass. sl@0: */ sl@0: TUint iPosition; sl@0: sl@0: /** sl@0: The frame number. sl@0: */ sl@0: TUint iFrameNumber; sl@0: sl@0: /** sl@0: Stores Request size, needed for dynamic buffer length. sl@0: */ sl@0: TInt iRequestSize; sl@0: sl@0: /** sl@0: Indicates if this is the last buffer. ETrue if it is. sl@0: */ sl@0: TBool iLastBuffer; sl@0: }; sl@0: sl@0: /** sl@0: Returns the buffer timestamp, in microseconds. sl@0: sl@0: @return The buffer timestamp, in microseconds. sl@0: */ sl@0: inline TTimeIntervalMicroSeconds CMMFBuffer::TimeToPlay() const sl@0: { sl@0: return iTimeToPlay; sl@0: } sl@0: sl@0: /** sl@0: Sets the buffer timestamp, in microseconds. sl@0: sl@0: @param aTime sl@0: The buffer timestamp, in microseconds. sl@0: */ sl@0: inline void CMMFBuffer::SetTimeToPlay (TTimeIntervalMicroSeconds aTime) sl@0: { sl@0: iTimeToPlay = aTime; sl@0: } sl@0: sl@0: /** sl@0: Returns the frame number. sl@0: sl@0: @return The frame number. sl@0: */ sl@0: inline TUint CMMFBuffer::FrameNumber() const sl@0: { sl@0: return iFrameNumber; sl@0: } sl@0: sl@0: /** sl@0: Sets the frame number. This is used for repositioning. sl@0: sl@0: @param aFrameNumber sl@0: The frame number. sl@0: */ sl@0: inline void CMMFBuffer::SetFrameNumber (TUint aFrameNumber) sl@0: { sl@0: iFrameNumber = aFrameNumber; sl@0: } sl@0: sl@0: /** sl@0: Sets the buffer as the next frame. sl@0: */ sl@0: inline void CMMFBuffer::NextFrame() sl@0: { sl@0: iFrameNumber++; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Sets the current buffer read/write position. sl@0: Used as read/write position on a buffer where a codec may need sl@0: several passes on the same buffer. sl@0: sl@0: @param aPosition sl@0: The buffer's number. sl@0: */ sl@0: inline void CMMFBuffer::SetPosition (TUint aPosition) sl@0: { sl@0: iPosition = aPosition; sl@0: } sl@0: sl@0: /** sl@0: Returns the current buffer read/write position. sl@0: Used as read/write position on a buffer where a codec may need sl@0: several passes on the same buffer. sl@0: sl@0: @return The buffer's number. sl@0: */ sl@0: inline TUint CMMFBuffer::Position() const sl@0: { sl@0: return iPosition; sl@0: } sl@0: sl@0: /** sl@0: Tests whether the buffer is the last buffer. sl@0: sl@0: @return A boolean indicating if the buffer is the last one. ETrue if it is the last buffer, sl@0: EFalse otherwise. sl@0: */ sl@0: inline TBool CMMFBuffer::LastBuffer() const sl@0: { sl@0: return iLastBuffer; sl@0: } sl@0: sl@0: /** sl@0: Sets the buffer as the last buffer. sl@0: sl@0: @param aLastBuffer sl@0: A boolean indicating if the buffer is the last buffer. ETrue if it is the last buffer, sl@0: EFalse otherwise. sl@0: */ sl@0: inline void CMMFBuffer::SetLastBuffer(TBool aLastBuffer) sl@0: { sl@0: iLastBuffer = aLastBuffer; sl@0: } sl@0: sl@0: /** sl@0: Returns the size of data processed by sink or data needed by source. sl@0: sl@0: @return The size of data sl@0: */ sl@0: inline TInt CMMFBuffer::RequestSize() const sl@0: { sl@0: return iRequestSize; sl@0: } sl@0: sl@0: #endif