camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp
author hgs
Mon, 23 Aug 2010 13:50:05 +0300
changeset 52 7e18d488ac5f
parent 46 c826656d6714
child 55 0da2a5b56583
permissions -rw-r--r--
201033
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
/*
41
hgs
parents: 39
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
*/
38
hgs
parents: 28
diff changeset
    17
hgs
parents: 28
diff changeset
    18
#include <algorithm>
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
38
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"
38
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"
46
hgs
parents: 42
diff changeset
    43
#include "cxesettingsmappersymbian.h"
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    44
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    45
#include "OstTraceDefinitions.h"
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#ifdef OST_TRACE_COMPILER_IN_USE
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include "cxevideocapturecontrolsymbianTraces.h"
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#endif
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
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
// constants
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    52
namespace
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    53
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    54
    // TMMFEvent UIDs for Async stop
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    55
    const TUid KCamCControllerCCVideoRecordStopped = {0x2000E546};
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    56
    const TUid KCamCControllerCCVideoFileComposed = {0x2000E547};
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    57
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    58
    const TInt64  KMinRequiredSpaceVideo      = 4000000;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    59
}
19
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
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
* CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
*/
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    65
CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian(
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    66
    CxeCameraDevice &cameraDevice,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    67
    CxeViewfinderControl &viewfinderControl,
38
hgs
parents: 28
diff changeset
    68
    CxeSnapshotControl &snapshotControl,
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    69
    CxeCameraDeviceControl &cameraDeviceControl,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    70
    CxeFilenameGenerator &nameGenerator,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    71
    CxeSettings &settings,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    72
    CxeQualityPresets &qualityPresets,
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    73
    CxeDiskMonitor &diskMonitor)
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    74
    : CxeStateMachine("CxeVideoCaptureControlSymbian"),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    75
      mVideoRecorder(NULL),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    76
      mCameraDevice(cameraDevice),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    77
      mCameraDeviceControl(cameraDeviceControl),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    78
      mViewfinderControl(viewfinderControl),
38
hgs
parents: 28
diff changeset
    79
      mSnapshotControl(snapshotControl),
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    80
      mFilenameGenerator(nameGenerator),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    81
      mSettings(settings),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    82
      mQualityPresets(qualityPresets),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    83
      mDiskMonitor(diskMonitor),
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    84
      mSnapshot(),
38
hgs
parents: 28
diff changeset
    85
      mVideoStartSoundPlayer(NULL),
hgs
parents: 28
diff changeset
    86
      mVideoStopSoundPlayer(NULL),
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    87
      mCurrentFilename("")
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
    CX_DEBUG_ENTER_FUNCTION();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    90
    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
    91
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
    qRegisterMetaType<CxeVideoCaptureControl::State> ();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
    initializeStates();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
    94
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
    mVideoStopSoundPlayer = new
41
hgs
parents: 39
diff changeset
    96
             CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStop,
hgs
parents: 39
diff changeset
    97
                                   mSettings);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
    mVideoStartSoundPlayer = new
41
hgs
parents: 39
diff changeset
    99
             CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStart,
