|
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 <QImage> |
|
20 #include "cxefakequalitypresets.h" |
|
21 #include "cxefakevideocapturecontrol.h" |
|
22 #include "cxutils.h" |
|
23 #include "cxestate.h" |
|
24 |
|
25 CxeFakeVideoCaptureControl::CxeFakeVideoCaptureControl() |
|
26 : CxeStateMachine("CxeFakeVideoCaptureControl") |
|
27 { |
|
28 CX_DEBUG_ENTER_FUNCTION(); |
|
29 |
|
30 initializeStates(); |
|
31 |
|
32 CX_DEBUG_EXIT_FUNCTION(); |
|
33 } |
|
34 |
|
35 CxeFakeVideoCaptureControl::~CxeFakeVideoCaptureControl() |
|
36 { |
|
37 } |
|
38 |
|
39 CxeVideoCaptureControl::State CxeFakeVideoCaptureControl::state() const |
|
40 { |
|
41 return static_cast<State>(stateId()); |
|
42 } |
|
43 |
|
44 void CxeFakeVideoCaptureControl::setState(CxeVideoCaptureControl::State newState) |
|
45 { |
|
46 CxeStateMachine::setState(newState, CxeError::None); |
|
47 } |
|
48 |
|
49 |
|
50 void CxeFakeVideoCaptureControl::record() |
|
51 { |
|
52 CX_DEBUG_IN_FUNCTION(); |
|
53 } |
|
54 |
|
55 void CxeFakeVideoCaptureControl::pause() |
|
56 { |
|
57 CX_DEBUG_IN_FUNCTION(); |
|
58 } |
|
59 |
|
60 void CxeFakeVideoCaptureControl::stop() |
|
61 { |
|
62 CX_DEBUG_ENTER_FUNCTION(); |
|
63 |
|
64 emit videoComposed(CxeError::None, filename()); |
|
65 emit snapshotReady(CxeError::None, QImage(), filename()); |
|
66 |
|
67 CX_DEBUG_EXIT_FUNCTION(); |
|
68 } |
|
69 |
|
70 void CxeFakeVideoCaptureControl::remainingTime(int &time) |
|
71 { |
|
72 CX_DEBUG_IN_FUNCTION(); |
|
73 |
|
74 time = 0; |
|
75 } |
|
76 |
|
77 bool CxeFakeVideoCaptureControl::elapsedTime(int &time) |
|
78 { |
|
79 CX_DEBUG_IN_FUNCTION(); |
|
80 |
|
81 time = 0; |
|
82 return true; |
|
83 } |
|
84 |
|
85 void CxeFakeVideoCaptureControl::reset() |
|
86 { |
|
87 CX_DEBUG_IN_FUNCTION(); |
|
88 } |
|
89 |
|
90 QString CxeFakeVideoCaptureControl::filename() const |
|
91 { |
|
92 CX_DEBUG_IN_FUNCTION(); |
|
93 return "e:/videos/dummyfilename.mp4"; |
|
94 } |
|
95 |
|
96 QPixmap CxeFakeVideoCaptureControl::snapshot() const |
|
97 { |
|
98 CX_DEBUG_IN_FUNCTION(); |
|
99 return QPixmap(); |
|
100 } |
|
101 |
|
102 void CxeFakeVideoCaptureControl::init() |
|
103 { |
|
104 CX_DEBUG_IN_FUNCTION(); |
|
105 mCallHistory.append(Init); |
|
106 } |
|
107 |
|
108 void CxeFakeVideoCaptureControl::deinit() |
|
109 { |
|
110 CX_DEBUG_IN_FUNCTION(); |
|
111 mCallHistory.append(Deinit); |
|
112 } |
|
113 |
|
114 void CxeFakeVideoCaptureControl::initializeStates() |
|
115 { |
|
116 // The fake state machine has more relaxed state transition checks |
|
117 // for testing purposes. |
|
118 int anyState = (Idle | Initialized | Preparing | Ready | Recording | Paused | Stopping | PlayingStartSound); |
|
119 |
|
120 // addState( id, name, allowed next states ) |
|
121 addState(new CxeState(Idle, "Idle", anyState)); |
|
122 addState(new CxeState(Initialized, "Initialized", anyState)); |
|
123 addState(new CxeState(Preparing, "Preparing", anyState)); |
|
124 addState(new CxeState(Ready, "Ready", anyState)); |
|
125 addState(new CxeState(Recording, "Recording", anyState)); |
|
126 addState(new CxeState(Paused, "Paused", anyState)); |
|
127 addState(new CxeState(Stopping, "Stopping", anyState)); |
|
128 addState(new CxeState(PlayingStartSound, "PlayingStartSound", anyState)); |
|
129 |
|
130 setInitialState(Idle); |
|
131 } |
|
132 |
|
133 void CxeFakeVideoCaptureControl::handleStateChanged( |
|
134 int newStateId, CxeError::Id error) |
|
135 { |
|
136 emit stateChanged(static_cast<State> (newStateId), error); |
|
137 } |
|
138 |
|
139 QList<CxeFakeVideoCaptureControl::MethodIndex> CxeFakeVideoCaptureControl::callHistory() const |
|
140 { |
|
141 return mCallHistory; |
|
142 } |
|
143 |
|
144 void CxeFakeVideoCaptureControl::resetCallHistory() |
|
145 { |
|
146 mCallHistory.clear(); |
|
147 } |
|
148 |
|
149 QList<CxeVideoDetails> CxeFakeVideoCaptureControl::supportedVideoQualities() |
|
150 { |
|
151 QList<CxeVideoDetails> list; |
|
152 list.append(CxeFakeQualityPresets::fakeVideoDetails()); |
|
153 return list; |
|
154 } |
|
155 |
|
156 // end of file |