os/mm/mmlibs/mmfw/tsrc/mmfunittest/VCLNT/TS_VideoOutput/MmfVideoOutput.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 "MmfVideoOutput.h"
sl@0
    17
#include <mmf/server/mmfdatabuffer.h>
sl@0
    18
#include <ecom/implementationproxy.h>
sl@0
    19
#include <mmf/common/mmffourcc.h>
sl@0
    20
sl@0
    21
sl@0
    22
void Panic(TInt aPanicCode)
sl@0
    23
	{
sl@0
    24
	_LIT(KMMFVideoOutputPanicCategory, "MMFVideoOutput");
sl@0
    25
	User::Panic(KMMFVideoOutputPanicCategory, aPanicCode);
sl@0
    26
	}
sl@0
    27
sl@0
    28
MDataSink* CMMFVideoOutput::NewSinkL()
sl@0
    29
	{
sl@0
    30
	CMMFVideoOutput* self = new (ELeave) CMMFVideoOutput ;
sl@0
    31
	return STATIC_CAST( MDataSink*, self ) ;
sl@0
    32
	}
sl@0
    33
sl@0
    34
sl@0
    35
void CMMFVideoOutput::ConstructSinkL( const TDesC8& /*aInitData*/ )
sl@0
    36
	{
sl@0
    37
sl@0
    38
	}
sl@0
    39
sl@0
    40
sl@0
    41
/**
sl@0
    42
 *
sl@0
    43
 * Send Video to MMFDevsound
sl@0
    44
 *
sl@0
    45
 * @param		"CMMFBuffer* aBuffer"
sl@0
    46
 *				The data to write out
sl@0
    47
 * @param		"MDataSource* aSupplier"
sl@0
    48
 * @param		"TMediaId aMediaId"
sl@0
    49
 *				Type of data supplied - currently ignored.
sl@0
    50
 */
sl@0
    51
sl@0
    52
void CMMFVideoOutput::EmptyBufferL(CMMFBuffer* /*aBuffer*/, MDataSource* /*aSupplier*/, TMediaId /*aMediaId*/)
sl@0
    53
	{
sl@0
    54
sl@0
    55
	}
sl@0
    56
sl@0
    57
void CMMFVideoOutput::NegotiateL(MDataSource& aSource)
sl@0
    58
	{
sl@0
    59
	if (aSource.DataSourceType() == KUidMmfFormatDecode)
sl@0
    60
		{//source is a clip so for now set sink settings to match source
sl@0
    61
		iSourceSampleRate = ((CMMFFormatDecode&)aSource).SampleRate();
sl@0
    62
		iSourceChannels = ((CMMFFormatDecode&)aSource).NumChannels();
sl@0
    63
		iSourceFourCC.Set(aSource.SourceDataTypeCode(TMediaId(KUidMediaTypeVideo)));
sl@0
    64
		((CMMFFormatDecode&)aSource).SuggestSourceBufferSize(KVideoOutputDefaultFrameSize);
sl@0
    65
		}
sl@0
    66
/*	[WINS DevSound supports different sample rates, stereo and different encoding]
sl@0
    67
	//Use SW conversion but  should configure Dev sound where possible
sl@0
    68
	// WINS DevSound is 8000 sample rate, mono & pcm16
sl@0
    69
	if ((iSourceChannels != 1)||(iSourceSampleRate != 8000)) 
sl@0
    70
		{
sl@0
    71
		iNeedsSWConversion = ETrue;
sl@0
    72
		TUint convertedBufferFrameSize = iMMFDevSound->BufferSize( ) / iSourceChannels;
sl@0
    73
		if (iConvertBuffer) delete iConvertBuffer; 
sl@0
    74
		iConvertBuffer = NULL;
sl@0
    75
		iConvertBuffer = CMMFDataBuffer::NewL(convertedBufferFrameSize);
sl@0
    76
		}
sl@0
    77
*/
sl@0
    78
	}
sl@0
    79
sl@0
    80
void CMMFVideoOutput::SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
sl@0
    81
	{
sl@0
    82
	iPrioritySettings = aPrioritySettings;
sl@0
    83
	}