hgs
parents: 39
diff changeset
   100
                                   mSettings);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   102
    // If camera is already allocated, call the slot ourselves.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   103
    if (mCameraDevice.camera()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   104
        handleCameraAllocated(CxeError::None);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   105
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   106
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   107
    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
   108
    // 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
   109
    connect(&cameraDevice, SIGNAL(prepareForCameraDelete()),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
            this, SLOT(prepareForCameraDelete()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    connect(&cameraDevice, SIGNAL(prepareForRelease()),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
            this, SLOT(prepareForRelease()) );
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    connect(&cameraDevice, SIGNAL(cameraAllocated(CxeError::Id)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
            this, SLOT(handleCameraAllocated(CxeError::Id)));
38
hgs
parents: 28
diff changeset
   115
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
    // connect playing sound signals
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
    connect(mVideoStartSoundPlayer, SIGNAL(playComplete(int)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
            this, SLOT(handleSoundPlayed()));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
38
hgs
parents: 28
diff changeset
   120
    // connect snapshot ready signal
41
hgs
parents: 39
diff changeset
   121
    connect(&mSnapshotControl, SIGNAL(snapshotReady(CxeError::Id, const QImage&)),
hgs
parents: 39
diff changeset
   122
            this, SLOT(handleSnapshotReady(CxeError::Id, const QImage&)));
38
hgs
parents: 28
diff changeset
   123
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
    // enabling setting change callbacks to videocapturecontrol
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
    connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)),
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
            this, SLOT(handleSettingValueChanged(const QString&,QVariant)));
46
hgs
parents: 42
diff changeset
   127
hgs
parents: 42
diff changeset
   128
    mSettings.listenForSetting(CxeSettingIds::VIDEO_SCENE, this, SLOT(handleSceneChanged(const QVariant&)));
hgs
parents: 42
diff changeset
   129
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   130
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0");
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   131
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   132
    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
   133
    CX_DEBUG_EXIT_FUNCTION();
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
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
CxeVideoCaptureControlSymbian::~CxeVideoCaptureControlSymbian()
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    releaseResources();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
    mIcmSupportedVideoResolutions.clear();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
    delete mVideoStartSoundPlayer;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
    delete mVideoStopSoundPlayer;
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
    CX_DEBUG_EXIT_FUNCTION();
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
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
* Initializes resources for video recording.
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
void CxeVideoCaptureControlSymbian::init()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
    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
   158
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
    if (state() == Idle) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
        // start initializing resources for video capture
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
        initVideoRecorder();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   162
    } else if (state() == Initialized) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
        // 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
   164
        open();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    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
   168
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
41
hgs
parents: 39
diff changeset
   171
/*!
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
* Releases all resources
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
void CxeVideoCaptureControlSymbian::deinit()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
38
hgs
parents: 28
diff changeset
   178
    // Nothing to do if already idle.
hgs
parents: 28
diff changeset
   179
    if(state() != Idle) {
hgs
parents: 28
diff changeset
   180
        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
   181
38
hgs
parents: 28
diff changeset
   182
        // first stop viewfinder
hgs
parents: 28
diff changeset
   183
        mViewfinderControl.stop();
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   184
38
hgs
parents: 28
diff changeset
   185
        // stop video-recording in-case if its ongoing.
hgs
parents: 28
diff changeset
   186
        stop();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   187
39
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   188
        // Check if state is stopping, in which case we have to inform the
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   189
        // file harvester that a file is to be completed. We would not
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   190
        // call harvestFile otherwise in this case.
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   191
        // Otherwise the video will not be found from videos app.
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   192
        if (state() == Stopping) {
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   193
            emit videoComposed(CxeError::None, mCurrentFilename);
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   194
        }
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   195
38
hgs
parents: 28
diff changeset
   196
        mSnapshotControl.stop();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
38
hgs
parents: 28
diff changeset
   198
        if (mVideoRecorder) {
hgs
parents: 28
diff changeset
   199
            mVideoRecorder->close();
hgs
parents: 28
diff changeset
   200
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
38
hgs
parents: 28
diff changeset
   202
        setState(Idle);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
38
hgs
parents: 28
diff changeset
   204
        OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 0" );
hgs
parents: 28
diff changeset
   205
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    CX_DEBUG_EXIT_FUNCTION();
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
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
* Intializes VideoRecorder for recording.
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
void CxeVideoCaptureControlSymbian::initVideoRecorder()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
38
hgs
parents: 28
diff changeset
   216
    // Init needed only in Idle state
hgs
parents: 28
diff changeset
   217
    if (state() == Idle) {
hgs
parents: 28
diff changeset
   218
        try {
46
hgs
parents: 42
diff changeset
   219
            // If video recorder is not yet created, do it now.
38
hgs
parents: 28
diff changeset
   220
            createVideoRecorder();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
46
hgs
parents: 42
diff changeset
   222
            // Update current video quality details from ICM.
38
hgs
parents: 28
diff changeset
   223
            // Throws an error if unable to get the quality.
46
hgs
parents: 42
diff changeset
   224
            updateVideoCaptureParameters();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
38
hgs
parents: 28
diff changeset
   226
            // 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
   227
            setState(Initialized);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
            open();
38
hgs
parents: 28
diff changeset
   229
        } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   230
            // Handle error
hgs
parents: 28
diff changeset
   231
            handlePrepareFailed();
19
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
    }
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
    CX_DEBUG_EXIT_FUNCTION();
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
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
* Opens file for video recording.
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
void CxeVideoCaptureControlSymbian::open()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
38
hgs
parents: 28
diff changeset
   245
    // Check valid state to start "open" operation
hgs
parents: 28
diff changeset
   246
    if (state() == Initialized) {
hgs
parents: 28
diff changeset
   247
        try {
hgs
parents: 28
diff changeset
   248
            // generate video file name, if necessary
hgs
parents: 28
diff changeset
   249
            generateFilename();
hgs
parents: 28
diff changeset
   250
            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
   251
38
hgs
parents: 28
diff changeset
   252
            // Start preparing..
hgs
parents: 28
diff changeset
   253
            setState(CxeVideoCaptureControl::Preparing);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
38
hgs
parents: 28
diff changeset
   255
            // Exception thrown if open fails.
hgs
parents: 28
diff changeset
   256
            mVideoRecorder->open(mCameraDevice.camera()->Handle(),
hgs
parents: 28
diff changeset
   257
                                 mCurrentFilename,
hgs
parents: 28
diff changeset
   258
                                 mCurrentVideoDetails.mVideoFileMimeType,
hgs
parents: 28
diff changeset
   259
                                 mCurrentVideoDetails.mPreferredSupplier,
hgs
parents: 28
diff changeset
   260
                                 mCurrentVideoDetails.mVideoCodecMimeType,
hgs
parents: 28
diff changeset
   261
                                 mCurrentVideoDetails.mAudioType);
hgs
parents: 28
diff changeset
   262
        } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   263
            handlePrepareFailed();
hgs
parents: 28
diff changeset
   264
        }
19
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
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
/*!
38
hgs
parents: 28
diff changeset
   270
* Helper method for generating filename.
hgs
parents: 28
diff changeset
   271
* Throws exception, if file type mime is formatted wrong or
hgs
parents: 28
diff changeset
   272
* filename generation fails.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
*/
38
hgs
parents: 28
diff changeset
   274
void CxeVideoCaptureControlSymbian::generateFilename()
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
    CX_DEBUG_ENTER_FUNCTION();
38
hgs
parents: 28
diff changeset
   277
    mCurrentFilename = QString("");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
38
hgs
parents: 28
diff changeset
   279
    QStringList list = mCurrentVideoDetails.mVideoFileMimeType.split("/");
hgs
parents: 28
diff changeset
   280
    // Throw exception if mime string is formatted wrong.
hgs
parents: 28
diff changeset
   281
    if (list.count() != 2) {
hgs
parents: 28
diff changeset
   282
        throw new CxeException(CxeError::General);
hgs
parents: 28
diff changeset
   283
    }
hgs
parents: 28
diff changeset
   284
    QString fileExt = "." + list[1];
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
38
hgs
parents: 28
diff changeset
   286
    // Generate new filename and open the file for writing video data
hgs
parents: 28
diff changeset
   287
    CxeException::throwIfError(mFilenameGenerator.generateFilename(mCurrentFilename, fileExt));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
38
hgs
parents: 28
diff changeset
   289
    CX_DEBUG_EXIT_FUNCTION();
19
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
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
* 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
   294
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
void CxeVideoCaptureControlSymbian::prepare()
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
    if (state() != Preparing) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
        // not valid state to continue prepare.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
        return;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
42
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   304
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_1, "msg: e_CX_VIDCAPCONT_PREPARE 1");
38
hgs
parents: 28
diff changeset
   305
    QSize frameSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
