os/mm/devsoundextensions/drmaudioplayer/DRMPlayServer/src/DRMPlaySession.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 Session
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
#include "DRMPlaySession.h"
sl@0
    20
#include <e32test.h>
sl@0
    21
#include <e32std.h>
sl@0
    22
#include <e32svr.h>
sl@0
    23
#include <mmf/common/mmfcontrollerframework.h>
sl@0
    24
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
    25
#include <tspclientmapper.h>
sl@0
    26
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
    27
sl@0
    28
#ifdef _DEBUG
sl@0
    29
#define DEP_PRN0(str)   RDebug::Print(str)
sl@0
    30
#define DEP_PRN1(str, v1)   RDebug::Print(str, v1)
sl@0
    31
#define DEP_PRN2(str, v1, v2)   RDebug::Print(str, v1, v2)
sl@0
    32
#else
sl@0
    33
#define DEP_PRN0(str)
sl@0
    34
#define DEP_PRN1(str, v1)
sl@0
    35
#define DEP_PRN2(str, v1, v2)
sl@0
    36
#endif // _DEBUG
sl@0
    37
sl@0
    38
// This is the UID defined by custom interface builder
sl@0
    39
const TUid KUidCustomInterfaceBuilderImpl = {0x10207A8E};
sl@0
    40
sl@0
    41
// panic the client
sl@0
    42
void CDRMPlayServerSession::PanicClient(const RMessage2 &aMessage, TInt aPanic) const
sl@0
    43
    {
sl@0
    44
    _LIT(KTxtServer,"DRM Play server");
sl@0
    45
    aMessage.Panic(KTxtServer,aPanic);
sl@0
    46
    }
sl@0
    47
sl@0
    48
CDRMPlayServerSession::CDRMPlayServerSession(CDRMPlayServer* aServer)
sl@0
    49
:iMessage2(NULL)
sl@0
    50
    {
sl@0
    51
    iServer=aServer;
sl@0
    52
    }
sl@0
    53
sl@0
    54
CDRMPlayServerSession* CDRMPlayServerSession::NewL(CDRMPlayServer* aServer, const RMessage2& aMessage )
sl@0
    55
    {
sl@0
    56
    DEP_PRN0(_L("CDRMPlayServerSession::NewL"));
sl@0
    57
sl@0
    58
    CDRMPlayServerSession* self = new(ELeave) CDRMPlayServerSession(aServer);
sl@0
    59
    CleanupStack::PushL(self);
sl@0
    60
    self->ConstructL( aMessage );
sl@0
    61
    CleanupStack::Pop(self);
sl@0
    62
    return self;
sl@0
    63
    }
sl@0
    64
sl@0
    65
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
    66
void CDRMPlayServerSession::ConstructL( const RMessage2& aMessage )
sl@0
    67
#else
sl@0
    68
void CDRMPlayServerSession::ConstructL( const RMessage2& /*aMessage*/ )
sl@0
    69
#endif //RD_TSP_CLIENT_MAPPER
sl@0
    70
    {
sl@0
    71
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
    72
    iTSPClientMapper = CTspClientMapper::NewL();
sl@0
    73
    // Get client process ID
sl@0
    74
    RThread clientThread;
sl@0
    75
    RProcess clientProcess;
sl@0
    76
    // Open client thread and process handles
sl@0
    77
    User::LeaveIfError( aMessage.Client(clientThread) );
sl@0
    78
    User::LeaveIfError(  clientThread.Process(clientProcess) );
sl@0
    79
    // Get process id
sl@0
    80
    iClientProcessId = clientProcess.Id();
sl@0
    81
    // Close client thread and client process handles
sl@0
    82
    clientThread.Close();
sl@0
    83
    clientProcess.Close();
sl@0
    84
sl@0
    85
    iTSPClientMapper->SetTspTargetClient(
sl@0
    86
                            CTspClientMapper::ERegisteredClients,
sl@0
    87
                            iClientProcessId );
sl@0
    88
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
    89
sl@0
    90
    // Increment number of sessions in server
sl@0
    91
    iServer->iClients++;
sl@0
    92
sl@0
    93
    DEP_PRN1(_L("CDRMPlayServerSession::iClients = %d"), iServer->iClients);
sl@0
    94
    }
sl@0
    95
sl@0
    96
CDRMPlayServerSession::~CDRMPlayServerSession()
sl@0
    97
    {
sl@0
    98
    if(iMetaDataBuffer)
sl@0
    99
    {
sl@0
   100
     delete iMetaDataBuffer;
sl@0
   101
     iMetaDataBuffer = NULL;
sl@0
   102
    }
sl@0
   103
    // Delete any pending message objects
sl@0
   104
    // This will never happen, only happens when
sl@0
   105
    // Client closes the session in the middle of playback
sl@0
   106
    // but we cannot complete the message as RSession Handle is invalid
sl@0
   107
/*    if (iMessage2)
sl@0
   108
        {
sl@0
   109
        iMessage2->Complete(KErrCancel);
sl@0
   110
        }
sl@0
   111
*/
sl@0
   112
    if(iMessage2)
sl@0
   113
    {	
sl@0
   114
     delete iMessage2;
sl@0
   115
     iMessage2 = NULL;
sl@0
   116
    }
sl@0
   117
sl@0
   118
    // Delete play utility
sl@0
   119
    if (iPlayUtil)
sl@0
   120
     {	
sl@0
   121
     	delete iPlayUtil;
sl@0
   122
     	iPlayUtil = NULL;
sl@0
   123
     }
sl@0
   124
    //delete iAsyncCallback;
sl@0
   125
    //iAsyncCallback = NULL;
sl@0
   126
sl@0
   127
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
   128
    if (iTSPClientMapper)
sl@0
   129
    	{
sl@0
   130
    
sl@0
   131
    TInt status = iTSPClientMapper->RemoveTspTargetClient(
sl@0
   132
                                        CTspClientMapper::ERegisteredClients,
sl@0
   133
                                        iClientProcessId );
sl@0
   134
    DEP_PRN2(_L("CDRMPlayServerSession::~CDRMPlayServerSession:Unreg PID[%x]Status[%d]"), iClientProcessId.Id(), status );
sl@0
   135
    delete iTSPClientMapper;
sl@0
   136
    	}
sl@0
   137
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
   138
sl@0
   139
    // Cancel any pending async messages.
sl@0
   140
    TInt index(0);
sl@0
   141
    CDRMCustomCommandAsyncAO* tempAO(NULL);
sl@0
   142
    for (;index < iActiveAsyncCustomCommands.Count(); index++)
sl@0
   143
        {
sl@0
   144
        tempAO = iActiveAsyncCustomCommands[0];
sl@0
   145
        if ( iCDRMCustomCommandAsyncAO2Phase == tempAO )
sl@0
   146
            {
sl@0
   147
            iCDRMCustomCommandAsyncAO2Phase = NULL;
sl@0
   148
            }
sl@0
   149
        delete tempAO;
sl@0
   150
        iActiveAsyncCustomCommands.Remove(0);
sl@0
   151
        }
sl@0
   152
    iActiveAsyncCustomCommands.Reset();
sl@0
   153
    iActiveAsyncCustomCommands.Close();
sl@0
   154
sl@0
   155
    delete iCDRMCustomCommandAsyncAO2Phase;
sl@0
   156
sl@0
   157
    iServer->iClients--;
sl@0
   158
sl@0
   159
    if(!iServer->iClients)
sl@0
   160
        {
sl@0
   161
        CActiveScheduler::Stop();
sl@0
   162
        }
sl@0
   163
    }
