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

0001 /*
0002     Copyright (C) 2012-2021 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_VIDEOMEMORYSTREAM_H
0019 #define PHONON_VLC_VIDEOMEMORYSTREAM_H
0020 
0021 // VLC 3.0 uses the restrict keyword. restrict is not a thing in C++, so
0022 // depending on the compiler you use an extension keyword or drop it entirely.
0023 #if defined(Q_CC_GNU)
0024 #define restrict __restrict__
0025 #elif defined(Q_CC_MSVC)
0026 #define restrict __restrict
0027 #else
0028 #define restrict
0029 #endif
0030 
0031 #include <vlc/plugins/vlc_common.h>
0032 #include <vlc/plugins/vlc_fourcc.h>
0033 
0034 namespace Phonon {
0035 namespace VLC {
0036 
0037 class MediaPlayer;
0038 
0039 class VideoMemoryStream
0040 {
0041 public:
0042     explicit VideoMemoryStream();
0043     virtual ~VideoMemoryStream();
0044 
0045     /**
0046      * @returns overall buffersize needed
0047      */
0048     static unsigned setPitchAndLines(uint32_t fourcc,
0049                                      unsigned width, unsigned height,
0050                                      unsigned *pitches, unsigned *lines);
0051 
0052     void setCallbacks(Phonon::VLC::MediaPlayer *player);
0053     void unsetCallbacks(Phonon::VLC::MediaPlayer *player);
0054 
0055 protected:
0056     virtual void *lockCallback(void **planes) = 0;
0057     virtual void unlockCallback(void *picture,void *const *planes) = 0;
0058     virtual void displayCallback(void *picture) = 0;
0059 
0060     virtual unsigned formatCallback(char *chroma,
0061                                     unsigned *width, unsigned *height,
0062                                     unsigned *pitches,
0063                                     unsigned *lines) = 0;
0064     virtual void formatCleanUpCallback() = 0;
0065 
0066 private:
0067     static void *lockCallbackInternal(void *opaque, void **planes);
0068     static void unlockCallbackInternal(void *opaque, void *picture, void *const *planes);
0069     static void displayCallbackInternal(void *opaque, void *picture);
0070 
0071     static unsigned formatCallbackInternal(void **opaque, char *chroma,
0072                                            unsigned *width, unsigned *height,
0073                                            unsigned *pitches,
0074                                            unsigned *lines);
0075     static void formatCleanUpCallbackInternal(void *opaque);
0076 
0077 };
0078 
0079 } // namespace VLC
0080 } // namespace Phonon
0081 
0082 #endif // PHONON_VLC_VIDEOMEMORYSTREAM_H