46
hgs
parents: 42
diff changeset
   307
    bool muteSetting = mSettings.get<bool>(CxeSettingIds::VIDEO_MUTE_SETTING, false);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   309
    // Check if scene defines frame rate.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   310
    // Use generic frame rate defined in video details, if no value is set in scene.
46
hgs
parents: 42
diff changeset
   311
    int frameRate = mSettings.get<int>(CxeSettingIds::FRAME_RATE, 0);
28
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
38
hgs
parents: 28
diff changeset
   316
    CX_DEBUG(("Video resolution (%d,%d)", mCurrentVideoDetails.mWidth,
hgs
parents: 28
diff changeset
   317
                                           mCurrentVideoDetails.mHeight));
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
38
hgs
parents: 28
diff changeset
   321
    try {
hgs
parents: 28
diff changeset
   322
        mVideoRecorder->setVideoFrameSize(frameSize);
hgs
parents: 28
diff changeset
   323
        mVideoRecorder->setVideoFrameRate(frameRate);
hgs
parents: 28
diff changeset
   324
        mVideoRecorder->setVideoBitRate(mCurrentVideoDetails.mVideoBitRate);
46
hgs
parents: 42
diff changeset
   325
        mVideoRecorder->setAudioEnabled(!muteSetting);
38
hgs
parents: 28
diff changeset
   326
        // "No limit" value is handled in video recorder wrapper.
hgs
parents: 28
diff changeset
   327
        mVideoRecorder->setVideoMaxSize(mCurrentVideoDetails.mMaximumSizeInBytes);
hgs
parents: 28
diff changeset
   328
hgs
parents: 28
diff changeset
   329
        // Settings have been applied successfully, start to prepare.
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
38
hgs
parents: 28
diff changeset
   332
        // Prepare zoom only when there are no errors during prepare.
hgs
parents: 28
diff changeset
   333
        emit prepareZoomForVideo();
hgs
parents: 28
diff changeset
   334
        emit videoPrepareComplete(CxeError::None);
hgs
parents: 28
diff changeset
   335
    } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   336
        // Handle error.
hgs
parents: 28
diff changeset
   337
        handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
42
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   340
    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
   341
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   342
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   343
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   344
/*!
46
hgs
parents: 42
diff changeset
   345
* Prepare video snapshot.
hgs
parents: 42
diff changeset
   346
* Throws exception on error.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   347
*/
46
hgs
parents: 42
diff changeset
   348
void CxeVideoCaptureControlSymbian::prepareSnapshot()
19
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
    CX_DEBUG_ENTER_FUNCTION();
46
hgs
parents: 42
diff changeset
   351
    OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARESNAP_1, "msg: e_CX_PREPARE_SNAPSHOT 1" );
hgs
parents: 42
diff changeset
   352
hgs
parents: 42
diff changeset
   353
    // Prepare snapshot. Snapshot control throws error if problems.
hgs
parents: 42
diff changeset
   354
    QSize snapshotSize = mSnapshotControl.calculateSnapshotSize(
hgs
parents: 42
diff changeset
   355
                            mViewfinderControl.deviceDisplayResolution(),
hgs
parents: 42
diff changeset
   356
                            mCurrentVideoDetails.mAspectRatio);
hgs
parents: 42
diff changeset
   357
    mSnapshotControl.start(snapshotSize);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   358
46
hgs
parents: 42
diff changeset
   359
    OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARESNAP_2, "msg: e_CX_PREPARE_SNAPSHOT 0" );
hgs
parents: 42
diff changeset
   360
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 42
diff changeset
   361
}
hgs
parents: 42
diff changeset
   362
hgs
parents: 42
diff changeset
   363
/*!
hgs
parents: 42
diff changeset
   364
  Fetch video quality details based on current video quality setting.
hgs
parents: 42
diff changeset
   365
*/
hgs
parents: 42
diff changeset
   366
