File indexing completed on 2024-05-05 04:44:40
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005-2006, 2008 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 0023 #include "phononnamespace_p.h" 0024 0025 #if defined(PHONON_NO_VIDEOCAPTURE) || defined(PHONON_NO_AUDIOCAPTURE) 0026 #define NO_PHONON_AVCAPTURE 0027 #endif 0028 0029 #ifndef NO_PHONON_AVCAPTURE 0030 0031 #include "avcapture.h" 0032 #include "avcapture_p.h" 0033 0034 #include "avcaptureinterface.h" 0035 #include "factory_p.h" 0036 #include "globalconfig.h" 0037 0038 #define PHONON_CLASSNAME AvCapture 0039 #define PHONON_INTERFACENAME AvCaptureInterface 0040 0041 namespace Phonon 0042 { 0043 namespace Experimental 0044 { 0045 PHONON_OBJECT_IMPL 0046 0047 AvCapture::AvCapture(Phonon::CaptureCategory category, QObject *parent) 0048 : QObject(parent), MediaNode(*new AvCapturePrivate()) 0049 { 0050 setCaptureDevices(category); 0051 } 0052 0053 Phonon::State AvCapture::state() const 0054 { 0055 P_D(const AvCapture); 0056 if (d->m_backendObject) { 0057 return INTERFACE_CALL(state()); 0058 } 0059 return Phonon::StoppedState; 0060 } 0061 0062 void AvCapture::start() 0063 { 0064 P_D(AvCapture); 0065 if (d->backendObject()) { 0066 INTERFACE_CALL(start()); 0067 } 0068 } 0069 0070 void AvCapture::pause() 0071 { 0072 P_D(AvCapture); 0073 if (d->backendObject()) { 0074 INTERFACE_CALL(pause()); 0075 } 0076 } 0077 0078 void AvCapture::stop() 0079 { 0080 P_D(AvCapture); 0081 if (d->backendObject()) { 0082 INTERFACE_CALL(stop()); 0083 } 0084 } 0085 0086 void AvCapture::setCaptureDevices(Phonon::CaptureCategory category) 0087 { 0088 setAudioCaptureDevice(category); 0089 setVideoCaptureDevice(category); 0090 } 0091 0092 Phonon::AudioCaptureDevice AvCapture::audioCaptureDevice() const 0093 { 0094 P_D(const AvCapture); 0095 if (d->m_backendObject) { 0096 return INTERFACE_CALL(audioCaptureDevice()); 0097 } 0098 return d->audioCaptureDevice; 0099 } 0100 0101 void AvCapture::setAudioCaptureDevice(const Phonon::AudioCaptureDevice &audioCaptureDevice) 0102 { 0103 P_D(AvCapture); 0104 d->audioCaptureDevice = audioCaptureDevice; 0105 if (d->m_backendObject) { 0106 INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); 0107 } 0108 } 0109 0110 void AvCapture::setAudioCaptureDevice(Phonon::CaptureCategory category) 0111 { 0112 P_D(AvCapture); 0113 d->audioCaptureDevice = AudioCaptureDevice::fromIndex(Phonon::GlobalConfig().audioCaptureDeviceFor(category)); 0114 if (d->m_backendObject) { 0115 INTERFACE_CALL(setAudioCaptureDevice(d->audioCaptureDevice)); 0116 } 0117 } 0118 0119 PHONON_DEPRECATED void AvCapture::setAudioCaptureDevice(Phonon::Category category) 0120 { 0121 setAudioCaptureDevice(Phonon::categoryToCaptureCategory(category)); 0122 } 0123 0124 Phonon::VideoCaptureDevice AvCapture::videoCaptureDevice() const 0125 { 0126 P_D(const AvCapture); 0127 if (d->m_backendObject) { 0128 return INTERFACE_CALL(videoCaptureDevice()); 0129 } 0130 return d->videoCaptureDevice; 0131 } 0132 0133 void AvCapture::setVideoCaptureDevice(const Phonon::Experimental::VideoCaptureDevice &videoCaptureDevice) 0134 { 0135 setVideoCaptureDevice(phononExperimentalVcdToVcd(videoCaptureDevice)); 0136 } 0137 0138 void AvCapture::setVideoCaptureDevice(const Phonon::VideoCaptureDevice &videoCaptureDevice) 0139 { 0140 P_D(AvCapture); 0141 d->videoCaptureDevice = videoCaptureDevice; 0142 if (d->m_backendObject) { 0143 INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); 0144 } 0145 } 0146 0147 void AvCapture::setVideoCaptureDevice(Phonon::CaptureCategory category) 0148 { 0149 P_D(AvCapture); 0150 d->videoCaptureDevice = Phonon::VideoCaptureDevice::fromIndex(Phonon::GlobalConfig().videoCaptureDeviceFor(category)); 0151 if (d->m_backendObject) { 0152 INTERFACE_CALL(setVideoCaptureDevice(d->videoCaptureDevice)); 0153 } 0154 } 0155 0156 void AvCapture::setVideoCaptureDevice(Phonon::Category category) 0157 { 0158 setVideoCaptureDevice(Phonon::categoryToCaptureCategory(category)); 0159 } 0160 0161 bool AvCapturePrivate::aboutToDeleteBackendObject() 0162 { 0163 audioCaptureDevice = pINTERFACE_CALL(audioCaptureDevice()); 0164 videoCaptureDevice = pINTERFACE_CALL(videoCaptureDevice()); 0165 return true; 0166 } 0167 0168 void AvCapturePrivate::setupBackendObject() 0169 { 0170 P_Q(AvCapture); 0171 Q_ASSERT(m_backendObject); 0172 0173 QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SIGNAL(stateChanged(Phonon::State,Phonon::State)), Qt::QueuedConnection); 0174 0175 // set up attributes 0176 pINTERFACE_CALL(setAudioCaptureDevice(audioCaptureDevice)); 0177 pINTERFACE_CALL(setVideoCaptureDevice(videoCaptureDevice)); 0178 } 0179 0180 } // namespace Experimental 0181 } // namespace Phonon 0182 0183 #include "moc_avcapture.cpp" 0184 0185 #undef PHONON_CLASSNAME 0186 #undef PHONON_INTERFACENAME 0187 0188 #endif // NO_PHONON_AVCAPTURE