File indexing completed on 2024-05-05 04:44:40

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
0003 
0004     This program is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU General Public License as
0006     published by the Free Software Foundation; either version 2 of
0007     the License or (at your option) version 3 or any later version
0008     accepted by the membership of KDE e.V. (or its successor approved
0009     by the membership of KDE e.V.), Nokia Corporation (or its successors,
0010     if any) and the KDE Free Qt Foundation, which shall act as a proxy
0011     defined in Section 14 of version 3 of the license.
0012 
0013     This program 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
0016     GNU General Public License for more details.
0017 
0018     You should have received a copy of the GNU General Public License
0019     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 #include "abstractvideodataoutput.h"
0023 #include "abstractvideodataoutput_p.h"
0024 #include "videodataoutputinterface.h"
0025 #include "factory_p.h"
0026 
0027 namespace Phonon
0028 {
0029 namespace Experimental
0030 {
0031 
0032 AbstractVideoDataOutput::AbstractVideoDataOutput()
0033     : AbstractVideoOutput(*new AbstractVideoDataOutputPrivate)
0034 {
0035     P_D(AbstractVideoDataOutput);
0036     d->isRunning = false;
0037     d->allowedFormats << VideoFrame2::Format_RGB888;
0038 }
0039 
0040 AbstractVideoDataOutput::AbstractVideoDataOutput(AbstractVideoDataOutputPrivate &dd)
0041     : AbstractVideoOutput(dd)
0042 {
0043 }
0044 
0045 AbstractVideoDataOutput::~AbstractVideoDataOutput()
0046 {
0047     setRunning(false);
0048 }
0049 
0050 QSet<VideoFrame2::Format> AbstractVideoDataOutput::allowedFormats() const
0051 {
0052     P_D(const AbstractVideoDataOutput);
0053     return d->allowedFormats;
0054 }
0055 
0056 void AbstractVideoDataOutput::setAllowedFormats(const QSet<VideoFrame2::Format> &allowedFormats)
0057 {
0058     P_D(AbstractVideoDataOutput);
0059     d->allowedFormats = allowedFormats;
0060 }
0061 
0062 bool AbstractVideoDataOutput::isRunning() const
0063 {
0064     P_D(const AbstractVideoDataOutput);
0065     return d->isRunning;
0066 }
0067 
0068 void AbstractVideoDataOutput::setRunning(bool running)
0069 {
0070     P_D(AbstractVideoDataOutput);
0071     d->isRunning = running;
0072     Iface<VideoDataOutputInterface> iface(d);
0073     if (iface) {
0074         if (running) {
0075             iface->setFrontendObject(this);
0076         } else {
0077             iface->setFrontendObject(nullptr);
0078         }
0079     }
0080 }
0081 
0082 void AbstractVideoDataOutput::start()
0083 {
0084     setRunning(true);
0085 }
0086 
0087 void AbstractVideoDataOutput::stop()
0088 {
0089     setRunning(false);
0090 }
0091 
0092 bool AbstractVideoDataOutputPrivate::aboutToDeleteBackendObject()
0093 {
0094     return AbstractVideoOutputPrivate::aboutToDeleteBackendObject();
0095 }
0096 
0097 void AbstractVideoDataOutputPrivate::setupBackendObject()
0098 {
0099     P_Q(AbstractVideoDataOutput);
0100     Q_ASSERT(m_backendObject);
0101     //AbstractVideoOutputPrivate::setupBackendObject();
0102     if (isRunning) {
0103         Iface<VideoDataOutputInterface> iface(this);
0104         if (iface) {
0105             iface->setFrontendObject(q);
0106         }
0107     }
0108 }
0109 
0110 void AbstractVideoDataOutputPrivate::createBackendObject()
0111 {
0112     if (m_backendObject)
0113         return;
0114     //P_Q(AbstractVideoDataOutput);
0115     m_backendObject = Factory::createVideoDataOutput(nullptr);
0116     if (m_backendObject) {
0117         setupBackendObject();
0118     }
0119 }
0120 
0121 } // namespace Experimental
0122 } // namespace Phonon