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 | #ifndef PHONON_EXPERIMENTAL_AVCAPTURE_H |
23 | #define PHONON_EXPERIMENTAL_AVCAPTURE_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 "export.h" |
32 | #include "../medianode.h" |
33 | #include "../phonondefs.h" |
34 | #include "objectdescription.h" |
35 | #include <phonon/phononnamespace.h> |
36 | |
37 | #include <QStringList> |
38 | class QString; |
39 | |
40 | namespace Phonon |
41 | { |
42 | namespace Experimental |
43 | { |
44 | |
45 | class AvCapturePrivate; |
46 | |
47 | /** |
48 | * @short Media data from a soundcard, soundserver, camera or any other |
49 | * hardware device supported by the backend. |
50 | * |
51 | * This class gives you access to the capture capabilities of the backend. |
52 | * There might be more than only one possible capture source, for audio, as |
53 | * well as for video. A preferable device may easily be obtained by providing |
54 | * a capture category. |
55 | * |
56 | * @ingroup Recording |
57 | * @author Matthias Kretz <kretz@kde.org> |
58 | * @see BackendCapabilities::availableAudioCaptureDevices |
59 | * @see BackendCapabilities::availableVideoCaptureDevices |
60 | */ |
61 | class PHONONEXPERIMENTAL_EXPORT AvCapture : public QObject, public Phonon::MediaNode |
62 | { |
63 | Q_OBJECT |
64 | P_DECLARE_PRIVATE(AvCapture) |
65 | PHONON_OBJECT(AvCapture) |
66 | Q_PROPERTY(Phonon::AudioCaptureDevice audioCaptureDevice READ audioCaptureDevice WRITE setAudioCaptureDevice) |
67 | Q_PROPERTY(Phonon::VideoCaptureDevice videoCaptureDevice READ videoCaptureDevice WRITE setVideoCaptureDevice) |
68 | public: |
69 | /** |
70 | * Constructs an AvCapture with the devices preferred for the specified |
71 | * capture category. |
72 | * |
73 | * @param category Used to determine what devices are most suited for |
74 | * the AvCapture. |
75 | * |
76 | * @see CaptureCategory |
77 | */ |
78 | AvCapture(Phonon::CaptureCategory category, QObject *parent = nullptr); |
79 | |
80 | /** |
81 | * Returns the current state of the capture. |
82 | * |
83 | * @li If only the audio capture device is valid, it returns the audio capture state. |
84 | * @li If only the video capture device is valid, it returns the video capture state. |
85 | * @li If both the audio and video capture devices are valid, it only returns the |
86 | * video capture state. |
87 | */ |
88 | State state() const; |
89 | |
90 | /** |
91 | * Returns the currently used capture source for the audio signal. |
92 | */ |
93 | Phonon::AudioCaptureDevice audioCaptureDevice() const; |
94 | |
95 | /** |
96 | * Returns the currently used capture source for the video signal. |
97 | */ |
98 | Phonon::VideoCaptureDevice videoCaptureDevice() const; |
99 | |
100 | /** |
101 | * Sets both the video and audio devices to the ones most suited for the |
102 | * specified category |
103 | * |
104 | * @param category Used to determine what devices are most suited for |
105 | * the AvCapture. |
106 | */ |
107 | void setCaptureDevices(Phonon::CaptureCategory category); |
108 | |
109 | /** |
110 | * Sets the audio capture source to use. |
111 | * |
112 | * @param source An object of class AudioCaptureDevice. |
113 | * |
114 | */ |
115 | void setAudioCaptureDevice(const Phonon::AudioCaptureDevice &source); |
116 | |
117 | /** |
118 | * Sets the audio capture device by using a capture category to get |
119 | * the appropriate device. |
120 | * |
121 | * @param category Capture category to use for getting a device |
122 | */ |
123 | void setAudioCaptureDevice(Phonon::CaptureCategory category); |
124 | |
125 | PHONON_DEPRECATED void setAudioCaptureDevice(Phonon::Category category); |
126 | |
127 | /** |
128 | * Sets the video capture source to use. |
129 | * |
130 | * @param source An object of class VideoCaptureDevice. |
131 | * |
132 | * @see videoCaptureDevice |
133 | * @see setVideoCaptureDevice(int) |
134 | */ |
135 | void setVideoCaptureDevice(const Phonon::VideoCaptureDevice &source); |
136 | |
137 | /** |
138 | * Sets the audio capture device by using a capture category to get |
139 | * the appropriate device. |
140 | * |
141 | * @param category Capture category to use for getting a device |
142 | */ |
143 | void setVideoCaptureDevice(Phonon::CaptureCategory category); |
144 | |
145 | PHONON_DEPRECATED void setVideoCaptureDevice(Phonon::Category category); |
146 | |
147 | /** |
148 | * @deprecated since 4.4.3, use |
149 | * setVideoCaptureDevice(const Phonon::VideoCaptureDevice &source) instead |
150 | */ |
151 | PHONON_DEPRECATED void setVideoCaptureDevice(const Phonon::Experimental::VideoCaptureDevice &source); |
152 | |
153 | public Q_SLOTS: |
154 | /** |
155 | * Start capture. |
156 | */ |
157 | void start(); |
158 | |
159 | /** |
160 | * Pause capture. |
161 | */ |
162 | void pause(); |
163 | |
164 | /** |
165 | * Stop capture. |
166 | */ |
167 | void stop(); |
168 | |
169 | Q_SIGNALS: |
170 | /** |
171 | * Emitted when the state of the video or audio capture device has been changed. |
172 | * |
173 | * \li If only the audio capture device is valid, it notifies about the audio capture state. |
174 | * \li If only the video capture device is valid, it notifies about the video capture state. |
175 | * \li If both the audio and video capture devices are valid, it only notifies about the |
176 | * video capture state. |
177 | */ |
178 | void stateChanged(Phonon::State newstate, Phonon::State oldstate); |
179 | }; |
180 | |
181 | } // namespace Experimental |
182 | } // namespace Phonon |
183 | |
184 | #endif // NO_PHONON_AVCAPTURE |
185 | |
186 | #endif // PHONON_EXPERIMENTAL_AVCAPTURE_H |
187 | |