camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp
author hgs
Thu, 15 Jul 2010 01:55:05 +0300
changeset 43 0e652f8f1fbd
parent 28 3075d9b614e6
child 45 24fd82631616
permissions -rw-r--r--
201027_1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
     2
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
d9aefe59d544 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
d9aefe59d544 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"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
d9aefe59d544 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".
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    17
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    18
#include <algorithm>
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    19
#include <exception>
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <QTime>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
#include <QPixmap>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <coemain.h>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
#include <QStringList>
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    25
#include "cxeexception.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
#include "cxevideocapturecontrolsymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include "cxevideorecorderutilitysymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
#include "cxecameradevicecontrolsymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
#include "cxefilenamegeneratorsymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include "cxeerrormappingsymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
#include "cxeviewfindercontrol.h"
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    32
#include "cxesnapshotcontrol.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
#include "cxestillimagesymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include "cxecameradevice.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
#include "cxutils.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "cxestate.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "cxesettings.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
#include "cxenamespace.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "cxesoundplayersymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "cxequalitypresetssymbian.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "cxeviewfindercontrolsymbian.h"
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    42
#include "cxediskmonitor.h"
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    43
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    44
#include "OstTraceDefinitions.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
#ifdef OST_TRACE_COMPILER_IN_USE
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "cxevideocapturecontrolsymbianTraces.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#endif
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
// constants
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    51
namespace
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    52
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    53
    // TMMFEvent UIDs for Async stop
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    54
    const TUid KCamCControllerCCVideoRecordStopped = {0x2000E546};
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    55
    const TUid KCamCControllerCCVideoFileComposed = {0x2000E547};
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    56
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    57
    const TInt64  KMinRequiredSpaceVideo      = 4000000;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    58
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
* CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
*/
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    64
CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian(
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    65
    CxeCameraDevice &cameraDevice,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    66
    CxeViewfinderControl &viewfinderControl,
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    67
    CxeSnapshotControl &snapshotControl,
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    68
    CxeCameraDeviceControl &cameraDeviceControl,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    69
    CxeFilenameGenerator &nameGenerator,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    70
    CxeSettings &settings,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    71
    CxeQualityPresets &qualityPresets,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    72
    CxeDiskMonitor &diskMonitor)
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    73
    : CxeStateMachine("CxeVideoCaptureControlSymbian"),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    74
      mVideoRecorder(NULL),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    75
      mCameraDevice(cameraDevice),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    76
      mCameraDeviceControl(cameraDeviceControl),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    77
      mViewfinderControl(viewfinderControl),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    78
      mSnapshotControl(snapshotControl),
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    79
      mFilenameGenerator(nameGenerator),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    80
      mSettings(settings),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    81
      mQualityPresets(qualityPresets),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    82
      mDiskMonitor(diskMonitor),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    83
      mSnapshot(),
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    84
      mVideoStartSoundPlayer(NULL),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    85
      mVideoStopSoundPlayer(NULL),
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    86
      mCurrentFilename("")
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
    CX_DEBUG_ENTER_FUNCTION();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    89
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_IN, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 1");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
    qRegisterMetaType<CxeVideoCaptureControl::State> ();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    initializeStates();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    93
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
    mVideoStopSoundPlayer = new
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    95
             CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStop,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    96
                                   mSettings);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
    mVideoStartSoundPlayer = new
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    98
             CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStart,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
    99
                                   mSettings);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   101
    // If camera is already allocated, call the slot ourselves.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   102
    if (mCameraDevice.camera()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   103
        handleCameraAllocated(CxeError::None);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   104
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   105
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   106
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M1, "msg: e_CX_ENGINE_CONNECT_SIGNALS 1");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    // connect signals from cameraDevice, so we recieve events when camera reference changes
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
    connect(&cameraDevice, SIGNAL(prepareForCameraDelete()),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
            this, SLOT(prepareForCameraDelete()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    connect(&cameraDevice, SIGNAL(prepareForRelease()),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
            this, SLOT(prepareForRelease()) );
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    connect(&cameraDevice, SIGNAL(cameraAllocated(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
            this, SLOT(handleCameraAllocated(CxeError::Id)));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   114
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
    // connect playing sound signals
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    connect(mVideoStartSoundPlayer, SIGNAL(playComplete(int)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
            this, SLOT(handleSoundPlayed()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   119
    // connect snapshot ready signal
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   120
    connect(&mSnapshotControl, SIGNAL(snapshotReady(CxeError::Id, const QImage&)),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   121
            this, SLOT(handleSnapshotReady(CxeError::Id, const QImage&)));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   122
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
    // enabling setting change callbacks to videocapturecontrol
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
            this, SLOT(handleSettingValueChanged(const QString&,QVariant)));
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   126
    connect(&mSettings, SIGNAL(sceneChanged(CxeScene&)),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   127
            this, SLOT(handleSceneChanged(CxeScene&)));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   128
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0");
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   129
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   130
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_OUT, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 0");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
* CxeVideoCaptureControlSymbian::~CxeVideoCaptureControlSymbian()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
CxeVideoCaptureControlSymbian::~CxeVideoCaptureControlSymbian()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
    releaseResources();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
    mIcmSupportedVideoResolutions.clear();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    delete mVideoStartSoundPlayer;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    delete mVideoStopSoundPlayer;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
* Initializes resources for video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
void CxeVideoCaptureControlSymbian::init()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
    OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_INIT, "msg: e_CX_VIDEO_CAPCONT_INIT 1" );
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    if (state() == Idle) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
        // start initializing resources for video capture
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
        initVideoRecorder();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
    } else if (state() == Initialized) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
        // video recorder already initalized. Continue to prepare video reocording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
        open();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_INIT, "msg: e_CX_VIDEO_CAPCONT_INIT 0" );
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   169
/*!
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
* Releases all resources
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
void CxeVideoCaptureControlSymbian::deinit()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   176
    // Nothing to do if already idle.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   177
    if(state() != Idle) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   178
        OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 1" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   180
        // first stop viewfinder
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   181
        mViewfinderControl.stop();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   182
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   183
        // stop video-recording in-case if its ongoing.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   184
        stop();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   185
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   186
        // Check if state is stopping, in which case we have to inform the
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   187
        // file harvester that a file is to be completed. We would not
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   188
        // call harvestFile otherwise in this case.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   189
        // Otherwise the video will not be found from videos app.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   190
        if (state() == Stopping) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   191
            emit videoComposed(CxeError::None, mCurrentFilename);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   192
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   194
        mSnapshotControl.stop();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   196
        if (mVideoRecorder) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   197
            mVideoRecorder->close();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   198
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   200
        setState(Idle);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   202
        OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 0" );
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   203
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
* Intializes VideoRecorder for recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
void CxeVideoCaptureControlSymbian::initVideoRecorder()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   214
    // Init needed only in Idle state
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   215
    if (state() == Idle) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   216
        try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   217
            // if video recorder is not created, do it now.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   218
            createVideoRecorder();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   220
            // update current video quality details from icm.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   221
            // Throws an error if unable to get the quality.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   222
            getVideoQualityDetails(mCurrentVideoDetails);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   224
            // Video recorder is ready to open video file for recording.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
            setState(Initialized);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
            open();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   227
        } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   228
            // Handle error
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   229
            handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
* Opens file for video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
void CxeVideoCaptureControlSymbian::open()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   243
    // Check valid state to start "open" operation
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   244
    if (state() == Initialized) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   245
        try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   246
            // generate video file name, if necessary
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   247
            generateFilename();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   248
            CX_DEBUG(( "Next video file path: %s", mCurrentFilename.toAscii().constData() ));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   250
            // Start preparing..
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   251
            setState(CxeVideoCaptureControl::Preparing);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   253
            // Exception thrown if open fails.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   254
            mVideoRecorder->open(mCameraDevice.camera()->Handle(),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   255
                                 mCurrentFilename,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   256
                                 mCurrentVideoDetails.mVideoFileMimeType,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   257
                                 mCurrentVideoDetails.mPreferredSupplier,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   258
                                 mCurrentVideoDetails.mVideoCodecMimeType,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   259
                                 mCurrentVideoDetails.mAudioType);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   260
        } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   261
            handlePrepareFailed();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   262
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   268
* Helper method for generating filename.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   269
* Throws exception, if file type mime is formatted wrong or
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   270
* filename generation fails.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
*/
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   272
void CxeVideoCaptureControlSymbian::generateFilename()
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   275
    mCurrentFilename = QString("");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   277
    QStringList list = mCurrentVideoDetails.mVideoFileMimeType.split("/");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   278
    // Throw exception if mime string is formatted wrong.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   279
    if (list.count() != 2) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   280
        throw new CxeException(CxeError::General);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   281
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   282
    QString fileExt = "." + list[1];
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   284
    // Generate new filename and open the file for writing video data
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   285
    CxeException::throwIfError(mFilenameGenerator.generateFilename(mCurrentFilename, fileExt));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   287
    CX_DEBUG_EXIT_FUNCTION();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
* Prepare Video Recorder with necessary settings for video capture.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
void CxeVideoCaptureControlSymbian::prepare()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
    if (state() != Preparing) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
        // not valid state to continue prepare.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
        return;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   302
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_1, "msg: e_CX_VIDCAPCONT_PREPARE 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   303
    QSize frameSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    int muteSetting = 0; // audio enabled
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
    mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   308
    // Check if scene defines frame rate.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   309
    // Use generic frame rate defined in video details, if no value is set in scene.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   310
    int frameRate = 0;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   311
    mSettings.get(CxeSettingIds::FRAME_RATE, frameRate);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   312
    if (frameRate <= 0) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   313
        frameRate = mCurrentVideoDetails.mVideoFrameRate;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   314
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   315
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   316
    CX_DEBUG(("Video resolution (%d,%d)", mCurrentVideoDetails.mWidth,
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   317
                                           mCurrentVideoDetails.mHeight));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   318
    CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   319
    CX_DEBUG(("Video frame rate = %d)", frameRate));
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   320
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   321
    try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   322
        mVideoRecorder->setVideoFrameSize(frameSize);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   323
        mVideoRecorder->setVideoFrameRate(frameRate);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   324
        mVideoRecorder->setVideoBitRate(mCurrentVideoDetails.mVideoBitRate);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   325
        mVideoRecorder->setAudioEnabled(muteSetting == 0);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   326
        // "No limit" value is handled in video recorder wrapper.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   327
        mVideoRecorder->setVideoMaxSize(mCurrentVideoDetails.mMaximumSizeInBytes);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   328
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   329
        // Settings have been applied successfully, start to prepare.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   330
        mVideoRecorder->prepare();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   332
        // Prepare snapshot. Snapshot control throws error if problems.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   333
        QSize snapshotSize = mSnapshotControl.calculateSnapshotSize(
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   334
                                mViewfinderControl.deviceDisplayResolution(),
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   335
                                mCurrentVideoDetails.mAspectRatio);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   336
        mSnapshotControl.start(snapshotSize);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   337
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   338
        // Prepare zoom only when there are no errors during prepare.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   339
        emit prepareZoomForVideo();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   340
        emit videoPrepareComplete(CxeError::None);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   341
    } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   342
        // Handle error.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   343
        handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   345
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   346
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_2, "msg: e_CX_VIDCAPCONT_PREPARE 0");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   348
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   349
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   350
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   351
* Fetches video qualites details based on video quality setting.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   352
*/
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   353
void
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   354
CxeVideoCaptureControlSymbian::getVideoQualityDetails(CxeVideoDetails &videoInfo)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   355
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   356
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   357
    OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_GETQUALITYDETAILS_1, "msg: e_CX_GET_QUALITY_DETAILS 1" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   359
    int quality(0);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   360
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   361
    // Get quality index for primary camera. Only one quality for secondary camera.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   362
    if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   363
        CxeException::throwIfError(mSettings.get(CxeSettingIds::VIDEO_QUALITY, quality));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   366
    if (quality < 0 || quality >= mIcmSupportedVideoResolutions.count()) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   367
       throw new CxeException(CxeError::NotFound);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   368
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   370
    // get video quality details
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   371
    videoInfo = mIcmSupportedVideoResolutions.at(quality);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   373
    OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_GETQUALITYDETAILS_2, "msg: e_CX_GET_QUALITY_DETAILS 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
* Resets the video snapshot and current video filename
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
void CxeVideoCaptureControlSymbian::reset()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
    // Snapshot will consume considerably memory.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
    // Replace it with null pixmap to have it freed.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
    mSnapshot = QPixmap();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
    // reset the current file name.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
    mCurrentFilename = QString("");
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
* Returns current video filename
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
QString CxeVideoCaptureControlSymbian::filename() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
    // Simply return the current contents of mCurrentFilename.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
    // If video recording was started then it returns proper filename
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    // otherwise an empty string is returned.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
    return mCurrentFilename;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
* Returns current video snapshot
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
QPixmap CxeVideoCaptureControlSymbian::snapshot() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
    return mSnapshot;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
* Starts video recording if we are in appropriate state.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
void CxeVideoCaptureControlSymbian::record()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
    if (state() == Ready || state() == Paused) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
        // ask the player to play the sound
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
        // recording will start once start sound is played
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
        setState(CxeVideoCaptureControl::PlayingStartSound);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
        mVideoStartSoundPlayer->play();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
* Pauses video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
void CxeVideoCaptureControlSymbian::pause()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   435
    try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   436
        mVideoRecorder->pause();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   437
        setState(CxeVideoCaptureControl::Paused);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   438
        // play the sound, but not changing the state
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   439
        mVideoStopSoundPlayer->play();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   440
    } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   441
        handleComposeFailed(qt_symbian_exception2Error(e));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
