os/mm/mmplugins/mmfwplugins/src/Plugin/Controller/Audio/OggVorbis/OggPlayController/oggdecode.h
Update contrib.
1 // Copyright (c) 2005-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 "VorbisInfo.h"
25 static const TInt KNumHeaders = 3;// vorbis has 3 header packets
26 //Average oggpage is of size 4K. we read 4K buffer during seeking and finding duration sothat we expect
27 //the page header in it.
28 static const TInt KReadBufferSize = 0x1000; // 4K
33 Interface to be implemented by clients of the class COggDecode. In specific, COggPlayController needs to implement
34 this interface.MOggDecodeObserver provides interface for the classes that are interested in receiving BufferFilled event
37 class MOggDecodeObserver
41 Function called by COggDecode to indicate that the buffer passed to it is filled.
43 This is a pure virtual function that each derived class must implement.
44 This method is used as the callback when the observer(controller in specific) requests COggDecode
45 to fill the buffer through FillThisBufferL() call. When the cnotroller gets this callback it knows
46 that the buffer has been filled and can be sent to devsound.
48 virtual void BufferFilled() = 0;
54 COggDecode class is mainly responsible for reading the encoded data from the clip and framing an oggpacket from it.
55 Reads header to retrieve the current audio configuration from the clip. This is useful when the client queries
56 the current samplerate, bitrate etc.Also limited seeking is provided by this class.
58 class COggDecode : public CBase,
62 static COggDecode* NewL(CMMFClip& aClip, MOggDecodeObserver& aObserver);
63 virtual ~COggDecode();
65 void InitializeVorbisL();
66 void FillThisBufferL(CMMFBuffer* aBuffer);
67 void GetPacketSyncL();
70 TBool IsAllDataSent();
72 void SetPlayWindowL(TTimeIntervalMicroSeconds aStart, TTimeIntervalMicroSeconds aEnd);
73 void ClearPlayWindowL();
76 TFourCC SinkDataTypeCode(TMediaId aMediaId);
77 void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);
78 void BufferFilledL(CMMFBuffer* aBuffer);
79 TBool CanCreateSinkBuffer();
80 CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool& aReference);
81 void ConstructSinkL( const TDesC8& aInitData);
83 //Repositioning methods
84 TInt64 ReadHeader(CMMFPtrBuffer* aSourceBuffer, TInt& aPos);
85 TTimeIntervalMicroSeconds DurationL();
86 void SetPositionL(TTimeIntervalMicroSeconds aPosition);
87 TInt GetStreamPositionL(TInt aSamples, TInt64& aGranulePos);
88 TTimeIntervalMicroSeconds SeekingTime();
89 void SetPositionL(TInt64 aGranulePos);
90 void SetLastPageFlag(CMMFPtrBuffer* aSourceBuffer);
92 COggDecode(CMMFClip& aClip, MOggDecodeObserver& aObserver);
96 MOggDecodeObserver& iObserver;
99 TInt iStoredSourcePos;
101 //clip position corresponding to playwindowstart
102 TInt iPlayWindowStart;
103 //clip position corresponding to playwindowend
105 //flag used to avoid calculating duration everytime DurationL() is called
106 TBool iDurationCalculated;
107 //we need to resend the codec initialization packets during seeking.
108 //This varible maintains number of header packets sent.
111 //Contains the current audio configuration read from the header of the clip
113 //granulePos corresponding to the current file position
114 TInt64 iCurrentGranulePos;
115 //granulePos corresponding to the duration
116 TInt64 iEndGranulePos;
117 //set when playwindowend is reached. This flag is checked for stopping the play.
118 TBool iPlayWindowEndReached;
119 //set when all data sent to devsound. This flag is checked for proper playcompletion.
121 TTimeIntervalMicroSeconds iDuration;
122 CMMFPtrBuffer* iSourceBuffer;
123 CMMFDataBuffer* iBufferFromSink;
128 /*data in an oggpacket is not always in one buffer may be spread over several using linked lists.
129 so data_store is used to keep the extracted data while traversing the linkedlist.
131 unsigned char *iDataStore;
132 TTimeIntervalMicroSeconds iPlayStartTime;
133 TTimeIntervalMicroSeconds iPlayEndTime;
134 TInt64 iPlayStartGranulePos;
135 TInt64 iPlayEndGranulePos;
136 #ifdef SYMBIAN_SEP_HEAP
142 #endif // OGGDECODE_H