| 1 | /* |
| 2 | Copyright (C) 2012-2021 Harald Sitter <sitter@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) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef PHONON_VLC_VIDEOMEMORYSTREAM_H |
| 19 | #define PHONON_VLC_VIDEOMEMORYSTREAM_H |
| 20 | |
| 21 | // VLC 3.0 uses the restrict keyword. restrict is not a thing in C++, so |
| 22 | // depending on the compiler you use an extension keyword or drop it entirely. |
| 23 | #if defined(Q_CC_GNU) |
| 24 | #define restrict __restrict__ |
| 25 | #elif defined(Q_CC_MSVC) |
| 26 | #define restrict __restrict |
| 27 | #else |
| 28 | #define restrict |
| 29 | #endif |
| 30 | |
| 31 | #include <vlc/plugins/vlc_common.h> |
| 32 | #include <vlc/plugins/vlc_fourcc.h> |
| 33 | |
| 34 | namespace Phonon { |
| 35 | namespace VLC { |
| 36 | |
| 37 | class MediaPlayer; |
| 38 | |
| 39 | class VideoMemoryStream |
| 40 | { |
| 41 | public: |
| 42 | explicit VideoMemoryStream(); |
| 43 | virtual ~VideoMemoryStream(); |
| 44 | |
| 45 | /** |
| 46 | * @returns overall buffersize needed |
| 47 | */ |
| 48 | static unsigned setPitchAndLines(uint32_t fourcc, |
| 49 | unsigned width, unsigned height, |
| 50 | unsigned *pitches, unsigned *lines); |
| 51 | |
| 52 | void setCallbacks(Phonon::VLC::MediaPlayer *player); |
| 53 | void unsetCallbacks(Phonon::VLC::MediaPlayer *player); |
| 54 | |
| 55 | protected: |
| 56 | virtual void *lockCallback(void **planes) = 0; |
| 57 | virtual void unlockCallback(void *picture,void *const *planes) = 0; |
| 58 | virtual void displayCallback(void *picture) = 0; |
| 59 | |
| 60 | virtual unsigned formatCallback(char *chroma, |
| 61 | unsigned *width, unsigned *height, |
| 62 | unsigned *pitches, |
| 63 | unsigned *lines) = 0; |
| 64 | virtual void formatCleanUpCallback() = 0; |
| 65 | |
| 66 | private: |
| 67 | static void *lockCallbackInternal(void *opaque, void **planes); |
| 68 | static void unlockCallbackInternal(void *opaque, void *picture, void *const *planes); |
| 69 | static void displayCallbackInternal(void *opaque, void *picture); |
| 70 | |
| 71 | static unsigned formatCallbackInternal(void **opaque, char *chroma, |
| 72 | unsigned *width, unsigned *height, |
| 73 | unsigned *pitches, |
| 74 | unsigned *lines); |
| 75 | static void formatCleanUpCallbackInternal(void *opaque); |
| 76 | |
| 77 | }; |
| 78 | |
| 79 | } // namespace VLC |
| 80 | } // namespace Phonon |
| 81 | |
| 82 | #endif // PHONON_VLC_VIDEOMEMORYSTREAM_H |
| 83 | |