* Stops video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
void CxeVideoCaptureControlSymbian::stop()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
    if (state() == Recording || state() == Paused) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        // first stop viewfinder
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
        mViewfinderControl.stop();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   457
        try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   458
            // Try asynchronous stopping first.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   459
            mVideoRecorder->stop(true);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   460
            // No error from asynchronous stop -> wait for stop event
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   461
            setState(Stopping);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   462
        } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   463
            CX_DEBUG(("CxeVideoCaptureControlSymbian - async stop failed, try sync.."));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   464
            try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   465
                mVideoRecorder->stop(false);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   466
                // stopping went ok
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   467
                emulateNormalStopping();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   468
            } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   469
                // Even synchronous stopping failed -> release resources.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   470
                CX_DEBUG(("CxeVideoCaptureControlSymbian - sync stop failed, too!"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   471
                handleComposeFailed(qt_symbian_exception2Error(e));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
            }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
* Callback when "Open" operation is complete.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
void CxeVideoCaptureControlSymbian::MvruoOpenComplete(TInt aError)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoOpenComplete, err=%d", aError));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    if (state() == Preparing) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   488
        if (!aError) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   489
            prepare();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
        } else {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   491
            handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
* Callback when "Prepare" request is complete.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
void CxeVideoCaptureControlSymbian::MvruoPrepareComplete(TInt aError)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoPrepareComplete, err=%d", aError));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
    if (state() == Preparing) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
        if (!aError) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
            setState(CxeVideoCaptureControl::Ready);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
            mViewfinderControl.start();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   510
            OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 0" );
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
        } else {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   512
            handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
* Callback when "Record" operation is complete.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
void CxeVideoCaptureControlSymbian::MvruoRecordComplete(TInt aError)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoRecordComplete, err=%d", aError));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
    //! async stop customcommand stuff
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
    if (aError == KErrNone) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        setState(CxeVideoCaptureControl::Ready);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
    } else if (aError == KErrCompletion) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        // KErrCompletion is received when video recording stops
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
        // because of maximum clip size is reached. Emulate
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        // normal stopping.
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   534
        emulateNormalStopping();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
    else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
        // error during recording, report to client
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   538
        handleComposeFailed(aError);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