void CxeVideoCaptureControlSymbian::updateVideoCaptureParameters()
hgs
parents: 42
diff changeset
   367
{
hgs
parents: 42
diff changeset
   368
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 42
diff changeset
   369
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_UPDATEVIDEOCAPTUREPARAMETERS_1, "msg: e_CX_UPDATE_VIDEO_CAPTURE_PARAMETERS 1");
hgs
parents: 42
diff changeset
   370
hgs
parents: 42
diff changeset
   371
    int quality = 0;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
38
hgs
parents: 28
diff changeset
   373
    // Get quality index for primary camera. Only one quality for secondary camera.
hgs
parents: 28
diff changeset
   374
    if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) {
46
hgs
parents: 42
diff changeset
   375
        quality = mSettings.get<int>(CxeSettingIds::VIDEO_QUALITY);
19
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
38
hgs
parents: 28
diff changeset
   378
    if (quality < 0 || quality >= mIcmSupportedVideoResolutions.count()) {
hgs
parents: 28
diff changeset
   379
       throw new CxeException(CxeError::NotFound);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
46
hgs
parents: 42
diff changeset
   382
    // Get video quality details
hgs
parents: 42
diff changeset
   383
    mCurrentVideoDetails = mIcmSupportedVideoResolutions.at(quality);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
46
hgs
parents: 42
diff changeset
   385
    OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_UPDATEVIDEOCAPTUREPARAMETERS_2, "msg: e_CX_UPDATE_VIDEO_CAPTURE_PARAMETERS 0");
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
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
* Resets the video snapshot and current video filename
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
void CxeVideoCaptureControlSymbian::reset()
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
    CX_DEBUG_ENTER_FUNCTION();
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
    // Snapshot will consume considerably memory.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
    // 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
   398
    mSnapshot = QPixmap();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
    // reset the current file name.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
    mCurrentFilename = QString("");
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
    CX_DEBUG_EXIT_FUNCTION();
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
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
* Returns current video filename
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
QString CxeVideoCaptureControlSymbian::filename() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
    // Simply return the current contents of mCurrentFilename.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
    // 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
   412
    // otherwise an empty string is returned.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
    return mCurrentFilename;
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
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
* Returns current video snapshot
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
QPixmap CxeVideoCaptureControlSymbian::snapshot() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    return mSnapshot;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
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
* 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
   426
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
void CxeVideoCaptureControlSymbian::record()
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    if (state() == Ready || state() == Paused) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
        // ask the player to play the sound
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
        // recording will start once start sound is played
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
        setState(CxeVideoCaptureControl::PlayingStartSound);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
        mVideoStartSoundPlayer->play();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
* Pauses video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
void CxeVideoCaptureControlSymbian::pause()
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
    CX_DEBUG_ENTER_FUNCTION();
38
hgs
parents: 28
diff changeset
   447
    try {
hgs
parents: 28
diff changeset
   448
        mVideoRecorder->pause();
hgs
parents: 28
diff changeset
   449
        setState(CxeVideoCaptureControl::Paused);
hgs
parents: 28
diff changeset
   450
        // play the sound, but not changing the state
hgs
parents: 28
diff changeset
   451
        mVideoStopSoundPlayer->play();
hgs
parents: 28
diff changeset
   452
    } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   453
        handleComposeFailed(qt_symbian_exception2Error(e));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
* Stops video recording.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
void CxeVideoCaptureControlSymbian::stop()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    if (state() == Recording || state() == Paused) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
        // first stop viewfinder
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
        mViewfinderControl.stop();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
38
hgs
parents: 28
diff changeset
   469
        try {
hgs
parents: 28
diff changeset
   470
            // Try asynchronous stopping first.
hgs
parents: 28
diff changeset
   471
            mVideoRecorder->stop(true);
hgs
parents: 28
diff changeset
   472
            // No error from asynchronous stop -> wait for stop event
52
hgs
parents: 46
diff changeset
   473
            if (state() != Ready) {
hgs
parents: 46
diff changeset
   474
                setState(Stopping);
hgs
parents: 46
diff changeset
   475
            }
38
hgs
parents: 28
diff changeset
   476
        } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   477
            CX_DEBUG(("CxeVideoCaptureControlSymbian - async stop failed, try sync.."));
hgs
parents: 28
diff changeset
   478
            try {
hgs
parents: 28
diff changeset
   479
                mVideoRecorder->stop(false);
39
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   480
                // stopping went ok
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   481
                emulateNormalStopping();
38
hgs
parents: 28
diff changeset
   482
            } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   483
                // Even synchronous stopping failed -> release resources.
hgs
parents: 28
diff changeset
   484
                CX_DEBUG(("CxeVideoCaptureControlSymbian - sync stop failed, too!"));
hgs
parents: 28
diff changeset
   485
                handleComposeFailed(qt_symbian_exception2Error(e));
19
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
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
}
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
* Callback when "Open" operation is complete.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
void CxeVideoCaptureControlSymbian::MvruoOpenComplete(TInt aError)
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoOpenComplete, err=%d", aError));
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
    if (state() == Preparing) {
38
hgs
parents: 28
diff changeset
   502
        if (!aError) {
hgs
parents: 28
diff changeset
   503
            prepare();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
        } else {
38
hgs
parents: 28
diff changeset
   505
            handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
* Callback when "Prepare" request is complete.
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
void CxeVideoCaptureControlSymbian::MvruoPrepareComplete(TInt aError)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoPrepareComplete, err=%d", aError));
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
    if (state() == Preparing) {
46
hgs
parents: 42
diff changeset
   521
        try {
hgs
parents: 42
diff changeset
   522
            // Check that no error coming in.
hgs
parents: 42
diff changeset
   523
            CxeException::throwIfError(aError);
hgs
parents: 42
diff changeset
   524
            // Start viewfinder
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
            mViewfinderControl.start();
46
hgs
parents: 42
diff changeset
   526
            // Prepare snapshot (throws exception if fails).
hgs
parents: 42
diff changeset
   527
            prepareSnapshot();
hgs
parents: 42
diff changeset
   528
            // Ready for recording now.
hgs
parents: 42
diff changeset
   529
            setState(CxeVideoCaptureControl::Ready);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   530
            OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 0" );
46
hgs
parents: 42
diff changeset
   531
        } catch (const std::exception &e) {
38
hgs
parents: 28
diff changeset
   532
            handlePrepareFailed();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
    }
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
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
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
* Callback when "Record" operation is complete.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
void CxeVideoCaptureControlSymbian::MvruoRecordComplete(TInt aError)
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
    CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoRecordComplete, err=%d", aError));
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
    //! async stop customcommand stuff
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
    if (aError == KErrNone) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
        setState(CxeVideoCaptureControl::Ready);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
    } else if (aError == KErrCompletion) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
        // KErrCompletion is received when video recording stops
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
        // because of maximum clip size is reached. Emulate
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
        // normal stopping.
39
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   554
        emulateNormalStopping();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
    else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
        // error during recording, report to client
38
hgs
parents: 28
diff changeset
   558
        handleComposeFailed(aError);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
* Callback from MVideoRecorderUtilityObserver
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
void CxeVideoCaptureControlSymbian::MvruoEvent(const TMMFEvent& aEvent)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
    CX_DEBUG_ENTER_FUNCTION();
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
    if (aEvent.iEventType.iUid == KCamCControllerCCVideoRecordStopped.iUid) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
        CX_DEBUG(("KCamCControllerCCVideoRecordStopped"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
        // play the sound, but not changing the state
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
        mVideoStopSoundPlayer->play();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
    } else if (aEvent.iEventType.iUid == KCamCControllerCCVideoFileComposed.iUid) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
        CX_DEBUG(("KCamCControllerCCVideoFileComposed"));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
        if (state() == Stopping) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
            // 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
   579
            setState(Initialized);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
        }
38
hgs
parents: 28
diff changeset
   581
        mFilenameGenerator.raiseCounterValue();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
        // 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
   583
        emit videoComposed(CxeError::None, filename());
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
    } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
        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
   586
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
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
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
* camera reference changing, release resources
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::prepareForCameraDelete()
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
    releaseResources();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
* prepare for camera release.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
void CxeVideoCaptureControlSymbian::prepareForRelease()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
    deinit();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
/*!
38
hgs
parents: 28
diff changeset
   612
* new camera available
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
void CxeVideoCaptureControlSymbian::handleCameraAllocated(CxeError::Id error)
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_ENTER_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
    if (!error) {
38
hgs
parents: 28
diff changeset
   619
        try {
hgs
parents: 28
diff changeset
   620
            // Create the video recorder utility
hgs
parents: 28
diff changeset
   621
            createVideoRecorder();
hgs
parents: 28
diff changeset
   622
        } catch (...) {
hgs
parents: 28
diff changeset
   623
            // We are just trying to create the recorder early.
hgs
parents: 28
diff changeset
   624
            // Retry later when preparing, and fail then if
hgs
parents: 28
diff changeset
   625
            // error still persists.
hgs
parents: 28
diff changeset
   626
        }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
        // new camera available, read supported video qualities from icm
38
hgs
parents: 28
diff changeset
   628
        // load all video qualities supported by icm
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
        mIcmSupportedVideoResolutions.clear();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
        Cxe::CameraIndex cameraIndex = mCameraDeviceControl.cameraIndex();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
        // 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
   632
        mIcmSupportedVideoResolutions =
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
                mQualityPresets.videoQualityPresets(cameraIndex);
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
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
}
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
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
* Initializes video recorder.
38
hgs
parents: 28
diff changeset
   641
* May throw exception.
19
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
void CxeVideoCaptureControlSymbian::createVideoRecorder()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
    CX_DEBUG_ENTER_FUNCTION();
38
hgs
parents: 28
diff changeset
   646
    if (mVideoRecorder == NULL) {
hgs
parents: 28
diff changeset
   647
        mVideoRecorder = new CxeVideoRecorderUtilitySymbian(*this);
19
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
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
}
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
/*!
38
hgs
parents: 28
diff changeset
   653
* releases resources used by video capture control
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
void CxeVideoCaptureControlSymbian::releaseResources()
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
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
    // first de-init videocapture control
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
    deinit();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
    reset();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
    delete mVideoRecorder;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
    mVideoRecorder = NULL;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
/*!
38
hgs
parents: 28
diff changeset
   670
* Returns current state of video capture control
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
CxeVideoCaptureControl::State CxeVideoCaptureControlSymbian::state() const
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
    return static_cast<CxeVideoCaptureControl::State> (stateId());
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
/*!
38
hgs
parents: 28
diff changeset
   678
* Called when state is changed.
19
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
void CxeVideoCaptureControlSymbian::handleStateChanged(int newStateId, CxeError::Id error)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
{
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   682
    switch (newStateId) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   683
    case Ready:
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   684
        if (error == CxeError::None && !mDiskMonitor.isMonitoring()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   685
            mDiskMonitor.start();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   686
            connect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   687
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   688
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   689
    default:
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   690
        // Stop monitoring when video mode is released.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   691
        // Same goes during recording, as video times come from recorder.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   692
        if (mDiskMonitor.isMonitoring()) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   693
            mDiskMonitor.stop();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   694
            disconnect(&mDiskMonitor, SIGNAL(diskSpaceChanged()), this, SLOT(handleDiskSpaceChanged()));
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   695
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   696
        break;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   697
    }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
    emit stateChanged(static_cast<State> (newStateId), error);
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
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
* Initialize states for videocapturecontrol
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::initializeStates()
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
    // addState( id, name, allowed next states )
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
    addState(new CxeState(Idle, "Idle", Initialized));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
    addState(new CxeState(Initialized, "Initialized", Preparing | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
    addState(new CxeState(Preparing, "Preparing", Ready | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
    addState(new CxeState(Ready, "Ready", Recording | PlayingStartSound | Preparing | Idle));
52
hgs
parents: 46
diff changeset
   711
    addState(new CxeState(Recording, "Recording", Recording | Paused | Stopping | Idle | Ready));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
    addState(new CxeState(Paused, "Paused", Recording | Stopping | PlayingStartSound | Idle));
52
hgs
parents: 46
diff changeset
   713
    addState(new CxeState(Stopping, "Stopping", Initialized | Idle | Ready));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
    addState(new CxeState(PlayingStartSound, "PlayingStartSound", Recording | Idle));
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
    setInitialState(Idle);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
}
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
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
* 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
   721
* 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
   722
* read from ICM for the first time
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
void CxeVideoCaptureControlSymbian::updateRemainingRecordingTimeCounter()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
    for( int index = 0; index < mIcmSupportedVideoResolutions.count(); index++) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
        CxeVideoDetails &qualityDetails = mIcmSupportedVideoResolutions[index];
38
hgs
parents: 28
diff changeset
   730
        qualityDetails.mRemainingTime = calculateRemainingTime(qualityDetails);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
    CX_DEBUG_EXIT_FUNCTION();
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
41
hgs
parents: 39
diff changeset
   736
/*!
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
* calculates remaining video recording time.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
void CxeVideoCaptureControlSymbian::remainingTime(int &time)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   743
    if (state() == CxeVideoCaptureControl::Recording ||
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   744
        state() == CxeVideoCaptureControl::Paused) {
38
hgs
parents: 28
diff changeset
   745
        time = mVideoRecorder->availableRecordingTime();
hgs
parents: 28
diff changeset
   746
        CX_DEBUG(("CxeVideoCaptureControlSymbian - time remaining: %d", time));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
    } else {
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   748
        // Check if we need to recalculate the remaining time.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   749
        if (mCurrentVideoDetails.mRemainingTime == CxeVideoDetails::UNKNOWN) {
38
hgs
parents: 28
diff changeset
   750
            mCurrentVideoDetails.mRemainingTime = calculateRemainingTime(mCurrentVideoDetails);
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   751
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   752
        time = mCurrentVideoDetails.mRemainingTime;
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
}
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
/*!
38
hgs
parents: 28
diff changeset
   759
* Get the remaining recording time
hgs
parents: 28
diff changeset
   760
* @param videoDetails Contains the current video resolution that is in use.
hgs
parents: 28
diff changeset
   761
* @return The remaining recording time
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
*/
38
hgs
parents: 28
diff changeset
   763
int CxeVideoCaptureControlSymbian::calculateRemainingTime(const CxeVideoDetails& videoDetails)
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
    CX_DEBUG_ENTER_FUNCTION();
38
hgs
parents: 28
diff changeset
   766
    qint64 availableSpace = mDiskMonitor.free() - KMinRequiredSpaceVideo;
hgs
parents: 28
diff changeset
   767
    int time = mQualityPresets.recordingTimeAvailable(videoDetails, availableSpace);
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
    CX_DEBUG_EXIT_FUNCTION();
38
hgs
parents: 28
diff changeset
   769
    return time;
19
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
/*!
38
hgs
parents: 28
diff changeset
   773
* Calculates elapsed recording time during video recording
hgs
parents: 28
diff changeset
   774
* @return Did fetching elapsed time succeed.
19
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
bool CxeVideoCaptureControlSymbian::elapsedTime(int &time)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
    bool ok = false;
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   781
    if (state() == CxeVideoCaptureControl::Recording ||
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   782
        state() == CxeVideoCaptureControl::Paused) {
38
hgs
parents: 28
diff changeset
   783
        try {
hgs
parents: 28
diff changeset
   784
            time = mVideoRecorder->duration();
hgs
parents: 28
diff changeset
   785
            CX_DEBUG(("CxeVideoCaptureControlSymbian - elapsed: %d", time));
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
            ok = true;
38
hgs
parents: 28
diff changeset
   787
        } catch (const std::exception &e) {
hgs
parents: 28
diff changeset
   788
            // Returning false.
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
    }
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
    return ok;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
* slot called when playing a sound has finished.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
void CxeVideoCaptureControlSymbian::handleSoundPlayed()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
    // start recording, if we were playing capture sound
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
    if (state() == CxeVideoCaptureControl::PlayingStartSound) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
        setState(CxeVideoCaptureControl::Recording);
38
hgs
parents: 28
diff changeset
   806
        mVideoRecorder->record();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
    // 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
   810
    // 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
   811
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
38
hgs
parents: 28
diff changeset
   815
/*!
hgs
parents: 28
diff changeset
   816
* Handle new snapshot.
hgs
parents: 28
diff changeset
   817
* @param status Status code for getting the snapshot.
hgs
parents: 28
diff changeset
   818
* @param snapshot Snapshot pixmap. Empty if error code reported.
hgs
parents: 28
diff changeset
   819
*/
41
hgs
parents: 39
diff changeset
   820
void CxeVideoCaptureControlSymbian::handleSnapshotReady(CxeError::Id status, const QImage &snapshot)
38
hgs
parents: 28
diff changeset
   821
{
hgs
parents: 28
diff changeset
   822
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 28
diff changeset
   823
hgs
parents: 28
diff changeset
   824
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
42
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   825
        OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_HANDLESNAPSHOT_1, "msg: e_CX_HANDLE_SNAPSHOT 1");
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   826
38
hgs
parents: 28
diff changeset
   827
        // Need to store snapshot for ui to be able to get it also later.
41
hgs
parents: 39
diff changeset
   828
        mSnapshot = QPixmap::fromImage(snapshot);
38
hgs
parents: 28
diff changeset
   829
        emit snapshotReady(status, snapshot, filename());
42
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   830
feebad15db8c 201027_1
hgs
parents: 41
diff changeset
   831
        OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_HANDLESNAPSHOT_2, "msg: e_CX_HANDLE_SNAPSHOT 0");
