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.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <e32std.h>
sl@0
    17
#include <ecom/implementationproxy.h>
sl@0
    18
#include <mmf/common/mmffourcc.h>
sl@0
    19
#include <mmf/server/mmfdatabuffer.h>
sl@0
    20
#include "MmfVideoInput.h"
sl@0
    21
sl@0
    22
sl@0
    23
sl@0
    24
void Panic(TInt aPanicCode)
sl@0
    25
	{
sl@0
    26
	_LIT(KMMFVideoInputPanicCategory, "MMFVideoInput");
sl@0
    27
	User::Panic(KMMFVideoInputPanicCategory, aPanicCode);
sl@0
    28
	}
sl@0
    29
sl@0
    30
MDataSource* CMMFVideoInput::NewSourceL() 
sl@0
    31
	{
sl@0
    32
	CMMFVideoInput* self = new (ELeave) CMMFVideoInput ;
sl@0
    33
	return  STATIC_CAST( MDataSource*, self );
sl@0
    34
	}
sl@0
    35
sl@0
    36
CMMFVideoInput::~CMMFVideoInput()
sl@0
    37
	{
sl@0
    38
#ifdef KVideoInputCanResample
sl@0
    39
	delete iChannelAndSampleRateConverterFactory; 
sl@0
    40
	delete iConvertBuffer; 
sl@0
    41
#endif
sl@0
    42
	}
sl@0
    43
sl@0
    44
sl@0
    45
void CMMFVideoInput::ConstructSourceL( const TDesC8& /*aInitData*/ ) 
sl@0
    46
	{
sl@0
    47
sl@0
    48
	}
sl@0
    49
sl@0
    50
sl@0
    51
void CMMFVideoInput::HWFillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/)
sl@0
    52
	{
sl@0
    53
sl@0
    54
	}
sl@0
    55
sl@0
    56
sl@0
    57
/**
sl@0
    58
 * 
sl@0
    59
 * Get audio from MMFDevsound
sl@0
    60
 *
sl@0
    61
 * @param		"CMMFBuffer* aBuffer"
sl@0
    62
 *				The data to write out. Assumed to really be CMMFBitmapFrameBuffer*.
sl@0
    63
 * @param		"MDataSink* aConsumer"
sl@0
    64
 * @param		"TMediaId aMediaId"
sl@0
    65
 *				Type of data supplied - currently ignored.
sl@0
    66
 */
sl@0
    67
sl@0
    68
void CMMFVideoInput::FillBufferL(CMMFBuffer* /*aBuffer*/, MDataSink* /*aConsumer*/,TMediaId)
sl@0
    69
	{
sl@0
    70
	}
sl@0
    71
sl@0
    72
void CMMFVideoInput::BufferEmptiedL(CMMFBuffer* /*aBuffer*/)
sl@0
    73
	{
sl@0
    74
sl@0
    75
	}
sl@0
    76
sl@0
    77
sl@0
    78
TBool CMMFVideoInput::CanCreateSourceBuffer()
sl@0
    79
	{
sl@0
    80
	return ETrue;
sl@0
    81
	}
sl@0
    82
sl@0
    83
CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/, TBool &aReference)
sl@0
    84
	{
sl@0
    85
	CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
sl@0
    86
sl@0
    87
	aReference = ETrue; // This is a reference from DevSound
sl@0
    88
	return buf;
sl@0
    89
	}
sl@0
    90
sl@0
    91
CMMFBuffer* CMMFVideoInput::CreateSourceBufferL(TMediaId /*aMediaId*/)
sl@0
    92
	{
sl@0
    93
	//0x1000 is what WINS DevSound expects
sl@0
    94
	CMMFDataBuffer* buf = CMMFDataBuffer::NewL(KVideoInputDefaultFrameSize);
sl@0
    95
	return buf;
sl@0
    96
	}
sl@0
    97
sl@0
    98
sl@0
    99
sl@0
   100
void CMMFVideoInput::SourcePrimeL()
sl@0
   101
	{
sl@0
   102
sl@0
   103
	}
sl@0
   104
sl@0
   105
void CMMFVideoInput::SourceStopL()
sl@0
   106
	{
sl@0
   107
	iStopped = ETrue;
sl@0
   108
	}
sl@0
   109
sl@0
   110
sl@0
   111