* Callback from MVideoRecorderUtilityObserver
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
void CxeVideoCaptureControlSymbian::MvruoEvent(const TMMFEvent& aEvent)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
    if (aEvent.iEventType.iUid == KCamCControllerCCVideoRecordStopped.iUid) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
        CX_DEBUG(("KCamCControllerCCVideoRecordStopped"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
        // play the sound, but not changing the state
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
        mVideoStopSoundPlayer->play();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    } else if (aEvent.iEventType.iUid == KCamCControllerCCVideoFileComposed.iUid) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
        CX_DEBUG(("KCamCControllerCCVideoFileComposed"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
        if (state() == Stopping) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
            // stop operation went fine, set back the state to intialized.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
            setState(Initialized);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
        }
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   561
        mFilenameGenerator.raiseCounterValue();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
        // video file has composed, everything went well, inform the client
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
        emit videoComposed(CxeError::None, filename());
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
    } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
        CX_DEBUG(("ignoring unknown MvruoEvent 0x%08x", aEvent.iEventType.iUid ));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
* camera reference changing, release resources
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
void CxeVideoCaptureControlSymbian::prepareForCameraDelete()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    releaseResources();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
* prepare for camera release.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
void CxeVideoCaptureControlSymbian::prepareForRelease()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
    deinit();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   592
* new camera available
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
void CxeVideoCaptureControlSymbian::handleCameraAllocated(CxeError::Id error)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
    if (!error) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   599
        try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   600
            // Create the video recorder utility
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   601
            createVideoRecorder();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   602
        } catch (...) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   603
            // We are just trying to create the recorder early.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   604
            // Retry later when preparing, and fail then if
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   605
            // error still persists.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   606
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
        // new camera available, read supported video qualities from icm
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   608
        // load all video qualities supported by icm
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
        mIcmSupportedVideoResolutions.clear();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
        Cxe::CameraIndex cameraIndex = mCameraDeviceControl.cameraIndex();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
        // get list of supported image qualities based on camera index
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
        mIcmSupportedVideoResolutions =
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
                mQualityPresets.videoQualityPresets(cameraIndex);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
