1 /*
2     Copyright (C) 2012 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(const vlc_chroma_description_t *chromaDescription,
49                                      unsigned width, unsigned height,
50                                      unsigned *pitches, unsigned *lines,
51                                      unsigned *visiblePitches = 0, unsigned *visibleLines = 0);
52 
53     void setCallbacks(Phonon::VLC::MediaPlayer *player);
54     void unsetCallbacks(Phonon::VLC::MediaPlayer *player);
55 
56 protected:
57     virtual void *lockCallback(void **planes) = 0;
58     virtual void unlockCallback(void *picture,void *const *planes) = 0;
59     virtual void displayCallback(void *picture) = 0;
60 
61     virtual unsigned formatCallback(char *chroma,
62                                     unsigned *width, unsigned *height,
63                                     unsigned *pitches,
64                                     unsigned *lines) = 0;
65     virtual void formatCleanUpCallback() = 0;
66 
67 private:
68     static void *lockCallbackInternal(void *opaque, void **planes);
69     static void unlockCallbackInternal(void *opaque, void *picture, void *const *planes);
70     static void displayCallbackInternal(void *opaque, void *picture);
71 
72     static unsigned formatCallbackInternal(void **opaque, char *chroma,
73                                            unsigned *width, unsigned *height,
74                                            unsigned *pitches,
75                                            unsigned *lines);
76     static void formatCleanUpCallbackInternal(void *opaque);
77 
78 };
79 
80 } // namespace VLC
81 } // namespace Phonon
82 
83 #endif // PHONON_VLC_VIDEOMEMORYSTREAM_H
84