khronosfws/openmax_al/src/mmf_adaptation/cmmfbackendengine.cpp
author hgs
Fri, 28 May 2010 19:26:28 -0500
changeset 21 2ed61feeead6
parent 20 b67dd1fc57c5
child 25 6f7ceef7b1d1
permissions -rw-r--r--
201021
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
19
hgs
parents: 12
diff changeset
    14
* Description:
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
#include "cmmfbackendengine.h"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
#include <string.h>
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <ctype.h>
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <uri8.h>
19
hgs
parents: 12
diff changeset
    22
#include <uri16.h>
hgs
parents: 12
diff changeset
    23
#include "markerpositiontimer.h"
hgs
parents: 12
diff changeset
    24
#include "positionupdatetimer.h"
hgs
parents: 12
diff changeset
    25
#include "profileutilmacro.h"
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
extern "C" {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "xaadaptationmmf.h"
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
}
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
19
hgs
parents: 12
diff changeset
    31
#define RET_IF_ERR(res, val) if (res != KErrNone) return val
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
19
hgs
parents: 12
diff changeset
    33
const XAuint32 XA_PLAYSTATE_PLAYERUNINITIALIZED = 0;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
CMMFBackendEngine* CMMFBackendEngine::NewL()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
    CMMFBackendEngine* self = new (ELeave) CMMFBackendEngine();
19
hgs
parents: 12
diff changeset
    38
    CleanupStack::PushL(self);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
    self->ConstructL();
19
hgs
parents: 12
diff changeset
    40
    CleanupStack::Pop(self);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
    return self;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