* Initializes video recorder.
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   621
* May throw exception.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
void CxeVideoCaptureControlSymbian::createVideoRecorder()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   626
    if (mVideoRecorder == NULL) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   627
        mVideoRecorder = new CxeVideoRecorderUtilitySymbian(*this);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   633
* releases resources used by video capture control
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
void CxeVideoCaptureControlSymbian::releaseResources()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
    // first de-init videocapture control
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
    deinit();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
    reset();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
    delete mVideoRecorder;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    mVideoRecorder = NULL;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   650
* Returns current state of video capture control
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
CxeVideoCaptureControl::State CxeVideoCaptureControlSymbian::state() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
    return static_cast<CxeVideoCaptureControl::State> (stateId());
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   658
* Called when state is changed.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
void CxeVideoCaptureControlSymbian::handleStateChanged(int newStateId, CxeError::Id error)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
{
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   662
    switch (newStateId) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   663
    case Ready:
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   664
        if (error == CxeError::None && !mDiskMonitor.isMonitoring()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   665
            mDiskMonitor.start();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   666
            connect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   667
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   668
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   669
    default:
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   670
        // Stop monitoring when video mode is released.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   671
        // Same goes during recording, as video times come from recorder.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   672
        if (mDiskMonitor.isMonitoring()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   673
            mDiskMonitor.stop();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   674
            disconnect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   675
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   676
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   677
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    emit stateChanged(static_cast<State> (newStateId), error);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
* Initialize states for videocapturecontrol
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
void CxeVideoCaptureControlSymbian::initializeStates()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
    // addState( id, name, allowed next states )
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
    addState(new CxeState(Idle, "Idle", Initialized));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
    addState(new CxeState(Initialized, "Initialized", Preparing | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
    addState(new CxeState(Preparing, "Preparing", Ready | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
    addState(new CxeState(Ready, "Ready", Recording | PlayingStartSound | Preparing | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
    addState(new CxeState(Recording, "Recording", Recording | Paused | Stopping | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
    addState(new CxeState(Paused, "Paused", Recording | Stopping | PlayingStartSound | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
    addState(new CxeState(Stopping, "Stopping", Initialized | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
    addState(new CxeState(PlayingStartSound, "PlayingStartSound", Recording | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
    setInitialState(Idle);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
* Updates remaining video recordng time counter to all the video qualities supported by ICM
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
* this should be done whenever storage location setting changes and when values are
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
* read from ICM for the first time
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
void CxeVideoCaptureControlSymbian::updateRemainingRecordingTimeCounter()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    for( int index = 0; index < mIcmSupportedVideoResolutions.count(); index++) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
        CxeVideoDetails &qualityDetails = mIcmSupportedVideoResolutions[index];
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   710
        qualityDetails.mRemainingTime = calculateRemainingTime(qualityDetails);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   716
/*!
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
* calculates remaining video recording time.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
void CxeVideoCaptureControlSymbian::remainingTime(int &time)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   723
    if (state() == CxeVideoCaptureControl::Recording ||
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   724
        state() == CxeVideoCaptureControl::Paused) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   725
        time = mVideoRecorder->availableRecordingTime();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   726
        CX_DEBUG(("CxeVideoCaptureControlSymbian - time remaining: %d", time));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
    } else {
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   728
        // Check if we need to recalculate the remaining time.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   729
        if (mCurrentVideoDetails.mRemainingTime == CxeVideoDetails::UNKNOWN) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   730
            mCurrentVideoDetails.mRemainingTime = calculateRemainingTime(mCurrentVideoDetails);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   731
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   732
        time = mCurrentVideoDetails.mRemainingTime;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   739
* Get the remaining recording time
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   740
* @param videoDetails Contains the current video resolution that is in use.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   741
* @return The remaining recording time
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
*/
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   743
int CxeVideoCaptureControlSymbian::calculateRemainingTime(const CxeVideoDetails& videoDetails)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
    CX_DEBUG_ENTER_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   746
    qint64 availableSpace = mDiskMonitor.free() - KMinRequiredSpaceVideo;
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   747
    int time = mQualityPresets.recordingTimeAvailable(videoDetails, availableSpace);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
    CX_DEBUG_EXIT_FUNCTION();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   749
    return time;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
/*!
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   753
* Calculates elapsed recording time during video recording
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   754
* @return Did fetching elapsed time succeed.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
bool CxeVideoCaptureControlSymbian::elapsedTime(int &time)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
    bool ok = false;
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   761
    if (state() == CxeVideoCaptureControl::Recording ||
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   762
        state() == CxeVideoCaptureControl::Paused) {
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   763
        try {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   764
            time = mVideoRecorder->duration();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   765
            CX_DEBUG(("CxeVideoCaptureControlSymbian - elapsed: %d", time));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
            ok = true;
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   767
        } catch (const std::exception &e) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   768
            // Returning false.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
    return ok;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
* slot called when playing a sound has finished.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
void CxeVideoCaptureControlSymbian::handleSoundPlayed()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
    // start recording, if we were playing capture sound
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
    if (state() == CxeVideoCaptureControl::PlayingStartSound) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
        setState(CxeVideoCaptureControl::Recording);
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   786
        mVideoRecorder->record();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
    // in case of video capture stop sound playing, nothing needs to be done
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    // meaning the state set elsewhere, and the video capture has been stopped already
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   795
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   796
* Handle new snapshot.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   797
* @param status Status code for getting the snapshot.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   798
* @param snapshot Snapshot pixmap. Empty if error code reported.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   799
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   800
void CxeVideoCaptureControlSymbian::handleSnapshotReady(CxeError::Id status, const QImage &snapshot)
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   801
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   802
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   803
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   804
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   805
        OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_HANDLESNAPSHOT_1, "msg: e_CX_HANDLE_SNAPSHOT 1");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   806
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   807
        // Need to store snapshot for ui to be able to get it also later.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   808
        mSnapshot = QPixmap::fromImage(snapshot);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   809
        emit snapshotReady(status, snapshot, filename());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   810
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   811
        OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_HANDLESNAPSHOT_2, "msg: e_CX_HANDLE_SNAPSHOT 0");
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   812
    }
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   813
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   814
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   815
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
* setting has changed, check if we are interested.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
void CxeVideoCaptureControlSymbian::handleSettingValueChanged(const QString& settingId,
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
                                                              QVariant newValue)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
    Q_UNUSED(newValue);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
        if (settingId == CxeSettingIds::VIDEO_QUALITY) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
            // re-prepare for video
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
            if (state() == Ready) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
                // release resources
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   831
                deinit();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
                // initialize video recording again
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   833
                init();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   834
            }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
        } else if (settingId == CxeSettingIds::VIDEO_MUTE_SETTING) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
            // mute setting changed, apply the new setting and re-prepare.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
            setState(Preparing);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
            prepare();
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   839
        } else if (settingId == CxeSettingIds::FRAME_RATE) {
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   840
            // Frame rate setting changed. Need to re-prepare if we are prepared already.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   841
            // Otherwise can wait for next init call.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   842
            if (state() == Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   843
                setState(Preparing);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   844
                prepare();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   845
            }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
        } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
            // Setting not relevant to video mode
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   854
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   855
 * Scene mode changed. We need to know about it because frame rate
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   856
 * might have changed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   857
 */
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   858
void CxeVideoCaptureControlSymbian::handleSceneChanged(CxeScene& scene)
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   859
{
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   860
    Q_UNUSED(scene)
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   861
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   862
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   863
    // make sure we are in video mode
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   864
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   865
        // Frame rate setting might have changed so re-prepare.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   866
        if (state() == Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   867
            setState(Preparing);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   868
            prepare();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   869
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   870
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   871
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   872
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   873
}
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   874
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   875
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   876
* Disk space changed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   877
* Emit remaining time changed signal, if space change affects it.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   878
*/
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   879
void CxeVideoCaptureControlSymbian::handleDiskSpaceChanged()
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   880
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   881
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   882
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   883
    // Ignore updates on preparing phase.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   884
    if (state() == CxeVideoCaptureControl::Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   885
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   886
        int time(calculateRemainingTime(mCurrentVideoDetails));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   887
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   888
        if (time !=  mCurrentVideoDetails.mRemainingTime) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   889
            mCurrentVideoDetails.mRemainingTime = time;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   890
            emit remainingTimeChanged();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   891
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   892
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   893
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   894
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   895
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
* Returns QList of all supported video quality details based on the camera index
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
* (primary/secondary).
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
QList<CxeVideoDetails> CxeVideoCaptureControlSymbian::supportedVideoQualities()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
    // update the remaining time counters for each quality setting
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
    updateRemainingRecordingTimeCounter();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
    return mIcmSupportedVideoResolutions;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
43
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   908
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   909
* Helper method to handle error during preparing phase.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   910
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   911
void CxeVideoCaptureControlSymbian::handlePrepareFailed()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   912
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   913
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   914
    CX_DEBUG(("[ERROR] Preparing video failed!"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   915
    // Cleanup
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   916
    deinit();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   917
    // Inform client
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   918
    emit videoPrepareComplete(CxeError::InitializationFailed);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   919
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   920
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   921
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   922
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   923
* Helper method to handle error from video composing.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   924
* @param error Symbian error code.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   925
*/
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   926
void CxeVideoCaptureControlSymbian::handleComposeFailed(int error)
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   927
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   928
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   929
    CX_DEBUG(("[ERROR] Composing video failed!"));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   930
    // Inform client
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   931
    emit videoComposed(CxeErrorHandlingSymbian::map(error), filename());
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   932
    // Cleanup
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   933
    deinit();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   934
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   935
}
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   936
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   937
/*!
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   938
 * Helper method to emulate video stopping events.
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   939
 */
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   940
void CxeVideoCaptureControlSymbian::emulateNormalStopping()
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   941
{
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   942
    CX_DEBUG_ENTER_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   943
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   944
    setState(Stopping);
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   945
    MvruoEvent(TMMFEvent(KCamCControllerCCVideoRecordStopped, KErrNone));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   946
    MvruoEvent(TMMFEvent(KCamCControllerCCVideoFileComposed, KErrNone));
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   947
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   948
    CX_DEBUG_EXIT_FUNCTION();
0e652f8f1fbd 201027_1
hgs
parents: 28
diff changeset
   949
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
// End of file