Phonon

avcapture.cpp
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
41namespace Phonon
42{
43namespace Experimental
44{
45PHONON_OBJECT_IMPL
46
47AvCapture::AvCapture(Phonon::CaptureCategory category, QObject *parent)
48 : QObject(parent), MediaNode(*new AvCapturePrivate())
49{
50 setCaptureDevices(category);
51}
52
53Phonon::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
63{
64 P_D(AvCapture);
65 if (d->backendObject()) {
66 INTERFACE_CALL(start());
67 }
68}
69
71{
72 P_D(AvCapture);
73 if (d->backendObject()) {
74 INTERFACE_CALL(pause());
75 }
76}
77
79{
80 P_D(AvCapture);
81 if (d->backendObject()) {
82 INTERFACE_CALL(stop());
83 }
84}
85
86void AvCapture::setCaptureDevices(Phonon::CaptureCategory category)
87{
88 setAudioCaptureDevice(category);
89 setVideoCaptureDevice(category);
90}
91
92Phonon::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
102{
103 P_D(AvCapture);
104 d->audioCaptureDevice = audioCaptureDevice;
105 if (d->m_backendObject) {
106 INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice));
107 }
108}
109
110void AvCapture::setAudioCaptureDevice(Phonon::CaptureCategory category)
111{
112 P_D(AvCapture);
113 d->audioCaptureDevice = AudioCaptureDevice::fromIndex(Phonon::GlobalConfig().audioCaptureDeviceFor(category));
114 if (d->m_backendObject) {
115 INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice));
116 }
117}
118
119PHONON_DEPRECATED void AvCapture::setAudioCaptureDevice(Phonon::Category category)
120{
121 setAudioCaptureDevice(Phonon::categoryToCaptureCategory(category));
122}
123
124Phonon::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
134{
135 setVideoCaptureDevice(phononExperimentalVcdToVcd(videoCaptureDevice));
136}
137
139{
140 P_D(AvCapture);
141 d->videoCaptureDevice = videoCaptureDevice;
142 if (d->m_backendObject) {
143 INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice));
144 }
145}
146
147void AvCapture::setVideoCaptureDevice(Phonon::CaptureCategory category)
148{
149 P_D(AvCapture);
150 d->videoCaptureDevice = Phonon::VideoCaptureDevice::fromIndex(Phonon::GlobalConfig().videoCaptureDeviceFor(category));
151 if (d->m_backendObject) {
152 INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice));
153 }
154}
155
156void AvCapture::setVideoCaptureDevice(Phonon::Category category)
157{
158 setVideoCaptureDevice(Phonon::categoryToCaptureCategory(category));
159}
160
161bool AvCapturePrivate::aboutToDeleteBackendObject()
162{
163 audioCaptureDevice = pINTERFACE_CALL(audioCaptureDevice());
164 videoCaptureDevice = pINTERFACE_CALL(videoCaptureDevice());
165 return true;
166}
167
168void AvCapturePrivate::setupBackendObject()
169{
170 P_Q(AvCapture);
171 Q_ASSERT(m_backendObject);
172
173 QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), 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
Media data from a soundcard, soundserver, camera or any other hardware device supported by the backen...
Definition avcapture.h:62
State state() const
Returns the current state of the capture.
Definition avcapture.cpp:53
void setVideoCaptureDevice(const Phonon::VideoCaptureDevice &source)
Sets the video capture source to use.
void start()
Start capture.
Definition avcapture.cpp:62
void setCaptureDevices(Phonon::CaptureCategory category)
Sets both the video and audio devices to the ones most suited for the specified category.
Definition avcapture.cpp:86
void pause()
Pause capture.
Definition avcapture.cpp:70
AvCapture(Phonon::CaptureCategory category, QObject *parent=nullptr)
Constructs an AvCapture with the devices preferred for the specified capture category.
Definition avcapture.cpp:47
void setAudioCaptureDevice(const Phonon::AudioCaptureDevice &source)
Sets the audio capture source to use.
Provides a tuple of enduser visible name and description.
static ObjectDescription< T > fromIndex(int index)
Returns a new description object that describes the device/effect/codec/... with the given index.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QueuedConnection
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.