1 | /* This file is part of the KDE project |
2 | Copyright (C) 2005-2006, 2008 Matthias Kretz <kretz@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) version 3, or any |
8 | later version accepted by the membership of KDE e.V. (or its |
9 | successor approved by the membership of KDE e.V.), Nokia Corporation |
10 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
11 | act as a proxy defined in Section 6 of version 3 of the license. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | |
21 | */ |
22 | |
23 | #include "phononnamespace_p.h" |
24 | |
25 | #if defined(PHONON_NO_VIDEOCAPTURE) || defined(PHONON_NO_AUDIOCAPTURE) |
26 | #define NO_PHONON_AVCAPTURE |
27 | #endif |
28 | |
29 | #ifndef NO_PHONON_AVCAPTURE |
30 | |
31 | #include "avcapture.h" |
32 | #include "avcapture_p.h" |
33 | |
34 | #include "avcaptureinterface.h" |
35 | #include "factory_p.h" |
36 | #include "globalconfig.h" |
37 | |
38 | #define PHONON_CLASSNAME AvCapture |
39 | #define PHONON_INTERFACENAME AvCaptureInterface |
40 | |
41 | namespace Phonon |
42 | { |
43 | namespace Experimental |
44 | { |
45 | PHONON_OBJECT_IMPL |
46 | |
47 | AvCapture::AvCapture(Phonon::CaptureCategory category, QObject *parent) |
48 | : QObject(parent), MediaNode(*new AvCapturePrivate()) |
49 | { |
50 | setCaptureDevices(category); |
51 | } |
52 | |
53 | Phonon::State AvCapture::state() const |
54 | { |
55 | P_D(const AvCapture); |
56 | if (d->m_backendObject) { |
57 | return INTERFACE_CALL(state()); |
58 | } |
59 | return Phonon::StoppedState; |
60 | } |
61 | |
62 | void AvCapture::start() |
63 | { |
64 | P_D(AvCapture); |
65 | if (d->backendObject()) { |
66 | INTERFACE_CALL(start()); |
67 | } |
68 | } |
69 | |
70 | void AvCapture::pause() |
71 | { |
72 | P_D(AvCapture); |
73 | if (d->backendObject()) { |
74 | INTERFACE_CALL(pause()); |
75 | } |
76 | } |
77 | |
78 | void AvCapture::stop() |
79 | { |
80 | P_D(AvCapture); |
81 | if (d->backendObject()) { |
82 | INTERFACE_CALL(stop()); |
83 | } |
84 | } |
85 | |
86 | void AvCapture::setCaptureDevices(Phonon::CaptureCategory category) |
87 | { |
88 | setAudioCaptureDevice(category); |
89 | setVideoCaptureDevice(category); |
90 | } |
91 | |
92 | Phonon::AudioCaptureDevice AvCapture::audioCaptureDevice() const |
93 | { |
94 | P_D(const AvCapture); |
95 | if (d->m_backendObject) { |
96 | return INTERFACE_CALL(audioCaptureDevice()); |
97 | } |
98 | return d->audioCaptureDevice; |
99 | } |
100 | |
101 | void AvCapture::setAudioCaptureDevice(const Phonon::AudioCaptureDevice &audioCaptureDevice) |
102 | { |
103 | P_D(AvCapture); |
104 | d->audioCaptureDevice = audioCaptureDevice; |
105 | if (d->m_backendObject) { |
106 | INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); |
107 | } |
108 | } |
109 | |
110 | void AvCapture::setAudioCaptureDevice(Phonon::CaptureCategory category) |
111 | { |
112 | P_D(AvCapture); |
113 | d->audioCaptureDevice = AudioCaptureDevice::fromIndex(index: Phonon::GlobalConfig().audioCaptureDeviceFor(category)); |
114 | if (d->m_backendObject) { |
115 | INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); |
116 | } |
117 | } |
118 | |
119 | PHONON_DEPRECATED void AvCapture::setAudioCaptureDevice(Phonon::Category category) |
120 | { |
121 | setAudioCaptureDevice(Phonon::categoryToCaptureCategory(c: category)); |
122 | } |
123 | |
124 | Phonon::VideoCaptureDevice AvCapture::videoCaptureDevice() const |
125 | { |
126 | P_D(const AvCapture); |
127 | if (d->m_backendObject) { |
128 | return INTERFACE_CALL(videoCaptureDevice()); |
129 | } |
130 | return d->videoCaptureDevice; |
131 | } |
132 | |
133 | void AvCapture::setVideoCaptureDevice(const Phonon::Experimental::VideoCaptureDevice &videoCaptureDevice) |
134 | { |
135 | setVideoCaptureDevice(phononExperimentalVcdToVcd(vcd: videoCaptureDevice)); |
136 | } |
137 | |
138 | void AvCapture::setVideoCaptureDevice(const Phonon::VideoCaptureDevice &videoCaptureDevice) |
139 | { |
140 | P_D(AvCapture); |
141 | d->videoCaptureDevice = videoCaptureDevice; |
142 | if (d->m_backendObject) { |
143 | INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); |
144 | } |
145 | } |
146 | |
147 | void AvCapture::setVideoCaptureDevice(Phonon::CaptureCategory category) |
148 | { |
149 | P_D(AvCapture); |
150 | d->videoCaptureDevice = Phonon::VideoCaptureDevice::fromIndex(index: Phonon::GlobalConfig().videoCaptureDeviceFor(category)); |
151 | if (d->m_backendObject) { |
152 | INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); |
153 | } |
154 | } |
155 | |
156 | void AvCapture::setVideoCaptureDevice(Phonon::Category category) |
157 | { |
158 | setVideoCaptureDevice(Phonon::categoryToCaptureCategory(c: category)); |
159 | } |
160 | |
161 | bool AvCapturePrivate::aboutToDeleteBackendObject() |
162 | { |
163 | audioCaptureDevice = pINTERFACE_CALL(audioCaptureDevice()); |
164 | videoCaptureDevice = pINTERFACE_CALL(videoCaptureDevice()); |
165 | return true; |
166 | } |
167 | |
168 | void AvCapturePrivate::setupBackendObject() |
169 | { |
170 | P_Q(AvCapture); |
171 | Q_ASSERT(m_backendObject); |
172 | |
173 | QObject::connect(sender: m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), receiver: q, SIGNAL(stateChanged(Phonon::State,Phonon::State)), Qt::QueuedConnection); |
174 | |
175 | // set up attributes |
176 | pINTERFACE_CALL(setAudioCaptureDevice(audioCaptureDevice)); |
177 | pINTERFACE_CALL(setVideoCaptureDevice(videoCaptureDevice)); |
178 | } |
179 | |
180 | } // namespace Experimental |
181 | } // namespace Phonon |
182 | |
183 | #include "moc_avcapture.cpp" |
184 | |
185 | #undef PHONON_CLASSNAME |
186 | #undef PHONON_INTERFACENAME |
187 | |
188 | #endif // NO_PHONON_AVCAPTURE |
189 | |