38
hgs
parents: 28
diff changeset
   832
    }
hgs
parents: 28
diff changeset
   833
hgs
parents: 28
diff changeset
   834
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 28
diff changeset
   835
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
/*!
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
* setting has changed, check if we are interested.
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
void CxeVideoCaptureControlSymbian::handleSettingValueChanged(const QString& settingId,
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
                                                              QVariant newValue)
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
    CX_DEBUG_ENTER_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
    Q_UNUSED(newValue);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
        if (settingId == CxeSettingIds::VIDEO_QUALITY) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
            // re-prepare for video
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
            if (state() == Ready) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
                // release resources
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   851
                deinit();
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
                // initialize video recording again
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   853
                init();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   854
            }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
        } else if (settingId == CxeSettingIds::VIDEO_MUTE_SETTING) {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
            // 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
   857
            setState(Preparing);
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
            prepare();
38
hgs
parents: 28
diff changeset
   859
        } else if (settingId == CxeSettingIds::FRAME_RATE) {
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   860
            // Frame rate setting changed. Need to re-prepare if we are prepared already.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   861
            // Otherwise can wait for next init call.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   862
            if (state() == Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   863
                setState(Preparing);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   864
                prepare();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   865
            }
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
        } else {
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
            // Setting not relevant to video mode
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
        }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
    }
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
    CX_DEBUG_EXIT_FUNCTION();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   874
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   875
 * Scene mode changed. We need to know about it because frame rate
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   876
 * might have changed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   877
 */
