examples/sfexamples/oggvorbiscodec/inc/OggUtil.h

00001 // OggUtil.h
00002 //
00003 // Copyright (c) Symbian Software Ltd 2005-2006.  All rights reserved.
00004 //
00005 
00006 
00007 #ifndef OGGUTIL_H
00008 #define OGGUTIL_H
00009 
00010 // OggVorbis C libraries are not alloc safe. So we create a separate heap for C library calls with enough space well before 
00011 // the codec starts processing and we switch to the new heap before making calls to the methods in these libraries. 
00012 // Chunk and Heap sizes are taken such a way that we have enough space on the new heap to avoid OOM situations to the 
00013 // maximum extent possible. Also the malloc, calloc and realloc functions in the C libraries are modified to leave with KErrMemory 
00014 // when the allocation fails. We TRAP the error and cleanup the new heap we had created. This way the library calls are made alloc safe.
00015 // SYMBIAN_SEP_HEAP is provided to enable/disable this separate heap mechanism.
00016 #ifdef SYMBIAN_SEP_HEAP
00017         #define VORBIS_TRAP(err, c) { User::SwitchHeap(iVorbisHeap); TRAP(err, c); User::SwitchHeap(iDefaultHeap); }
00018         #define VORBIS_TRAPD(err, c) TInt err = KErrNone; VORBIS_TRAP(err, c);
00019         const TInt KInitialChunkSize = 0x80000;
00020         const TInt KMaxChunkSize = 0x800000;
00021         const TInt KMinHeapLength = 0x40000;
00022 #else
00023         #define VORBIS_TRAP(err, c) c;
00024         #define VORBIS_TRAPD(err, c) TInt err = KErrNone; c;
00025 #endif
00026 
00027 class TOggPage;  //declared here
00028 
00034 NONSHARABLE_CLASS(TOggPage)
00035     {
00036 public:
00037     IMPORT_C TOggPage(const TPtr8& aHead, const TPtr8& aBody);
00038     IMPORT_C TOggPage();
00039     IMPORT_C TInt Version() const;
00040     IMPORT_C TBool Continued() const;
00041     IMPORT_C TInt Packets() const;
00042     IMPORT_C TInt BOS() const;
00043     IMPORT_C TInt EOS() const;
00044     IMPORT_C TInt GranulePos() const;
00045     IMPORT_C TInt SerialNo() const;
00046     IMPORT_C TInt PageNo() const;
00047 public:
00048     TPtr8 iHead;
00049     TPtr8 iBody;
00050     };
00051 
00052 class TOggPacket;  //declared here
00058 NONSHARABLE_CLASS(TOggPacket)
00059     {
00060 public:
00061     IMPORT_C TOggPacket();
00062     IMPORT_C TOggPacket(const TPtrC8& aPtr, TInt64 aGranulePos, TInt64 aPacketNo);
00063 #ifndef SYMBIAN_CODEC_FLOAT_POINT 
00064     IMPORT_C void GetOggData(TPtr8& aDataStore);
00065 #endif
00066 public:    
00067     TPtr8 iData;
00068     TBool iBOS; // beginning of stream
00069     TBool iEOS; // end of stream
00070     TInt64 iGranulePos; // last logical item that can be decoded from this stream
00071                         // e.g. sample of PCM or frame number
00072     TInt64 iPacketNo;   // number of packet in sequence (use to detect holes in data)
00073     };
00074 
00075 class COggPager;   //declared here
00082 NONSHARABLE_CLASS(COggPager) : public CBase
00083     {
00084 public:
00085     IMPORT_C static COggPager* NewL();
00086     virtual ~COggPager();
00087     //resets ogg_sync_state
00088     IMPORT_C void Reset(); 
00089     IMPORT_C TInt GetBuffer(TPtr8& aBuf, TInt aSize);
00090     IMPORT_C TInt DataWritten(TDes8& aBuf);
00091     IMPORT_C TInt NextPage(TOggPage& aPage);
00092 private:
00093     COggPager();
00094     void ConstructL();
00095 private:
00096     class CBody;
00097     CBody* iBody;
00098     };
00099 
00100 class COggStream;  //declared here
00107 NONSHARABLE_CLASS(COggStream) : public CBase
00108     {
00109 public:
00110     IMPORT_C static COggStream* NewL();
00111     virtual ~COggStream();
00112     IMPORT_C TInt PageIn(TOggPage& aPage);
00113     IMPORT_C TInt PacketOut(TOggPacket& aDst);
00114     IMPORT_C void Reset();
00115     IMPORT_C TInt GetSerialNo();
00116 private:
00117     COggStream();
00118     void ConstructL();
00119 private:
00120     class CBody;
00121     CBody* iBody;
00122     };
00123 
00124 #endif

Generated by  doxygen 1.6.2