examples/sfexamples/oggvorbiscodec/src/VorbisDecoder/VorbisDecoderPlugIn.cpp

00001 // VorbisDecoderPlugIn.cpp
00002 //
00003 // Copyright (c) Symbian Software Ltd 2005-2008.  All rights reserved.
00004 //
00005 
00006 
00007 #include <e32base.h>
00008 #include <ecom/implementationproxy.h>
00009 #include "VorbisDecoderPlugIn.h"
00010 #include "VorbisDecoderUIDs.hrh"
00011 #include "VorbisDecoder.h"
00012 
00013 const TInt KSourceBufferSize = 0x1000;//enough to accomodate atleast one oggpacket
00014 const TInt KSinkBufferSize = 0x8000; //Good enough to accomodate the pcm obtained after processing one oggpacket
00015 
00016 CVorbisDecoderPlugInWrapper* CVorbisDecoderPlugInWrapper::NewL()
00017     {
00018     CVorbisDecoderPlugInWrapper* self = new(ELeave)CVorbisDecoderPlugInWrapper;
00019     CleanupStack::PushL(self);
00020     self->ConstructL();
00021     CleanupStack::Pop(self);
00022     return self;
00023     }
00024 
00025 CVorbisDecoderPlugInWrapper::~CVorbisDecoderPlugInWrapper()
00026     {
00027     // just in case the codec was never asked for:
00028     if (!iCodecReturned) 
00029         {
00030         delete iDevice;
00031         }
00032     }
00033 
00034 CVorbisDecoderPlugInWrapper::CVorbisDecoderPlugInWrapper()
00035     : iCodecReturned(EFalse)
00036     {
00037     }
00038 
00039 void CVorbisDecoderPlugInWrapper::ConstructL()
00040     {
00041     iDevice = CVorbisDecoderPlugIn::NewL();
00042     }
00043     
00050 CMMFSwCodec& CVorbisDecoderPlugInWrapper::Codec()
00051     {
00052     iCodecReturned=ETrue;
00053     return *iDevice; // this is owned by the SwWrapper
00054     }
00055 
00062 TInt CVorbisDecoderPlugInWrapper::Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd)
00063         {
00064         TInt err = CMMFSwCodecWrapper::Start(aFuncCmd, aFlowCmd);
00065         if(err == KErrNone)
00066                 {
00067                 SetVbrFlag();
00068                 }
00069         return err;
00070         }
00071         
00072 CVorbisDecoderPlugIn* CVorbisDecoderPlugIn::NewL()
00073     {
00074     CVorbisDecoderPlugIn* self = new(ELeave)CVorbisDecoderPlugIn();
00075     CleanupStack::PushL(self);
00076     self->ConstructL();
00077     CleanupStack::Pop(self);
00078     return self;
00079     }
00080 
00081 CVorbisDecoderPlugIn::CVorbisDecoderPlugIn()
00082     {
00083     }
00084 
00085 CVorbisDecoderPlugIn::~CVorbisDecoderPlugIn()
00086     {
00087     delete iProc;
00088     }
00089 
00090 void CVorbisDecoderPlugIn::ConstructL()
00091     {
00092     iProc = CVorbisDecoderProcessor::NewL();
00093     }
00094 
00109 CMMFSwCodec::TCodecProcessResult CVorbisDecoderPlugIn::ProcessL(const CMMFBuffer& aSource, CMMFBuffer& aDst)
00110     {
00111     CMMFSwCodec::TCodecProcessResult res;
00112     CVorbisDecoderProcessor::TProcessResult status;
00113     iProc->ProcessL(aSource, aDst, status, res.iSrcBytesProcessed, res.iDstBytesAdded);
00114     switch (status)
00115         {
00116     case CVorbisDecoderProcessor::EComplete:
00117         res.iCodecProcessStatus = TCodecProcessResult::EProcessComplete;
00118         break;
00119     case CVorbisDecoderProcessor::EIncomplete:
00120         res.iCodecProcessStatus = TCodecProcessResult::EProcessIncomplete;
00121         break;
00122     case CVorbisDecoderProcessor::EDestNotFilled:
00123         res.iCodecProcessStatus = TCodecProcessResult::EDstNotFilled;
00124         break;
00125     default:
00126         User::Leave(KErrNotSupported);
00127         }
00128     return res;
00129     }
00130 
00131 TUint CVorbisDecoderPlugIn::SourceBufferSize()
00132     {
00133     //enough to accomodate one oggpacket
00134     return KSourceBufferSize;
00135     }
00136 
00137 TUint CVorbisDecoderPlugIn::SinkBufferSize()
00138     {
00139     //enough to accomodate the pcm obtained after processing one oggpacket
00140     return KSinkBufferSize;
00141     }
00142 
00143 // __________________________________________________________________________
00144 // Exported proxy for instantiation method resolution
00145 // Define the interface UIDs
00146 
00147 const TImplementationProxy ImplementationTable[] =
00148         {
00149         IMPLEMENTATION_PROXY_ENTRY(KVorbisHwDecodeUid,  CVorbisDecoderPlugInWrapper::NewL),
00150         };
00151 
00152 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
00153         {
00154         aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
00155 
00156         return ImplementationTable;
00157         }

Generated by  doxygen 1.6.2