0
|
1 |
/* This file is part of the KDE project.
|
|
2 |
|
|
3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
|
|
5 |
This library is free software: you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU Lesser General Public License as published by
|
|
7 |
the Free Software Foundation, either version 2.1 or 3 of the License.
|
|
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
|
|
12 |
GNU Lesser General Public License for more details.
|
|
13 |
|
|
14 |
You should have received a copy of the GNU Lesser General Public License
|
|
15 |
along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef Phonon_GSTREAMER_VIDEOSINK_H
|
|
19 |
#define Phonon_GSTREAMER_VIDEOSINK_H
|
|
20 |
|
|
21 |
#include "common.h"
|
|
22 |
|
|
23 |
#include <QtCore/QByteArray>
|
|
24 |
#include <QtCore/QEvent>
|
|
25 |
|
|
26 |
#include <gst/video/gstvideosink.h>
|
|
27 |
|
|
28 |
QT_BEGIN_NAMESPACE
|
|
29 |
|
|
30 |
class NewFrameEvent : public QEvent
|
|
31 |
{
|
|
32 |
public:
|
|
33 |
NewFrameEvent(const QByteArray &newFrame, int w, int h) :
|
|
34 |
QEvent(QEvent::User),
|
|
35 |
frame(newFrame),
|
|
36 |
width(w),
|
|
37 |
height(h)
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
QByteArray frame;
|
|
42 |
int width;
|
|
43 |
int height;
|
|
44 |
};
|
|
45 |
|
|
46 |
namespace Phonon
|
|
47 |
{
|
|
48 |
namespace Gstreamer
|
|
49 |
{
|
|
50 |
|
|
51 |
enum VideoFormat {
|
|
52 |
VideoFormat_YUV,
|
|
53 |
VideoFormat_RGB
|
|
54 |
};
|
|
55 |
|
|
56 |
class QWidgetVideoSinkBase
|
|
57 |
{
|
|
58 |
public:
|
|
59 |
GstVideoSink videoSink;
|
|
60 |
|
|
61 |
QWidget * renderWidget;
|
|
62 |
gint width;
|
|
63 |
gint height;
|
|
64 |
gint bpp;
|
|
65 |
gint depth;
|
|
66 |
};
|
|
67 |
|
|
68 |
template <VideoFormat FMT>
|
|
69 |
class QWidgetVideoSink : public QWidgetVideoSinkBase
|
|
70 |
{
|
|
71 |
public:
|
|
72 |
static GstCaps* get_caps(GstBaseSink* sink);
|
|
73 |
static gboolean set_caps(GstBaseSink* sink, GstCaps* caps);
|
|
74 |
static GstStateChangeReturn change_state(GstElement* element, GstStateChange transition);
|
|
75 |
static GstFlowReturn render(GstBaseSink* sink, GstBuffer* buf);
|
|
76 |
static void base_init(gpointer g_class);
|
|
77 |
static void instance_init(GTypeInstance *instance, gpointer g_class);
|
|
78 |
};
|
|
79 |
|
|
80 |
template <VideoFormat FMT>
|
|
81 |
struct QWidgetVideoSinkClass
|
|
82 |
{
|
|
83 |
GstVideoSinkClass parent_class;
|
|
84 |
static void class_init(gpointer g_class, gpointer class_data);
|
|
85 |
static GType get_type();
|
|
86 |
static const char* get_name();
|
|
87 |
};
|
|
88 |
|
|
89 |
GType get_type_YUV();
|
|
90 |
GType get_type_RGB();
|
|
91 |
|
|
92 |
}
|
|
93 |
} //namespace Phonon::Gstreamer
|
|
94 |
|
|
95 |
QT_END_NAMESPACE
|
|
96 |
|
|
97 |
#endif // Phonon_GSTREAMER_VIDEOSINK_H
|