sl@0
    84
sl@0
    85
sl@0
    86
void CMMFVideoOutput::SinkPrimeL()
sl@0
    87
	{
sl@0
    88
	iFirstBufferSent = EFalse;
sl@0
    89
	}
sl@0
    90
sl@0
    91
sl@0
    92
void CMMFVideoOutput::SinkPauseL()
sl@0
    93
	{
sl@0
    94
	iFirstBufferSent = EFalse;
sl@0
    95
	iState = EPaused;
sl@0
    96
	}
sl@0
    97
sl@0
    98
sl@0
    99
void CMMFVideoOutput::SinkPlayL()
sl@0
   100
	{
sl@0
   101
	}
sl@0
   102
sl@0
   103
void CMMFVideoOutput::SinkStopL()
sl@0
   104
	{
sl@0
   105
	}
sl@0
   106
sl@0
   107
TInt CMMFVideoOutput::State()
sl@0
   108
	{
sl@0
   109
	return iState;
sl@0
   110
	}
sl@0
   111
sl@0
   112
sl@0
   113
TInt CMMFVideoOutput::SinkThreadLogon(MAsyncEventHandler& /*aEventHandler*/)
sl@0
   114
	{
sl@0
   115
	return KErrNone;
sl@0
   116
	}
sl@0
   117
sl@0
   118
sl@0
   119
void CMMFVideoOutput::SinkThreadLogoff()
sl@0
   120
	{
sl@0
   121
	}
sl@0
   122
sl@0
   123
sl@0
   124
void CMMFVideoOutput::BufferFilledL(CMMFBuffer* /*aBuffer*/)
sl@0
   125
	{
sl@0
   126
//	__ASSERT_DEBUG(EFalse, Panic(EMMFVideoOutputPanicBufferFilledLNotSupported));
sl@0
   127
	}
sl@0
   128
sl@0
   129
sl@0
   130
TFourCC CMMFVideoOutput::SinkDataTypeCode(TMediaId /*aMediaId*/)
sl@0
   131
	{
sl@0
   132
	//hardwire 4CC - DevSound should have an interface to get this value
sl@0
   133
	return KMMFFourCCCodePCM16;
sl@0
   134
	}
sl@0
   135
sl@0
   136
TBool CMMFVideoOutput::CanCreateSinkBuffer()
sl@0
   137
	{
sl@0
   138
	return ETrue;
sl@0
   139
	}
sl@0
   140
sl@0
   141
CMMFBuffer* CMMFVideoOutput::CreateSinkBufferL(TMediaId /*aMediaId*/, TBool &aReference)
sl@0
   142
	{
sl@0
   143
	iDevSoundBuffer = CMMFDataBuffer::NewL(KVideoOutputDefaultFrameSize);
sl@0
   144
	aReference = ETrue;
sl@0
   145
	if ( iNeedsSWConversion )
sl@0
   146
		return iConvertBuffer;
sl@0
   147
	else
sl@0
   148
		return iDevSoundBuffer;
sl@0
   149
	}
sl@0
   150
sl@0
   151
sl@0
   152
CMMFVideoOutput::~CMMFVideoOutput()
sl@0
   153
	{
sl@0
   154
	delete iChannelAndSampleRateConverterFactory;
sl@0
   155
	delete iConvertBuffer;
sl@0
   156
	}
sl@0
   157
sl@0
   158
sl@0
   159
// __________________________________________________________________________
sl@0
   160
// Exported proxy for instantiation method resolution
sl@0
   161
// Define the interface UIDs
sl@0
   162
sl@0
   163
sl@0
   164
sl@0
   165
const TImplementationProxy ImplementationTable[] =
sl@0
   166
	{
sl@0
   167
		IMPLEMENTATION_PROXY_ENTRY(KMmfUidVideoOutputInterface,	CMMFVideoOutput::NewSinkL)
sl@0
   168
	};
sl@0
   169
sl@0
   170
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   171
	{
sl@0
   172
	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   173
sl@0
   174
	return ImplementationTable;
sl@0
   175
	}
sl@0
   176