46
hgs
parents: 42
diff changeset
   878
void CxeVideoCaptureControlSymbian::handleSceneChanged(const QVariant& scene)
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   879
{
38
hgs
parents: 28
diff changeset
   880
    Q_UNUSED(scene)
28
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
    // make sure we are in video mode
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   884
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   885
        // Frame rate setting might have changed so re-prepare.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   886
        if (state() == Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   887
            setState(Preparing);
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   888
            prepare();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   889
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   890
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   891
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   892
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   893
}
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   894
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   895
/*!
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   896
* Disk space changed.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   897
* Emit remaining time changed signal, if space change affects it.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   898
*/
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   899
void CxeVideoCaptureControlSymbian::handleDiskSpaceChanged()
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   900
{
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   901
    CX_DEBUG_ENTER_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   902
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   903
    // Ignore updates on preparing phase.
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   904
    if (state() == CxeVideoCaptureControl::Ready) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   905
38
hgs
parents: 28
diff changeset
   906
        int time(calculateRemainingTime(mCurrentVideoDetails));
28
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   907
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   908
        if (time !=  mCurrentVideoDetails.mRemainingTime) {
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   909
            mCurrentVideoDetails.mRemainingTime = time;
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   910
            emit remainingTimeChanged();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   911
        }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   912
    }
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   913
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   914
    CX_DEBUG_EXIT_FUNCTION();
3075d9b614e6 201017_1
hgs
parents: 19
diff changeset
   915
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
/*!
46
hgs
parents: 42
diff changeset
   918
    Use ECam Use Case Hint Custom API to inform ECam of our intended use case
hgs
parents: 42
diff changeset
   919
    before calling Reserve().
hgs
parents: 42
diff changeset
   920
*/
hgs
parents: 42
diff changeset
   921
void CxeVideoCaptureControlSymbian::hintUseCase()
hgs
parents: 42
diff changeset
   922
{
hgs
parents: 42
diff changeset
   923
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 42
diff changeset
   924
hgs
parents: 42
diff changeset
   925
    // Make sure ECam knows we're doing video recording so it can prepare
hgs
parents: 42
diff changeset
   926
    // for the correct use case.
hgs
parents: 42
diff changeset
   927
    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
hgs
parents: 42
diff changeset
   928
        MCameraUseCaseHint *useCaseHintApi = mCameraDevice.useCaseHintApi();
hgs
parents: 42
diff changeset
   929
        if (useCaseHintApi) {
hgs
parents: 42
diff changeset
   930
            MCameraUseCaseHint::TVideoCodec codec =
hgs
parents: 42
diff changeset
   931
                    MCameraUseCaseHint::ECodecUnknown;
hgs
parents: 42
diff changeset
   932
            MCameraUseCaseHint::TVideoProfile profile =
hgs
parents: 42
diff changeset
   933
                    MCameraUseCaseHint::EProfileUnknown;
hgs
parents: 42
diff changeset
   934
hgs
parents: 42
diff changeset
   935
            updateVideoCaptureParameters();
hgs
parents: 42
diff changeset
   936
            CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters(
hgs
parents: 42
diff changeset
   937
                    mCurrentVideoDetails, codec, profile);
hgs
parents: 42
diff changeset
   938
hgs
parents: 42
diff changeset
   939
            TSize resolution(mCurrentVideoDetails.mWidth,
hgs
parents: 42
diff changeset
   940
                             mCurrentVideoDetails.mHeight);
hgs
parents: 42
diff changeset
   941
            TRAP_IGNORE(useCaseHintApi->HintDirectVideoCaptureL(codec, profile,
hgs
parents: 42
diff changeset
   942
                                                                resolution));
hgs
parents: 42
diff changeset
   943
        }
hgs
parents: 42
diff changeset
   944
    }
hgs
parents: 42
diff changeset
   945
hgs
parents: 42
diff changeset
   946
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 42
diff changeset
   947
}
hgs
parents: 42
diff changeset
   948
