camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideocapturecontrol.cpp
changeset 19 d9aefe59d544
child 37 64817133cd1d
equal deleted inserted replaced
3:8b2d6d0384b0 19:d9aefe59d544
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QPixmap>
       
    19 #include "cxefakequalitypresets.h"
       
    20 #include "cxefakevideocapturecontrol.h"
       
    21 #include "cxutils.h"
       
    22 #include "cxestate.h"
       
    23 
       
    24 CxeFakeVideoCaptureControl::CxeFakeVideoCaptureControl()
       
    25     : CxeStateMachine("CxeFakeVideoCaptureControl")
       
    26 {
       
    27     CX_DEBUG_ENTER_FUNCTION();
       
    28 
       
    29     initializeStates();
       
    30 
       
    31     CX_DEBUG_EXIT_FUNCTION();
       
    32 }
       
    33 
       
    34 CxeFakeVideoCaptureControl::~CxeFakeVideoCaptureControl()
       
    35 {
       
    36 }
       
    37 
       
    38 CxeVideoCaptureControl::State CxeFakeVideoCaptureControl::state() const
       
    39 {
       
    40     return static_cast<State>(stateId());
       
    41 }
       
    42 
       
    43 void CxeFakeVideoCaptureControl::setState(CxeVideoCaptureControl::State newState)
       
    44 {
       
    45     CxeStateMachine::setState(newState, CxeError::None);
       
    46 }
       
    47 
       
    48 
       
    49 void CxeFakeVideoCaptureControl::record()
       
    50 {
       
    51     CX_DEBUG_IN_FUNCTION();
       
    52 }
       
    53 
       
    54 void CxeFakeVideoCaptureControl::pause()
       
    55 {
       
    56     CX_DEBUG_IN_FUNCTION();
       
    57 }
       
    58 
       
    59 void CxeFakeVideoCaptureControl::stop()
       
    60 {
       
    61     CX_DEBUG_ENTER_FUNCTION();
       
    62 
       
    63     emit videoComposed(CxeError::None, filename());
       
    64     emit snapshotReady(CxeError::None, snapshot(), filename());
       
    65 
       
    66     CX_DEBUG_EXIT_FUNCTION();
       
    67 }
       
    68 
       
    69 void CxeFakeVideoCaptureControl::remainingTime(int &time)
       
    70 {
       
    71     CX_DEBUG_IN_FUNCTION();
       
    72 
       
    73     time = 0;
       
    74 }
       
    75 
       
    76 bool CxeFakeVideoCaptureControl::elapsedTime(int &time)
       
    77 {
       
    78     CX_DEBUG_IN_FUNCTION();
       
    79 
       
    80     time = 0;
       
    81     return true;
       
    82 }
       
    83 
       
    84 void CxeFakeVideoCaptureControl::reset()
       
    85 {
       
    86     CX_DEBUG_IN_FUNCTION();
       
    87 }
       
    88 
       
    89 QString CxeFakeVideoCaptureControl::filename() const
       
    90 {
       
    91     CX_DEBUG_IN_FUNCTION();
       
    92     return "e:/videos/dummyfilename.mp4";
       
    93 }
       
    94 
       
    95 QPixmap CxeFakeVideoCaptureControl::snapshot() const
       
    96 {
       
    97     CX_DEBUG_IN_FUNCTION();
       
    98     return QPixmap();
       
    99 }
       
   100 
       
   101 void CxeFakeVideoCaptureControl::init()
       
   102 {
       
   103     CX_DEBUG_IN_FUNCTION();
       
   104     mCallHistory.append(Init);
       
   105 }
       
   106 
       
   107 void CxeFakeVideoCaptureControl::deinit()
       
   108 {
       
   109     CX_DEBUG_IN_FUNCTION();
       
   110     mCallHistory.append(Deinit);
       
   111 }
       
   112 
       
   113 void CxeFakeVideoCaptureControl::initializeStates()
       
   114 {
       
   115     // The fake state machine has more relaxed state transition checks
       
   116     // for testing purposes.
       
   117     int anyState = (Idle | Initialized | Preparing | Ready | Recording | Paused | Stopping | PlayingStartSound);
       
   118 
       
   119     // addState( id, name, allowed next states )
       
   120     addState(new CxeState(Idle, "Idle", anyState));
       
   121     addState(new CxeState(Initialized, "Initialized", anyState));
       
   122     addState(new CxeState(Preparing, "Preparing", anyState));
       
   123     addState(new CxeState(Ready, "Ready", anyState));
       
   124     addState(new CxeState(Recording, "Recording", anyState));
       
   125     addState(new CxeState(Paused, "Paused", anyState));
       
   126     addState(new CxeState(Stopping, "Stopping", anyState));
       
   127     addState(new CxeState(PlayingStartSound, "PlayingStartSound", anyState));
       
   128 
       
   129     setInitialState(Idle);
       
   130 }
       
   131 
       
   132 void CxeFakeVideoCaptureControl::handleStateChanged(
       
   133         int newStateId, CxeError::Id error)
       
   134 {
       
   135     emit stateChanged(static_cast<State> (newStateId), error);
       
   136 }
       
   137 
       
   138 QList<CxeFakeVideoCaptureControl::MethodIndex> CxeFakeVideoCaptureControl::callHistory() const
       
   139 {
       
   140     return mCallHistory;
       
   141 }
       
   142 
       
   143 void CxeFakeVideoCaptureControl::resetCallHistory()
       
   144 {
       
   145     mCallHistory.clear();
       
   146 }
       
   147 
       
   148 QList<CxeVideoDetails> CxeFakeVideoCaptureControl::supportedVideoQualities()
       
   149 {
       
   150     QList<CxeVideoDetails> list;
       
   151     list.append(CxeFakeQualityPresets::fakeVideoDetails());
       
   152     return list;
       
   153 }
       
   154 
       
   155 // end of file