sl@0
   164
sl@0
   165
void CDRMPlayServerSession::ServiceL(const RMessage2& aMessage)
sl@0
   166
    {
sl@0
   167
    TInt ret = KErrNone;
sl@0
   168
    TRAPD(err,ret = DispatchMessageL(aMessage));
sl@0
   169
    if (KErrNone != err)
sl@0
   170
        {
sl@0
   171
        ret = err;
sl@0
   172
        }
sl@0
   173
    if(iAsyncComplete == EFalse)
sl@0
   174
        {
sl@0
   175
        DEP_PRN1(_L("CDRMPlayServerSession::ServiceL - ret = %d"),ret);
sl@0
   176
        aMessage.Complete(ret);
sl@0
   177
        }
sl@0
   178
    }
sl@0
   179
sl@0
   180
sl@0
   181
sl@0
   182
// service a client request; test the opcode and then do appropriate servicing
sl@0
   183
TInt CDRMPlayServerSession::DispatchMessageL(const RMessage2 &aMessage)
sl@0
   184
    {
sl@0
   185
    TInt ret=KErrNone;
sl@0
   186
    iAsyncComplete= EFalse;
sl@0
   187
    DEP_PRN1(_L("CDRMPlayServerSession::DispatchMessageL:FnId[%d]"),aMessage.Function());
sl@0
   188
    switch (aMessage.Function())
sl@0
   189
        {
sl@0
   190
        case EDRMPlayServCreate:
sl@0
   191
             break;
sl@0
   192
        case EDRMPlayServNewFilePlayerL:
sl@0
   193
            iMessage = aMessage;
sl@0
   194
            NewFilePlayerL(aMessage);
sl@0
   195
            iAsyncComplete = ETrue;
sl@0
   196
            break;
sl@0
   197
        case EDRMPlayServNewDesPlayerL:
sl@0
   198
            iMessage = aMessage;
sl@0
   199
            NewDesPlayerL(aMessage);
sl@0
   200
            iAsyncComplete = ETrue;
sl@0
   201
            break;
sl@0
   202
        case EDRMPlayServNewDesPlayerReadOnlyL:
sl@0
   203
            iMessage = aMessage;
sl@0
   204
            NewDesPlayerReadOnlyL(aMessage);
sl@0
   205
            iAsyncComplete = ETrue;
sl@0
   206
            break;
sl@0
   207
        case EDRMPlayServNewPlayerL:
sl@0
   208
            NewPlayerL(aMessage);
sl@0
   209
            break;
sl@0
   210
        case EDRMPlayServOpenFile:
sl@0
   211
            iMessage = aMessage;
sl@0
   212
            OpenFileL(aMessage);
sl@0
   213
            iAsyncComplete = ETrue;
sl@0
   214
            break;
sl@0
   215
        case EDRMPlayServOpenFileByHandle:
sl@0
   216
            iMessage = aMessage;
sl@0
   217
            OpenFileByHandleL(aMessage);
sl@0
   218
            iAsyncComplete = ETrue;
sl@0
   219
            break;
sl@0
   220
        case EDRMPlayServOpenFileBySource:
sl@0
   221
            iMessage = aMessage;
sl@0
   222
            OpenFileBySourceL(aMessage);
sl@0
   223
            iAsyncComplete = ETrue;
sl@0
   224
            break;
sl@0
   225
        case EDRMPlayServOpenDes:
sl@0
   226
            iMessage = aMessage;
sl@0
   227
            OpenDesL(aMessage);
sl@0
   228
            iAsyncComplete = ETrue;
sl@0
   229
            break;
sl@0
   230
        case EDRMPlayServOpenUrl:
sl@0
   231
            iMessage = aMessage;
sl@0
   232
            OpenUrlL(aMessage);
sl@0
   233
            iAsyncComplete = ETrue;
sl@0
   234
            break;
sl@0
   235
        case EDRMPlayServPlay:
sl@0
   236
            iMessage = aMessage;
sl@0
   237
            if(iMessage2)
sl@0
   238
                {
sl@0
   239
                iMessage2->Complete(KErrCancel);
sl@0
   240
                delete iMessage2;
sl@0
   241
                iMessage2 = NULL;
sl@0
   242
                }
sl@0
   243
            iMessage2 = new (ELeave) RMessage2(aMessage);
sl@0
   244
            Play();
sl@0
   245
            iAsyncComplete = ETrue;
sl@0
   246
            break;
sl@0
   247
        case EDRMPlayServStop:
sl@0
   248
            if(iState == EStopped)
sl@0
   249
                break;
sl@0
   250
            if(iMessage2)
sl@0
   251
                {
sl@0
   252
                iMessage2->Complete(KErrCancel);
sl@0
   253
                delete iMessage2;
sl@0
   254
                iMessage2 = NULL;
sl@0
   255
                }
sl@0
   256
            Stop();
sl@0
   257
            break;
sl@0
   258
        case EDRMPlayServSetVolume:
sl@0
   259
            SetVolume(aMessage);
sl@0
   260
            break;
sl@0
   261
        case EDRMPlayServSetRepeats:
sl@0
   262
            SetRepeats(aMessage);
sl@0
   263
            break;
sl@0
   264
        case EDRMPlayServSetVolumeRamp:
sl@0
   265
            SetVolumeRamp(aMessage);
sl@0
   266
            break;
sl@0
   267
        case EDRMPlayServDuration:
sl@0
   268
            Duration(aMessage);
sl@0
   269
            break;
sl@0
   270
        case EDRMPlayServMaxVolume:
sl@0
   271
            ret = MaxVolume();
sl@0
   272
            break;
sl@0
   273
        case EDRMPlayServPause:
sl@0
   274
            ret = Pause();
sl@0
   275
            if(iMessage2)
sl@0
   276
                {
sl@0
   277
                iMessage2->Complete(KErrCancel);
sl@0
   278
                delete iMessage2;
sl@0
   279
                iMessage2 = NULL;
sl@0
   280
                }
sl@0
   281
            iAsyncComplete = EFalse;
sl@0
   282
            break;
sl@0
   283
        case EDRMPlayServClose:
sl@0
   284
            Close();
sl@0
   285
            break;
sl@0
   286
        case EDRMPlayServGetPosition:
sl@0
   287
            ret = GetPosition(aMessage);
sl@0
   288
            break;
sl@0
   289
        case EDRMPlayServSetPosition:
sl@0
   290
            SetPosition(aMessage);
sl@0
   291
            break;
sl@0
   292
        case EDRMPlayServSetPriority:
sl@0
   293
            ret = SetPriority(aMessage);
sl@0
   294
            break;
sl@0
   295
        case EDRMPlayServGetVolume:
sl@0
   296
            ret = GetVolume(aMessage);
sl@0
   297
            break;
sl@0
   298
        case EDRMPlayServGetNumberOfMetaDataEntries:
sl@0
   299
            ret = GetNumberOfMetaDataEntries(aMessage);
sl@0
   300
            break;
sl@0
   301
        case EDRMPlayServGetMetaDataEntry:
sl@0
   302
            GetMetaDataEntryL(aMessage);
sl@0
   303
            break;
sl@0
   304
        case EDRMPlayServClearPlayWindow:
sl@0
   305
            ret = ClearPlayWindow();
sl@0
   306
            break;
sl@0
   307
        case EDRMPlayServSetBalance:
sl@0
   308
            ret = SetBalance(aMessage);
sl@0
   309
            break;
sl@0
   310
        case EDRMPlayServGetBalance:
sl@0
   311
            ret = GetBalance(aMessage);
sl@0
   312
            break;
sl@0
   313
        case EDRMPlayServGetBitRate:
sl@0
   314
            ret = GetBitRate(aMessage);
sl@0
   315
            break;
sl@0
   316
        case EDRMPlayServRegisterForAudioLoadingNotification:
sl@0
   317
            iMessage = aMessage;
sl@0
   318
            RegisterForAudioLoadingNotification(aMessage);
sl@0
   319
            iAsyncComplete = ETrue;
sl@0
   320
            break;
sl@0
   321
        case EDRMPlayServGetAudioLoadingProgress:
sl@0
   322
            GetAudioLoadingProgressL(aMessage);
sl@0
   323
            break;
sl@0
   324
        case EDRMPlayServSetPlayWindow:
sl@0
   325
            SetPlayWindow(aMessage);
sl@0
   326
            break;
sl@0
   327
        case EDRMPlayServControllerImplementationInformation:
sl@0
   328
            ControllerImplementationInformationL(aMessage);
sl@0
   329
            break;
sl@0
   330
        case EDRMPlayServCustomCommandSyncWithReturn:
sl@0
   331
        case EDRMPlayServCustomCommandSyncWithoutReturn:
sl@0
   332
                CustomCommandSyncL(aMessage);
sl@0
   333
                break;
sl@0
   334
        case EDRMPlayServCustomCommandAsyncWithReturnStep1:
sl@0
   335
        case EDRMPlayServCustomCommandAsyncWithoutReturnStep1:
sl@0
   336
            CustomCommandAsyncStep1L(aMessage);
sl@0
   337
            // Setting this flag does not complete message in ServiceL,
sl@0
   338
            iAsyncComplete = ETrue;
sl@0
   339
            break;
sl@0
   340
        case EDRMPlayServCustomCommandAsyncWithReturnStep2:
sl@0
   341
        case EDRMPlayServCustomCommandAsyncWithoutReturnStep2:
sl@0
   342
            CustomCommandAsyncStep2L(aMessage);
sl@0
   343
            // Setting this flag does not complete message in ServiceL,
sl@0
   344
            iAsyncComplete = ETrue;
sl@0
   345
            break;
sl@0
   346
        case EDRMPlayServSetPriorityPreference:
sl@0
   347
            SetPriorityPreference(aMessage);
sl@0
   348
            break;
sl@0
   349
sl@0
   350
       default:
sl@0
   351
         PanicClient(aMessage, EBadRequest);
sl@0
   352
         break;
sl@0
   353
        }
sl@0
   354
    return ret;
sl@0
   355
    }