hgs
parents: 42
diff changeset
   949
/*!
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
* 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
   951
* (primary/secondary).
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
*/
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
QList<CxeVideoDetails> CxeVideoCaptureControlSymbian::supportedVideoQualities()
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
{
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
    // 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
   956
    updateRemainingRecordingTimeCounter();
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
    return mIcmSupportedVideoResolutions;
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
}
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
38
hgs
parents: 28
diff changeset
   960
/*!
hgs
parents: 28
diff changeset
   961
* Helper method to handle error during preparing phase.
hgs
parents: 28
diff changeset
   962
*/
hgs
parents: 28
diff changeset
   963
void CxeVideoCaptureControlSymbian::handlePrepareFailed()
hgs
parents: 28
diff changeset
   964
{
hgs
parents: 28
diff changeset
   965
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 28
diff changeset
   966
    CX_DEBUG(("[ERROR] Preparing video failed!"));
hgs
parents: 28
diff changeset
   967
    // Cleanup
hgs
parents: 28
diff changeset
   968
    deinit();
hgs
parents: 28
diff changeset
   969
    // Inform client
hgs
parents: 28
diff changeset
   970
    emit videoPrepareComplete(CxeError::InitializationFailed);
hgs
parents: 28
diff changeset
   971
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 28
diff changeset
   972
}
hgs
parents: 28
diff changeset
   973
