mmserv/tms/tmscallserver/inc/tmscsdevsound.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 03 May 2010 12:59:52 +0300
changeset 14 80975da52420
child 21 2ed61feeead6
child 40 60e492b28869
permissions -rw-r--r--
Revision: 201015 Kit: 201018

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: Telephony Multimedia Service
 *
 */

#ifndef TMSCSDEVSOUND_H
#define TMSCSDEVSOUND_H

#include <sounddevice.h>

namespace TMS {

class TMSCSPDevSoundObserver;

/**
 *  Wrapper for CMMFDevSound
 *
 */
NONSHARABLE_CLASS(TMSCSPDevSound) : public CBase,
                                    public MDevSoundObserver
    {
public:

    /**
     * Destructor.
     */
    virtual ~TMSCSPDevSound();

    /**
     * Activates the dev sound stream. TMSCSPDevSoundObserver methods are called
     * when activation goes ok or fails. If the stream is already active or
     * activating then nothing is done.
     */
    virtual void Activate();

    /**
     * Deactivates the devsound stream. If stream is not active or
     * activation is not ongoing then nothing is done.
     */
    virtual void Deactivate();

    /**
     * Indicates that activation is ongoing,
     * but the result of the activation is still unknown.
     * @return ETrue - activation ongoing, EFalse - activation not ongoing.
     */
    TBool IsActivationOngoing() const;

    /**
     * Determines wether the devsound stream is active or not.
     * @return ETrue - Stream is active, EFalse - Stream not active.
     */
    TBool IsActive() const;

    CMMFDevSound& DevSound();

    // from base class MDevSoundObserver

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void InitializeComplete(TInt aError);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void BufferToBeFilled(CMMFBuffer* aBuffer);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void PlayError(TInt aError);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void ToneFinished(TInt aError);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void BufferToBeEmptied(CMMFBuffer* aBuffer);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void RecordError(TInt aError);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void ConvertError(TInt aError);

    /**
     * From MDevSoundObserver
     * Empty implementation
     */
    void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);

protected:

    TMSCSPDevSound(TMSCSPDevSoundObserver& aObserver);

    void ConstructL(TMMFState aMode, gint aAudioPreference,
            gint aAudioPriority);

private:

    /**
     * Derived class has to activate the stream here.
     */
    virtual void DoActivateL() = 0;

protected:

    TUint iStreamType;

    /**
     * Indication if device is activated. Derived class has to update this.
     */
    TBool iActive;

    /**
     * Indication if activation is ongoing.
     * Derived class has to update this.
     */
    TBool iActivationOngoing;

    /**
     * Devsound instance
     * Own.
     */
    CMMFDevSound* iDevSound;

    /**
     * Observer for successfull activation.
     * Not own.
     */
    TMSCSPDevSoundObserver& iObserver;

    };

} //namespace TMS

#endif // TMSCSDEVSOUND_H