sl@0
   356
sl@0
   357
void CDRMPlayServerSession::NewFilePlayerL(const RMessage2 aMessage)
sl@0
   358
    {
sl@0
   359
    TDataStructPckgBuf params;
sl@0
   360
sl@0
   361
    aMessage.Read(0,iCallbackState);
sl@0
   362
    aMessage.Read(1,params);
sl@0
   363
    aMessage.Read(2,iErrDurPckg);
sl@0
   364
    HBufC16* inputBuf = HBufC16::NewL(aMessage.GetDesLengthL(3));
sl@0
   365
    TPtr16 ptr = inputBuf->Des();
sl@0
   366
    aMessage.Read(3,ptr);
sl@0
   367
    const TDataStruct &theStruct = params();
sl@0
   368
    delete iPlayUtil;
sl@0
   369
    iPlayUtil = NULL;
sl@0
   370
    iPlayUtil = CMdaAudioPlayerUtility::NewFilePlayerL( inputBuf->Des(),
sl@0
   371
                                                       *this,
sl@0
   372
                                                       iPriority,
sl@0
   373
                                                       iPref);
sl@0
   374
    delete inputBuf;
sl@0
   375
    }
sl@0
   376
sl@0
   377
void CDRMPlayServerSession::NewDesPlayerL(const RMessage2 aMessage)
sl@0
   378
    {
sl@0
   379
    TDataStructPckgBuf thePckg;
sl@0
   380
    aMessage.Read(0,iCallbackState);
sl@0
   381
    aMessage.Read(1,thePckg);
sl@0
   382
    aMessage.Read(2,iErrDurPckg);
sl@0
   383
sl@0
   384
    delete iPlayUtil;
sl@0
   385
    iPlayUtil = NULL;
sl@0
   386
    iPlayUtil = CMdaAudioPlayerUtility::NewDesPlayerL(thePckg().iData,
sl@0
   387
                                                      *this,
sl@0
   388
                                                      iPriority,
sl@0
   389
                                                      iPref);
sl@0
   390
sl@0
   391
    }
sl@0
   392
sl@0
   393
void CDRMPlayServerSession::NewDesPlayerReadOnlyL(const RMessage2 aMessage)
sl@0
   394
    {
sl@0
   395
    TDataStructPckgBuf thePckg;
sl@0
   396
    aMessage.Read(0,iCallbackState);
sl@0
   397
    aMessage.Read(1,thePckg);
sl@0
   398
    aMessage.Read(2,iErrDurPckg);
sl@0
   399
sl@0
   400
    delete iPlayUtil;
sl@0
   401
    iPlayUtil = NULL;
sl@0
   402
    iPlayUtil = CMdaAudioPlayerUtility::NewDesPlayerReadOnlyL(thePckg().iData,
sl@0
   403
                                                              *this,
sl@0
   404
                                                              iPriority,
sl@0
   405
                                                              iPref);
sl@0
   406
    }
sl@0
   407
sl@0
   408
void CDRMPlayServerSession::NewPlayerL(const RMessage2 aMessage)
sl@0
   409
    {
sl@0
   410
sl@0
   411
    TDataStructPckgBuf thePckg;
sl@0
   412
    aMessage.Read(0,iCallbackState);
sl@0
   413
    aMessage.Read(1,thePckg);
sl@0
   414
    aMessage.Read(2,iErrDurPckg);
sl@0
   415
sl@0
   416
    delete iPlayUtil;
sl@0
   417
    iPlayUtil = NULL;
sl@0
   418
    iPlayUtil = CMdaAudioPlayerUtility::NewL(*this,
sl@0
   419
                                             iPriority,
sl@0
   420
                                             iPref);
sl@0
   421
    }
sl@0
   422
sl@0
   423
void CDRMPlayServerSession::OpenFileL(const RMessage2 &aMessage)
sl@0
   424
    {
sl@0
   425
    //call mmfclientaudioplayer open file
sl@0
   426
    iFileHandleUsed = EFalse;
sl@0
   427
sl@0
   428
    aMessage.Read(0,iCallbackState);
sl@0
   429
    // Get the file length
sl@0
   430
    TInt len = aMessage.GetDesLengthL(1);
sl@0
   431
    HBufC* fileName = HBufC::NewLC(len);
sl@0
   432
    TPtr fileNamePtr = fileName->Des();
sl@0
   433
    aMessage.Read(1,fileNamePtr);
sl@0
   434
    aMessage.Read(2,iErrDurPckg);
sl@0
   435
    if(iPlayUtil)
sl@0
   436
        {
sl@0
   437
        iPlayUtil->OpenFileL(fileNamePtr);
sl@0
   438
        }
sl@0
   439
    CleanupStack::PopAndDestroy(fileName);
sl@0
   440
    }
