os/mm/devsoundextensions/drmaudioplayer/DRMPlayServer/src/DRMPlayServer.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2006 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:   DRM Play Server
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include <e32std.h>
sl@0
    20
#include <e32svr.h>
sl@0
    21
#include "DRMPlayClientServer.h"
sl@0
    22
#include "DRMPlayServer.h"
sl@0
    23
sl@0
    24
sl@0
    25
sl@0
    26
CDRMPlayServer::CDRMPlayServer(TInt aPriority)
sl@0
    27
    : CServer2(aPriority)
sl@0
    28
    {
sl@0
    29
    }
sl@0
    30
sl@0
    31
sl@0
    32
// Create and start a new DRM play server.
sl@0
    33
CDRMPlayServer* CDRMPlayServer::New()
sl@0
    34
    {
sl@0
    35
    CDRMPlayServer *pS=new CDRMPlayServer(EPriority);
sl@0
    36
    __ASSERT_ALWAYS(pS!=NULL,PanicServer(ESvrCreateServer));
sl@0
    37
    __ASSERT_ALWAYS(pS->Start(KDRMPlayServerName)==KErrNone, PanicServer(ESvrCreateServer));
sl@0
    38
    return pS;
sl@0
    39
    }
sl@0
    40
sl@0
    41
sl@0
    42
// Create a new server session.
sl@0
    43
CSession2 *CDRMPlayServer::NewSessionL(const TVersion& aVersion,const RMessage2& aMessage ) const
sl@0
    44
    {
sl@0
    45
    // check we're the right version
sl@0
    46
    TVersion v(KDRMPlayServMajorVersionNumber,KDRMPlayServMinorVersionNumber,KDRMPlayServBuildVersionNumber);
sl@0
    47
    if (!User::QueryVersionSupported(v,aVersion))
sl@0
    48
        User::Leave(KErrNotSupported);
sl@0
    49
    // make new session
sl@0
    50
    return CDRMPlayServerSession::NewL(const_cast<CDRMPlayServer*>(this), aMessage);
sl@0
    51
    }
sl@0
    52
sl@0
    53
CDRMPlayServer::~CDRMPlayServer()
sl@0
    54
    {
sl@0
    55
sl@0
    56
    }
sl@0
    57
sl@0
    58
sl@0
    59
// Panic the server
sl@0
    60
GLDEF_C void PanicServer(TDRMPlayServPanic aPanic)
sl@0
    61
    {
sl@0
    62
    _LIT(KTxtServerPanic,"DRM Play server panic");
sl@0
    63
    User::Panic(KTxtServerPanic,aPanic);
sl@0
    64
    }
sl@0
    65
sl@0
    66
sl@0
    67
static void StartDRMPlayServerL()
sl@0
    68
// Perform all server initialisation, in particular creation of the
sl@0
    69
// scheduler and server and then run the scheduler
sl@0
    70
//
sl@0
    71
    {
sl@0
    72
sl@0
    73
sl@0
    74
sl@0
    75
    // Naming the server thread after the server helps to debug panics
sl@0
    76
sl@0
    77
    User::LeaveIfError(User::RenameThread(KDRMPlayServerName));
sl@0
    78
sl@0
    79
    // Create and install the active scheduler we need
sl@0
    80
    CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
sl@0
    81
    CActiveScheduler::Install(scheduler);
sl@0
    82
sl@0
    83
    // create the server
sl@0
    84
    CDRMPlayServer* server = CDRMPlayServer::New();
sl@0
    85
sl@0
    86
    // Initialisation complete, now signal the client
sl@0
    87
    RProcess::Rendezvous(KErrNone);
sl@0
    88
sl@0
    89
    // Start the scheduler and wait for client requests
sl@0
    90
    CActiveScheduler::Start();
sl@0
    91
sl@0
    92
    // Cleanup the server and scheduler
sl@0
    93
    CActiveScheduler::Install(NULL);
sl@0
    94
    delete scheduler;
sl@0
    95
    delete server;
sl@0
    96
    }
sl@0
    97
sl@0
    98
TInt E32Main()
sl@0
    99
//
sl@0
   100
// Server process entry-point
sl@0
   101
// Recover the startup parameters and run the server
sl@0
   102
//
sl@0
   103
    {
sl@0
   104
    __UHEAP_MARK;
sl@0
   105
    //
sl@0
   106
    CTrapCleanup* cleanup=CTrapCleanup::New();
sl@0
   107
    TInt r=KErrNoMemory;
sl@0
   108
    if (cleanup)
sl@0
   109
        {
sl@0
   110
        TRAP(r,StartDRMPlayServerL());
sl@0
   111
        delete cleanup;
sl@0
   112
        }
sl@0
   113
    //
sl@0
   114
    __UHEAP_MARKEND;
sl@0
   115
    return r;
sl@0
   116
    }
sl@0
   117
sl@0
   118
// End of file