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.
16 #include "MmfVideoOutput.h"
17 #include <mmf/server/mmfdatabuffer.h>
18 #include <ecom/implementationproxy.h>
19 #include <mmf/common/mmffourcc.h>
22 void Panic(TInt aPanicCode)
24 _LIT(KMMFVideoOutputPanicCategory, "MMFVideoOutput");
25 User::Panic(KMMFVideoOutputPanicCategory, aPanicCode);
28 MDataSink* CMMFVideoOutput::NewSinkL()
30 CMMFVideoOutput* self = new (ELeave) CMMFVideoOutput ;
31 return STATIC_CAST( MDataSink*, self ) ;
35 void CMMFVideoOutput::ConstructSinkL( const TDesC8& /*aInitData*/ )
43 * Send Video to MMFDevsound
45 * @param "CMMFBuffer* aBuffer"
46 * The data to write out
47 * @param "MDataSource* aSupplier"
48 * @param "TMediaId aMediaId"
49 * Type of data supplied - currently ignored.
52 void CMMFVideoOutput::EmptyBufferL(CMMFBuffer* /*aBuffer*/, MDataSource* /*aSupplier*/, TMediaId /*aMediaId*/)
57 void CMMFVideoOutput::NegotiateL(MDataSource& aSource)
59 if (aSource.DataSourceType() == KUidMmfFormatDecode)
60 {//source is a clip so for now set sink settings to match source
61 iSourceSampleRate = ((CMMFFormatDecode&)aSource).SampleRate();
62 iSourceChannels = ((CMMFFormatDecode&)aSource).NumChannels();
63 iSourceFourCC.Set(aSource.SourceDataTypeCode(TMediaId(KUidMediaTypeVideo)));
64 ((CMMFFormatDecode&)aSource).SuggestSourceBufferSize(KVideoOutputDefaultFrameSize);
66 /* [WINS DevSound supports different sample rates, stereo and different encoding]
67 //Use SW conversion but should configure Dev sound where possible
68 // WINS DevSound is 8000 sample rate, mono & pcm16
69 if ((iSourceChannels != 1)||(iSourceSampleRate != 8000))
71 iNeedsSWConversion = ETrue;
72 TUint convertedBufferFrameSize = iMMFDevSound->BufferSize( ) / iSourceChannels;
73 if (iConvertBuffer) delete iConvertBuffer;
74 iConvertBuffer = NULL;
75 iConvertBuffer = CMMFDataBuffer::NewL(convertedBufferFrameSize);
80 void CMMFVideoOutput::SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
82 iPrioritySettings = aPrioritySettings;
86 void CMMFVideoOutput::SinkPrimeL()
88 iFirstBufferSent = EFalse;
92 void CMMFVideoOutput::SinkPauseL()
94 iFirstBufferSent = EFalse;
99 void CMMFVideoOutput::SinkPlayL()
103 void CMMFVideoOutput::SinkStopL()
107 TInt CMMFVideoOutput::State()
113 TInt CMMFVideoOutput::SinkThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
119 void CMMFVideoOutput::SinkThreadLogoff()
124 void CMMFVideoOutput::BufferFilledL(CMMFBuffer* /*aBuffer*/)
126 // __ASSERT_DEBUG(EFalse, Panic(EMMFVideoOutputPanicBufferFilledLNotSupported));
130 TFourCC CMMFVideoOutput::SinkDataTypeCode(TMediaId /*aMediaId*/)
132 //hardwire 4CC - DevSound should have an interface to get this value
133 return KMMFFourCCCodePCM16;
136 TBool CMMFVideoOutput::CanCreateSinkBuffer()
141 CMMFBuffer* CMMFVideoOutput::CreateSinkBufferL(TMediaId /*aMediaId*/, TBool &aReference)
143 iDevSoundBuffer = CMMFDataBuffer::NewL(KVideoOutputDefaultFrameSize);
145 if ( iNeedsSWConversion )
146 return iConvertBuffer;
148 return iDevSoundBuffer;
152 CMMFVideoOutput::~CMMFVideoOutput()
154 delete iChannelAndSampleRateConverterFactory;
155 delete iConvertBuffer;
159 // __________________________________________________________________________
160 // Exported proxy for instantiation method resolution
161 // Define the interface UIDs
165 const TImplementationProxy ImplementationTable[] =
167 IMPLEMENTATION_PROXY_ENTRY(KMmfUidVideoOutputInterface, CMMFVideoOutput::NewSinkL)
170 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
172 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
174 return ImplementationTable;