sl@0
   441
sl@0
   442
void CDRMPlayServerSession::OpenFileByHandleL(const RMessage2 &aMessage)
sl@0
   443
    {
sl@0
   444
    iFileHandleUsed = ETrue;
sl@0
   445
    TInt err = iFileHandle.AdoptFromClient(aMessage,1,3);
sl@0
   446
sl@0
   447
    aMessage.Read(0,iCallbackState);
sl@0
   448
    aMessage.Read(2,iErrDurPckg);
sl@0
   449
sl@0
   450
    if (err == KErrNone)
sl@0
   451
        {
sl@0
   452
        if(iPlayUtil)
sl@0
   453
            {
sl@0
   454
            iPlayUtil->OpenFileL(iFileHandle);
sl@0
   455
            }
sl@0
   456
        }
sl@0
   457
    else
sl@0
   458
        {
sl@0
   459
        User::Leave(err);
sl@0
   460
        }
sl@0
   461
    }
sl@0
   462
sl@0
   463
void CDRMPlayServerSession::OpenFileBySourceL(const RMessage2 &/*aMessage*/)
sl@0
   464
    {
sl@0
   465
sl@0
   466
    }
sl@0
   467
sl@0
   468
void CDRMPlayServerSession::OpenDesL(const RMessage2 &aMessage)
sl@0
   469
    {
sl@0
   470
    //call mmfclientaudioplayer OpenDesL
sl@0
   471
    TBuf8<50> aDes;
sl@0
   472
sl@0
   473
    aMessage.Read(0,iCallbackState);
sl@0
   474
    aMessage.Read(1,aDes);
sl@0
   475
    aMessage.Read(2,iErrDurPckg);
sl@0
   476
sl@0
   477
    if(iPlayUtil)
sl@0
   478
        {
sl@0
   479
        iPlayUtil->OpenDesL(aDes);
sl@0
   480
        }
sl@0
   481
    }
sl@0
   482
sl@0
   483
void CDRMPlayServerSession::OpenUrlL(const RMessage2 &aMessage)
sl@0
   484
    {
sl@0
   485
    //call mmfclientaudioplayer OpenUrlL
sl@0
   486
    TUrlStructPckgBuf thePckg;
sl@0
   487
sl@0
   488
    aMessage.Read(0,iCallbackState);
sl@0
   489
    aMessage.Read(1,thePckg);
sl@0
   490
    aMessage.Read(2,iErrDurPckg);
sl@0
   491
sl@0
   492
    if(iPlayUtil)
sl@0
   493
        {
sl@0
   494
        iPlayUtil->OpenUrlL(thePckg().iUrl,
sl@0
   495
                            thePckg().iIapId,
sl@0
   496
                            thePckg().iMimeType);
sl@0
   497
        }
sl@0
   498
    }
sl@0
   499
sl@0
   500
void CDRMPlayServerSession::Play()
sl@0
   501
    {
sl@0
   502
    //call mmfclientaudioplayer Play
sl@0
   503
    iState = EPlaying;
sl@0
   504
    if(iPlayUtil)
sl@0
   505
        {
sl@0
   506
        iPlayUtil->Play();
sl@0
   507
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
   508
        TInt status = iTSPClientMapper->SetTspTargetClientToOtherType(
sl@0
   509
                                            CTspClientMapper::EPlayingClients,
sl@0
   510
                                            iClientProcessId );
sl@0
   511
        DEP_PRN2(_L("CDRMPlayServerSession::Play:Change PID[%x]Status[%d]"), iClientProcessId.Id(), status );
sl@0
   512
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
   513
        }
sl@0
   514
    }
sl@0
   515
sl@0
   516
void CDRMPlayServerSession::Stop()
sl@0
   517
    {
sl@0
   518
    //call mmfclientaudioplayer Stop
sl@0
   519
    if(iPlayUtil)
sl@0
   520
        {
sl@0
   521
        iPlayUtil->Stop();
sl@0
   522
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
   523
        TInt status = iTSPClientMapper->SetTspTargetClientToOtherType(
sl@0
   524
                                            CTspClientMapper::EStoppedClients,
sl@0
   525
                                            iClientProcessId );
sl@0
   526
        DEP_PRN2(_L("CDRMPlayServerSession::Stop:Change PID[%x]Status[%d]"), iClientProcessId.Id(), status );
sl@0
   527
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
   528
        }
sl@0
   529
    iState = EStopped;
sl@0
   530
    }
sl@0
   531
sl@0
   532
void CDRMPlayServerSession::SetVolume(const RMessage2 & aMessage)
sl@0
   533
    {
sl@0
   534
    //call mmfclientaudioplayer SetVolume
sl@0
   535
    TInt theVolume = aMessage.Int0();
sl@0
   536
sl@0
   537
    if(iPlayUtil)
sl@0
   538
        {
sl@0
   539
        iPlayUtil->SetVolume(theVolume);
sl@0
   540
        }
sl@0
   541
    }
sl@0
   542
sl@0
   543
void CDRMPlayServerSession::SetRepeats(const RMessage2 &aMessage)
sl@0
   544
    {
sl@0
   545
    //call mmfclientaudioplayer SetRepeats
sl@0
   546
    TInt theRepeatNumberOfTimes = aMessage.Int0();
sl@0
   547
    TTimeIntervalMicroSeconds theTrailingSilence;
sl@0
   548
sl@0
   549
    TPckgTTimeIntervalMicroSeconds theTrailingSilencePckg(theTrailingSilence);
sl@0
   550
    aMessage.Read(1,theTrailingSilencePckg);
sl@0
   551
sl@0
   552
    iPlayUtil->SetRepeats(theRepeatNumberOfTimes,theTrailingSilence);
sl@0
   553
    }
sl@0
   554
sl@0
   555
void CDRMPlayServerSession::SetVolumeRamp(const RMessage2 &aMessage)
sl@0
   556
    {
sl@0
   557
    //call mmfclientaudioplayer SetVolumeRamp
sl@0
   558
    TTimeIntervalMicroSeconds theRampDuration;
sl@0
   559
    TPckgTTimeIntervalMicroSeconds theRampDurationPckg(theRampDuration);
sl@0
   560
    aMessage.Read(0,theRampDurationPckg);
sl@0
   561
sl@0
   562
    iPlayUtil->SetVolumeRamp(theRampDuration);
sl@0
   563
    }
sl@0
   564
sl@0
   565
void CDRMPlayServerSession::Duration(const RMessage2& aMessage)
sl@0
   566
    {
sl@0
   567
    TTimeIntervalMicroSeconds theDuration;
sl@0
   568
    theDuration = iPlayUtil->Duration();
sl@0
   569
sl@0
   570
    TPckgBufTTimeIntervalMicroSeconds theDurationPckg(theDuration);
sl@0
   571
    aMessage.Write(0,theDurationPckg);
sl@0
   572
    }
sl@0
   573
sl@0
   574
TInt CDRMPlayServerSession::MaxVolume()
sl@0
   575
    {
sl@0
   576
    TInt theMaxVolume;
sl@0
   577
    theMaxVolume = iPlayUtil->MaxVolume();
sl@0
   578
sl@0
   579
    return theMaxVolume;
sl@0
   580
    }
