2 Copyright (C) 2010 Collabora Ltd. <info@collabora.co.uk>
3 @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
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
7 by the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef CALLCHANNELHANDLER_P_H
19 #define CALLCHANNELHANDLER_P_H
23 #include <QGst/GhostPad>
24 #include <QGst/Pipeline>
25 #include <QGst/StreamVolume>
26 #include <QGst/ColorBalance>
27 #include <QGst/Ui/VideoWidget>
29 #include <TelepathyQt4/Contact>
30 #include <TelepathyQt4/StreamedMediaChannel>
32 #include "callchannelhandler.h"
34 class ParticipantData
;
37 //BEGIN Ugly forward declarations
39 /* These declarations are copied here instead of including the proper headers,
40 * because the proper headers also include too many unrelated stuff and we have
41 * to depend on many useless (at build time) external libraries (such as dbus-glib,
42 * libxml2, gstreamer) for no good reason.
45 typedef unsigned long GType
;
48 typedef struct _GList GList
;
49 typedef struct _TfChannel TfChannel
;
52 GType
fs_codec_list_get_type(void);
53 GList
*fs_codec_list_from_keyfile(const gchar
*filename
, GError
**error
);
54 gboolean
tf_channel_bus_message(TfChannel
*channel
, GstMessage
*message
);
58 Q_DECL_IMPORT TfChannel
*createFarsightChannel(const StreamedMediaChannelPtr
&channel
);
60 //END Ugly forward declarations
63 namespace MaknetoBackend
{
65 class CallChannelHandlerPrivate
: public QObject
{
70 Myself
= 0, RemoteContact
= 1
73 GST_QUEUE_NO_LEAK
= 0,
74 GST_QUEUE_LEAK_UPSTREAM
= 1,
75 GST_QUEUE_LEAK_DOWNSTREAM
= 2
78 inline CallChannelHandlerPrivate(CallChannelHandler
*qq
) : QObject(), q(qq
) {
80 void init(const Tp::StreamedMediaChannelPtr
& channel
);
82 ~CallChannelHandlerPrivate();
84 inline Tp::StreamedMediaChannelPtr
channel() const {
88 inline QList
<CallParticipant
*> participants() const {
89 return m_participants
.values();
91 Tp::ContactPtr
contactOfParticipant(Who who
) const;
95 void onChannelInvalidated(Tp::DBusProxy
*proxy
,
96 const QString
& errorName
,
97 const QString
& errorMessage
);
100 void onBusMessage(const QGst::MessagePtr
& message
);
101 bool tryStopElements(bool audio
, QGst::BinPtr
&bin
, QGst::ElementPtr
& element
, Who who
);
102 bool tryStopElement(const QGst::ElementPtr
&element
, QGst::BinPtr bin
= QGst::BinPtr());
104 // -- from TfChannel signals
105 void onTfChannelClosed();
106 void onSessionCreated(QGst::ElementPtr
& conference
);
107 void onStreamCreated(const QGlib::ObjectPtr
& stream
);
108 GList
*onStreamGetCodecConfig();
110 // -- from TfStream signals
111 void onSrcPadAdded(const QGlib::ObjectPtr
& stream
, QGst::PadPtr
& src
);
112 bool onRequestResource(const QGlib::ObjectPtr
& stream
, uint direction
);
113 void onFreeResource(const QGlib::ObjectPtr
& stream
, uint direction
);
114 void onStreamClosed(const QGlib::ObjectPtr
& stream
);
116 bool createAudioBin(QExplicitlySharedDataPointer
<ParticipantData
> & data
);
117 bool createVideoBin(QExplicitlySharedDataPointer
<ParticipantData
> & data
, bool isVideoSrc
);
121 CallChannelHandler
*q
;
122 Tp::StreamedMediaChannelPtr m_channel
;
124 QMap
<Who
, CallParticipant
*> m_participants
;
125 QExplicitlySharedDataPointer
<ParticipantData
> m_participantData
[2];
127 QGst::PipelinePtr m_pipeline
;
128 QGst::ElementPtr m_audioInputDevice
;
129 QGst::ElementPtr m_videoInputDevice
;
130 QGst::ElementPtr m_audioOutputDevice
;
132 QGlib::ObjectPtr m_tfChannel
;
133 QGst::ElementPtr m_conference
;
136 class ParticipantData
: public QSharedData
{
139 inline ParticipantData() //just for being able to construct the array above without initialization
140 : handlerPriv(NULL
), who(CallChannelHandlerPrivate::Myself
) {
143 inline ParticipantData(CallChannelHandlerPrivate
*h
, CallChannelHandlerPrivate::Who w
)
144 : handlerPriv(h
), who(w
) {
147 QGst::BinPtr audioBin
;
148 QGst::BinPtr videoBin
;
149 QGst::StreamVolumePtr volumeControl
;
150 QGst::ColorBalancePtr colorBalanceControl
;
151 QGst::ElementPtr videoOutElemPtr
;
152 //QWeakPointer<QGst::Ui::VideoWidget> videoWidget;
153 CallChannelHandlerPrivate
*handlerPriv
;
154 CallChannelHandlerPrivate::Who who
;
156 QGst::PadPtr preparedPad
;