os/mm/mmhais/refacladapt/src/audiostream/audiostream.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description:
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#ifndef AUDIOSTREAM_H
sl@0
    20
#define AUDIOSTREAM_H
sl@0
    21
sl@0
    22
#include <e32base.h>
sl@0
    23
#include <f32file.h>
sl@0
    24
#include <a3f/a3f_trace_utils.h>
sl@0
    25
#include <a3f/a3fbase.h>
sl@0
    26
#include "audiostreamadaptation.h"
sl@0
    27
#include "maudiocodecadaptationobserver.h"
sl@0
    28
#include "mconfigurationhelper.h"
sl@0
    29
#include "mstreambuffercontrol.h"
sl@0
    30
sl@0
    31
class CAudioCodec;
sl@0
    32
class CAudioStream;
sl@0
    33
class CAudioDeviceSource;
sl@0
    34
class CAudioDeviceSink;
sl@0
    35
class CBufferSink;
sl@0
    36
class CBufferSource;
sl@0
    37
class CAudioGainControl;
sl@0
    38
class CFourCCConvertor;
sl@0
    39
class MAudioStreamAdaptationObserver;
sl@0
    40
class MInputPort;
sl@0
    41
class MOutputPort;
sl@0
    42
class MAudioCodecObserver;
sl@0
    43
sl@0
    44
sl@0
    45
#include "mlogicalchain.h"
sl@0
    46
sl@0
    47
class CLogicalAudioStream;
sl@0
    48
sl@0
    49
/////
sl@0
    50
 // This is the implementation of audio stream adaptation.
sl@0
    51
 ///
sl@0
    52
sl@0
    53
class CAudioStream : 	public CAudioStreamAdaptation,
sl@0
    54
						public MAudioCodecAdaptationObserver,
sl@0
    55
						public MConfigurationHelper, 
sl@0
    56
						public MStreamBufferControl, 
sl@0
    57
						public MFlushHandlerObserver
sl@0
    58
	{
sl@0
    59
public:
sl@0
    60
sl@0
    61
	/////
sl@0
    62
	// Create a new instance.
sl@0
    63
	//
sl@0
    64
	// @param aStream the stream implementation. Ownership of the pointer is transferred to the create CAudioStream object instance.
sl@0
    65
	// @return CAudioStreamComponent* a pointer to the created instance.
sl@0
    66
	///
sl@0
    67
	static CAudioStream* NewL();
sl@0
    68
sl@0
    69
	/////
sl@0
    70
	// Destructor.
sl@0
    71
	//
sl@0
    72
	// Deletes all objects and releases all resource owned by this instance.
sl@0
    73
	///
sl@0
    74
	virtual ~CAudioStream();
sl@0
    75
sl@0
    76
	// From CAudioStreamAdaptation
sl@0
    77
	TInt RegisterAudioStreamObserver(MAudioStreamAdaptationObserver& aObserver);
sl@0
    78
	void UnregisterAudioStreamObserver(MAudioStreamAdaptationObserver& aObserver);
sl@0
    79
	void UnregisterAllAudioStreamObserver();
sl@0
    80
	void SetFourCC(const CFourCCConvertor& aFourCCConvertor);
sl@0
    81
sl@0
    82
	TInt Message(MLogicalChain& aCurrentChain, MLogicalChain& aDesiredChain, MAudioContext& aContext, TInt aFlags);
sl@0
    83
sl@0
    84
	// from class MAudioCodecAdaptationObserver
sl@0
    85
	void AllBuffersProcessed();
sl@0
    86
	void ProcessingUnitError(TInt aError);
sl@0
    87
	TInt RegisterAudioCodecObserver(MAudioCodecObserver& aObserver);
sl@0
    88
	void UnregisterAudioCodecObserver(MAudioCodecObserver& aObserver);
sl@0
    89
	void GetSupportedAModesComplete(TInt aError);
sl@0
    90
	void GetSupportedARatesComplete(TInt aError);
sl@0
    91
sl@0
    92
	// from base clase MStreamBufferControl
sl@0
    93
	TInt FlushBuffers();
sl@0
    94
sl@0
    95
	// from class MFlushHandlerObserver
sl@0
    96
	void FlushComplete(TInt aError);
sl@0
    97
protected:
sl@0
    98
	// from base clase MConfigurationhelper
sl@0
    99
	TInt GetSupportedModes(RArray<TUid>& aSupportedModes);
sl@0
   100
	TInt GetSupportedSampleRates(RArray<TInt>& aSupportedRates);
sl@0
   101
sl@0
   102
private:
sl@0
   103
	TInt CreateDataPath();
sl@0
   104
sl@0
   105
	TInt DemolishDataPath();
sl@0
   106
sl@0
   107
	TInt ChangeState(TAudioState aPreviousState, TAudioState aTargetState);
sl@0
   108
sl@0
   109
	TAny* GetComponent(TUid aType);
sl@0
   110
sl@0
   111
	TInt CreatePhysicalComponents(MLogicalChain& aDesiredChain);
sl@0
   112
sl@0
   113
	void DeletePhysicalComponents();
sl@0
   114
sl@0
   115
	void ConstructL();
sl@0
   116
sl@0
   117
	CAudioStream();
sl@0
   118
sl@0
   119
private:
sl@0
   120
	// Flags
sl@0
   121
	TBool				iIsCodecConfig;
sl@0
   122
sl@0
   123
	// Components
sl@0
   124
	MLogicalChain*		iDesiredChain;
sl@0
   125
sl@0
   126
	MLogicalChain*		iCurrentChain;
sl@0
   127
sl@0
   128
	MAudioContext* 		iAudioContext;
sl@0
   129
sl@0
   130
	CAudioCodec*		iCodec;
sl@0
   131
sl@0
   132
	CBufferSource*		iBufferSource;
sl@0
   133
sl@0
   134
	CBufferSink*		iBufferSink;
sl@0
   135
sl@0
   136
	CAudioDeviceSource*	iDeviceSource;
sl@0
   137
sl@0
   138
	CAudioDeviceSink*	iDeviceSink;
sl@0
   139
sl@0
   140
	CAudioGainControl*	iGainControl;
sl@0
   141
sl@0
   142
	// Not owned
sl@0
   143
	CFourCCConvertor*	iFourCCConvertor;
sl@0
   144
sl@0
   145
	TInt				iSampleRateConfig;
sl@0
   146
sl@0
   147
	TUid				iModeConfig;
sl@0
   148
sl@0
   149
	TAudioState			iCurrentStreamState;
sl@0
   150
sl@0
   151
	TAudioState			iDesiredStreamState;
sl@0
   152
sl@0
   153
	// Observers
sl@0
   154
	RPointerArray<MAudioStreamAdaptationObserver> iAudioStreamObservers;
sl@0
   155
sl@0
   156
	RPointerArray<MAudioCodecObserver>	iAudioCodecObservers;
sl@0
   157
sl@0
   158
	MOutputPort*		iOutputport;	// remove ports when changing to Uninitialized
sl@0
   159
sl@0
   160
	MInputPort*			iInputport;
sl@0
   161
sl@0
   162
	TTimeIntervalMicroSeconds iTimeProcessed;
sl@0
   163
	};
sl@0
   164
sl@0
   165
#endif // AUDIOSTREAM_H__