sl@0
   581
sl@0
   582
// API Additions since version 7.0
sl@0
   583
TInt CDRMPlayServerSession::Pause()
sl@0
   584
    {
sl@0
   585
    TInt ret = KErrNone;
sl@0
   586
    if(iPlayUtil)
sl@0
   587
        {
sl@0
   588
        ret = iPlayUtil->Pause();
sl@0
   589
        }
sl@0
   590
    
sl@0
   591
    // This message should not be completed here. It should be completed in ServiceL()
sl@0
   592
/*    if(iState == EPlaying)
sl@0
   593
        {
sl@0
   594
        iMessage.Complete(KErrNone);
sl@0
   595
        }*/
sl@0
   596
    iState = EStopped;
sl@0
   597
    return ret;
sl@0
   598
    }
sl@0
   599
sl@0
   600
void CDRMPlayServerSession::Close()
sl@0
   601
    {
sl@0
   602
sl@0
   603
    if(iFileHandleUsed)
sl@0
   604
     iFileHandle.Close();
sl@0
   605
sl@0
   606
    iPlayUtil->Close();
sl@0
   607
    }
sl@0
   608
sl@0
   609
TInt CDRMPlayServerSession::GetPosition(const RMessage2 &aMessage)
sl@0
   610
    {
sl@0
   611
    TInt ret;
sl@0
   612
    TTimeIntervalMicroSeconds thePosition;
sl@0
   613
sl@0
   614
    ret = iPlayUtil->GetPosition(thePosition);
sl@0
   615
sl@0
   616
sl@0
   617
    TPckgTTimeIntervalMicroSeconds thePositionPckg(thePosition);
sl@0
   618
    aMessage.Write(0,thePositionPckg);
sl@0
   619
sl@0
   620
    return ret;
sl@0
   621
    }
sl@0
   622
sl@0
   623
void CDRMPlayServerSession::SetPosition(const RMessage2 &aMessage)
sl@0
   624
    {
sl@0
   625
    TTimeIntervalMicroSeconds thePosition;
sl@0
   626
    TPckgTTimeIntervalMicroSeconds thePositionPckg(thePosition);
sl@0
   627
    aMessage.Read(0,thePositionPckg);
sl@0
   628
    iPlayUtil->SetPosition(thePosition);
sl@0
   629
    }
sl@0
   630
sl@0
   631
TInt CDRMPlayServerSession::SetPriority(const RMessage2 &aMessage)
sl@0
   632
    {
sl@0
   633
    TInt thePriority = aMessage.Int0();
sl@0
   634
    TMdaPriorityPreference thePref = (TMdaPriorityPreference)aMessage.Int1();
sl@0
   635
sl@0
   636
    TInt ret = iPlayUtil->SetPriority(thePriority,thePref);
sl@0
   637
sl@0
   638
    return ret;
sl@0
   639
    }
sl@0
   640
sl@0
   641
TInt CDRMPlayServerSession::GetVolume(const RMessage2 &aMessage)
sl@0
   642
    {
sl@0
   643
    TInt theVolume;
sl@0
   644
    TInt ret = iPlayUtil->GetVolume(theVolume);
sl@0
   645
    TPckgBufTInt pckg(theVolume);
sl@0
   646
    aMessage.Write(0,pckg);
sl@0
   647
    return ret;
sl@0
   648
    }
sl@0
   649
sl@0
   650
TInt CDRMPlayServerSession::GetNumberOfMetaDataEntries(const RMessage2 &aMessage)
sl@0
   651
    {
sl@0
   652
    TInt ret;
sl@0
   653
    TInt theNumOfMetaDataEntries;
sl@0
   654
sl@0
   655
    ret = iPlayUtil->GetNumberOfMetaDataEntries(theNumOfMetaDataEntries);
sl@0
   656
sl@0
   657
    TPckgBufTInt pckg(theNumOfMetaDataEntries);
sl@0
   658
    aMessage.Write(0,pckg);
sl@0
   659
sl@0
   660
    return ret;
sl@0
   661
    }
sl@0
   662
sl@0
   663
sl@0
   664
void CDRMPlayServerSession::GetMetaDataEntryL(const RMessage2 &aMessage)
sl@0
   665
    {
sl@0
   666
    //Get the index of the required entry
sl@0
   667
    TInt theIndex = aMessage.Int0();
sl@0
   668
    CMMFMetaDataEntry* entry = iPlayUtil->GetMetaDataEntryL(theIndex);
sl@0
   669
    CleanupStack::PushL(entry);
sl@0
   670
    // Delete any existing buffer
sl@0
   671
    if (iMetaDataBuffer)
sl@0
   672
    	{
sl@0
   673
    	delete iMetaDataBuffer;
sl@0
   674
    	iMetaDataBuffer = NULL;
sl@0
   675
    	}
sl@0
   676
    
sl@0
   677
    // Create a buffer to hold the externalised entry
sl@0
   678
    iMetaDataBuffer = CBufFlat::NewL(32);
sl@0
   679
    RBufWriteStream s;
sl@0
   680
    s.Open(*iMetaDataBuffer);
sl@0
   681
    CleanupClosePushL(s);
sl@0
   682
    entry->ExternalizeL(s);
sl@0
   683
    CleanupStack::PopAndDestroy(2);//s, entry
sl@0
   684
sl@0
   685
    //Write the externalised data back to the client
sl@0
   686
    aMessage.Write(1,iMetaDataBuffer->Ptr(0));
sl@0
   687
    }
sl@0
   688
sl@0
   689
sl@0
   690
TInt CDRMPlayServerSession::SetPlayWindow(const RMessage2 &aMessage)
sl@0
   691
    {
sl@0
   692
    TPlayWindowStructBuf buf;
sl@0
   693
    aMessage.Read(0,buf);
sl@0
   694
sl@0
   695
    TTimeIntervalMicroSeconds playStart = buf().iPlayStart;
sl@0
   696
    TTimeIntervalMicroSeconds playEnd = buf().iPlayEnd;
sl@0
   697
sl@0
   698
    TInt ret = iPlayUtil->SetPlayWindow(playStart,playEnd);
sl@0
   699
sl@0
   700
    return ret;
sl@0
   701
    }
sl@0
   702
sl@0
   703
TInt CDRMPlayServerSession::ClearPlayWindow()
sl@0
   704
    {
sl@0
   705
    return iPlayUtil->ClearPlayWindow();
sl@0
   706
    }
sl@0
   707
sl@0
   708
TInt CDRMPlayServerSession::SetBalance(const RMessage2 &aMessage)
sl@0
   709
    {
sl@0
   710
    TInt theBalance = aMessage.Int0();
sl@0
   711
    return iPlayUtil->SetBalance(theBalance);
sl@0
   712
    }
sl@0
   713
sl@0
   714
TInt CDRMPlayServerSession::GetBalance(const RMessage2 &aMessage)
sl@0
   715
    {
sl@0
   716
    TInt theBalance;
sl@0
   717
    TInt ret;
sl@0
   718
sl@0
   719
    ret = iPlayUtil->GetBalance(theBalance);
sl@0
   720
sl@0
   721
    TPckgBufTInt pckg(theBalance);
sl@0
   722
    aMessage.Write(0,pckg);
sl@0
   723
sl@0
   724
    return ret;
sl@0
   725
    }
sl@0
   726
