Update contrib.
1 // Copyright (c) 2002-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.
17 #include <ecom/implementationproxy.h>
18 #include <mmf/common/mmffourcc.h>
19 #include <mmf/server/mmfdatabuffer.h>
20 #include "MmfVideoInput.h"
24 void Panic(TInt aPanicCode)
26 _LIT(KMMFVideoInputPanicCategory, "MMFVideoInput");
27 User::Panic(KMMFVideoInputPanicCategory, aPanicCode);
30 MDataSource* CMMFVideoInput::NewSourceL()
32 CMMFVideoInput* self = new (ELeave) CMMFVideoInput ;
33 return STATIC_CAST( MDataSource*, self );
36 CMMFVideoInput::~CMMFVideoInput()
38 #ifdef KVideoInputCanResample
39 delete iChannelAndSampleRateConverterFactory;
40 delete iConvertBuffer;
45 void CMMFVideoInput::ConstructSourceL( const TDesC8& /*aInitData*/ )
51 void CMMFVideoInput::HWFillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/)
59 * Get audio from MMFDevsound
61 * @param "CMMFBuffer* aBuffer"
62 * The data to write out. Assumed to really be CMMFBitmapFrameBuffer*.
63 * @param "MDataSink* aConsumer"
64 * @param "TMediaId aMediaId"
65 * Type of data supplied - currently ignored.
68 void CMMFVideoInput::FillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/,TMediaId)
72 void CMMFVideoInput::BufferEmptiedL(CMMFBuffer* /*aBuffer*/)
78 TBool CMMFVideoInput::CanCreateSourceBuffer()
83 CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference)
85 CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
87 aReference = ETrue; // This is a reference from DevSound
91 CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/)
93 //0x1000 is what WINS DevSound expects
94 CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
100 void CMMFVideoInput::SourcePrimeL()
105 void CMMFVideoInput::SourceStopL()
111 void CMMFVideoInput::SourcePlayL()
113 #ifdef KVideoInputCanResample
114 if ((iNeedsSWConversion)&&(iSinkChannels>0))
115 {//can only do SW convert - therefore need to do a conversion
116 //currently only pcm16 is supported so return with an error if format not pcm16
117 iChannelAndSampleRateConverterFactory
118 = new(ELeave)CMMFChannelAndSampleRateConverterFactory;
119 iChannelAndSampleRateConverter =
120 iChannelAndSampleRateConverterFactory->CreateConverterL( iSinkSampleRate, iSinkChannels,
122 //need to create an intermediate buffer in which to place the converted data
124 TUint convertedBufferFrameSize = KVideoInputDefaultFrameSize/iSinkChannels;
125 if (iConvertBuffer) delete iConvertBuffer;
126 iConvertBuffer = NULL;
127 iConvertBuffer = CMMFDataBuffer::NewL(convertedBufferFrameSize);
132 TInt CMMFVideoInput::SourceThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
137 void CMMFVideoInput::SourceThreadLogoff()
141 void CMMFVideoInput::NegotiateL(MDataSink& aSink)
143 aSink = aSink; //to keep compiler happy
144 #ifdef KVideoInputCanResample
145 if (aSink.DataSinkType() == KUidMmfFormatDecode)
146 {//source is a clip so for now set sink settings to match source
147 iSinkSampleRate = ((CMMFFormatDecode&)aSink).SampleRate();
148 iSinkChannels = ((CMMFFormatDecode&)aSink).NumChannels();
149 iSinkFourCC.Set(aSink.SinkDataTypeCode(TMediaId(KUidMediaTypeVideo)));
150 ((CMMFFormatDecode&)aSink).SuggestSourceBufferSize(KVideoInputDefaultFrameSize);
153 //Use SW conversion but should configure Dev sound where possible
154 //WINS DevSound is always 8000 sample rate, mono & pcm16
155 if ((iSinkChannels != 1)||(iSinkSampleRate != 8000)) iNeedsSWConversion = ETrue;
156 else iNeedsSWConversion = EFalse; //incase it was set to true
160 void CMMFVideoInput::SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
162 iPrioritySettings = aPrioritySettings;
166 TFourCC CMMFVideoInput::SourceDataTypeCode(TMediaId /*aMediaId*/)
168 //indicate we can only handle PCM16, although low-level WINS LDD can take Alaw directly
169 return KMMFFourCCCodePCM16;
173 TInt CMMFVideoInput::BytesPlayed()
178 // _________________________________________________________________________
179 // Exported proxy for instantiation method resolution
180 // Define the interface UIDs
182 const TImplementationProxy ImplementationTable[] =
184 IMPLEMENTATION_PROXY_ENTRY(KMmfUidVideoInputInterface, CMMFVideoInput::NewSourceL)
187 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
189 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
191 return ImplementationTable;