CMMFBackendEngine::~CMMFBackendEngine()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
    {
19
hgs
parents: 12
diff changeset
    46
    Close();
hgs
parents: 12
diff changeset
    47
    Destroy();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
19
hgs
parents: 12
diff changeset
    50
CMMFBackendEngine::CMMFBackendEngine()
hgs
parents: 12
diff changeset
    51
:iPositionUpdatePeriod(1000), /* default is 1000 millisec */
hgs
parents: 12
diff changeset
    52
 iUriPtr(NULL,0)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
    {
19
hgs
parents: 12
diff changeset
    54
/*    m_bWindowReferencePassed = FALSE;*/
hgs
parents: 12
diff changeset
    55
    iRecordState = ERecorderNotReady;
hgs
parents: 12
diff changeset
    56
    iPositionUpdateTimer = NULL;
hgs
parents: 12
diff changeset
    57
    iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED;
hgs
parents: 12
diff changeset
    58
    iMMFPlayerState = EPlayerClosed;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
void CMMFBackendEngine::ConstructL()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
    {
19
hgs
parents: 12
diff changeset
    63
    iAPIBeingUsed = ENoUtility;
hgs
parents: 12
diff changeset
    64
    iActiveSchedulerWait = new (ELeave) CActiveSchedulerWait;
hgs
parents: 12
diff changeset
    65
    }
hgs
parents: 12
diff changeset
    66
20
hgs
parents: 19
diff changeset
    67
void CMMFBackendEngine::InitAudioRecorderUtilityL()
hgs
parents: 19
diff changeset
    68
    {
hgs
parents: 19
diff changeset
    69
    if (!iAudioRecorder)
hgs
parents: 19
diff changeset
    70
        {
hgs
parents: 19
diff changeset
    71
        iBaseAudioRecorder = CMdaAudioRecorderUtility::NewL(*this);
hgs
parents: 19
diff changeset
    72
        iAudioRecorder = (CMdaAudioRecorderUtility*)iBaseAudioRecorder;
hgs
parents: 19
diff changeset
    73
        }
hgs
parents: 19
diff changeset
    74
    }
hgs
parents: 19
diff changeset
    75
19
hgs
parents: 12
diff changeset
    76
void CMMFBackendEngine::InitAudioPlayerUtilityL()
hgs
parents: 12
diff changeset
    77
    {
hgs
parents: 12
diff changeset
    78
    if (!iAudioPlayer)
hgs
parents: 12
diff changeset
    79
        {
hgs
parents: 12
diff changeset
    80
        iBaseAudioPlayer = CMdaAudioPlayerUtility::NewL(*this);
hgs
parents: 12
diff changeset
    81
        iAudioPlayer = (CMdaAudioPlayerUtility*)iBaseAudioPlayer;
hgs
parents: 12
diff changeset
    82
        }
hgs
parents: 12
diff changeset
    83
    InitPlayerTimersL();
hgs
parents: 12
diff changeset
    84
    }
hgs
parents: 12
diff changeset
    85
hgs
parents: 12
diff changeset
    86
void CMMFBackendEngine::InitVideoPlayerUtilityL()
hgs
parents: 12
diff changeset
    87
    {
hgs
parents: 12
diff changeset
    88
    if (!iVideoPlayer)
hgs
parents: 12
diff changeset
    89
        {
hgs
parents: 12
diff changeset
    90
        iBaseVideoPlayer = CVideoPlayerUtility2::NewL(*this, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
hgs
parents: 12
diff changeset
    91
        iVideoPlayer = (CVideoPlayerUtility2*)iBaseVideoPlayer;
hgs
parents: 12
diff changeset
    92
        iVideoPlayer->RegisterForVideoLoadingNotification(*this);
hgs
parents: 12
diff changeset
    93
        }
hgs
parents: 12
diff changeset
    94
    InitPlayerTimersL();
hgs
parents: 12
diff changeset
    95
    }
hgs
parents: 12
diff changeset
    96
hgs
parents: 12
diff changeset
    97
void CMMFBackendEngine::InitPlayerTimersL()
hgs
parents: 12
diff changeset
    98
    {
hgs
parents: 12
diff changeset
    99
    if (!iMarkerPositionTimer)
hgs
parents: 12
diff changeset
   100
        {
hgs
parents: 12
diff changeset
   101
        iMarkerPositionTimer = CMarkerPositionTimer::NewL(iAudioPlayer, iVideoPlayer);
hgs
parents: 12
diff changeset
   102
        iMarkerPositionTimer->SetContext(iAdaptContext);
hgs
parents: 12
diff changeset
   103
        }
hgs
parents: 12
diff changeset
   104
    if (!iPlayItfPositionUpdateTimer)
hgs
parents: 12
diff changeset
   105
        {
hgs
parents: 12
diff changeset
   106
        iPlayItfPositionUpdateTimer = CPositionUpdateTimer::NewL(iAudioPlayer, iVideoPlayer);
hgs
parents: 12
diff changeset
   107
        iPlayItfPositionUpdateTimer->SetContext(iAdaptContext);
hgs
parents: 12
diff changeset
   108
        }
hgs
parents: 12
diff changeset
   109
    iMarkerPositionTimer->Stop();
hgs
parents: 12
diff changeset
   110
    iPlayItfPositionUpdateTimer->Stop();
hgs
parents: 12
diff changeset
   111
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
TInt CMMFBackendEngine::SetFileName(char* uri, XAuint32 format, TFuncInUse func)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    _LIT8(KFileSlash,"file:///");
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    TInt fileslashlen = KFileSlash().Length();
19
hgs
parents: 12
diff changeset
   118
    if (func == ERecord)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
        {
19
hgs
parents: 12
diff changeset
   120
        if (iRecordState == ERecorderNotReady)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
            iFileFormat = format;
21
hgs
parents: 20
diff changeset
   123
            iAPIBeingUsed = DetermineAPIToUse(uri, ERecord);
20
hgs
parents: 19
diff changeset
   124
            err = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 19
diff changeset
   125
            if (iAPIBeingUsed == EAudioRecorderUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
                {
20
hgs
parents: 19
diff changeset
   127
                /* Initialize URI as needed by MMF utilities */
hgs
parents: 19
diff changeset
   128
                err = InitializeURIForMMFUtil(uri);
hgs
parents: 19
diff changeset
   129
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 19
diff changeset
   130
                /* Initalize Recorder related objects */
hgs
parents: 19
diff changeset
   131
                TRAP(err, InitAudioRecorderUtilityL());
hgs
parents: 19
diff changeset
   132
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 19
diff changeset
   133
    
21
hgs
parents: 20
diff changeset
   134
                TRAP(err, iAudioRecorder->OpenFileL(iUriPtr));
20
hgs
parents: 19
diff changeset
   135
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 19
diff changeset
   136
                /* Wait until we receive moscostatechanged callback */
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
                if(!iActiveSchedulerWait->IsStarted())
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
                    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
                    iActiveSchedulerWait->Start();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
                    }
20
hgs
parents: 19
diff changeset
   141
                RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 19
diff changeset
   142
               }
hgs
parents: 19
diff changeset
   143
            }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    else
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
        {
19
hgs
parents: 12
diff changeset
   147
        /* The second one is needed for dynamic source interface */
hgs
parents: 12
diff changeset
   148
        if ((iMediaPlayerState == XA_PLAYSTATE_PLAYERUNINITIALIZED) ||
hgs
parents: 12
diff changeset
   149
                (iMediaPlayerState == XA_PLAYSTATE_STOPPED))
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
            iFileFormat = format;
19
hgs
parents: 12
diff changeset
   152
            iAPIBeingUsed = DetermineAPIToUse(uri, EPlay);
hgs
parents: 12
diff changeset
   153
            err = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 12
diff changeset
   154
            if (iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
   155
                {
hgs
parents: 12
diff changeset
   156
                /* Initialize URI as needed by MMF utilities */
hgs
parents: 12
diff changeset
   157
                err = InitializeURIForMMFUtil(uri);
hgs
parents: 12
diff changeset
   158
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   159
                /* Initalize Player related objects */
hgs
parents: 12
diff changeset
   160
                TRAP(err, InitAudioPlayerUtilityL());
hgs
parents: 12
diff changeset
   161
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   162
hgs
parents: 12
diff changeset
   163
                TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
   164
                TRAP(err, iAudioPlayer->OpenFileL(iUriPtr));
hgs
parents: 12
diff changeset
   165
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   166
                TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
   167
                PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
   168
hgs
parents: 12
diff changeset
   169
                /* Wait until we receive mapc init complete */
hgs
parents: 12
diff changeset
   170
                PRINT_TO_CONSOLE_HOME_TIME;
hgs
parents: 12
diff changeset
   171
                if (!iActiveSchedulerWait->IsStarted())
hgs
parents: 12
diff changeset
   172
                    {
hgs
parents: 12
diff changeset
   173
                    iActiveSchedulerWait->Start();
hgs
parents: 12
diff changeset
   174
                    }
hgs
parents: 12
diff changeset
   175
                RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   176
                }
hgs
parents: 12
diff changeset
   177
            else if (iAPIBeingUsed == EVideoPlayerUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
                {
19
hgs
parents: 12
diff changeset
   179
                /* Initialize URI as needed by MMF utilities */
hgs
parents: 12
diff changeset
   180
                err = InitializeURIForMMFUtil(uri);
hgs
parents: 12
diff changeset
   181
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   182
                /* Initalize Player related objects */
hgs
parents: 12
diff changeset
   183
                TRAP(err, InitVideoPlayerUtilityL());
hgs
parents: 12
diff changeset
   184
                RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   185
21
hgs
parents: 20
diff changeset
   186
                if(iUriType == ELocal)
hgs
parents: 20
diff changeset
   187
                    {
hgs
parents: 20
diff changeset
   188
                    /* Open file */
hgs
parents: 20
diff changeset
   189
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 20
diff changeset
   190
                    TRAP(err, iVideoPlayer->OpenFileL(iUriPtr));
hgs
parents: 20
diff changeset
   191
                    RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 20
diff changeset
   192
                    TAG_TIME_PROFILING_END;
hgs
parents: 20
diff changeset
   193
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 20
diff changeset
   194
                    }
hgs
parents: 20
diff changeset
   195
                else
hgs
parents: 20
diff changeset
   196
                    {
hgs
parents: 20
diff changeset
   197
                    /* Open URL */
hgs
parents: 20
diff changeset
   198
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 20
diff changeset
   199
                    TRAP(err, iVideoPlayer->OpenUrlL(iUriPtr));
hgs
parents: 20
diff changeset
   200
                    RET_IF_ERR(err, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 20
diff changeset
   201
                    TAG_TIME_PROFILING_END;
hgs
parents: 20
diff changeset
   202
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 20
diff changeset
   203
                    }
19
hgs
parents: 12
diff changeset
   204
                /* Wait until we receive  MvpuoOpenComplete */
hgs
parents: 12
diff changeset
   205
                PRINT_TO_CONSOLE_HOME_TIME;
hgs
parents: 12
diff changeset
   206
                if (!iActiveSchedulerWait->IsStarted())
hgs
parents: 12
diff changeset
   207
                    {
hgs
parents: 12
diff changeset
   208
                    iActiveSchedulerWait->Start();
hgs
parents: 12
diff changeset
   209
                    }
hgs
parents: 12
diff changeset
   210
                RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
   211
hgs
parents: 12
diff changeset
   212
                /* Prepare utility */
hgs
parents: 12
diff changeset
   213
                TAG_TIME_PROFILING_BEGIN_NO_VAR_DEF;
hgs
parents: 12
diff changeset
   214
                iVideoPlayer->Prepare();
hgs
parents: 12
diff changeset
   215
                TAG_TIME_PROFILING_END_NO_VAR_DEF;
hgs
parents: 12
diff changeset
   216
                PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
   217
hgs
parents: 12
diff changeset
   218
                /* Wait until we receive  MvpuoPrepareComplete */
hgs
parents: 12
diff changeset
   219
                PRINT_TO_CONSOLE_HOME_TIME_NO_VAR_DEF;
hgs
parents: 12
diff changeset
   220
                if (!iActiveSchedulerWait->IsStarted())
hgs
parents: 12
diff changeset
   221
                    {
hgs
parents: 12
diff changeset
   222
                    iActiveSchedulerWait->Start();
hgs
parents: 12
diff changeset
   223
                    }
hgs
parents: 12
diff changeset
   224
                RET_IF_ERR(iErrorCode, XA_RESULT_INTERNAL_ERROR);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
                }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
           }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        }
19
hgs
parents: 12
diff changeset
   228
    if (err != KErrNone)
hgs
parents: 12
diff changeset
   229
        {
hgs
parents: 12
diff changeset
   230
        err = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 12
diff changeset
   231
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
TInt CMMFBackendEngine::DetermineAPIToUse(char* uri, TFuncInUse aFunc)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
    {
19
hgs
parents: 12
diff changeset
   237
    char* dotPtr = NULL;
hgs
parents: 12
diff changeset
   238
    char ext[MAX_EXTENSION_SIZE] = { 0 };
hgs
parents: 12
diff changeset
   239
    int extLen;
hgs
parents: 12
diff changeset
   240
21
hgs
parents: 20
diff changeset
   241
    int colpos;
hgs
parents: 20
diff changeset
   242
    char urischeme[MAX_EXTENSION_SIZE] = { 0 };
hgs
parents: 20
diff changeset
   243
    int urischemeLen;
hgs
parents: 20
diff changeset
   244
19
hgs
parents: 12
diff changeset
   245
    dotPtr = strrchr(uri, (int)'.');
hgs
parents: 12
diff changeset
   246
    if (!dotPtr)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
        {
19
hgs
parents: 12
diff changeset
   248
        return KErrNotFound;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
        }
19
hgs
parents: 12
diff changeset
   250
hgs
parents: 12
diff changeset
   251
    strncpy(ext, dotPtr,strlen(dotPtr));
hgs
parents: 12
diff changeset
   252
    /*Null terminate the string*/
hgs
parents: 12
diff changeset
   253
    ext[strlen(dotPtr)] = '\0';
hgs
parents: 12
diff changeset
   254
    extLen = sizeof(ext);
hgs
parents: 12
diff changeset
   255
    for(unsigned int i=0; i < extLen; i++)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
        {
19
hgs
parents: 12
diff changeset
   257
        ext[i] = tolower(ext[i]);
hgs
parents: 12
diff changeset
   258
        }
hgs
parents: 12
diff changeset
   259
21
hgs
parents: 20
diff changeset
   260
    colpos = strcspn(uri,":");
hgs
parents: 20
diff changeset
   261
hgs
parents: 20
diff changeset
   262
    strncpy(urischeme, uri, colpos+1);
hgs
parents: 20
diff changeset
   263
    /*Null terminate the string*/
hgs
parents: 20
diff changeset
   264
    urischeme[colpos+1] = '\0';
hgs
parents: 20
diff changeset
   265
    urischemeLen = sizeof(urischeme);
hgs
parents: 20
diff changeset
   266
    for(unsigned int i=0; i < urischemeLen; i++)
hgs
parents: 20
diff changeset
   267
        {
hgs
parents: 20
diff changeset
   268
        urischeme[i] = tolower(urischeme[i]);
hgs
parents: 20
diff changeset
   269
        }
hgs
parents: 20
diff changeset
   270
    
hgs
parents: 20
diff changeset
   271
    
hgs
parents: 20
diff changeset
   272
    
19
hgs
parents: 12
diff changeset
   273
    if (aFunc == ERecord)
hgs
parents: 12
diff changeset
   274
        {
hgs
parents: 12
diff changeset
   275
        return EAudioRecorderUtility;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
    else
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
        {
21
hgs
parents: 20
diff changeset
   279
        if(!strcasecmp(urischeme, "file:"))
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
            {
21
hgs
parents: 20
diff changeset
   281
            if (!strcasecmp(ext, ".mp3") ||
hgs
parents: 20
diff changeset
   282
               !strcasecmp(ext, ".amr") ||
hgs
parents: 20
diff changeset
   283
               !strcasecmp(ext, ".aac") ||
hgs
parents: 20
diff changeset
   284
               !strcasecmp(ext, ".mid") ||
hgs
parents: 20
diff changeset
   285
               !strcasecmp(ext, ".wav") ||
hgs
parents: 20
diff changeset
   286
               !strcasecmp(ext, ".awb"))
hgs
parents: 20
diff changeset
   287
                {
hgs
parents: 20
diff changeset
   288
                return EAudioPlayerUtility;
hgs
parents: 20
diff changeset
   289
                }
hgs
parents: 20
diff changeset
   290
              else
hgs
parents: 20
diff changeset
   291
                {
hgs
parents: 20
diff changeset
   292
                return EVideoPlayerUtility;
hgs
parents: 20
diff changeset
   293
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
            }
21
hgs
parents: 20
diff changeset
   295
        else
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
            return EVideoPlayerUtility;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
//From MVidePlayerUtilityObserver
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
void CMMFBackendEngine::MvpuoOpenComplete(TInt aError)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    {
19
hgs
parents: 12
diff changeset
   305
    PRINT_TO_CONSOLE_HOME_TIME;
hgs
parents: 12
diff changeset
   306
hgs
parents: 12
diff changeset
   307
    iErrorCode = aError;
hgs
parents: 12
diff changeset
   308
    if (iErrorCode == KErrNone)
hgs
parents: 12
diff changeset
   309
        {
hgs
parents: 12
diff changeset
   310
        iMMFPlayerState = EPlayerOpened;
hgs
parents: 12
diff changeset
   311
        }
hgs
parents: 12
diff changeset
   312
    if (iActiveSchedulerWait->IsStarted())
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
        {
19
hgs
parents: 12
diff changeset
   314
        iActiveSchedulerWait->AsyncStop();
hgs
parents: 12
diff changeset
   315
        }
hgs
parents: 12
diff changeset
   316
    }
hgs
parents: 12
diff changeset
   317
hgs
parents: 12
diff changeset
   318
void CMMFBackendEngine::MvpuoPrepareComplete(TInt aError)
hgs
parents: 12
diff changeset
   319
    {
hgs
parents: 12
diff changeset
   320
    PRINT_TO_CONSOLE_HOME_TIME;
hgs
parents: 12
diff changeset
   321
hgs
parents: 12
diff changeset
   322
    TAutoScaleType autoScale = EAutoScaleBestFit;
hgs
parents: 12
diff changeset
   323
    iErrorCode = aError;
hgs
parents: 12
diff changeset
   324
    iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED;
hgs
parents: 12
diff changeset
   325
    iMediaDuration = 0;
hgs
parents: 12
diff changeset
   326
    iMarkerPositionTimer->ResetPlayer();
hgs
parents: 12
diff changeset
   327
    iPlayItfPositionUpdateTimer->ResetPlayer();
hgs
parents: 12
diff changeset
   328
    if (iErrorCode == KErrNone)
hgs
parents: 12
diff changeset
   329
        {
hgs
parents: 12
diff changeset
   330
        iMMFPlayerState = EPlayerPrepared;
hgs
parents: 12
diff changeset
   331
        TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
   332
        TRAP(iErrorCode, iMediaDuration = iVideoPlayer->DurationL());
hgs
parents: 12
diff changeset
   333
        TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
   334
        PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
   335
        if (iErrorCode == KErrNone)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
            {
19
hgs
parents: 12
diff changeset
   337
            iPlaybackHead = 0;
hgs
parents: 12
diff changeset
   338
            iMediaPlayerState = XA_PLAYSTATE_STOPPED;
hgs
parents: 12
diff changeset
   339
            iMarkerPositionTimer->UseVideoPlayer();
hgs
parents: 12
diff changeset
   340
            iPlayItfPositionUpdateTimer->UseVideoPlayer();
hgs
parents: 12
diff changeset
   341
            if (m_pWs && m_pScr && m_pWindow)
hgs
parents: 12
diff changeset
   342
                {
hgs
parents: 12
diff changeset
   343
                TRect videoExtent = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   344
                TRect clipRect = TRect(m_pWindow->Size());        
hgs
parents: 12
diff changeset
   345
                TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
   346
                TRAP_IGNORE(iVideoPlayer->AddDisplayWindowL(*m_pWs, *m_pScr, *m_pWindow, videoExtent, clipRect));
hgs
parents: 12
diff changeset
   347
                TRAP_IGNORE(iVideoPlayer->SetAutoScaleL(*m_pWindow, autoScale));
hgs
parents: 12
diff changeset
   348
                TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
   349
                PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
   350
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   351
            }
19
hgs
parents: 12
diff changeset
   352
        }
hgs
parents: 12
diff changeset
   353
    if (iActiveSchedulerWait->IsStarted())
hgs
parents: 12
diff changeset
   354
        {
hgs
parents: 12
diff changeset
   355
        iActiveSchedulerWait->AsyncStop();
hgs
parents: 12
diff changeset
   356
        }
hgs
parents: 12
diff changeset
   357
    }
hgs
parents: 12
diff changeset
   358
hgs
parents: 12
diff changeset
   359
void CMMFBackendEngine::MvpuoFrameReady(CFbsBitmap& /*aFrame*/,TInt /*aError*/)
hgs
parents: 12
diff changeset
   360
    {
hgs
parents: 12
diff changeset
   361
hgs
parents: 12
diff changeset
   362
    }
hgs
parents: 12
diff changeset
   363
void CMMFBackendEngine::MvpuoPlayComplete(TInt aError)
hgs
parents: 12
diff changeset
   364
    {
hgs
parents: 12
diff changeset
   365
    iErrorCode = aError;
hgs
parents: 12
diff changeset
   366
    if (iErrorCode == KErrNone)
hgs
parents: 12
diff changeset
   367
        {
hgs
parents: 12
diff changeset
   368
        iPlaybackHead = iMediaDuration;
hgs
parents: 12
diff changeset
   369
        /* Per OpenMAX AL Spec, when playback is completed, media player stays in
hgs
parents: 12
diff changeset
   370
         * paused state with playhead at the end of the media clip */
hgs
parents: 12
diff changeset
   371
        iMediaPlayerState = XA_PLAYSTATE_PAUSED;
hgs
parents: 12
diff changeset
   372
        DoPostEvent(XA_PLAYEVENT_HEADATEND);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    else
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
        {
19
hgs
parents: 12
diff changeset
   376
        iPlaybackHead = 0;
hgs
parents: 12
diff changeset
   377
        iMediaPlayerState = XA_PLAYSTATE_STOPPED;
hgs
parents: 12
diff changeset
   378
        XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL};
hgs
parents: 12
diff changeset
   379
        XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event );
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
        }
19
hgs
parents: 12
diff changeset
   381
    iMMFPlayerState = EPlayerPrepared;
hgs
parents: 12
diff changeset
   382
    iMarkerPositionTimer->Stop();
hgs
parents: 12
diff changeset
   383
    iPlayItfPositionUpdateTimer->Stop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
void CMMFBackendEngine::MvpuoEvent(class TMMFEvent const & event)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
    {
19
hgs
parents: 12
diff changeset
   388
    //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent (0x%x %d)"), event.iEventType, event.iErrorCode);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError &&
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
        event.iErrorCode == KErrHardwareNotAvailable)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
        {
19
hgs
parents: 12
diff changeset
   393
        //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Hardware Not Available"));
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
19
hgs
parents: 12
diff changeset
   396
    else if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError &&
hgs
parents: 12
diff changeset
   397
             event.iErrorCode == KErrMMPartialPlayback)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
        {
19
hgs
parents: 12
diff changeset
   399
        //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Partial playback"));
hgs
parents: 12
diff changeset
   400
        }    
hgs
parents: 12
diff changeset
   401
    if (event.iEventType == KMMFEventCategoryVideoPlayerGeneralError &&
hgs
parents: 12
diff changeset
   402
        event.iErrorCode == -12014)
hgs
parents: 12
diff changeset
   403
        {
hgs
parents: 12
diff changeset
   404
        //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Audio Device taken"));
hgs
parents: 12
diff changeset
   405
        PausePlayback();
hgs
parents: 12
diff changeset
   406
        XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL};
hgs
parents: 12
diff changeset
   407
        XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event );
hgs
parents: 12
diff changeset
   408
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
    else if (event.iEventType == KMMFRefreshMetaData)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
        {
19
hgs
parents: 12
diff changeset
   411
        //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: EventType == KMMFRefreshMetaData"));
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
    else
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
        {
19
hgs
parents: 12
diff changeset
   415
        //RDebug::Print(_L("CMMFBackendEngine::MvpuoEvent: Unhandled event"));
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
// From MRebufferCallback
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
void CMMFBackendEngine::MvloLoadingStarted()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
void CMMFBackendEngine::MvloLoadingComplete()
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
    //file playing
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
//MMdaAudioPlayerCallback
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
void CMMFBackendEngine::MapcInitComplete(TInt aError,
19
hgs
parents: 12
diff changeset
   432
                                          const TTimeIntervalMicroSeconds& aDuration)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
    {
19
hgs
parents: 12
diff changeset
   434
    PRINT_TO_CONSOLE_HOME_TIME;
hgs
parents: 12
diff changeset
   435
hgs
parents: 12
diff changeset
   436
    iErrorCode = aError;
hgs
parents: 12
diff changeset
   437
    iMediaPlayerState = XA_PLAYSTATE_PLAYERUNINITIALIZED;
hgs
parents: 12
diff changeset
   438
    iMMFPlayerState = EPlayerClosed;
hgs
parents: 12
diff changeset
   439
    iMediaDuration = 0;
hgs
parents: 12
diff changeset
   440
    iMarkerPositionTimer->ResetPlayer();
hgs
parents: 12
diff changeset
   441
    iPlayItfPositionUpdateTimer->ResetPlayer();
hgs
parents: 12
diff changeset
   442
    if (iErrorCode == KErrNone)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
        {
19
hgs
parents: 12
diff changeset
   444
        iMediaDuration = aDuration;
hgs
parents: 12
diff changeset
   445
        iPlaybackHead = 0;
hgs
parents: 12
diff changeset
   446
        iMediaPlayerState = XA_PLAYSTATE_STOPPED;
hgs
parents: 12
diff changeset
   447
        iMMFPlayerState = EPlayerOpened;
hgs
parents: 12
diff changeset
   448
        iMarkerPositionTimer->UseAudioPlayer();
hgs
parents: 12
diff changeset
   449
        iPlayItfPositionUpdateTimer->UseAudioPlayer();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
        }
19
hgs
parents: 12
diff changeset
   451
    if (iActiveSchedulerWait->IsStarted())
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
        {
19
hgs
parents: 12
diff changeset
   453
        iActiveSchedulerWait->AsyncStop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
19
hgs
parents: 12
diff changeset
   458
void CMMFBackendEngine::MapcPlayComplete(TInt aError)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    {
19
hgs
parents: 12
diff changeset
   460
    iErrorCode = aError;
hgs
parents: 12
diff changeset
   461
    if (iErrorCode == KErrNone)
hgs
parents: 12
diff changeset
   462
        {
hgs
parents: 12
diff changeset
   463
        /* Now we should have better value. Start using that */
hgs
parents: 12
diff changeset
   464
        iAudioPlayer->Duration(iMediaDuration);
hgs
parents: 12
diff changeset
   465
        iPlaybackHead = iMediaDuration;
hgs
parents: 12
diff changeset
   466
        /* Per OpenMAX AL Spec, when playback is completed, media player stays in
hgs
parents: 12
diff changeset
   467
         * paused state with playhead at the end of the media clip */
hgs
parents: 12
diff changeset
   468
        iMediaPlayerState = XA_PLAYSTATE_PAUSED;
hgs
parents: 12
diff changeset
   469
        DoPostEvent(XA_PLAYEVENT_HEADATEND);
hgs
parents: 12
diff changeset
   470
        iMMFPlayerState = EPlayerOpened;
hgs
parents: 12
diff changeset
   471
        }
hgs
parents: 12
diff changeset
   472
    else
hgs
parents: 12
diff changeset
   473
        {
hgs
parents: 12
diff changeset
   474
        iAudioPlayer->GetPosition(iPlaybackHead);
hgs
parents: 12
diff changeset
   475
        iMediaPlayerState = XA_PLAYSTATE_PAUSED;
hgs
parents: 12
diff changeset
   476
        iMMFPlayerState = EPlayerPaused;
hgs
parents: 12
diff changeset
   477
        XAAdaptEvent event = {XA_PLAYITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL};
hgs
parents: 12
diff changeset
   478
        XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event );
hgs
parents: 12
diff changeset
   479
        }
hgs
parents: 12
diff changeset
   480
    iMarkerPositionTimer->Stop();
hgs
parents: 12
diff changeset
   481
    iPlayItfPositionUpdateTimer->Stop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
// from MMdaObjectStateChangeObserver
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
void CMMFBackendEngine::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
    {
19
hgs
parents: 12
diff changeset
   487
    TInt err(KErrNone);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    iPreviousRecordState = aPreviousState;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
    iCurrentRecordState = aCurrentState;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    iErrorCode = aErrorCode;
19
hgs
parents: 12
diff changeset
   491
    //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 1 Error[%d]"),aErrorCode);
hgs
parents: 12
diff changeset
   492
    if (iCurrentRecordState == CMdaAudioClipUtility::EOpen)  //EOpen
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
        //outputfile is open and ready for recording
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
        iRecordState = CMMFBackendEngine::ERecorderOpen;
19
hgs
parents: 12
diff changeset
   496
        if (iErrorCode == KErrNone)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
            if (iPreviousRecordState == CMdaAudioClipUtility::ENotReady)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
                {
19
hgs
parents: 12
diff changeset
   500
                //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 2"));
21
hgs
parents: 20
diff changeset
   501
                TRAP(err,iAudioInputRecord = CAudioInput::NewL( *iAudioRecorder ));
hgs
parents: 20
diff changeset
   502
                if(err == KErrNone)
hgs
parents: 20
diff changeset
   503
                    {
hgs
parents: 20
diff changeset
   504
                    RArray<CAudioInput::TAudioInputPreference> inputArray;
hgs
parents: 20
diff changeset
   505
                    inputArray.Append( CAudioInput::EDefaultMic );
hgs
parents: 20
diff changeset
   506
                    // Set Audio Input
hgs
parents: 20
diff changeset
   507
                    TRAP(err, iAudioInputRecord->SetAudioInputL( inputArray.Array( ) ));
hgs
parents: 20
diff changeset
   508
                    inputArray.Close();
hgs
parents: 20
diff changeset
   509
                    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
                TMMFMessageDestination destination(KUidMetaDataWriteCustomCommand);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
                TMMFMessageDestinationPckg pckg = TMMFMessageDestinationPckg(destination);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
                TInt ret = iAudioRecorder->RecordControllerCustomCommandSync(pckg, 0, KNullDesC8, KNullDesC8);
19
hgs
parents: 12
diff changeset
   513
                //RDebug::Print(_L("CMMFBackendEngine::MoscoStateChangeEvent 3 [%d]"),ret);
hgs
parents: 12
diff changeset
   514
                if (ret != KErrNone && iFileFormat == XA_CONTAINERTYPE_MP4)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
                    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
                    iPauseSupportMP4 = FALSE;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
                    }
19
hgs
parents: 12
diff changeset
   518
                if (iActiveSchedulerWait->IsStarted())
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
                    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
                    iActiveSchedulerWait->AsyncStop();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
                    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
                }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
        else
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
            {
19
hgs
parents: 12
diff changeset
   526
            XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_OBJECT_EVENT_RESOURCES_LOST, 0, NULL};
hgs
parents: 12
diff changeset
   527
            XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event );
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        }
19
hgs
parents: 12
diff changeset
   530
    else if (iCurrentRecordState == CMdaAudioClipUtility::ERecording)  //ERecording
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
        iRecordState = CMMFBackendEngine::ERecorderRecording;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        iPositionUpdateTimer->Start(iTimerDelay);
19
hgs
parents: 12
diff changeset
   534
        XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADMOVING, 0, NULL};
hgs
parents: 12
diff changeset
   535
        XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &event );
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
    else   //ENotReady
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
        //outputfile is not open
19
hgs
parents: 12
diff changeset
   540
        iRecordState = CMMFBackendEngine::ERecorderNotReady;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
TInt CMMFBackendEngine::SetRecorderState(TRecorderState state, XAboolean stopCalled)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
    TInt err(KErrNone);
20
hgs
parents: 19
diff changeset
   547
hgs
parents: 19
diff changeset
   548
    if (iAPIBeingUsed != EAudioRecorderUtility)
hgs
parents: 19
diff changeset
   549
        {
hgs
parents: 19
diff changeset
   550
        return XA_RESULT_INTERNAL_ERROR;
hgs
parents: 19
diff changeset
   551
        }
hgs
parents: 19
diff changeset
   552
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
    switch(state)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
        case ERecorderNotReady:
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
            iAudioRecorder->Close();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
            iRecordState = ERecorderNotReady;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
            break;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
        case ERecorderOpen:
19
hgs
parents: 12
diff changeset
   560
            if (iFileFormat == XA_CONTAINERTYPE_MP4 && !iPauseSupportMP4 && !stopCalled)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
                {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
                err = KErrNotSupported;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
                return err;
19
hgs
parents: 12
diff changeset
   564
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
            iPositionUpdateTimer->Stop();
19
hgs
parents: 12
diff changeset
   566
            iAudioRecorder->Stop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
            iRecordState = ERecorderOpen;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
            break;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
        case ERecorderRecording:
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
            TRAP(err, iAudioRecorder->RecordL());
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
            break;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
19
hgs
parents: 12
diff changeset
   576
void CMMFBackendEngine::Close()
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    {
19
hgs
parents: 12
diff changeset
   578
    if (iMarkerPositionTimer)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
        {
19
hgs
parents: 12
diff changeset
   580
        iMarkerPositionTimer->Stop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
        }
19
hgs
parents: 12
diff changeset
   582
    if (iPlayItfPositionUpdateTimer)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
        {
19
hgs
parents: 12
diff changeset
   584
        iPlayItfPositionUpdateTimer->Stop();
hgs
parents: 12
diff changeset
   585
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    if (iBaseVideoPlayer && iVideoPlayer)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
        {
19
hgs
parents: 12
diff changeset
   589
        switch(iMMFPlayerState)
hgs
parents: 12
diff changeset
   590
            {
hgs
parents: 12
diff changeset
   591
            case EPlayerPlaying:
hgs
parents: 12
diff changeset
   592
            case EPlayerPaused:
hgs
parents: 12
diff changeset
   593
            case EPlayerPrepared:
hgs
parents: 12
diff changeset
   594
                iVideoPlayer->Stop();
hgs
parents: 12
diff changeset
   595
            case EPlayerOpened:
hgs
parents: 12
diff changeset
   596
            if (m_pWs && m_pScr && m_pWindow)
hgs
parents: 12
diff changeset
   597
                {
hgs
parents: 12
diff changeset
   598
                iVideoPlayer->RemoveDisplayWindow(*m_pWindow);
hgs
parents: 12
diff changeset
   599
                }
hgs
parents: 12
diff changeset
   600
                iVideoPlayer->Close();
hgs
parents: 12
diff changeset
   601
            case EPlayerClosed:
hgs
parents: 12
diff changeset
   602
            default:
hgs
parents: 12
diff changeset
   603
                break;
hgs
parents: 12
diff changeset
   604
            };
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
        }
21
hgs
parents: 20
diff changeset
   606
    
hgs
parents: 20
diff changeset
   607
    // deleting the AudioInput object
hgs
parents: 20
diff changeset
   608
    if(iAudioInputRecord)
hgs
parents: 20
diff changeset
   609
        {
hgs
parents: 20
diff changeset
   610
          delete iAudioInputRecord;
hgs
parents: 20
diff changeset
   611
          iAudioInputRecord = NULL;
hgs
parents: 20
diff changeset
   612
        }
hgs
parents: 20
diff changeset
   613
    
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
    if (iBaseAudioPlayer && iAudioPlayer)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
        iAudioPlayer->Close();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
        }
19
hgs
parents: 12
diff changeset
   618
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
    if (iBaseAudioRecorder)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
        iAudioRecorder->Close();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
        }
19
hgs
parents: 12
diff changeset
   623
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
    if(iPositionUpdateTimer)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
        {
19
hgs
parents: 12
diff changeset
   626
        iPositionUpdateTimer->Stop();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
20
hgs
parents: 19
diff changeset
   629
    if (iActiveSchedulerWait && iActiveSchedulerWait->IsStarted())
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
        {
20
hgs
parents: 19
diff changeset
   631
        iActiveSchedulerWait->AsyncStop();
19
hgs
parents: 12
diff changeset
   632
        }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
19
hgs
parents: 12
diff changeset
   635
void CMMFBackendEngine::Destroy()
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    {
19
hgs
parents: 12
diff changeset
   637
    delete iPositionUpdateTimer;
hgs
parents: 12
diff changeset
   638
    iPositionUpdateTimer = NULL;
hgs
parents: 12
diff changeset
   639
    delete iUri;
hgs
parents: 12
diff changeset
   640
    iUri = NULL;
hgs
parents: 12
diff changeset
   641
    delete iMarkerPositionTimer;
hgs
parents: 12
diff changeset
   642
    iMarkerPositionTimer = NULL;
hgs
parents: 12
diff changeset
   643
    delete iPlayItfPositionUpdateTimer;
hgs
parents: 12
diff changeset
   644
    iPlayItfPositionUpdateTimer = NULL;
hgs
parents: 12
diff changeset
   645
    delete iBaseVideoPlayer;
hgs
parents: 12
diff changeset
   646
    iBaseVideoPlayer = NULL;
hgs
parents: 12
diff changeset
   647
    iVideoPlayer = NULL;
hgs
parents: 12
diff changeset
   648
    delete iBaseAudioPlayer;
hgs
parents: 12
diff changeset
   649
    iBaseAudioPlayer = NULL;
hgs
parents: 12
diff changeset
   650
    iAudioPlayer = NULL;
hgs
parents: 12
diff changeset
   651
    delete iBaseAudioRecorder;
hgs
parents: 12
diff changeset
   652
    iBaseAudioRecorder = NULL;
hgs
parents: 12
diff changeset
   653
    iAudioRecorder = NULL;
hgs
parents: 12
diff changeset
   654
    delete iActiveSchedulerWait;
hgs
parents: 12
diff changeset
   655
    iActiveSchedulerWait = NULL;
hgs
parents: 12
diff changeset
   656
    delete m_pScr;
hgs
parents: 12
diff changeset
   657
    m_pScr = NULL;
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
TInt CMMFBackendEngine::GetRecordPosition(XAuint64* position)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
    *position = iAudioRecorder->Position().Int64();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
TInt CMMFBackendEngine::SetPositionUpdatePerioed(XAmillisecond period)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
    iTimerDelay = period;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
TInt CMMFBackendEngine::SetAdaptContext(void* adaptcontext)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
    iAdaptContext = adaptcontext;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    TRAP(err, iPositionUpdateTimer = new (ELeave) LocalTimer(this, iAdaptContext));
19
hgs
parents: 12
diff changeset
   679
    if (!err)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
        iPositionUpdateTimer->PostInit();
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
19
hgs
parents: 12
diff changeset
   686
TInt CMMFBackendEngine::GetCodecId(XAuint32* codecid)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
    TInt err(KErrNone);
19
hgs
parents: 12
diff changeset
   689
hgs
parents: 12
diff changeset
   690
    if(iAPIBeingUsed == EAudioRecorderUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
        {
19
hgs
parents: 12
diff changeset
   692
        if(iRecordState != CMMFBackendEngine::ERecorderNotReady)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
            {
19
hgs
parents: 12
diff changeset
   694
            TFourCC dest;
hgs
parents: 12
diff changeset
   695
            TRAP(err, dest = iAudioRecorder->DestinationDataTypeL());
hgs
parents: 12
diff changeset
   696
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   697
                {
hgs
parents: 12
diff changeset
   698
                *codecid = dest.FourCC();
hgs
parents: 12
diff changeset
   699
                }
hgs
parents: 12
diff changeset
   700
            }
hgs
parents: 12
diff changeset
   701
        }
hgs
parents: 12
diff changeset
   702
    else if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
   703
        {
hgs
parents: 12
diff changeset
   704
        if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED)
hgs
parents: 12
diff changeset
   705
            {
hgs
parents: 12
diff changeset
   706
            TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController);
hgs
parents: 12
diff changeset
   707
            TPckgBuf<TMMFAudioConfig> configPackage;
hgs
parents: 12
diff changeset
   708
            TInt err =  iAudioPlayer->CustomCommandSync(pckg,
hgs
parents: 12
diff changeset
   709
                                                        EMMFAudioControllerGetSourceDataType,
hgs
parents: 12
diff changeset
   710
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   711
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   712
                                                        configPackage);
hgs
parents: 12
diff changeset
   713
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   714
                {
hgs
parents: 12
diff changeset
   715
                *codecid = configPackage().iSourceDataTypeCode.FourCC();
hgs
parents: 12
diff changeset
   716
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
19
hgs
parents: 12
diff changeset
   722
TInt CMMFBackendEngine::GetBitRate(XAuint32* bitrate)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
    TUint br(0);
19
hgs
parents: 12
diff changeset
   726
    if(iAPIBeingUsed == EAudioRecorderUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
        {
19
hgs
parents: 12
diff changeset
   728
        if(iRecordState != CMMFBackendEngine::ERecorderNotReady)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
            {
19
hgs
parents: 12
diff changeset
   730
            TRAP(err, br = iAudioRecorder->DestinationBitRateL());
hgs
parents: 12
diff changeset
   731
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   732
                {
hgs
parents: 12
diff changeset
   733
                *bitrate = br;
hgs
parents: 12
diff changeset
   734
                }
hgs
parents: 12
diff changeset
   735
            }
hgs
parents: 12
diff changeset
   736
        }
hgs
parents: 12
diff changeset
   737
    else if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
   738
        {
hgs
parents: 12
diff changeset
   739
        if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED)
hgs
parents: 12
diff changeset
   740
            {
hgs
parents: 12
diff changeset
   741
            TInt err =  iAudioPlayer->GetBitRate(br);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
            *bitrate = br;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
19
hgs
parents: 12
diff changeset
   748
TInt CMMFBackendEngine::GetSampleRate(XAmilliHertz* samplerate)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
    TUint sr(0);
19
hgs
parents: 12
diff changeset
   752
    if(iAPIBeingUsed == EAudioRecorderUtility)
hgs
parents: 12
diff changeset
   753
        {
hgs
parents: 12
diff changeset
   754
        if(iRecordState != CMMFBackendEngine::ERecorderNotReady)
hgs
parents: 12
diff changeset
   755
            {
hgs
parents: 12
diff changeset
   756
            TRAP(err, sr = iAudioRecorder->DestinationSampleRateL());
hgs
parents: 12
diff changeset
   757
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   758
                {
21
hgs
parents: 20
diff changeset
   759
                *samplerate = sr*1000;
19
hgs
parents: 12
diff changeset
   760
                }
hgs
parents: 12
diff changeset
   761
            }
hgs
parents: 12
diff changeset
   762
        }
hgs
parents: 12
diff changeset
   763
    else if(iAPIBeingUsed == EAudioPlayerUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
        {
19
hgs
parents: 12
diff changeset
   765
        if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
            {
19
hgs
parents: 12
diff changeset
   767
            TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController);
hgs
parents: 12
diff changeset
   768
            TPckgBuf<TMMFAudioConfig> configPackage;
hgs
parents: 12
diff changeset
   769
            TInt err =  iAudioPlayer->CustomCommandSync(pckg,
hgs
parents: 12
diff changeset
   770
                                                        EMMFAudioControllerGetSourceSampleRate,
hgs
parents: 12
diff changeset
   771
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   772
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   773
                                                        configPackage);
hgs
parents: 12
diff changeset
   774
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   775
                {
21
hgs
parents: 20
diff changeset
   776
                *samplerate = configPackage().iSampleRate*1000;
19
hgs
parents: 12
diff changeset
   777
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
19
hgs
parents: 12
diff changeset
   783
TInt CMMFBackendEngine::GetChannels(XAuint32* channels)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
    TUint ch(0);
19
hgs
parents: 12
diff changeset
   787
    if(iAPIBeingUsed == EAudioRecorderUtility)
hgs
parents: 12
diff changeset
   788
        {
hgs
parents: 12
diff changeset
   789
        if(iRecordState != CMMFBackendEngine::ERecorderNotReady)
hgs
parents: 12
diff changeset
   790
            {
hgs
parents: 12
diff changeset
   791
            TRAP(err,ch = iAudioRecorder->DestinationNumberOfChannelsL());
hgs
parents: 12
diff changeset
   792
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   793
                {
hgs
parents: 12
diff changeset
   794
                *channels = ch;
hgs
parents: 12
diff changeset
   795
                }
hgs
parents: 12
diff changeset
   796
            }
hgs
parents: 12
diff changeset
   797
        }
hgs
parents: 12
diff changeset
   798
    else if(iAPIBeingUsed == EAudioPlayerUtility)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
        {
19
hgs
parents: 12
diff changeset
   800
        if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
            {
19
hgs
parents: 12
diff changeset
   802
            TMMFMessageDestinationPckg pckg(KUidInterfaceMMFAudioController);
hgs
parents: 12
diff changeset
   803
            TPckgBuf<TMMFAudioConfig> configPackage;
hgs
parents: 12
diff changeset
   804
            TInt err =  iAudioPlayer->CustomCommandSync(  pckg,
hgs
parents: 12
diff changeset
   805
                                                        EMMFAudioControllerGetSourceNumChannels,
hgs
parents: 12
diff changeset
   806
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   807
                                                        KNullDesC8,
hgs
parents: 12
diff changeset
   808
                                                        configPackage   );
hgs
parents: 12
diff changeset
   809
            if(err == KErrNone)
hgs
parents: 12
diff changeset
   810
                {
hgs
parents: 12
diff changeset
   811
                *channels = configPackage().iChannels;
hgs
parents: 12
diff changeset
   812
                }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
TInt CMMFBackendEngine::SetDestinationBitRate(XAuint32* bitrate)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
    if(iRecordState == CMMFBackendEngine::ERecorderOpen)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
        TRAP(err, iAudioRecorder->SetDestinationBitRateL(*bitrate));
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
        if(err != KErrNone)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
            return XA_RESULT_PARAMETER_INVALID;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
TInt CMMFBackendEngine::SetDestinationSampleRate(XAmilliHertz* samplerate)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
    TInt err(KErrNone);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
    if(iRecordState == CMMFBackendEngine::ERecorderOpen)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
        {
21
hgs
parents: 20
diff changeset
   837
        TRAP(err, iAudioRecorder->SetDestinationSampleRateL(*samplerate/1000));
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
        if(err != KErrNone)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
            return XA_RESULT_PARAMETER_INVALID;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
TInt CMMFBackendEngine::SetDestinationChannels(XAuint32* channels)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
    TInt err(KErrNone);
19
hgs
parents: 12
diff changeset
   849
    if (iRecordState == CMMFBackendEngine::ERecorderOpen)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
        {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
        TRAP(err,iAudioRecorder->SetDestinationNumberOfChannelsL(*channels));
19
hgs
parents: 12
diff changeset
   852
        if (err != KErrNone)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
            {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
            return XA_RESULT_PARAMETER_INVALID;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
            }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
        }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
    return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
19
hgs
parents: 12
diff changeset
   860
/*
hgs
parents: 12
diff changeset
   861
XAresult CMMFBackendEngine::SetWindowHandle(void* display_info)
hgs
parents: 12
diff changeset
   862
    {
hgs
parents: 12
diff changeset
   863
    XADataLocator_NativeDisplay* nativeDisplay;
hgs
parents: 12
diff changeset
   864
    XADataSink* videoSink = (XADataSink*)display_info;
hgs
parents: 12
diff changeset
   865
hgs
parents: 12
diff changeset
   866
    nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator);
hgs
parents: 12
diff changeset
   867
hgs
parents: 12
diff changeset
   868
    m_pWindow = ((RWindow*)(nativeDisplay->hWindow));
hgs
parents: 12
diff changeset
   869
    m_pWs =     ((RWsSession*)(nativeDisplay->hDisplay));
hgs
parents: 12
diff changeset
   870
hgs
parents: 12
diff changeset
   871
    m_bWindowReferencePassed = TRUE;
hgs
parents: 12
diff changeset
   872
    return XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
   873
    }
hgs
parents: 12
diff changeset
   874
hgs
parents: 12
diff changeset
   875
*/
hgs
parents: 12
diff changeset
   876
XAresult CMMFBackendEngine::CreateAndConfigureWindowL()
hgs
parents: 12
diff changeset
   877
    {
hgs
parents: 12
diff changeset
   878
#ifdef USE_LOCAL_WINDOW_RESOURCES
hgs
parents: 12
diff changeset
   879
    // create window for attaching the surface as its background
hgs
parents: 12
diff changeset
   880
    //RWsSession ws;
hgs
parents: 12
diff changeset
   881
    //TInt err2(KErrNone);
hgs
parents: 12
diff changeset
   882
    TInt err2 = m_ws.Connect();
hgs
parents: 12
diff changeset
   883
    m_pScr = new(ELeave) CWsScreenDevice(m_ws);
hgs
parents: 12
diff changeset
   884
    err2 = m_pScr->Construct();
hgs
parents: 12
diff changeset
   885
    CWindowGc* gc = NULL;
hgs
parents: 12
diff changeset
   886
    err2 = m_pScr->CreateContext(gc);
hgs
parents: 12
diff changeset
   887
    RWindowGroup grp(m_ws);
hgs
parents: 12
diff changeset
   888
    err2 = grp.Construct(0xf00f00);
hgs
parents: 12
diff changeset
   889
    const TSize KWinSize(320, 240);
hgs
parents: 12
diff changeset
   890
    m_pWindow = new (ELeave) RWindow(m_ws);
hgs
parents: 12
diff changeset
   891
    err2 = m_pWindow->Construct(grp, 0xfeefee);
hgs
parents: 12
diff changeset
   892
    m_pWindow->SetExtent(TPoint(), KWinSize);
hgs
parents: 12
diff changeset
   893
    m_pWindow->SetBackgroundColor(TRgb(255,0,0,128));
hgs
parents: 12
diff changeset
   894
    //win.SetBackgroundColor(TRgb(0,0,0,0));
hgs
parents: 12
diff changeset
   895
    m_pWindow->Activate();
hgs
parents: 12
diff changeset
   896
    m_pWindow->Invalidate();
hgs
parents: 12
diff changeset
   897
    m_pWindow->BeginRedraw();
hgs
parents: 12
diff changeset
   898
    gc->Activate(*m_pWindow);
hgs
parents: 12
diff changeset
   899
    m_pWindow->EndRedraw();
hgs
parents: 12
diff changeset
   900
    m_ws.Flush();
hgs
parents: 12
diff changeset
   901
hgs
parents: 12
diff changeset
   902
    //Create MediaClientUitlity for NGA Surfaces
hgs
parents: 12
diff changeset
   903
    TInt displayId = m_pScr->GetScreenNumber();
hgs
parents: 12
diff changeset
   904
hgs
parents: 12
diff changeset
   905
    // Add the display window
hgs
parents: 12
diff changeset
   906
    m_cropRegion = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   907
    m_clipRect = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   908
    m_videoExtent = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   909
    m_rotation = EVideoRotationNone;
hgs
parents: 12
diff changeset
   910
#endif /* USE_LOCAL_WINDOW_RESOURCES */
hgs
parents: 12
diff changeset
   911
hgs
parents: 12
diff changeset
   912
    return XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
   913
    }
hgs
parents: 12
diff changeset
   914
hgs
parents: 12
diff changeset
   915
XAresult CMMFBackendEngine::SetNativeDisplayInformation(void* display_info)
hgs
parents: 12
diff changeset
   916
    {
hgs
parents: 12
diff changeset
   917
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
   918
    //display_info is of type XADataSink
hgs
parents: 12
diff changeset
   919
    //display_info.pLocator is of type XADataLocator_NativeDisplay
hgs
parents: 12
diff changeset
   920
    XADataLocator_NativeDisplay* nativeDisplay;
hgs
parents: 12
diff changeset
   921
    XADataSink* videoSink = (XADataSink*)display_info;
hgs
parents: 12
diff changeset
   922
hgs
parents: 12
diff changeset
   923
    if (videoSink)
hgs
parents: 12
diff changeset
   924
        {
hgs
parents: 12
diff changeset
   925
        nativeDisplay = (XADataLocator_NativeDisplay*) (videoSink->pLocator);
hgs
parents: 12
diff changeset
   926
        m_pWindow = ((RWindow*)(nativeDisplay->hWindow));
hgs
parents: 12
diff changeset
   927
        m_pWs = ((RWsSession*)(nativeDisplay->hDisplay));
hgs
parents: 12
diff changeset
   928
    /*
hgs
parents: 12
diff changeset
   929
        m_cropRegion = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   930
        m_videoExtent = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   931
        m_cropRect = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   932
        m_clipRect = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   933
        m_cropRegion = TRect(m_pWindow->Size());
hgs
parents: 12
diff changeset
   934
    */
hgs
parents: 12
diff changeset
   935
        if (m_pWs)
hgs
parents: 12
diff changeset
   936
            {
hgs
parents: 12
diff changeset
   937
            delete m_pScr;
hgs
parents: 12
diff changeset
   938
            m_pScr = NULL;
hgs
parents: 12
diff changeset
   939
            TRAPD(err, m_pScr = new CWsScreenDevice(*m_pWs));
hgs
parents: 12
diff changeset
   940
            RET_IF_ERR(err, XA_RESULT_MEMORY_FAILURE);
hgs
parents: 12
diff changeset
   941
            m_pScr->Construct();
hgs
parents: 12
diff changeset
   942
            }
hgs
parents: 12
diff changeset
   943
        }
hgs
parents: 12
diff changeset
   944
    return retVal;
hgs
parents: 12
diff changeset
   945
    }
hgs
parents: 12
diff changeset
   946
hgs
parents: 12
diff changeset
   947
XAresult CMMFBackendEngine::ResumePlayback()
hgs
parents: 12
diff changeset
   948
    {
hgs
parents: 12
diff changeset
   949
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
   950
    TBool postHeadMovingEvent(EFalse);
hgs
parents: 12
diff changeset
   951
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
   952
        {
hgs
parents: 12
diff changeset
   953
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
   954
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
   955
            /* If we are already at the end of clip, do nothing
hgs
parents: 12
diff changeset
   956
             * check ::MapcPlayComplete for documentation */
hgs
parents: 12
diff changeset
   957
            if ((iPlaybackHead < iMediaDuration) &&
hgs
parents: 12
diff changeset
   958
                    ((iAPIBeingUsed == EAudioPlayerUtility) ||
hgs
parents: 12
diff changeset
   959
                     (iAPIBeingUsed == EVideoPlayerUtility)) )
hgs
parents: 12
diff changeset
   960
                {
hgs
parents: 12
diff changeset
   961
                if (iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
   962
                    {
hgs
parents: 12
diff changeset
   963
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
   964
                    iAudioPlayer->Play();
hgs
parents: 12
diff changeset
   965
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
   966
                    PRINT_TO_CONSOLE_TIME_DIFF;                    
hgs
parents: 12
diff changeset
   967
                    }
hgs
parents: 12
diff changeset
   968
                else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
   969
                    {
hgs
parents: 12
diff changeset
   970
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
   971
                    //iVideoPlayer->Play( iPlaybackHead, iMediaDuration);
hgs
parents: 12
diff changeset
   972
                    iVideoPlayer->Play();
hgs
parents: 12
diff changeset
   973
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
   974
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
   975
                    }
hgs
parents: 12
diff changeset
   976
                postHeadMovingEvent = ETrue;
hgs
parents: 12
diff changeset
   977
                iMediaPlayerState = XA_PLAYSTATE_PLAYING;
hgs
parents: 12
diff changeset
   978
                iMMFPlayerState = EPlayerPlaying;
hgs
parents: 12
diff changeset
   979
                iMarkerPositionTimer->Start();
hgs
parents: 12
diff changeset
   980
                iPlayItfPositionUpdateTimer->Start();
hgs
parents: 12
diff changeset
   981
                }
hgs
parents: 12
diff changeset
   982
            break;
hgs
parents: 12
diff changeset
   983
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
   984
            break;
hgs
parents: 12
diff changeset
   985
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
   986
        default:
hgs
parents: 12
diff changeset
   987
            retVal = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 12
diff changeset
   988
            break;
hgs
parents: 12
diff changeset
   989
        }
hgs
parents: 12
diff changeset
   990
hgs
parents: 12
diff changeset
   991
    if (postHeadMovingEvent)
hgs
parents: 12
diff changeset
   992
        {
hgs
parents: 12
diff changeset
   993
        DoPostEvent(XA_PLAYEVENT_HEADMOVING);
hgs
parents: 12
diff changeset
   994
        }
hgs
parents: 12
diff changeset
   995
    return retVal;
hgs
parents: 12
diff changeset
   996
    }
hgs
parents: 12
diff changeset
   997
hgs
parents: 12
diff changeset
   998
XAresult CMMFBackendEngine::PausePlayback()
hgs
parents: 12
diff changeset
   999
    {
hgs
parents: 12
diff changeset
  1000
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1001
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1002
        {
hgs
parents: 12
diff changeset
  1003
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1004
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1005
            if ((iAPIBeingUsed == EAudioPlayerUtility) ||
hgs
parents: 12
diff changeset
  1006
                (iAPIBeingUsed == EVideoPlayerUtility) )
hgs
parents: 12
diff changeset
  1007
                {
hgs
parents: 12
diff changeset
  1008
                TInt pauseOpRes(KErrNone);
hgs
parents: 12
diff changeset
  1009
                if (iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1010
                    {
hgs
parents: 12
diff changeset
  1011
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1012
                    pauseOpRes = iAudioPlayer->Pause();
hgs
parents: 12
diff changeset
  1013
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1014
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1015
                    }
hgs
parents: 12
diff changeset
  1016
                else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1017
                    {
hgs
parents: 12
diff changeset
  1018
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1019
                    TRAP(pauseOpRes, iVideoPlayer->PauseL());
hgs
parents: 12
diff changeset
  1020
                    if (pauseOpRes == KErrNone)
hgs
parents: 12
diff changeset
  1021
                        {
hgs
parents: 12
diff changeset
  1022
                        TRAPD(err, iPlaybackHead = iVideoPlayer->PositionL());
hgs
parents: 12
diff changeset
  1023
                        if (err != KErrNone)
hgs
parents: 12
diff changeset
  1024
                            {
hgs
parents: 12
diff changeset
  1025
                            iPlaybackHead = 0;
hgs
parents: 12
diff changeset
  1026
                            }
hgs
parents: 12
diff changeset
  1027
                        }
hgs
parents: 12
diff changeset
  1028
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1029
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1030
                    }
hgs
parents: 12
diff changeset
  1031
                if ( pauseOpRes == KErrNone)
hgs
parents: 12
diff changeset
  1032
                    {
hgs
parents: 12
diff changeset
  1033
                    iMediaPlayerState = XA_PLAYSTATE_PAUSED;
hgs
parents: 12
diff changeset
  1034
                    iMMFPlayerState = EPlayerPaused;
hgs
parents: 12
diff changeset
  1035
                    iMarkerPositionTimer->Stop();
hgs
parents: 12
diff changeset
  1036
                    iPlayItfPositionUpdateTimer->Stop();
hgs
parents: 12
diff changeset
  1037
                    }
hgs
parents: 12
diff changeset
  1038
                }
hgs
parents: 12
diff changeset
  1039
            break;
hgs
parents: 12
diff changeset
  1040
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1041
            break;
hgs
parents: 12
diff changeset
  1042
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1043
        default:
hgs
parents: 12
diff changeset
  1044
            retVal = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 12
diff changeset
  1045
            break;
hgs
parents: 12
diff changeset
  1046
        }
hgs
parents: 12
diff changeset
  1047
    return retVal;
hgs
parents: 12
diff changeset
  1048
    }
hgs
parents: 12
diff changeset
  1049
hgs
parents: 12
diff changeset
  1050
XAresult CMMFBackendEngine::StopPlayback()
hgs
parents: 12
diff changeset
  1051
    {
hgs
parents: 12
diff changeset
  1052
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1053
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1054
        {
hgs
parents: 12
diff changeset
  1055
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1056
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1057
            if ((iAPIBeingUsed == EAudioPlayerUtility) ||
hgs
parents: 12
diff changeset
  1058
                (iAPIBeingUsed == EVideoPlayerUtility) )
hgs
parents: 12
diff changeset
  1059
                {
hgs
parents: 12
diff changeset
  1060
                if (iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1061
                    {
hgs
parents: 12
diff changeset
  1062
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1063
                    iAudioPlayer->Stop();
hgs
parents: 12
diff changeset
  1064
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1065
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1066
hgs
parents: 12
diff changeset
  1067
                    iMMFPlayerState = EPlayerOpened;
hgs
parents: 12
diff changeset
  1068
                    }
hgs
parents: 12
diff changeset
  1069
                else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1070
                    {
hgs
parents: 12
diff changeset
  1071
                    TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1072
                    iVideoPlayer->Stop();
hgs
parents: 12
diff changeset
  1073
                    TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1074
                    PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1075
                    
hgs
parents: 12
diff changeset
  1076
                    iMMFPlayerState = EPlayerPrepared;
hgs
parents: 12
diff changeset
  1077
                    }
hgs
parents: 12
diff changeset
  1078
                iMediaPlayerState = XA_PLAYSTATE_STOPPED;
hgs
parents: 12
diff changeset
  1079
                iPlaybackHead = 0;
hgs
parents: 12
diff changeset
  1080
                iMarkerPositionTimer->Stop();
hgs
parents: 12
diff changeset
  1081
                iPlayItfPositionUpdateTimer->Stop();
hgs
parents: 12
diff changeset
  1082
                }
hgs
parents: 12
diff changeset
  1083
            break;
hgs
parents: 12
diff changeset
  1084
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1085
            break;
hgs
parents: 12
diff changeset
  1086
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1087
        default:
hgs
parents: 12
diff changeset
  1088
            retVal = XA_RESULT_INTERNAL_ERROR;
hgs
parents: 12
diff changeset
  1089
            break;
hgs
parents: 12
diff changeset
  1090
        }
hgs
parents: 12
diff changeset
  1091
    return retVal;
hgs
parents: 12
diff changeset
  1092
    }
hgs
parents: 12
diff changeset
  1093
XAresult CMMFBackendEngine::GetPlayState(XAuint32 *pState)
hgs
parents: 12
diff changeset
  1094
    {
hgs
parents: 12
diff changeset
  1095
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1096
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1097
        {
hgs
parents: 12
diff changeset
  1098
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1099
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1100
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1101
            *pState = iMediaPlayerState;
hgs
parents: 12
diff changeset
  1102
            retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1103
            break;
hgs
parents: 12
diff changeset
  1104
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1105
        default:
hgs
parents: 12
diff changeset
  1106
            break;
hgs
parents: 12
diff changeset
  1107
        }
hgs
parents: 12
diff changeset
  1108
    return retVal;
hgs
parents: 12
diff changeset
  1109
    }
hgs
parents: 12
diff changeset
  1110
hgs
parents: 12
diff changeset
  1111
XAresult CMMFBackendEngine::GetDuration(XAmillisecond *pMsec)
hgs
parents: 12
diff changeset
  1112
    {
hgs
parents: 12
diff changeset
  1113
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1114
    /* to convert from microseconds to milliseconds */
hgs
parents: 12
diff changeset
  1115
    TInt64 divider(1000);
hgs
parents: 12
diff changeset
  1116
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1117
        {
hgs
parents: 12
diff changeset
  1118
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1119
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1120
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1121
            /* TODO Check if we query from MMF*/
hgs
parents: 12
diff changeset
  1122
            *pMsec = iMediaDuration.Int64() / divider;
hgs
parents: 12
diff changeset
  1123
            retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1124
            break;
hgs
parents: 12
diff changeset
  1125
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1126
        default:
hgs
parents: 12
diff changeset
  1127
            break;
hgs
parents: 12
diff changeset
  1128
        }
hgs
parents: 12
diff changeset
  1129
    return retVal;
hgs
parents: 12
diff changeset
  1130
    }
hgs
parents: 12
diff changeset
  1131
hgs
parents: 12
diff changeset
  1132
XAresult CMMFBackendEngine::GetPosition(XAmillisecond *pMsec)
hgs
parents: 12
diff changeset
  1133
    {
hgs
parents: 12
diff changeset
  1134
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1135
    TInt64 divider(1000);
hgs
parents: 12
diff changeset
  1136
    TTimeIntervalMicroSeconds pos;
hgs
parents: 12
diff changeset
  1137
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1138
        {
hgs
parents: 12
diff changeset
  1139
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1140
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1141
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1142
            if (iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1143
                {
hgs
parents: 12
diff changeset
  1144
                if (iAudioPlayer->GetPosition(pos) == KErrNone)
hgs
parents: 12
diff changeset
  1145
                    {
hgs
parents: 12
diff changeset
  1146
                    *pMsec = pos.Int64() / divider;
hgs
parents: 12
diff changeset
  1147
                    retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1148
                    }
hgs
parents: 12
diff changeset
  1149
                }
hgs
parents: 12
diff changeset
  1150
            else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1151
                {
hgs
parents: 12
diff changeset
  1152
                TInt err(KErrNone);
hgs
parents: 12
diff changeset
  1153
                TRAP(err, pos = iVideoPlayer->PositionL());
hgs
parents: 12
diff changeset
  1154
                if (err == KErrNone)
hgs
parents: 12
diff changeset
  1155
                    {
hgs
parents: 12
diff changeset
  1156
                    *pMsec = pos.Int64() / divider; 
hgs
parents: 12
diff changeset
  1157
                    retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1158
                    }
hgs
parents: 12
diff changeset
  1159
                }
hgs
parents: 12
diff changeset
  1160
            break;
hgs
parents: 12
diff changeset
  1161
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1162
        default:
hgs
parents: 12
diff changeset
  1163
            break;
hgs
parents: 12
diff changeset
  1164
        }
hgs
parents: 12
diff changeset
  1165
    return retVal;
hgs
parents: 12
diff changeset
  1166
    }
hgs
parents: 12
diff changeset
  1167
hgs
parents: 12
diff changeset
  1168
XAresult CMMFBackendEngine::SetPosition(XAmillisecond pMsec)
hgs
parents: 12
diff changeset
  1169
    {
hgs
parents: 12
diff changeset
  1170
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1171
    TInt64 multiplier(1000);
hgs
parents: 12
diff changeset
  1172
    TTimeIntervalMicroSeconds pos;
hgs
parents: 12
diff changeset
  1173
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1174
        {
hgs
parents: 12
diff changeset
  1175
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1176
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1177
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1178
            if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1179
                {
hgs
parents: 12
diff changeset
  1180
                pos = pMsec * multiplier;
hgs
parents: 12
diff changeset
  1181
                TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1182
                iAudioPlayer->SetPosition(pos);
hgs
parents: 12
diff changeset
  1183
                TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1184
                PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1185
hgs
parents: 12
diff changeset
  1186
                retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1187
                }
hgs
parents: 12
diff changeset
  1188
            else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1189
                {
hgs
parents: 12
diff changeset
  1190
                pos = pMsec * multiplier;
hgs
parents: 12
diff changeset
  1191
                TAG_TIME_PROFILING_BEGIN;
hgs
parents: 12
diff changeset
  1192
                TRAPD(err, iVideoPlayer->SetPositionL(pos));
hgs
parents: 12
diff changeset
  1193
                TAG_TIME_PROFILING_END;
hgs
parents: 12
diff changeset
  1194
                PRINT_TO_CONSOLE_TIME_DIFF;
hgs
parents: 12
diff changeset
  1195
                if (err == KErrNone)
hgs
parents: 12
diff changeset
  1196
                    {
hgs
parents: 12
diff changeset
  1197
                    retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1198
                    }
hgs
parents: 12
diff changeset
  1199
                }
hgs
parents: 12
diff changeset
  1200
            break;
hgs
parents: 12
diff changeset
  1201
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1202
        default:
hgs
parents: 12
diff changeset
  1203
            break;
hgs
parents: 12
diff changeset
  1204
        }
hgs
parents: 12
diff changeset
  1205
    return retVal;
hgs
parents: 12
diff changeset
  1206
    }
hgs
parents: 12
diff changeset
  1207
hgs
parents: 12
diff changeset
  1208
XAresult CMMFBackendEngine::SetRepeats(XAboolean repeat)
hgs
parents: 12
diff changeset
  1209
    {
hgs
parents: 12
diff changeset
  1210
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1211
    TInt numRepeats(0);
hgs
parents: 12
diff changeset
  1212
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1213
        {
hgs
parents: 12
diff changeset
  1214
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1215
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1216
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1217
            if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1218
                {
hgs
parents: 12
diff changeset
  1219
                numRepeats = repeat ? -2 : 0;
hgs
parents: 12
diff changeset
  1220
                iAudioPlayer->SetRepeats(numRepeats, 0);
hgs
parents: 12
diff changeset
  1221
                retVal = XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1222
                }
hgs
parents: 12
diff changeset
  1223
            else
hgs
parents: 12
diff changeset
  1224
                {
hgs
parents: 12
diff changeset
  1225
                }
hgs
parents: 12
diff changeset
  1226
            break;
hgs
parents: 12
diff changeset
  1227
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1228
        default:
hgs
parents: 12
diff changeset
  1229
            break;
hgs
parents: 12
diff changeset
  1230
        }
hgs
parents: 12
diff changeset
  1231
    return retVal;
hgs
parents: 12
diff changeset
  1232
    }
hgs
parents: 12
diff changeset
  1233
hgs
parents: 12
diff changeset
  1234
XAresult CMMFBackendEngine::SetPlayWindow(XAmillisecond start, XAmillisecond end)
hgs
parents: 12
diff changeset
  1235
    {
hgs
parents: 12
diff changeset
  1236
    XAresult retVal(XA_RESULT_INTERNAL_ERROR);
hgs
parents: 12
diff changeset
  1237
    TInt64 multiplier(1000);
hgs
parents: 12
diff changeset
  1238
    TTimeIntervalMicroSeconds startpos(0);
hgs
parents: 12
diff changeset
  1239
    TTimeIntervalMicroSeconds endpos(0);
hgs
parents: 12
diff changeset
  1240
hgs
parents: 12
diff changeset
  1241
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1242
        {
hgs
parents: 12
diff changeset
  1243
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1244
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1245
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1246
            if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1247
                {
hgs
parents: 12
diff changeset
  1248
                startpos = start * multiplier;
hgs
parents: 12
diff changeset
  1249
                endpos = end * multiplier;
hgs
parents: 12
diff changeset
  1250
                retVal = iAudioPlayer->SetPlayWindow(startpos,endpos);
hgs
parents: 12
diff changeset
  1251
                }
hgs
parents: 12
diff changeset
  1252
            else
hgs
parents: 12
diff changeset
  1253
                {
hgs
parents: 12
diff changeset
  1254
                }
hgs
parents: 12
diff changeset
  1255
            break;
hgs
parents: 12
diff changeset
  1256
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1257
        default:
hgs
parents: 12
diff changeset
  1258
            break;
hgs
parents: 12
diff changeset
  1259
        }
hgs
parents: 12
diff changeset
  1260
    return retVal;
hgs
parents: 12
diff changeset
  1261
    }
hgs
parents: 12
diff changeset
  1262
hgs
parents: 12
diff changeset
  1263
XAresult CMMFBackendEngine::SetPlayAdaptContext(void * adaptcontext)
hgs
parents: 12
diff changeset
  1264
    {
hgs
parents: 12
diff changeset
  1265
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1266
hgs
parents: 12
diff changeset
  1267
    iAdaptContext = adaptcontext;
hgs
parents: 12
diff changeset
  1268
hgs
parents: 12
diff changeset
  1269
    return retVal;
hgs
parents: 12
diff changeset
  1270
    }
hgs
parents: 12
diff changeset
  1271
hgs
parents: 12
diff changeset
  1272
XAresult CMMFBackendEngine::RegisterCallback(xaPlayCallback cbFunction)
hgs
parents: 12
diff changeset
  1273
    {
hgs
parents: 12
diff changeset
  1274
    iPlayItfCBFunction = cbFunction;
hgs
parents: 12
diff changeset
  1275
    return DoHandlePlayItfAttributesChanged();
hgs
parents: 12
diff changeset
  1276
    }
hgs
parents: 12
diff changeset
  1277
hgs
parents: 12
diff changeset
  1278
XAresult CMMFBackendEngine::SetCallbackEventsMask(XAuint32 eventflags)
hgs
parents: 12
diff changeset
  1279
    {
hgs
parents: 12
diff changeset
  1280
    iPlayItfEventFlags = eventflags;
hgs
parents: 12
diff changeset
  1281
    return DoHandlePlayItfAttributesChanged();
hgs
parents: 12
diff changeset
  1282
    }
hgs
parents: 12
diff changeset
  1283
hgs
parents: 12
diff changeset
  1284
XAresult CMMFBackendEngine::SetMarkerPosition(XAmillisecond mSec)
hgs
parents: 12
diff changeset
  1285
    {
hgs
parents: 12
diff changeset
  1286
    iMarkerPosition = mSec;
hgs
parents: 12
diff changeset
  1287
    return DoHandlePlayItfAttributesChanged();
hgs
parents: 12
diff changeset
  1288
    }
hgs
parents: 12
diff changeset
  1289
hgs
parents: 12
diff changeset
  1290
XAresult CMMFBackendEngine::ClearMarkerPosition()
hgs
parents: 12
diff changeset
  1291
    {
hgs
parents: 12
diff changeset
  1292
    iMarkerPosition = XA_TIME_UNKNOWN;
hgs
parents: 12
diff changeset
  1293
    DoHandlePlayItfAttributesChanged();
hgs
parents: 12
diff changeset
  1294
    return XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1295
    }
hgs
parents: 12
diff changeset
  1296
hgs
parents: 12
diff changeset
  1297
XAresult CMMFBackendEngine::SetPositionUpdatePeriod(XAmillisecond mSec)
hgs
parents: 12
diff changeset
  1298
    {
hgs
parents: 12
diff changeset
  1299
    iPositionUpdatePeriod = mSec;
hgs
parents: 12
diff changeset
  1300
    DoHandlePlayItfAttributesChanged();
hgs
parents: 12
diff changeset
  1301
    return XA_RESULT_SUCCESS;
hgs
parents: 12
diff changeset
  1302
    }
hgs
parents: 12
diff changeset
  1303
hgs
parents: 12
diff changeset
  1304
XAresult CMMFBackendEngine::DoHandlePlayItfAttributesChanged()
hgs
parents: 12
diff changeset
  1305
    {
hgs
parents: 12
diff changeset
  1306
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1307
hgs
parents: 12
diff changeset
  1308
    iMarkerPositionTimer->SetCallbackEventMask(iPlayItfEventFlags);
hgs
parents: 12
diff changeset
  1309
    iMarkerPositionTimer->RegisterCallback(iPlayItfCBFunction);
hgs
parents: 12
diff changeset
  1310
    iMarkerPositionTimer->SetMarkerPosition(iMarkerPosition);
hgs
parents: 12
diff changeset
  1311
hgs
parents: 12
diff changeset
  1312
    iPlayItfPositionUpdateTimer->SetCallbackEventMask(iPlayItfEventFlags);
hgs
parents: 12
diff changeset
  1313
    iPlayItfPositionUpdateTimer->RegisterCallback(iPlayItfCBFunction);
hgs
parents: 12
diff changeset
  1314
    iPlayItfPositionUpdateTimer->SetPositionUpdatePeriod(iPositionUpdatePeriod);
hgs
parents: 12
diff changeset
  1315
hgs
parents: 12
diff changeset
  1316
    switch (iMediaPlayerState)
hgs
parents: 12
diff changeset
  1317
        {
hgs
parents: 12
diff changeset
  1318
        case XA_PLAYSTATE_STOPPED:
hgs
parents: 12
diff changeset
  1319
        case XA_PLAYSTATE_PAUSED:
hgs
parents: 12
diff changeset
  1320
            break;
hgs
parents: 12
diff changeset
  1321
        case XA_PLAYSTATE_PLAYING:
hgs
parents: 12
diff changeset
  1322
            iMarkerPositionTimer->Start();
hgs
parents: 12
diff changeset
  1323
            iPlayItfPositionUpdateTimer->Start();
hgs
parents: 12
diff changeset
  1324
            break;
hgs
parents: 12
diff changeset
  1325
        case XA_PLAYSTATE_PLAYERUNINITIALIZED:
hgs
parents: 12
diff changeset
  1326
        default:
hgs
parents: 12
diff changeset
  1327
            break;
hgs
parents: 12
diff changeset
  1328
        }
hgs
parents: 12
diff changeset
  1329
    return retVal;
hgs
parents: 12
diff changeset
  1330
    }
hgs
parents: 12
diff changeset
  1331
hgs
parents: 12
diff changeset
  1332
void CMMFBackendEngine::DoPostEvent(XAuint32 event)
hgs
parents: 12
diff changeset
  1333
    {
hgs
parents: 12
diff changeset
  1334
    if ((iPlayItfEventFlags & event) &&
hgs
parents: 12
diff changeset
  1335
        (iPlayItfCBFunction != NULL))
hgs
parents: 12
diff changeset
  1336
        {
hgs
parents: 12
diff changeset
  1337
        XAAdaptEvent xaevent = {XA_PLAYITFEVENTS, event, 0, 0 };
hgs
parents: 12
diff changeset
  1338
        XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iAdaptContext, &xaevent );
hgs
parents: 12
diff changeset
  1339
        }
hgs
parents: 12
diff changeset
  1340
    }
hgs
parents: 12
diff changeset
  1341
hgs
parents: 12
diff changeset
  1342
XAresult CMMFBackendEngine::GetNumStreams(XAuint32* numstreams)
hgs
parents: 12
diff changeset
  1343
    {
hgs
parents: 12
diff changeset
  1344
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1345
    TInt bitRate(0);
hgs
parents: 12
diff changeset
  1346
    TInt numS(0);
hgs
parents: 12
diff changeset
  1347
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1348
        {
hgs
parents: 12
diff changeset
  1349
        numS = 1;
hgs
parents: 12
diff changeset
  1350
        *numstreams = numS;
hgs
parents: 12
diff changeset
  1351
        }
hgs
parents: 12
diff changeset
  1352
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1353
        {
hgs
parents: 12
diff changeset
  1354
        TRAPD(err, bitRate = iVideoPlayer->VideoBitRateL());
hgs
parents: 12
diff changeset
  1355
        if(!err && bitRate)
hgs
parents: 12
diff changeset
  1356
            {
hgs
parents: 12
diff changeset
  1357
            numS++;
hgs
parents: 12
diff changeset
  1358
            *numstreams = numS;
hgs
parents: 12
diff changeset
  1359
            }
hgs
parents: 12
diff changeset
  1360
        
hgs
parents: 12
diff changeset
  1361
        bitRate = 0;
hgs
parents: 12
diff changeset
  1362
        TRAP(err, bitRate = iVideoPlayer->AudioBitRateL());
hgs
parents: 12
diff changeset
  1363
        if(!err && bitRate)
hgs
parents: 12
diff changeset
  1364
            {
hgs
parents: 12
diff changeset
  1365
            numS++;
hgs
parents: 12
diff changeset
  1366
            *numstreams = numS;
hgs
parents: 12
diff changeset
  1367
            }
hgs
parents: 12
diff changeset
  1368
        }
hgs
parents: 12
diff changeset
  1369
    return retVal;
hgs
parents: 12
diff changeset
  1370
    }
hgs
parents: 12
diff changeset
  1371
hgs
parents: 12
diff changeset
  1372
XAresult CMMFBackendEngine::GetStreamInfo(XAuint32 streamindex, XAuint32* streamtype)
hgs
parents: 12
diff changeset
  1373
    {
hgs
parents: 12
diff changeset
  1374
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1375
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1376
        {
hgs
parents: 12
diff changeset
  1377
        *streamtype = XA_DOMAINTYPE_AUDIO;
hgs
parents: 12
diff changeset
  1378
        }
hgs
parents: 12
diff changeset
  1379
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1380
        {
hgs
parents: 12
diff changeset
  1381
        switch(streamindex)
hgs
parents: 12
diff changeset
  1382
            {
hgs
parents: 12
diff changeset
  1383
            case 1:
hgs
parents: 12
diff changeset
  1384
                *streamtype = XA_DOMAINTYPE_VIDEO;
hgs
parents: 12
diff changeset
  1385
                break;
hgs
parents: 12
diff changeset
  1386
            case 2:
hgs
parents: 12
diff changeset
  1387
                *streamtype = XA_DOMAINTYPE_AUDIO;
hgs
parents: 12
diff changeset
  1388
                break;
hgs
parents: 12
diff changeset
  1389
            default:
hgs
parents: 12
diff changeset
  1390
                retVal = XA_RESULT_PARAMETER_INVALID;
hgs
parents: 12
diff changeset
  1391
                break;
hgs
parents: 12
diff changeset
  1392
            }
hgs
parents: 12
diff changeset
  1393
        }
hgs
parents: 12
diff changeset
  1394
    return retVal;
hgs
parents: 12
diff changeset
  1395
    }
hgs
parents: 12
diff changeset
  1396
hgs
parents: 12
diff changeset
  1397
hgs
parents: 12
diff changeset
  1398
XAresult CMMFBackendEngine::GetVideoFrameSize(XAuint32* height, XAuint32* width, XAuint32* frameRate)
hgs
parents: 12
diff changeset
  1399
    {
hgs
parents: 12
diff changeset
  1400
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1401
    if(iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1402
        {
hgs
parents: 12
diff changeset
  1403
        if(iMediaPlayerState != XA_PLAYSTATE_PLAYERUNINITIALIZED)
hgs
parents: 12
diff changeset
  1404
            {
hgs
parents: 12
diff changeset
  1405
            TSize size;
hgs
parents: 12
diff changeset
  1406
            TReal32 framerate(0);
hgs
parents: 12
diff changeset
  1407
            TRAPD(err, iVideoPlayer->VideoFrameSizeL(size));
hgs
parents: 12
diff changeset
  1408
            if(!err)
hgs
parents: 12
diff changeset
  1409
                {
hgs
parents: 12
diff changeset
  1410
                *height = size.iHeight;
hgs
parents: 12
diff changeset
  1411
                *width = size.iWidth;
hgs
parents: 12
diff changeset
  1412
                }
hgs
parents: 12
diff changeset
  1413
            else
hgs
parents: 12
diff changeset
  1414
                {
hgs
parents: 12
diff changeset
  1415
                retVal = err;
hgs
parents: 12
diff changeset
  1416
                }
hgs
parents: 12
diff changeset
  1417
hgs
parents: 12
diff changeset
  1418
            TRAP(err, framerate = iVideoPlayer->VideoFrameRateL());
hgs
parents: 12
diff changeset
  1419
            if(!err)
hgs
parents: 12
diff changeset
  1420
                {
hgs
parents: 12
diff changeset
  1421
                *frameRate = framerate;
hgs
parents: 12
diff changeset
  1422
                }
hgs
parents: 12
diff changeset
  1423
            }
hgs
parents: 12
diff changeset
  1424
        else
hgs
parents: 12
diff changeset
  1425
            {
hgs
parents: 12
diff changeset
  1426
            retVal = XA_RESULT_PRECONDITIONS_VIOLATED;
hgs
parents: 12
diff changeset
  1427
            }
hgs
parents: 12
diff changeset
  1428
        }
hgs
parents: 12
diff changeset
  1429
    else
hgs
parents: 12
diff changeset
  1430
        {
hgs
parents: 12
diff changeset
  1431
        retVal = XA_RESULT_FEATURE_UNSUPPORTED;
hgs
parents: 12
diff changeset
  1432
        }
hgs
parents: 12
diff changeset
  1433
    return retVal;
hgs
parents: 12
diff changeset
  1434
    }
hgs
parents: 12
diff changeset
  1435
hgs
parents: 12
diff changeset
  1436
XAresult CMMFBackendEngine::SetActiveState(XAuint32 streamindex, XAboolean active)
hgs
parents: 12
diff changeset
  1437
    {
hgs
parents: 12
diff changeset
  1438
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1439
    TInt err(KErrNone);
hgs
parents: 12
diff changeset
  1440
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1441
        {
hgs
parents: 12
diff changeset
  1442
        retVal = XA_RESULT_FEATURE_UNSUPPORTED;
hgs
parents: 12
diff changeset
  1443
        }
hgs
parents: 12
diff changeset
  1444
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1445
        {
hgs
parents: 12
diff changeset
  1446
        switch(streamindex)
hgs
parents: 12
diff changeset
  1447
            {
hgs
parents: 12
diff changeset
  1448
            case 1:
hgs
parents: 12
diff changeset
  1449
                TRAP(err, iVideoPlayer->SetVideoEnabledL(active));
hgs
parents: 12
diff changeset
  1450
                retVal = err;
hgs
parents: 12
diff changeset
  1451
                break;
hgs
parents: 12
diff changeset
  1452
            case 2:
hgs
parents: 12
diff changeset
  1453
                TRAP(err, iVideoPlayer->SetAudioEnabledL(active));
hgs
parents: 12
diff changeset
  1454
                retVal = err;
hgs
parents: 12
diff changeset
  1455
                break;
hgs
parents: 12
diff changeset
  1456
            default:
hgs
parents: 12
diff changeset
  1457
                retVal = XA_RESULT_PARAMETER_INVALID;
hgs
parents: 12
diff changeset
  1458
                break;
hgs
parents: 12
diff changeset
  1459
            }
hgs
parents: 12
diff changeset
  1460
        }
hgs
parents: 12
diff changeset
  1461
    return retVal;
hgs
parents: 12
diff changeset
  1462
    }
hgs
parents: 12
diff changeset
  1463
hgs
parents: 12
diff changeset
  1464
TInt CMMFBackendEngine::InitializeURIForMMFUtil(char *uri)
hgs
parents: 12
diff changeset
  1465
    {
hgs
parents: 12
diff changeset
  1466
    /* Initializes and save uri param into iUri structure */
hgs
parents: 12
diff changeset
  1467
    TInt err(KErrNone);
hgs
parents: 12
diff changeset
  1468
    TInt uriLen;
hgs
parents: 12
diff changeset
  1469
    
hgs
parents: 12
diff changeset
  1470
    if (!uri)
hgs
parents: 12
diff changeset
  1471
        return KErrArgument;
hgs
parents: 12
diff changeset
  1472
hgs
parents: 12
diff changeset
  1473
    if (iUri)
hgs
parents: 12
diff changeset
  1474
        {
hgs
parents: 12
diff changeset
  1475
        delete iUri;
hgs
parents: 12
diff changeset
  1476
        iUri = NULL;
hgs
parents: 12
diff changeset
  1477
        }
hgs
parents: 12
diff changeset
  1478
    
hgs
parents: 12
diff changeset
  1479
    uriLen = strlen(uri);
hgs
parents: 12
diff changeset
  1480
    TPtr8 uriParam((TUint8*)uri, uriLen, uriLen);
hgs
parents: 12
diff changeset
  1481
    
hgs
parents: 12
diff changeset
  1482
    TRAP(err, iUri = HBufC::NewL(uriLen));
hgs
parents: 12
diff changeset
  1483
    if (err != KErrNone)
hgs
parents: 12
diff changeset
  1484
        return err;
hgs
parents: 12
diff changeset
  1485
hgs
parents: 12
diff changeset
  1486
    iUriPtr.Set(iUri->Des());
hgs
parents: 12
diff changeset
  1487
    iUriPtr.Copy(uriParam); /* Copy data*/
21
hgs
parents: 20
diff changeset
  1488
    //iUriPtr.LowerCase();
19
hgs
parents: 12
diff changeset
  1489
hgs
parents: 12
diff changeset
  1490
    /* For file scheme convert from file:///c:/folder/file.ext
hgs
parents: 12
diff changeset
  1491
     * format to c:\\folder\\file.ext using TUriParser. */
hgs
parents: 12
diff changeset
  1492
    _LIT(KFileScheme,"file:///");
hgs
parents: 12
diff changeset
  1493
    if (iUriPtr.Find(KFileScheme) >= 0)
hgs
parents: 12
diff changeset
  1494
        {
21
hgs
parents: 20
diff changeset
  1495
        iUriType = ELocal;
19
hgs
parents: 12
diff changeset
  1496
        TPtr tmp(const_cast<TUint16 *>(iUriPtr.Ptr()) + KFileScheme().Length(),
hgs
parents: 12
diff changeset
  1497
                iUriPtr.Length(),
hgs
parents: 12
diff changeset
  1498
                iUriPtr.Length());
hgs
parents: 12
diff changeset
  1499
        /* Convert from c:/folder/file.ext format to
hgs
parents: 12
diff changeset
  1500
         * c:\\folder\\file.ext using TUriParser.
hgs
parents: 12
diff changeset
  1501
         * TUriParser8 accepts uri in format file:///c/folder/file.ext,
hgs
parents: 12
diff changeset
  1502
         * so get rid of ':' after drive letter (if any) */
hgs
parents: 12
diff changeset
  1503
        TInt pos = tmp.Find(_L(":"));
hgs
parents: 12
diff changeset
  1504
        if (pos != KErrNotFound)
hgs
parents: 12
diff changeset
  1505
            {
hgs
parents: 12
diff changeset
  1506
            iUriPtr.Delete(KFileScheme().Length() + pos, 1);
hgs
parents: 12
diff changeset
  1507
            }
hgs
parents: 12
diff changeset
  1508
hgs
parents: 12
diff changeset
  1509
        TUriParser16 uriParser;
hgs
parents: 12
diff changeset
  1510
        err = uriParser.Parse(iUriPtr);
hgs
parents: 12
diff changeset
  1511
        if (err != KErrNone)
hgs
parents: 12
diff changeset
  1512
            return err;
hgs
parents: 12
diff changeset
  1513
hgs
parents: 12
diff changeset
  1514
        HBufC* file = NULL;
hgs
parents: 12
diff changeset
  1515
        TRAP(err, file = uriParser.GetFileNameL());
hgs
parents: 12
diff changeset
  1516
        if (err != KErrNone)
hgs
parents: 12
diff changeset
  1517
            return err;
hgs
parents: 12
diff changeset
  1518
hgs
parents: 12
diff changeset
  1519
        iUriPtr.Copy(file->Des());
hgs
parents: 12
diff changeset
  1520
        delete file;
hgs
parents: 12
diff changeset
  1521
        file = NULL;
hgs
parents: 12
diff changeset
  1522
hgs
parents: 12
diff changeset
  1523
        }
21
hgs
parents: 20
diff changeset
  1524
    else
hgs
parents: 20
diff changeset
  1525
        {
hgs
parents: 20
diff changeset
  1526
        iUriType = EStreaming;
hgs
parents: 20
diff changeset
  1527
        }
19
hgs
parents: 12
diff changeset
  1528
    return err;
hgs
parents: 12
diff changeset
  1529
    }
hgs
parents: 12
diff changeset
  1530
hgs
parents: 12
diff changeset
  1531
hgs
parents: 12
diff changeset
  1532
XAresult CMMFBackendEngine::SetVolume(XAuint32 volume)
hgs
parents: 12
diff changeset
  1533
    {
hgs
parents: 12
diff changeset
  1534
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1535
    TInt err(KErrNone);
hgs
parents: 12
diff changeset
  1536
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1537
        {
hgs
parents: 12
diff changeset
  1538
        retVal = iAudioPlayer->SetVolume(volume);
hgs
parents: 12
diff changeset
  1539
        }
hgs
parents: 12
diff changeset
  1540
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1541
        {
hgs
parents: 12
diff changeset
  1542
        TRAP(err, iVideoPlayer->SetVolumeL(volume));
hgs
parents: 12
diff changeset
  1543
        retVal = err;
hgs
parents: 12
diff changeset
  1544
        }
hgs
parents: 12
diff changeset
  1545
    else if(iAPIBeingUsed == EAudioRecorderUtility)
hgs
parents: 12
diff changeset
  1546
        {
hgs
parents: 12
diff changeset
  1547
        retVal = iAudioRecorder->SetVolume(volume);
hgs
parents: 12
diff changeset
  1548
        }
hgs
parents: 12
diff changeset
  1549
    return retVal;    
hgs
parents: 12
diff changeset
  1550
    }
hgs
parents: 12
diff changeset
  1551
hgs
parents: 12
diff changeset
  1552
XAresult CMMFBackendEngine::GetMaxVolume(XAuint32* maxvolume)
hgs
parents: 12
diff changeset
  1553
    {
hgs
parents: 12
diff changeset
  1554
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1555
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1556
        {
hgs
parents: 12
diff changeset
  1557
        *maxvolume = iAudioPlayer->MaxVolume();
hgs
parents: 12
diff changeset
  1558
        }
hgs
parents: 12
diff changeset
  1559
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1560
        {
hgs
parents: 12
diff changeset
  1561
        *maxvolume = iVideoPlayer->MaxVolume();
hgs
parents: 12
diff changeset
  1562
        }
hgs
parents: 12
diff changeset
  1563
    else if(iAPIBeingUsed == EAudioRecorderUtility)
hgs
parents: 12
diff changeset
  1564
        {
hgs
parents: 12
diff changeset
  1565
        *maxvolume = iAudioRecorder->MaxVolume();
hgs
parents: 12
diff changeset
  1566
        }
hgs
parents: 12
diff changeset
  1567
    return retVal;     
hgs
parents: 12
diff changeset
  1568
    }
hgs
parents: 12
diff changeset
  1569
hgs
parents: 12
diff changeset
  1570
XAresult CMMFBackendEngine::GetVolume(XAuint32* volume)
hgs
parents: 12
diff changeset
  1571
    {
hgs
parents: 12
diff changeset
  1572
    XAresult retVal(XA_RESULT_SUCCESS);
hgs
parents: 12
diff changeset
  1573
    TInt mmfvolume(0);
hgs
parents: 12
diff changeset
  1574
    if(iAPIBeingUsed == EAudioPlayerUtility)
hgs
parents: 12
diff changeset
  1575
        {
hgs
parents: 12
diff changeset
  1576
        retVal = iAudioPlayer->GetVolume(mmfvolume);
hgs
parents: 12
diff changeset
  1577
        if(retVal == XA_RESULT_SUCCESS)
hgs
parents: 12
diff changeset
  1578
            {
hgs
parents: 12
diff changeset
  1579
            *volume = mmfvolume;
hgs
parents: 12
diff changeset
  1580
            }
hgs
parents: 12
diff changeset
  1581
        }
hgs
parents: 12
diff changeset
  1582
    else if (iAPIBeingUsed == EVideoPlayerUtility)
hgs
parents: 12
diff changeset
  1583
        {
hgs
parents: 12
diff changeset
  1584
        *volume = iVideoPlayer->Volume();
hgs
parents: 12
diff changeset
  1585
        }
hgs
parents: 12
diff changeset
  1586
    else if(iAPIBeingUsed == EAudioRecorderUtility)
hgs
parents: 12
diff changeset
  1587
        {
hgs
parents: 12
diff changeset
  1588
        retVal = iAudioRecorder->GetVolume(mmfvolume);
hgs
parents: 12
diff changeset
  1589
        if(retVal == XA_RESULT_SUCCESS)
hgs
parents: 12
diff changeset
  1590
            {
hgs
parents: 12
diff changeset
  1591
            *volume = mmfvolume;
hgs
parents: 12
diff changeset
  1592
            }
hgs
parents: 12
diff changeset
  1593
        }
hgs
parents: 12
diff changeset
  1594
    return retVal;     
hgs
parents: 12
diff changeset
  1595
    }
hgs
parents: 12
diff changeset
  1596
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1597
extern "C" {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1598
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1599
    int mmf_backend_engine_init(void** engine)
19
hgs
parents: 12
diff changeset
  1600
    {
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1601
        TRAPD(err, *engine = CMMFBackendEngine::NewL());
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1602
        return err;
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1603
    }
19
hgs
parents: 12
diff changeset
  1604
hgs
parents: 12
diff changeset
  1605
    void mmf_backend_engine_deinit(void* engine)
hgs
parents: 12
diff changeset
  1606
    {
hgs
parents: 12
diff changeset
  1607
        delete ((CMMFBackendEngine*)engine);
hgs
parents: 12
diff changeset
  1608
    }
hgs
parents: 12
diff changeset
  1609
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1610
    int mmf_set_recorder_uri(void* context, char* uri, XAuint32 format)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1611
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1612
        return ((CMMFBackendEngine*)(context))->SetFileName(uri,format,CMMFBackendEngine::ERecord);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1613
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1614
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1615
    int mmf_set_adapt_context(void* context, void* adaptcontext)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1616
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1617
        return ((CMMFBackendEngine*)(context))->SetAdaptContext(adaptcontext);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1618
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1619
19
hgs
parents: 12
diff changeset
  1620
    void mmf_close(void* context)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1621
    {
19
hgs
parents: 12
diff changeset
  1622
        ((CMMFBackendEngine*)context)->Close();
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1623
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1624
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1625
    int mmf_start_recording(void* context)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1626
    {
19
hgs
parents: 12
diff changeset
  1627
        return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderRecording,FALSE);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1628
    }
19
hgs
parents: 12
diff changeset
  1629
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1630
    int mmf_stop_recording(void* context, XAboolean stopCalled )
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1631
    {
19
hgs
parents: 12
diff changeset
  1632
        return ((CMMFBackendEngine*)(context))->SetRecorderState(CMMFBackendEngine::ERecorderOpen, stopCalled);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1633
    }
19
hgs
parents: 12
diff changeset
  1634
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1635
    int mmf_get_record_position(void* context, XAuint64* position)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1636
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1637
        return ((CMMFBackendEngine*)(context))->GetRecordPosition(position);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1638
    }
19
hgs
parents: 12
diff changeset
  1639
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1640
    int mmf_set_record_position_update_period(void* context, XAmillisecond msec)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1641
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1642
        return ((CMMFBackendEngine*)(context))->SetPositionUpdatePerioed(msec);
19
hgs
parents: 12
diff changeset
  1643
    }
hgs
parents: 12
diff changeset
  1644
hgs
parents: 12
diff changeset
  1645
    int mmf_get_codec_id(void* context, XAuint32* encoderId)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1646
    {
19
hgs
parents: 12
diff changeset
  1647
        return ((CMMFBackendEngine*)(context))->GetCodecId(encoderId);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1648
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1649
19
hgs
parents: 12
diff changeset
  1650
    int mmf_get_channels(void* context, XAuint32* channelsIn)
hgs
parents: 12
diff changeset
  1651
    {
hgs
parents: 12
diff changeset
  1652
        return ((CMMFBackendEngine*)(context))->GetChannels(channelsIn);
hgs
parents: 12
diff changeset
  1653
    }
hgs
parents: 12
diff changeset
  1654
hgs
parents: 12
diff changeset
  1655
    int mmf_get_samplerate(void* context, XAmilliHertz* sampleRate)
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1656
    {
19
hgs
parents: 12
diff changeset
  1657
        return ((CMMFBackendEngine*)(context))->GetSampleRate(sampleRate);
hgs
parents: 12
diff changeset
  1658
    }
hgs
parents: 12
diff changeset
  1659
hgs
parents: 12
diff changeset
  1660
    int mmf_get_bitrate(void* context, XAuint32* bitRate)
hgs
parents: 12
diff changeset
  1661
    {
hgs
parents: 12
diff changeset
  1662
        return ((CMMFBackendEngine*)(context))->GetBitRate(bitRate);
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1663
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1664
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1665
    int mmf_set_destination_channels(void* context, XAuint32* channelsIn)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1666
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1667
        return ((CMMFBackendEngine*)(context))->SetDestinationChannels(channelsIn);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1668
    }
19
hgs
parents: 12
diff changeset
  1669
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1670
    int mmf_set_destination_samplerate(void* context, XAmilliHertz* sampleRate)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1671
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1672
        return ((CMMFBackendEngine*)(context))->SetDestinationSampleRate(sampleRate);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1673
    }
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1674
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1675
    int mmf_set_destination_bitrate(void* context, XAuint32* bitRate)
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1676
    {
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1677
        return ((CMMFBackendEngine*)(context))->SetDestinationBitRate(bitRate);
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1678
    }
19
hgs
parents: 12
diff changeset
  1679
hgs
parents: 12
diff changeset
  1680
    XAresult mmf_set_play_adapt_context(void * context, void * adaptcontext)
hgs
parents: 12
diff changeset
  1681
    {
hgs
parents: 12
diff changeset
  1682
        return ((CMMFBackendEngine *)(context))->SetPlayAdaptContext(adaptcontext);
hgs
parents: 12
diff changeset
  1683
    }
hgs
parents: 12
diff changeset
  1684
hgs
parents: 12
diff changeset
  1685
    XAresult mmf_set_player_uri(void * context, char * uri, XAuint32 format)
hgs
parents: 12
diff changeset
  1686
    {
hgs
parents: 12
diff changeset
  1687
        return ((CMMFBackendEngine *)(context))->SetFileName(uri,format,CMMFBackendEngine::EPlay);
hgs
parents: 12
diff changeset
  1688
    }
hgs
parents: 12
diff changeset
  1689
hgs
parents: 12
diff changeset
  1690
/*
hgs
parents: 12
diff changeset
  1691
    XAresult mmf_set_window_handle(void * context, void *  display_info)
hgs
parents: 12
diff changeset
  1692
    {
hgs
parents: 12
diff changeset
  1693
        return ((CMMFBackendEngine *)(context))->SetWindowHandle(display_info);
hgs
parents: 12
diff changeset
  1694
    }
hgs
parents: 12
diff changeset
  1695
hgs
parents: 12
diff changeset
  1696
*/
hgs
parents: 12
diff changeset
  1697
    XAresult mmf_setup_native_display(void * context, void * display_info)
hgs
parents: 12
diff changeset
  1698
    {
hgs
parents: 12
diff changeset
  1699
        return ((CMMFBackendEngine *)(context))->SetNativeDisplayInformation(display_info);
hgs
parents: 12
diff changeset
  1700
    }
hgs
parents: 12
diff changeset
  1701
hgs
parents: 12
diff changeset
  1702
    XAresult mmf_playitf_resume_playback(void * context)
hgs
parents: 12
diff changeset
  1703
    {
hgs
parents: 12
diff changeset
  1704
        return ((CMMFBackendEngine *)(context))->ResumePlayback();
hgs
parents: 12
diff changeset
  1705
    }
hgs
parents: 12
diff changeset
  1706
hgs
parents: 12
diff changeset
  1707
    XAresult mmf_playitf_pause_playback(void * context)
hgs
parents: 12
diff changeset
  1708
    {
hgs
parents: 12
diff changeset
  1709
        return ((CMMFBackendEngine *)(context))->PausePlayback();
hgs
parents: 12
diff changeset
  1710
    }
hgs
parents: 12
diff changeset
  1711
hgs
parents: 12
diff changeset
  1712
    XAresult mmf_playitf_stop_playback(void * context)
hgs
parents: 12
diff changeset
  1713
    {
hgs
parents: 12
diff changeset
  1714
        return ((CMMFBackendEngine *)(context))->StopPlayback();
hgs
parents: 12
diff changeset
  1715
    }
hgs
parents: 12
diff changeset
  1716
hgs
parents: 12
diff changeset
  1717
    XAresult mmf_playitf_get_play_state(void * context, XAuint32 * pState)
hgs
parents: 12
diff changeset
  1718
    {
hgs
parents: 12
diff changeset
  1719
        return ((CMMFBackendEngine *)(context))->GetPlayState(pState);
hgs
parents: 12
diff changeset
  1720
    }
hgs
parents: 12
diff changeset
  1721
hgs
parents: 12
diff changeset
  1722
    XAresult mmf_playitf_get_duration(void * context, XAmillisecond * pMsec)
hgs
parents: 12
diff changeset
  1723
    {
hgs
parents: 12
diff changeset
  1724
        return ((CMMFBackendEngine *)(context))->GetDuration(pMsec);
hgs
parents: 12
diff changeset
  1725
    }
hgs
parents: 12
diff changeset
  1726
hgs
parents: 12
diff changeset
  1727
    XAresult mmf_playitf_get_position(void * context, XAmillisecond * pMsec)
hgs
parents: 12
diff changeset
  1728
    {
hgs
parents: 12
diff changeset
  1729
        return ((CMMFBackendEngine *)(context))->GetPosition(pMsec);
hgs
parents: 12
diff changeset
  1730
    }
hgs
parents: 12
diff changeset
  1731
hgs
parents: 12
diff changeset
  1732
    XAresult mmf_playitf_register_callback(void * context, xaPlayCallback callback)
hgs
parents: 12
diff changeset
  1733
    {
hgs
parents: 12
diff changeset
  1734
        return ((CMMFBackendEngine *)(context))->RegisterCallback(callback);
hgs
parents: 12
diff changeset
  1735
    }
hgs
parents: 12
diff changeset
  1736
hgs
parents: 12
diff changeset
  1737
    XAresult mmf_playitf_set_callback_events_mask(void * context, XAuint32 eventflags)
hgs
parents: 12
diff changeset
  1738
    {
hgs
parents: 12
diff changeset
  1739
        return ((CMMFBackendEngine *)(context))->SetCallbackEventsMask(eventflags);
hgs
parents: 12
diff changeset
  1740
    }
hgs
parents: 12
diff changeset
  1741
hgs
parents: 12
diff changeset
  1742
    XAresult mmf_playitf_set_marker_position(void * context, XAmillisecond mSec)
hgs
parents: 12
diff changeset
  1743
    {
hgs
parents: 12
diff changeset
  1744
        return ((CMMFBackendEngine *)(context))->SetMarkerPosition(mSec);
hgs
parents: 12
diff changeset
  1745
    }
hgs
parents: 12
diff changeset
  1746
hgs
parents: 12
diff changeset
  1747
    XAresult mmf_playitf_clear_marker_position(void * context)
hgs
parents: 12
diff changeset
  1748
    {
hgs
parents: 12
diff changeset
  1749
        return ((CMMFBackendEngine *)(context))->ClearMarkerPosition();
hgs
parents: 12
diff changeset
  1750
hgs
parents: 12
diff changeset
  1751
    }
hgs
parents: 12
diff changeset
  1752
hgs
parents: 12
diff changeset
  1753
    XAresult mmf_playitf_set_position_update_period(void * context, XAmillisecond mSec)
hgs
parents: 12
diff changeset
  1754
    {
hgs
parents: 12
diff changeset
  1755
        return ((CMMFBackendEngine *)(context))->SetPositionUpdatePeriod(mSec);
hgs
parents: 12
diff changeset
  1756
    }
hgs
parents: 12
diff changeset
  1757
hgs
parents: 12
diff changeset
  1758
    XAresult mmf_seekitf_set_position(void * context, XAmillisecond pMsec)
hgs
parents: 12
diff changeset
  1759
    {
hgs
parents: 12
diff changeset
  1760
        return ((CMMFBackendEngine *)(context))->SetPosition(pMsec);
hgs
parents: 12
diff changeset
  1761
    }
hgs
parents: 12
diff changeset
  1762
hgs
parents: 12
diff changeset
  1763
    XAresult mmf_seekitf_set_playwindow(void * context, XAmillisecond start, XAmillisecond end)
hgs
parents: 12
diff changeset
  1764
    {
hgs
parents: 12
diff changeset
  1765
        return ((CMMFBackendEngine *)(context))->SetPlayWindow(start,end);
hgs
parents: 12
diff changeset
  1766
    }
hgs
parents: 12
diff changeset
  1767
hgs
parents: 12
diff changeset
  1768
    XAresult mmf_seekitf_set_repeats(void * context, XAboolean repeat)
hgs
parents: 12
diff changeset
  1769
    {
hgs
parents: 12
diff changeset
  1770
        return ((CMMFBackendEngine *)(context))->SetRepeats(repeat);
hgs
parents: 12
diff changeset
  1771
    }
hgs
parents: 12
diff changeset
  1772
hgs
parents: 12
diff changeset
  1773
    XAresult mmf_streaminformationitf_get_streaminfo(void * context, XAuint32 streamindex,
hgs
parents: 12
diff changeset
  1774
                                                                    XAuint32* streamtype)
hgs
parents: 12
diff changeset
  1775
    {
hgs
parents: 12
diff changeset
  1776
        return ((CMMFBackendEngine *)(context))->GetStreamInfo(streamindex, streamtype);
hgs
parents: 12
diff changeset
  1777
    }
hgs
parents: 12
diff changeset
  1778
hgs
parents: 12
diff changeset
  1779
    XAresult mmf_streaminformationitf_get_numstreams(void * context, XAuint32* numstreams)
hgs
parents: 12
diff changeset
  1780
    {
hgs
parents: 12
diff changeset
  1781
        return ((CMMFBackendEngine *)(context))->GetNumStreams(numstreams);
hgs
parents: 12
diff changeset
  1782
    }
hgs
parents: 12
diff changeset
  1783
hgs
parents: 12
diff changeset
  1784
    XAresult mmf_streaminformationitf_get_videoframesize(void * context, XAuint32* height,
hgs
parents: 12
diff changeset
  1785
                                                        XAuint32* width, XAuint32* frameRate)
hgs
parents: 12
diff changeset
  1786
    {
hgs
parents: 12
diff changeset
  1787
        return ((CMMFBackendEngine *)(context))->GetVideoFrameSize(height,width,frameRate);
hgs
parents: 12
diff changeset
  1788
    }
hgs
parents: 12
diff changeset
  1789
hgs
parents: 12
diff changeset
  1790
    XAresult mmf_streaminformationitf_set_activestream(void * context, XAuint32 streamindex,
hgs
parents: 12
diff changeset
  1791
                                                                    XAboolean active)
hgs
parents: 12
diff changeset
  1792
    {
hgs
parents: 12
diff changeset
  1793
        return ((CMMFBackendEngine *)(context))->SetActiveState(streamindex, active);
hgs
parents: 12
diff changeset
  1794
    }
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1795
    
19
hgs
parents: 12
diff changeset
  1796
    XAresult mmf_volumeitf_set_volume(void * context, XAuint32 volume)
hgs
parents: 12
diff changeset
  1797
    {
hgs
parents: 12
diff changeset
  1798
        return ((CMMFBackendEngine *)(context))->SetVolume(volume);
hgs
parents: 12
diff changeset
  1799
    }    
hgs
parents: 12
diff changeset
  1800
hgs
parents: 12
diff changeset
  1801
    XAresult mmf_volumeitf_get_maxvolume(void * context, XAuint32* volume)
hgs
parents: 12
diff changeset
  1802
    {
hgs
parents: 12
diff changeset
  1803
        return ((CMMFBackendEngine *)(context))->GetMaxVolume(volume);
hgs
parents: 12
diff changeset
  1804
    }    
hgs
parents: 12
diff changeset
  1805
    
hgs
parents: 12
diff changeset
  1806
    XAresult mmf_volumeitf_get_volume(void * context, XAuint32* volume)
hgs
parents: 12
diff changeset
  1807
    {
hgs
parents: 12
diff changeset
  1808
        return ((CMMFBackendEngine *)(context))->GetVolume(volume);
hgs
parents: 12
diff changeset
  1809
    }     
12
5a06f39ad45b Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1810
}