sl@0
   727
TInt CDRMPlayServerSession::GetBitRate(const RMessage2 &aMessage)
sl@0
   728
    {
sl@0
   729
    TUint theBitRate;
sl@0
   730
    TInt ret;
sl@0
   731
sl@0
   732
    ret = iPlayUtil->GetBitRate(theBitRate);
sl@0
   733
sl@0
   734
    TPckgBufTUint pckg(theBitRate);
sl@0
   735
    aMessage.Write(0,pckg);
sl@0
   736
sl@0
   737
    return ret;
sl@0
   738
    }
sl@0
   739
sl@0
   740
void CDRMPlayServerSession::RegisterForAudioLoadingNotification(const RMessage2 &aMessage)
sl@0
   741
    {
sl@0
   742
    aMessage.Read(0,iCallbackState);
sl@0
   743
sl@0
   744
    if(iCallbackState()==ELoadingStarted)
sl@0
   745
        {
sl@0
   746
        iPlayUtil->RegisterForAudioLoadingNotification(*this);
sl@0
   747
        }
sl@0
   748
    }
sl@0
   749
sl@0
   750
void CDRMPlayServerSession::GetAudioLoadingProgressL(const RMessage2 &aMessage)
sl@0
   751
    {
sl@0
   752
    TInt thePercentProgress;
sl@0
   753
sl@0
   754
    iPlayUtil->GetAudioLoadingProgressL(thePercentProgress);
sl@0
   755
sl@0
   756
    TPckgBufTInt pckg(thePercentProgress);
sl@0
   757
sl@0
   758
    aMessage.Write(0,pckg);
sl@0
   759
    }
sl@0
   760
sl@0
   761
void CDRMPlayServerSession::ControllerImplementationInformationL(const RMessage2 &aMessage)
sl@0
   762
    {
sl@0
   763
    const CMMFControllerImplementationInformation& x= iPlayUtil->ControllerImplementationInformationL();
sl@0
   764
sl@0
   765
    //for now just write Uid by to client
sl@0
   766
    typedef TPckg<TUid> TPckgTUid;
sl@0
   767
sl@0
   768
    TPckgTUid thePckg(x.Uid());
sl@0
   769
    aMessage.Write(0,thePckg);
sl@0
   770
    }
sl@0
   771
sl@0
   772
sl@0
   773
void CDRMPlayServerSession::CustomCommandSyncL(const RMessage2 &aMessage)
sl@0
   774
    {
sl@0
   775
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandSyncL:Enter"));
sl@0
   776
sl@0
   777
    TPckgCustomCommand thePckgCustomCommand;
sl@0
   778
    User::LeaveIfError(aMessage.Read(0,thePckgCustomCommand));
sl@0
   779
sl@0
   780
    HBufC8* dataTo1Buf(NULL);
sl@0
   781
    HBufC8* dataTo2Buf(NULL);
sl@0
   782
    HBufC8* dataFromBuf(NULL);
sl@0
   783
    TPtr8 ptr1(NULL, NULL);
sl@0
   784
    TPtr8 ptr2(NULL, NULL);
sl@0
   785
    TPtr8 ptr3(NULL, NULL);
sl@0
   786
sl@0
   787
    // Read data1
sl@0
   788
    dataTo1Buf = HBufC8::NewL(aMessage.GetDesLengthL(1));
sl@0
   789
    CleanupStack::PushL(dataTo1Buf);
sl@0
   790
    ptr1.Set(dataTo1Buf->Des());
sl@0
   791
    User::LeaveIfError(aMessage.Read(1,ptr1));
sl@0
   792
sl@0
   793
   // Check and filter the messages
sl@0
   794
   // Dont Allow Select Custom Commands
sl@0
   795
   if( !IsValidCustomCommandDestination(thePckgCustomCommand().iDestination().InterfaceId(), ptr1) )
sl@0
   796
            User::Leave(KErrAccessDenied);
sl@0
   797
sl@0
   798
    // Read data2
sl@0
   799
    dataTo2Buf = HBufC8::NewL(aMessage.GetDesLengthL(2));
sl@0
   800
    CleanupStack::PushL(dataTo2Buf);
sl@0
   801
    ptr2.Set(dataTo2Buf->Des());
sl@0
   802
    User::LeaveIfError(aMessage.Read(2,ptr2));
sl@0
   803
sl@0
   804
    if ( aMessage.Function() == EDRMPlayServCustomCommandSyncWithReturn )
sl@0
   805
        {
sl@0
   806
        // Read data3
sl@0
   807
        dataFromBuf = HBufC8::NewL(aMessage.GetDesLengthL(3));
sl@0
   808
        CleanupStack::PushL(dataFromBuf);
sl@0
   809
        ptr3.Set(dataFromBuf->Des());
sl@0
   810
        User::LeaveIfError(aMessage.Read(3,ptr3));
sl@0
   811
/*
sl@0
   812
        RDebug::Print(_L("CDRMPlayServerSession::CustomCommandSync:IFId[%x]DestHndl[%x]Fn[%d]RetDesLen[%d]"),
sl@0
   813
                                    thePckgCustomCommand().iDestination().InterfaceId(),
sl@0
   814
                                    thePckgCustomCommand().iDestination().DestinationHandle(),
sl@0
   815
                                    thePckgCustomCommand().iFunction,
sl@0
   816
                                    ptr3.MaxLength());
sl@0
   817
*/
sl@0
   818
        // Call CustomCommandSync on play util
sl@0
   819
        User::LeaveIfError(iPlayUtil->CustomCommandSync(
sl@0
   820
                                            thePckgCustomCommand().iDestination,
sl@0
   821
                                            thePckgCustomCommand().iFunction,
sl@0
   822
                                            ptr1,
sl@0
   823
                                            ptr2,
sl@0
   824
                                            ptr3));
sl@0
   825
        User::LeaveIfError(aMessage.Write(3,ptr3));
sl@0
   826
sl@0
   827
        // Free heap allocated for data3
sl@0
   828
        CleanupStack::PopAndDestroy(dataFromBuf);
sl@0
   829
        }
sl@0
   830
    else
sl@0
   831
        {
sl@0
   832
/*
sl@0
   833
        RDebug::Print(_L("CDRMPlayServerSession::CustomCommandSync:IFId[%x]DestHndl[%x]Fn[%d]"),
sl@0
   834
                                    thePckgCustomCommand().iDestination().InterfaceId(),
sl@0
   835
                                    thePckgCustomCommand().iDestination().DestinationHandle(),
sl@0
   836
                                    thePckgCustomCommand().iFunction );
sl@0
   837
*/
sl@0
   838
        // Call CustomCommandSync on play util
sl@0
   839
        User::LeaveIfError(iPlayUtil->CustomCommandSync(
sl@0
   840
                                            thePckgCustomCommand().iDestination,
sl@0
   841
                                            thePckgCustomCommand().iFunction,
sl@0
   842
                                            ptr1,
sl@0
   843
                                            ptr2));
sl@0
   844
        }
sl@0
   845
sl@0
   846
    // Free heap allocated for data2
sl@0
   847
    CleanupStack::PopAndDestroy(dataTo2Buf);
sl@0
   848
    // Free heap allocated for data1
sl@0
   849
    CleanupStack::PopAndDestroy(dataTo1Buf);
sl@0
   850
sl@0
   851
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandSyncL:Exit"));
sl@0
   852
    }
