os/mm/mmlibs/mmfw/tsrc/mmfunittest/VCLNT/TS_VideoInput/MmfVideoInput.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <e32std.h>
    17 #include <ecom/implementationproxy.h>
    18 #include <mmf/common/mmffourcc.h>
    19 #include <mmf/server/mmfdatabuffer.h>
    20 #include "MmfVideoInput.h"
    21 
    22 
    23 
    24 void Panic(TInt aPanicCode)
    25 	{
    26 	_LIT(KMMFVideoInputPanicCategory, "MMFVideoInput");
    27 	User::Panic(KMMFVideoInputPanicCategory, aPanicCode);
    28 	}
    29 
    30 MDataSource* CMMFVideoInput::NewSourceL() 
    31 	{
    32 	CMMFVideoInput* self = new (ELeave) CMMFVideoInput ;
    33 	return  STATIC_CAST( MDataSource*, self );
    34 	}
    35 
    36 CMMFVideoInput::~CMMFVideoInput()
    37 	{
    38 #ifdef KVideoInputCanResample
    39 	delete iChannelAndSampleRateConverterFactory; 
    40 	delete iConvertBuffer; 
    41 #endif
    42 	}
    43 
    44 
    45 void CMMFVideoInput::ConstructSourceL( const TDesC8& /*aInitData*/ ) 
    46 	{
    47 
    48 	}
    49 
    50 
    51 void CMMFVideoInput::HWFillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/)
    52 	{
    53 
    54 	}
    55 
    56 
    57 /**
    58  * 
    59  * Get audio from MMFDevsound
    60  *
    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.
    66  */
    67 
    68 void CMMFVideoInput::FillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/,TMediaId)
    69 	{
    70 	}
    71 
    72 void CMMFVideoInput::BufferEmptiedL(CMMFBuffer* /*aBuffer*/)
    73 	{
    74 
    75 	}
    76 
    77 
    78 TBool CMMFVideoInput::CanCreateSourceBuffer()
    79 	{
    80 	return ETrue;
    81 	}
    82 
    83 CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference)
    84 	{
    85 	CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
    86 
    87 	aReference = ETrue; // This is a reference from DevSound
    88 	return buf;
    89 	}
    90 
    91 CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/)
    92 	{
    93 	//0x1000 is what WINS DevSound expects
    94 	CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
    95 	return buf;
    96 	}
    97 
    98 
    99 
   100 void CMMFVideoInput::SourcePrimeL()
   101 	{
   102 
   103 	}
   104 
   105 void CMMFVideoInput::SourceStopL()
   106 	{
   107 	iStopped = ETrue;
   108 	}
   109 
   110 
   111 void CMMFVideoInput::SourcePlayL()
   112 	{
   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, 
   121 																	8000, 1);
   122 		//need to create an intermediate buffer in which to place the converted data
   123 
   124 		TUint convertedBufferFrameSize = KVideoInputDefaultFrameSize/iSinkChannels;
   125 		if (iConvertBuffer) delete iConvertBuffer; 
   126 		iConvertBuffer = NULL;
   127 		iConvertBuffer = CMMFDataBuffer::NewL(convertedBufferFrameSize);
   128 		}
   129 #endif
   130 	}
   131 
   132 TInt CMMFVideoInput::SourceThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
   133 	{
   134 	return KErrNone;
   135 	}
   136 
   137 void CMMFVideoInput::SourceThreadLogoff()
   138 	{
   139 	}
   140 
   141 void CMMFVideoInput::NegotiateL(MDataSink& aSink)
   142 	{
   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); 
   151 		}
   152 
   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
   157 #endif
   158 	}
   159 
   160 void CMMFVideoInput::SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
   161 	{
   162 	iPrioritySettings = aPrioritySettings;
   163 	}
   164 
   165 
   166 TFourCC CMMFVideoInput::SourceDataTypeCode(TMediaId /*aMediaId*/)
   167 	{
   168 	//indicate we can only handle PCM16, although low-level WINS LDD can take Alaw directly
   169 	return KMMFFourCCCodePCM16;
   170 	}
   171 
   172 
   173 TInt CMMFVideoInput::BytesPlayed()
   174 	{
   175 	return 0;
   176 	}
   177 
   178 // _________________________________________________________________________
   179 // Exported proxy for instantiation method resolution
   180 // Define the interface UIDs
   181 
   182 const TImplementationProxy ImplementationTable[] = 
   183 	{
   184 		IMPLEMENTATION_PROXY_ENTRY(KMmfUidVideoInputInterface,	CMMFVideoInput::NewSourceL)
   185 	};
   186 
   187 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   188 	{
   189 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   190 
   191 	return ImplementationTable;
   192 	}
   193