hgs
parents: 28
diff changeset
   974
/*!
hgs
parents: 28
diff changeset
   975
* Helper method to handle error from video composing.
hgs
parents: 28
diff changeset
   976
* @param error Symbian error code.
hgs
parents: 28
diff changeset
   977
*/
hgs
parents: 28
diff changeset
   978
void CxeVideoCaptureControlSymbian::handleComposeFailed(int error)
hgs
parents: 28
diff changeset
   979
{
hgs
parents: 28
diff changeset
   980
    CX_DEBUG_ENTER_FUNCTION();
hgs
parents: 28
diff changeset
   981
    CX_DEBUG(("[ERROR] Composing video failed!"));
hgs
parents: 28
diff changeset
   982
    // Inform client
hgs
parents: 28
diff changeset
   983
    emit videoComposed(CxeErrorHandlingSymbian::map(error), filename());
hgs
parents: 28
diff changeset
   984
    // Cleanup
hgs
parents: 28
diff changeset
   985
    deinit();
hgs
parents: 28
diff changeset
   986
    CX_DEBUG_EXIT_FUNCTION();
hgs
parents: 28
diff changeset
   987
}
39
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   988
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   989
/*!
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   990
 * Helper method to emulate video stopping events.
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   991
 */
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   992
void CxeVideoCaptureControlSymbian::emulateNormalStopping()
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   993
{
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   994
    CX_DEBUG_ENTER_FUNCTION();
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   995
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   996
    setState(Stopping);
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   997
    MvruoEvent(TMMFEvent(KCamCControllerCCVideoRecordStopped, KErrNone));
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   998
    MvruoEvent(TMMFEvent(KCamCControllerCCVideoFileComposed, KErrNone));
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
   999
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
  1000
    CX_DEBUG_EXIT_FUNCTION();
c5025ea871a1 201021_1
hgs
parents: 38
diff changeset
  1001
}
19
d9aefe59d544 Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1002
// End of file