sl@0
   853
sl@0
   854
void CDRMPlayServerSession::CustomCommandAsyncStep1L( const RMessage2& aMessage )
sl@0
   855
    {
sl@0
   856
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandAsyncStep1L:Enter"));
sl@0
   857
sl@0
   858
    // If there is a pending phase1, then there is something wrong.
sl@0
   859
    if ( iCDRMCustomCommandAsyncAO2Phase )
sl@0
   860
        {
sl@0
   861
        User::Leave(KErrAlreadyExists);
sl@0
   862
        }
sl@0
   863
sl@0
   864
    if ( aMessage.Function() == EDRMPlayServCustomCommandAsyncWithReturnStep1 )
sl@0
   865
        {
sl@0
   866
        iCDRMCustomCommandAsyncAO2Phase = CDRMCustomCommandAsyncAO::NewL(
sl@0
   867
                                                    aMessage,
sl@0
   868
                                                    CDRMCustomCommandAsyncAO::ECustomCommandWithResult,
sl@0
   869
                                                    *this );
sl@0
   870
        }
sl@0
   871
    else /*if ( aMessage.Function() == EDRMPlayServCustomCommandAsyncWithoutReturnStep1 )*/
sl@0
   872
        {
sl@0
   873
        iCDRMCustomCommandAsyncAO2Phase = CDRMCustomCommandAsyncAO::NewL(
sl@0
   874
                                                    aMessage,
sl@0
   875
                                                    CDRMCustomCommandAsyncAO::ECustomCommandWithoutResult,
sl@0
   876
                                                    *this );
sl@0
   877
        }
sl@0
   878
    // Get reference to data1 descriptor
sl@0
   879
    TPtr8 data1Ptr(iCDRMCustomCommandAsyncAO2Phase->GetData1FromClient()->Des());
sl@0
   880
sl@0
   881
    // Check and filter the messages
sl@0
   882
    // Dont Allow Select Custom Commands
sl@0
   883
    if( !IsValidCustomCommandDestination((iCDRMCustomCommandAsyncAO2Phase->GetMMFMessageDestinationPckg())().InterfaceId(), data1Ptr) )
sl@0
   884
        {
sl@0
   885
        User::Leave( KErrAccessDenied );
sl@0
   886
        }
sl@0
   887
sl@0
   888
    aMessage.Complete( KErrNone );
sl@0
   889
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandAsyncStep1L:Exit"));
sl@0
   890
    }
sl@0
   891
sl@0
   892
void CDRMPlayServerSession::CustomCommandAsyncStep2L( const RMessage2& aMessage )
sl@0
   893
    {
sl@0
   894
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandAsyncStep2L:Enter"));
sl@0
   895
sl@0
   896
    // Read info from client session
sl@0
   897
    TPtr8 data1Ptr(NULL,NULL);
sl@0
   898
    TPtr8 data2Ptr(NULL,NULL);
sl@0
   899
    TPtr8 dataToClientPtr(NULL,NULL);
sl@0
   900
sl@0
   901
    // If there is no pending phase1, then there is something wrong.
sl@0
   902
    if ( !iCDRMCustomCommandAsyncAO2Phase )
sl@0
   903
        {
sl@0
   904
        User::Leave(KErrNotReady);
sl@0
   905
        }
sl@0
   906
sl@0
   907
    // Add custCmdAsyncAO object to array of async custom command objects
sl@0
   908
    iActiveAsyncCustomCommands.AppendL( iCDRMCustomCommandAsyncAO2Phase );
sl@0
   909
sl@0
   910
    // aMessage ownership is transferred to custCmdAsyncAO.
sl@0
   911
    // After succesful transfer, aMessage should not be completed
sl@0
   912
    // anywhere outside of this object.
sl@0
   913
    iCDRMCustomCommandAsyncAO2Phase->TransferOwnershipL(aMessage);
sl@0
   914
sl@0
   915
    CDRMCustomCommandAsyncAO* drmCCAsyncAO = iCDRMCustomCommandAsyncAO2Phase;
sl@0
   916
    iCDRMCustomCommandAsyncAO2Phase = NULL;
sl@0
   917
sl@0
   918
    // Get reference to descriptors
sl@0
   919
    data1Ptr.Set(drmCCAsyncAO->GetData1FromClient()->Des());
sl@0
   920
    data2Ptr.Set(drmCCAsyncAO->GetData2FromClient()->Des());
sl@0
   921
sl@0
   922
    // Make call on controller
sl@0
   923
    drmCCAsyncAO->SetActive();
sl@0
   924
    if ( aMessage.Function() == EDRMPlayServCustomCommandAsyncWithReturnStep2 )
sl@0
   925
        {
sl@0
   926
        // If date needs to be returned, get reference to the descriptor
sl@0
   927
        dataToClientPtr.Set(drmCCAsyncAO->GetDataToClient()->Des());
sl@0
   928
/*
sl@0
   929
        RDebug::Print(_L("CDRMPlayServerSession::CustomCommandAsyncStep2L:IFId[%x]DestHndl[%x]Fn[%d]Data1[Len:%d:MaxLen:%d]Data2Len[Len:%d:MaxLen:%d]RetDesLen[Len:%d:MaxLen:%d]"),
sl@0
   930
                                    (drmCCAsyncAO->GetMMFMessageDestinationPckg())().InterfaceId(),
sl@0
   931
                                    (drmCCAsyncAO->GetMMFMessageDestinationPckg())().DestinationHandle(),
sl@0
   932
                                    drmCCAsyncAO->GetMMFMessageFunction(),
sl@0
   933
                                    data1Ptr.Length(),
sl@0
   934
                                    data1Ptr.MaxLength(),
sl@0
   935
                                    data2Ptr.Length(),
sl@0
   936
                                    data2Ptr.MaxLength(),
sl@0
   937
                                    dataToClientPtr.Length(),
sl@0
   938
                                    dataToClientPtr.MaxLength() );
sl@0
   939
*/
sl@0
   940
        // Call CustomCommandAsync on play util
sl@0
   941
        iPlayUtil->CustomCommandAsync(
sl@0
   942
                        drmCCAsyncAO->GetMMFMessageDestinationPckg(),
sl@0
   943
                        drmCCAsyncAO->GetMMFMessageFunction(),
sl@0
   944
                        data1Ptr,
sl@0
   945
                        data2Ptr,
sl@0
   946
                        dataToClientPtr,
sl@0
   947
                        drmCCAsyncAO->iStatus );
sl@0
   948
        }
sl@0
   949
    else /*if ( aMessage.Function() == EDRMPlayServCustomCommandAsyncWithoutReturnStep2 )*/
sl@0
   950
        {
sl@0
   951
/*
sl@0
   952
        RDebug::Print(_L("CDRMPlayServerSession::CustomCommandAsyncStep2L:IFId[%x]DestHndl[%x]Fn[%d]Data1[Len:%d:MaxLen:%d]Data2Len[Len:%d:MaxLen:%d]"),
sl@0
   953
                                    (drmCCAsyncAO->GetMMFMessageDestinationPckg())().InterfaceId(),
sl@0
   954
                                    (drmCCAsyncAO->GetMMFMessageDestinationPckg())().DestinationHandle(),
sl@0
   955
                                    drmCCAsyncAO->GetMMFMessageFunction(),
sl@0
   956
                                    data1Ptr.Length(),
sl@0
   957
                                    data1Ptr.MaxLength(),
sl@0
   958
                                    data2Ptr.Length(),
sl@0
   959
                                    data2Ptr.MaxLength() );
sl@0
   960
*/
sl@0
   961
        // Call CustomCommandAsync on play util
sl@0
   962
        iPlayUtil->CustomCommandAsync(
sl@0
   963
                        drmCCAsyncAO->GetMMFMessageDestinationPckg(),
sl@0
   964
                        drmCCAsyncAO->GetMMFMessageFunction(),
sl@0
   965
                        data1Ptr,
sl@0
   966
                        data2Ptr,
sl@0
   967
                        drmCCAsyncAO->iStatus );
sl@0
   968
        }
sl@0
   969
sl@0
   970
    DEP_PRN0(_L("CDRMPlayServerSession::CustomCommandAsyncStep2L:Exit"));
sl@0
   971
    }
