os/mm/mmplugins/mmfwplugins/src/Plugin/Controller/Video/AviPlayController/avireader.h
First public contribution.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include <mmf/server/mmffile.h>
23 #include <mmf/devvideo/devvideoplay.h>
26 //Observer class for CAviReader
27 class MAviReaderObserver
30 virtual void AudioBufferFilled() = 0;
31 virtual void VideoBufferFilled(TVideoInputBuffer* aBuffer) = 0;
35 //The main class to read from an.avi file.
36 class CAviReader:public CBase,public MDataSink
39 static CAviReader* NewL(CMMFClip& aClip,MAviReaderObserver& aObserver);
40 virtual ~CAviReader();
41 TTimeIntervalMicroSeconds Duration() const ;
42 void SetPositionL(TInt aPosition);
44 void SetPlayWindowL(TTimeIntervalMicroSeconds aStart,TTimeIntervalMicroSeconds aEnd);
45 void FillVideoBufferL(TVideoInputBuffer* aBuffer);
46 void FillAudioBufferL(CMMFBuffer* aBuffer);
47 void ReadNextFrameL(TUid aMediaType, TInt& aPosition);
48 TBool ReadNextFrameStartL(TInt& aStart);
49 TBool IsValidBlock(TUint aChunkId);
50 TBool IsVideoInputEnd();
51 TBool IsAudioInputEnd();
53 void AudioEnabled(TBool& aEnabled);
54 void FrameRate(TReal32& aFramesPerSecond);
55 void AudioCodec(TFourCC& aCodec);
57 void VideoMimeType(TDes8& aMimeType);
58 void VideoFrameSize(TSize& aSize);
61 TBool IsAudioDataAvailableL(TInt aStartPos);
64 TFourCC SinkDataTypeCode(TMediaId aMediaId);
65 void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);
66 void BufferFilledL(CMMFBuffer* aBuffer);
67 TBool CanCreateSinkBuffer();
68 CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool& aReference);
69 void ConstructSinkL( const TDesC8& aInitData);
75 TUint iMicroSecPerFrame;
76 TUint iMaxBytesPerSec;
77 TUint iPaddingGranularity;
82 TUint iSuggestedBufferSize;
88 struct TAviStreamHeader //represents stream header
99 TUint iSuggestedBufferSize;
110 TAviStreamHeader iStreamHeader[2];
112 struct TPcmWaveFormat
118 TUint iNSamplesPerSec;
119 TUint iNAvgBytesPerSec;
120 TUint16 iNBlockAlign;
122 TUint16 iBitsPerSample;
125 //Video Stream Format
128 struct TBitmapInfoHeader
135 TUint iBiCompression;
137 TUint iBiXPelsPerMeter;
138 TUint iBiYPelsPerMeter;
140 TUint iBiClrImportant;
145 void ProcessFormatL();
146 TInt FindRiffChunksL();
147 CAviReader(CMMFClip& aClip, MAviReaderObserver& aObserver);
149 void DoReadL(TInt aReadPosition);
150 void SetMediaEOS(TUid aMediaType);
152 MAviReaderObserver& iObserver;
154 CMMFDescriptorBuffer* iSourceBuffer;
155 CMMFDescriptorBuffer* iAudioBuffer;
156 CMMFDescriptorBuffer* iVideoBuffer;
157 TInt iNumberOfStreams;
165 TVideoInputBuffer* iBufferFromDevVideo;
166 CMMFBuffer* iBufferFromDevSound;
167 TBool iVideoRequestMade;
168 TBool iAudioRequestMade;
169 TBool iReadCompleted;
170 TBool iReadRequestMade;