void CMMFVideoInput::SourcePlayL()
sl@0
   112
	{
sl@0
   113
#ifdef KVideoInputCanResample
sl@0
   114
	if ((iNeedsSWConversion)&&(iSinkChannels>0))
sl@0
   115
		{//can only do SW convert  - therefore need to do a conversion 
sl@0
   116
		//currently only pcm16 is supported so return with an error if format not pcm16
sl@0
   117
		iChannelAndSampleRateConverterFactory 
sl@0
   118
			= new(ELeave)CMMFChannelAndSampleRateConverterFactory;
sl@0
   119
		iChannelAndSampleRateConverter = 
sl@0
   120
			iChannelAndSampleRateConverterFactory->CreateConverterL( iSinkSampleRate, iSinkChannels, 
sl@0
   121
																	8000, 1);
sl@0
   122
		//need to create an intermediate buffer in which to place the converted data
sl@0
   123
sl@0
   124
		TUint convertedBufferFrameSize = KVideoInputDefaultFrameSize/iSinkChannels;
sl@0
   125
		if (iConvertBuffer) delete iConvertBuffer; 
sl@0
   126
		iConvertBuffer = NULL;
sl@0
   127
		iConvertBuffer = CMMFDataBuffer::NewL(convertedBufferFrameSize);
sl@0
   128
		}
sl@0
   129
#endif
sl@0
   130
	}
sl@0
   131
sl@0
   132
TInt CMMFVideoInput::SourceThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
sl@0
   133
	{
sl@0
   134
	return KErrNone;
sl@0
   135
	}
sl@0
   136
sl@0
   137
void CMMFVideoInput::SourceThreadLogoff()
sl@0
   138
	{
sl@0
   139
	}
sl@0
   140
sl@0
   141
void CMMFVideoInput::NegotiateL(MDataSink& aSink)
sl@0
   142
	{
sl@0
   143
	aSink = aSink; //to keep compiler happy
sl@0
   144
#ifdef KVideoInputCanResample
sl@0
   145
	if (aSink.DataSinkType() == KUidMmfFormatDecode) 
sl@0
   146
		{//source is a clip so for now set sink settings to match source
sl@0
   147
		iSinkSampleRate = ((CMMFFormatDecode&)aSink).SampleRate(); 
sl@0
   148
		iSinkChannels = ((CMMFFormatDecode&)aSink).NumChannels();
sl@0
   149
		iSinkFourCC.Set(aSink.SinkDataTypeCode(TMediaId(KUidMediaTypeVideo)));
sl@0
   150
		((CMMFFormatDecode&)aSink).SuggestSourceBufferSize(KVideoInputDefaultFrameSize); 
sl@0
   151
		}
sl@0
   152
sl@0
   153
	//Use SW conversion but  should configure Dev sound where possible
sl@0
   154
	//WINS DevSound is always 8000 sample rate, mono & pcm16
sl@0
   155
	if ((iSinkChannels != 1)||(iSinkSampleRate != 8000)) iNeedsSWConversion = ETrue;
sl@0
   156
	else iNeedsSWConversion = EFalse; //incase it was set to true
sl@0
   157
#endif
sl@0
   158
	}
sl@0
   159
sl@0
   160
void CMMFVideoInput::SetSourcePrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
sl@0
   161
	{
sl@0
   162
	iPrioritySettings = aPrioritySettings;
sl@0
   163
	}
sl@0
   164
sl@0
   165
sl@0
   166
TFourCC CMMFVideoInput::SourceDataTypeCode(TMediaId /*aMediaId*/)
sl@0
   167
	{
sl@0
   168
	//indicate we can only handle PCM16, although low-level WINS LDD can take Alaw directly
sl@0
   169
	return KMMFFourCCCodePCM16;
sl@0
   170
	}
sl@0
   171
sl@0
   172
sl@0
   173
TInt CMMFVideoInput::BytesPlayed()
sl@0
   174
	{
sl@0
   175
	return 0;
sl@0
   176
	}
sl@0
   177
sl@0
   178
// _________________________________________________________________________
sl@0
   179
// Exported proxy for instantiation method resolution
sl@0
   180
// Define the interface UIDs
sl@0
   181
sl@0
   182
const TImplementationProxy ImplementationTable[] = 
sl@0
   183
	{
sl@0
   184
		IMPLEMENTATION_PROXY_ENTRY(KMmfUidVideoInputInterface,	CMMFVideoInput::NewSourceL)
sl@0
   185
	};
sl@0
   186
sl@0
   187
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   188
	{
sl@0
   189
	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   190
sl@0
   191
	return ImplementationTable;
sl@0
   192
	}
sl@0
   193