File indexing completed on 2024-05-12 04:44:37

0001 /*
0002     Copyright (C) 2012 Harald Sitter <sitter@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) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Lesser General Public License for more details.
0013 
0014     You should have received a copy of the GNU Lesser General Public
0015     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016 */
0017 
0018 #ifndef Phonon_VLC_VIDEODATAOUTPUT_H
0019 #define Phonon_VLC_VIDEODATAOUTPUT_H
0020 
0021 #include <QMutex>
0022 #include <QObject>
0023 
0024 #include <phonon/experimental/videodataoutputinterface.h>
0025 #include <phonon/experimental/videoframe2.h>
0026 
0027 #include "sinknode.h"
0028 #include "videomemorystream.h"
0029 
0030 namespace Phonon
0031 {
0032 namespace VLC
0033 {
0034 
0035 /**
0036  * @author Harald Sitter <apachelogger@ubuntu.com>
0037  */
0038 class VideoDataOutput : public QObject, public SinkNode,
0039         public Experimental::VideoDataOutputInterface, private VideoMemoryStream
0040 {
0041     Q_OBJECT
0042     Q_INTERFACES(Phonon::Experimental::VideoDataOutputInterface)
0043 public:
0044     explicit VideoDataOutput(QObject *parent);
0045     ~VideoDataOutput();
0046 
0047     void handleConnectToMediaObject(MediaObject *mediaObject) override;
0048     void handleDisconnectFromMediaObject(MediaObject *mediaObject) override;
0049     void handleAddToMedia(Media *media) override;
0050 
0051     Experimental::AbstractVideoDataOutput *frontendObject() const override;
0052     void setFrontendObject(Experimental::AbstractVideoDataOutput *frontend) override;
0053 
0054     void *lockCallback(void **planes) override;
0055     void unlockCallback(void *picture,void *const *planes) override;
0056     void displayCallback(void *picture) override;
0057 
0058     unsigned formatCallback(char *chroma,
0059                                     unsigned *width, unsigned *height,
0060                                     unsigned *pitches,
0061                                     unsigned *lines) override;
0062     void formatCleanUpCallback() override;
0063 
0064 private:
0065     Experimental::AbstractVideoDataOutput *m_frontend;
0066     Experimental::VideoFrame2 m_frame;
0067     QByteArray m_buffer;
0068     QMutex m_mutex;
0069 };
0070 
0071 } // namespace VLC
0072 } // namespace Phonon
0073 
0074 #endif // PHONON_VLC_VIDEODATAOUTPUT_H