sl@0
   972
sl@0
   973
void CDRMPlayServerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)
sl@0
   974
    {
sl@0
   975
sl@0
   976
    DEP_PRN2(_L("CDRMPlayServerSession::MapcInitComplete :-> Status[%d] Duration[%d]"), aError, I64INT(aDuration.Int64()));
sl@0
   977
     //iMessage.Write aError & aDuration to client
sl@0
   978
    iCallbackState() = EInitComplete;
sl@0
   979
sl@0
   980
    iMessage.Write(0,iCallbackState);
sl@0
   981
sl@0
   982
    iErrDurPckg().iError = aError;
sl@0
   983
    iErrDurPckg().iDuration = aDuration;
sl@0
   984
sl@0
   985
    iMessage.Write(2,iErrDurPckg);
sl@0
   986
    iMessage.Complete(aError);
sl@0
   987
    iAsyncComplete= EFalse;
sl@0
   988
    }
sl@0
   989
sl@0
   990
void CDRMPlayServerSession::MapcPlayComplete(TInt aError)
sl@0
   991
    {
sl@0
   992
    DEP_PRN1(_L("CDRMPlayServerSession::MapcPlayComplete :-> Error[%d]"), aError);
sl@0
   993
sl@0
   994
#ifdef RD_TSP_CLIENT_MAPPER
sl@0
   995
    TInt status = iTSPClientMapper->SetTspTargetClientToOtherType(
sl@0
   996
                                        CTspClientMapper::EStoppedClients,
sl@0
   997
                                        iClientProcessId );
sl@0
   998
    DEP_PRN2(_L("CDRMPlayServerSession::MapcPlayComplete:Change PID[%x]Status[%d]"), iClientProcessId.Id(), status );
sl@0
   999
#endif // #ifdef RD_TSP_CLIENT_MAPPER
sl@0
  1000
sl@0
  1001
sl@0
  1002
    iState = EStopped;
sl@0
  1003
sl@0
  1004
    iCallbackState()= EPlayComplete;
sl@0
  1005
/*
sl@0
  1006
    iMessage.Write(0,iCallbackState);
sl@0
  1007
    iErrDurPckg().iError = aError;
sl@0
  1008
    iErrDurPckg().iDuration = 0;
sl@0
  1009
    iMessage.Write(2,iErrDurPckg);
sl@0
  1010
    iMessage.Complete(aError);
sl@0
  1011
*/
sl@0
  1012
    if ( iMessage2 )
sl@0
  1013
        {
sl@0
  1014
         //iMessage2. Write aError & aDuration to client
sl@0
  1015
        iCallbackState() = EPlayComplete;
sl@0
  1016
    
sl@0
  1017
        iMessage2->Write(0,iCallbackState);
sl@0
  1018
    
sl@0
  1019
        iErrDurPckg().iError = aError;
sl@0
  1020
        iErrDurPckg().iDuration = 0;    
sl@0
  1021
        iMessage2->Write(2,iErrDurPckg);
sl@0
  1022
        iMessage2->Complete(aError);
sl@0
  1023
        delete iMessage2;
sl@0
  1024
        iMessage2 = NULL;
sl@0
  1025
        }
sl@0
  1026
sl@0
  1027
    iAsyncComplete= EFalse;
sl@0
  1028
    }
sl@0
  1029
sl@0
  1030
sl@0
  1031
void CDRMPlayServerSession::MaloLoadingStarted()
sl@0
  1032
    {
sl@0
  1033
    //send event to client
sl@0
  1034
    iCallbackState() = ELoadingStarted;
sl@0
  1035
    iMessage.Write(0,iCallbackState);
sl@0
  1036
    iMessage.Complete(KErrNone);
sl@0
  1037
    iAsyncComplete= EFalse;
sl@0
  1038
    }
sl@0
  1039
void CDRMPlayServerSession::MaloLoadingComplete()
sl@0
  1040
    {
sl@0
  1041
    //send event to client
sl@0
  1042
    iCallbackState() = ELoadingComplete;
sl@0
  1043
    iMessage.Write(0,iCallbackState);
sl@0
  1044
    iMessage.Complete(KErrNone);
sl@0
  1045
    iAsyncComplete= EFalse;
sl@0
  1046
    }
sl@0
  1047
sl@0
  1048
void CDRMPlayServerSession::AsyncCustomCommandCompleted( CDRMCustomCommandAsyncAO* aObject)
sl@0
  1049
    {
sl@0
  1050
    TInt index = iActiveAsyncCustomCommands.Find( aObject );
sl@0
  1051
    // This should never happen. Else there is something wrong....
sl@0
  1052
    if ( index != KErrNotFound )
sl@0
  1053
        {
sl@0
  1054
        iActiveAsyncCustomCommands.Remove(index);
sl@0
  1055
        }
sl@0
  1056
    delete aObject;
sl@0
  1057
    }
sl@0
  1058
sl@0
  1059
void CDRMPlayServerSession::SetPriorityPreference(const RMessage2 &aMessage)
sl@0
  1060
    {
sl@0
  1061
    iPriority = aMessage.Int0();
sl@0
  1062
    iPref = (TMdaPriorityPreference)aMessage.Int1();
sl@0
  1063
    }
sl@0
  1064
sl@0
  1065
TBool CDRMPlayServerSession::IsValidCustomCommandDestination(TUid aDestinationUid, TDesC8& aParam)
sl@0
  1066
    {
sl@0
  1067
    TBool retValue(ETrue);
sl@0
  1068
    if (aDestinationUid == KUidInterfaceMMFDRMControl)
sl@0
  1069
        {
sl@0
  1070
        retValue = EFalse;
sl@0
  1071
        }
sl@0
  1072
    else if ( aDestinationUid == KUidCustomInterfaceBuilderImpl )
sl@0
  1073
        {
sl@0
  1074
        RDesReadStream stream(aParam);
sl@0
  1075
        CleanupClosePushL(stream);
sl@0
  1076
        TUid paramUid;
sl@0
  1077
        TRAPD(status, paramUid.iUid = stream.ReadInt32L());
sl@0
  1078
        CleanupStack::PopAndDestroy(&stream);
sl@0
  1079
        if ( (status == KErrNone ) && (paramUid == KUidAudioOutput) )
sl@0
  1080
            {
sl@0
  1081
            retValue = EFalse;
sl@0
  1082
            }
sl@0
  1083
        }
sl@0
  1084
    return retValue;
sl@0
  1085
    }
sl@0
  1086
sl@0
  1087
// End of File
sl@0
  1088