|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "s60audiomediarecordercontrol.h" |
|
43 #include "s60audiocapturesession.h" |
|
44 |
|
45 #include <QtCore/qdebug.h> |
|
46 |
|
47 S60AudioMediaRecorderControl::S60AudioMediaRecorderControl(QObject *session, QObject *parent) |
|
48 :QMediaRecorderControl(parent), m_state(QMediaRecorder::StoppedState) |
|
49 { |
|
50 m_session = qobject_cast<S60AudioCaptureSession*>(session); |
|
51 connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(durationChanged(qint64))); |
|
52 connect(m_session, SIGNAL(stateChanged(S60AudioCaptureSession::TAudioCaptureState)), this, SLOT(updateState(S60AudioCaptureSession::TAudioCaptureState))); |
|
53 } |
|
54 |
|
55 S60AudioMediaRecorderControl::~S60AudioMediaRecorderControl() |
|
56 { |
|
57 } |
|
58 |
|
59 QUrl S60AudioMediaRecorderControl::outputLocation() const |
|
60 { |
|
61 return m_session->outputLocation(); |
|
62 } |
|
63 |
|
64 bool S60AudioMediaRecorderControl::setOutputLocation(const QUrl& sink) |
|
65 { |
|
66 return m_session->setOutputLocation(sink); |
|
67 } |
|
68 |
|
69 QMediaRecorder::State S60AudioMediaRecorderControl::convertState(S60AudioCaptureSession::TAudioCaptureState aState) const |
|
70 { |
|
71 QMediaRecorder::State state = QMediaRecorder::StoppedState;; |
|
72 switch (aState) { |
|
73 case S60AudioCaptureSession::ERecording: |
|
74 state = QMediaRecorder::RecordingState; |
|
75 break; |
|
76 case S60AudioCaptureSession::EPaused: |
|
77 state = QMediaRecorder::PausedState; |
|
78 break; |
|
79 case S60AudioCaptureSession::ERecordComplete: |
|
80 case S60AudioCaptureSession::ENotInitialized: |
|
81 case S60AudioCaptureSession::EOpenCompelete: |
|
82 case S60AudioCaptureSession::EInitialized: |
|
83 state = QMediaRecorder::StoppedState; |
|
84 break; |
|
85 } |
|
86 return state; |
|
87 } |
|
88 |
|
89 void S60AudioMediaRecorderControl::updateState(S60AudioCaptureSession::TAudioCaptureState aState) |
|
90 { |
|
91 QMediaRecorder::State newState = convertState(aState); |
|
92 if (m_state != newState) { |
|
93 m_state = newState; |
|
94 emit stateChanged(m_state); |
|
95 } |
|
96 } |
|
97 |
|
98 QMediaRecorder::State S60AudioMediaRecorderControl::state() const |
|
99 { |
|
100 return m_state; |
|
101 } |
|
102 |
|
103 qint64 S60AudioMediaRecorderControl::duration() const |
|
104 { |
|
105 return m_session->position(); |
|
106 } |
|
107 |
|
108 void S60AudioMediaRecorderControl::record() |
|
109 { |
|
110 m_session->record(); |
|
111 } |
|
112 |
|
113 void S60AudioMediaRecorderControl::pause() |
|
114 { |
|
115 m_session->pause(); |
|
116 } |
|
117 |
|
118 void S60AudioMediaRecorderControl::stop() |
|
119 { |
|
120 m_session->stop(); |
|
121 } |