author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2006-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 |
// |
sl@0 | 15 |
|
sl@0 | 16 |
#ifndef AVIREADER_H |
sl@0 | 17 |
#define AVIREADER_H |
sl@0 | 18 |
|
sl@0 | 19 |
|
sl@0 | 20 |
#include <mmf/server/mmffile.h> |
sl@0 | 21 |
#include <e32std.h> |
sl@0 | 22 |
#include <e32base.h> |
sl@0 | 23 |
#include <mmf/devvideo/devvideoplay.h> |
sl@0 | 24 |
|
sl@0 | 25 |
|
sl@0 | 26 |
//Observer class for CAviReader |
sl@0 | 27 |
class MAviReaderObserver |
sl@0 | 28 |
{ |
sl@0 | 29 |
public: |
sl@0 | 30 |
virtual void AudioBufferFilled() = 0; |
sl@0 | 31 |
virtual void VideoBufferFilled(TVideoInputBuffer* aBuffer) = 0; |
sl@0 | 32 |
}; |
sl@0 | 33 |
|
sl@0 | 34 |
|
sl@0 | 35 |
//The main class to read from an.avi file. |
sl@0 | 36 |
class CAviReader:public CBase,public MDataSink |
sl@0 | 37 |
{ |
sl@0 | 38 |
public: |
sl@0 | 39 |
static CAviReader* NewL(CMMFClip& aClip,MAviReaderObserver& aObserver); |
sl@0 | 40 |
virtual ~CAviReader(); |
sl@0 | 41 |
TTimeIntervalMicroSeconds Duration() const ; |
sl@0 | 42 |
void SetPositionL(TInt aPosition); |
sl@0 | 43 |
void ResetL(); |
sl@0 | 44 |
void SetPlayWindowL(TTimeIntervalMicroSeconds aStart,TTimeIntervalMicroSeconds aEnd); |
sl@0 | 45 |
void FillVideoBufferL(TVideoInputBuffer* aBuffer); |
sl@0 | 46 |
void FillAudioBufferL(CMMFBuffer* aBuffer); |
sl@0 | 47 |
void ReadNextFrameL(TUid aMediaType, TInt& aPosition); |
sl@0 | 48 |
TBool ReadNextFrameStartL(TInt& aStart); |
sl@0 | 49 |
TBool IsValidBlock(TUint aChunkId); |
sl@0 | 50 |
TBool IsVideoInputEnd(); |
sl@0 | 51 |
TBool IsAudioInputEnd(); |
sl@0 | 52 |
void ReadComplete(); |
sl@0 | 53 |
void AudioEnabled(TBool& aEnabled); |
sl@0 | 54 |
void FrameRate(TReal32& aFramesPerSecond); |
sl@0 | 55 |
void AudioCodec(TFourCC& aCodec); |
sl@0 | 56 |
TInt SampleRate(); |
sl@0 | 57 |
void VideoMimeType(TDes8& aMimeType); |
sl@0 | 58 |
void VideoFrameSize(TSize& aSize); |
sl@0 | 59 |
TInt Channels(); |
sl@0 | 60 |
TInt BitsPerSample(); |
sl@0 | 61 |
TBool IsAudioDataAvailableL(TInt aStartPos); |
sl@0 | 62 |
|
sl@0 | 63 |
//MDataSink |
sl@0 | 64 |
TFourCC SinkDataTypeCode(TMediaId aMediaId); |
sl@0 | 65 |
void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId); |
sl@0 | 66 |
void BufferFilledL(CMMFBuffer* aBuffer); |
sl@0 | 67 |
TBool CanCreateSinkBuffer(); |
sl@0 | 68 |
CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool& aReference); |
sl@0 | 69 |
void ConstructSinkL( const TDesC8& aInitData); |
sl@0 | 70 |
private: |
sl@0 | 71 |
|
sl@0 | 72 |
//Main Avi Header |
sl@0 | 73 |
struct TAviMainHeader |
sl@0 | 74 |
{ |
sl@0 | 75 |
TUint iMicroSecPerFrame; |
sl@0 | 76 |
TUint iMaxBytesPerSec; |
sl@0 | 77 |
TUint iPaddingGranularity; |
sl@0 | 78 |
TUint iFlags; |
sl@0 | 79 |
TUint iTotalFrames; |
sl@0 | 80 |
TUint iInitialFrames; |
sl@0 | 81 |
TUint iStreams; |
sl@0 | 82 |
TUint iSuggestedBufferSize; |
sl@0 | 83 |
TUint iWidth; |
sl@0 | 84 |
TUint iHeight; |
sl@0 | 85 |
TUint iReserved[4]; |
sl@0 | 86 |
} iMainHeader; |
sl@0 | 87 |
|
sl@0 | 88 |
struct TAviStreamHeader //represents stream header |
sl@0 | 89 |
{ |
sl@0 | 90 |
TUint iFccType; |
sl@0 | 91 |
TUint iFccHandler; |
sl@0 | 92 |
TUint iFlags; |
sl@0 | 93 |
TUint iReserved; |
sl@0 | 94 |
TUint iInitialFrames; |
sl@0 | 95 |
TUint iScale; |
sl@0 | 96 |
TUint iRate; |
sl@0 | 97 |
TUint iStart; |
sl@0 | 98 |
TUint iLength; |
sl@0 | 99 |
TUint iSuggestedBufferSize; |
sl@0 | 100 |
TUint iQuality; |
sl@0 | 101 |
TUint iSampleSize; |
sl@0 | 102 |
struct |
sl@0 | 103 |
{ |
sl@0 | 104 |
TInt16 iLeft; |
sl@0 | 105 |
TInt16 iTop; |
sl@0 | 106 |
TInt16 iRight; |
sl@0 | 107 |
TInt16 iBottom; |
sl@0 | 108 |
}iRcFrame; |
sl@0 | 109 |
}; |
sl@0 | 110 |
TAviStreamHeader iStreamHeader[2]; |
sl@0 | 111 |
|
sl@0 | 112 |
struct TPcmWaveFormat |
sl@0 | 113 |
{ |
sl@0 | 114 |
struct TWaveFormat |
sl@0 | 115 |
{ |
sl@0 | 116 |
TUint16 iFormatTag; |
sl@0 | 117 |
TUint16 iNChannels; |
sl@0 | 118 |
TUint iNSamplesPerSec; |
sl@0 | 119 |
TUint iNAvgBytesPerSec; |
sl@0 | 120 |
TUint16 iNBlockAlign; |
sl@0 | 121 |
} iWaveFormat; |
sl@0 | 122 |
TUint16 iBitsPerSample; |
sl@0 | 123 |
} iPCMWaveFormat; |
sl@0 | 124 |
|
sl@0 | 125 |
//Video Stream Format |
sl@0 | 126 |
|
sl@0 | 127 |
|
sl@0 | 128 |
struct TBitmapInfoHeader |
sl@0 | 129 |
{ |
sl@0 | 130 |
TUint iBiSize; |
sl@0 | 131 |
TUint iBiWidth; |
sl@0 | 132 |
TUint iBiHeight; |
sl@0 | 133 |
TUint16 iBiPlanes; |
sl@0 | 134 |
TUint16 iBiBitCount; |
sl@0 | 135 |
TUint iBiCompression; |
sl@0 | 136 |
TUint iBiSizeImage; |
sl@0 | 137 |
TUint iBiXPelsPerMeter; |
sl@0 | 138 |
TUint iBiYPelsPerMeter; |
sl@0 | 139 |
TUint iBiClrUsed; |
sl@0 | 140 |
TUint iBiClrImportant; |
sl@0 | 141 |
}iBitmapInfoHeader; |
sl@0 | 142 |
|
sl@0 | 143 |
private: |
sl@0 | 144 |
TInt ReadFormatL(); |
sl@0 | 145 |
void ProcessFormatL(); |
sl@0 | 146 |
TInt FindRiffChunksL(); |
sl@0 | 147 |
CAviReader(CMMFClip& aClip, MAviReaderObserver& aObserver); |
sl@0 | 148 |
void ConstructL(); |
sl@0 | 149 |
void DoReadL(TInt aReadPosition); |
sl@0 | 150 |
void SetMediaEOS(TUid aMediaType); |
sl@0 | 151 |
private: |
sl@0 | 152 |
MAviReaderObserver& iObserver; |
sl@0 | 153 |
CMMFClip& iClip; |
sl@0 | 154 |
CMMFDescriptorBuffer* iSourceBuffer; |
sl@0 | 155 |
CMMFDescriptorBuffer* iAudioBuffer; |
sl@0 | 156 |
CMMFDescriptorBuffer* iVideoBuffer; |
sl@0 | 157 |
TInt iNumberOfStreams; |
sl@0 | 158 |
TBool iAudioEos; |
sl@0 | 159 |
TBool iVideoEos; |
sl@0 | 160 |
TInt iSourcePos; |
sl@0 | 161 |
TInt iAudioPos; |
sl@0 | 162 |
TInt iVideoPos; |
sl@0 | 163 |
TUint8* iClipPos; |
sl@0 | 164 |
TBool iAudioEnabled; |
sl@0 | 165 |
TVideoInputBuffer* iBufferFromDevVideo; |
sl@0 | 166 |
CMMFBuffer* iBufferFromDevSound; |
sl@0 | 167 |
TBool iVideoRequestMade; |
sl@0 | 168 |
TBool iAudioRequestMade; |
sl@0 | 169 |
TBool iReadCompleted; |
sl@0 | 170 |
TBool iReadRequestMade; |
sl@0 | 171 |
TInt iFileSize; |
sl@0 | 172 |
TInt iAudioIdx; |
sl@0 | 173 |
TInt iVideoIdx; |
sl@0 | 174 |
}; |
sl@0 | 175 |
#endif |