mmserv/tms/tmsserver/inc/tmsserver.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 02 Feb 2010 01:08:46 +0200
changeset 0 71ca22bcf22a
child 3 4f62049db6ac
permissions -rw-r--r--
Revision: 201003 Kit: 201005

/*
 * 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 __TMSSERVER_H
#define __TMSSERVER_H

#include <e32base.h>
#include <mmcccodecinformation.h>
#include <tms.h>
#include "tmsshared.h"
#include "tmsclientserver.h"

namespace TMS {

// FORWARD DECLARATIONS
class TMSServerShutDown;
class CStartAndMonitorTMSCallThread;
class TMSCallProxyLocal;
class GlobalEffectsSettings;
class CTarEventHandler;
class CSPCenRepListener;
class CSPAudioHandler;

// -----------------------------------------------------------------------------
// TMSServer class
// -----------------------------------------------------------------------------
//
class TMSServer : public CServer2
    {
public:
    static TMSServer* NewL();
    ~TMSServer();

    void AddSession();
    void DropSession();
    TInt SessionCount();

    void SetDnLinkSession(TBool aSession);
    void SetUpLinkSession(TBool aSession);

    TBool HasDnLinkSession() const;
    TBool HasUpLinkSession() const;

    void GetNewTMSCallSessionHandleL(RHandleBase& aHandle);
    TInt SetOutput(CSession2* sid, TInt output);
    TInt GetOutput(const RMessage2& aMessage);
    TInt GetPreviousOutput(const RMessage2& aMessage);
    TInt GetAvailableOutputs(const RMessage2& aMessage);

    TInt GetMaxLevel(const RMessage2& aMessage);
    TInt GetLevel(const RMessage2& aMessage);
    TInt SetLevel(CSession2* sid, TBool tmsclient, TInt level);

    TInt GetMaxGain(const RMessage2& aMessage);
    TInt GetGain(const RMessage2& aMessage);
    TInt SetGain(CSession2* sid, TInt level);
    TInt GetSupportedCodecs(const TMSStreamType strmType,
            RArray<TFourCC>*& aCodecs);

    TInt NotifyTarClients(TRoutingMsgBufPckg routingpckg);

    void StartRoutingNotifierL();
    void CancelRoutingNotifier();
    void StartCenRepHandlerL();
    void CancelCenRepHandler();

private:
    TMSServer();
    void ConstructL();
    CSession2* NewSessionL(const TVersion& aVersion,
            const RMessage2& aMessage) const;

    TInt StartTMSCallServer(TMSCallProxyLocal& aHandle);
    void GetAvailableOutputsL(const RMessage2& aMessage);
    TInt SendMessageToCallServ(TInt func, TInt value);
    TInt SendMessageToCallServ(TInt func, TIpcArgs args);

private:
    TInt iSession;
    TMSServerShutDown *iShutdownTimer;

    TBool iDnlinkSession;
    TBool iUplinkSession;

    mutable RPointerArray<CStartAndMonitorTMSCallThread> iTMSCallServList;
    GlobalEffectsSettings* iEffectSettings;
    CTarEventHandler* iTarHandler;
    CSPAudioHandler* iAudioCenRepHandler;
    TMSAudioOutput iCurrentRouting;

    RArray<TFourCC> iDnlCodecs;
    RArray<TFourCC> iUplCodecs;
    };

// -----------------------------------------------------------------------------
// CStartAndMonitorTMSCallThread class
// -----------------------------------------------------------------------------
//
class TMSCallProxyLocal : public RSessionBase
    {
public:
    TInt Open(RServer2& aTMSCallServerHandle);
    TInt SendToCallServer(TInt aFunc, TUint value);
    TInt SendToCallServer(TInt aFunc, TIpcArgs args);
    TInt ReceiveFromCallServer(TInt aFunc, TUint& value);
    TInt ReceiveFromCallServer(TInt aFunc, TIpcArgs args);
    };

// -----------------------------------------------------------------------------
// CStartAndMonitorTMSCallThread class
// -----------------------------------------------------------------------------
//
class CStartAndMonitorTMSCallThread : public CActive
    {
public:
    static CStartAndMonitorTMSCallThread* NewL(TMSServer* aServer);
    ~CStartAndMonitorTMSCallThread();
    TInt StartTMSCallServer(TMSCallProxyLocal& aHandle);

private:
    // Construct
    CStartAndMonitorTMSCallThread(TMSServer* aServer);
    void ConstructL();

    // From CActive
    void RunL();
    void DoCancel();

public:
    RServer2 iCallSrvrHndl;
    TMSCallProxyLocal iTMSCallProxyLocal;

private:
    TMSServer* iTMSServer;
    RThread iServerThread;
    };

} //namespace TMS

#endif //__TMSSERVER_H

// End of file