~ubuntu-branches/ubuntu/saucy/kopete/saucy-proposed

« back to all changes in this revision

Viewing changes to protocols/jabber/jingle/jinglertpsession.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-06-21 02:22:39 UTC
  • Revision ID: package-import@ubuntu.com-20130621022239-63l3zc8p0nf26pt6
Tags: upstream-4.10.80
ImportĀ upstreamĀ versionĀ 4.10.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef JINGLE_RTP_SESSION_H
 
2
#define JINGLE_RTP_SESSION_H
 
3
 
 
4
#include <QObject>
 
5
 
 
6
#include <ortp/ortp.h>
 
7
 
 
8
class QAbstractSocket;
 
9
class QUdpSocket;
 
10
class QDomElement;
 
11
class MediaSession;
 
12
 
 
13
class JingleRtpSession : public QObject
 
14
{
 
15
        Q_OBJECT
 
16
public:
 
17
        /*
 
18
         * Directions :
 
19
         *      In = for data coming in.
 
20
         *      Out = for data going out.
 
21
         */
 
22
        enum Direction {In = 0, Out};
 
23
        
 
24
        /*
 
25
         * Creates a new RTP session with direction dir.
 
26
         */
 
27
        JingleRtpSession(Direction dir);
 
28
 
 
29
        /*
 
30
         * Destroys the RTP sessions and frees all allocated memory.
 
31
         */
 
32
        ~JingleRtpSession();
 
33
        
 
34
        /*
 
35
         * Sets the socket as RTP socket. This socket must be connected to a host.
 
36
         * It will create the RTCP socket on port rtcpPort if set, RTP socket port + 1 if not.
 
37
         */
 
38
        void setRtpSocket(QAbstractSocket*, int rtcpPort = 0);
 
39
        
 
40
        /*
 
41
         * Create UDP sockets with the given address and ports respectively for RTP and RTCP.
 
42
         * If rtcpPort is not set, rtpPort + 1 will be used.
 
43
         */
 
44
        void connectToHost(const QString& address, int rtpPort, int rtcpPort = 0);
 
45
        
 
46
        /*
 
47
         * Binds sockets to any address on ports rtpPort and rtcpPort for respectively RTP and RTCP.
 
48
         * If rtcpPort is not set, rtpPort + 1 will be used.
 
49
         */
 
50
        void bind(int rtpPort, int rtcpPort = 0);
 
51
 
 
52
        /*
 
53
         * Sends data to the remote host after wrapping it in a RTP packet.
 
54
         * TODO:There should be overloaded methods to support other data type (QString, const *char).
 
55
         */
 
56
        void send(const QByteArray& data);
 
57
 
 
58
        /*
 
59
         * Sets the payload type used for this session.
 
60
         * The argument is the payload type in a payload-type XML tag.
 
61
         */
 
62
        void setPayload(const QDomElement& payload);
 
63
 
 
64
        void setMediaSession(MediaSession *mSession);
 
65
 
 
66
private slots:
 
67
        /*
 
68
         * Called when rtp data is ready to be read from the socket, we then wait
 
69
         * for the media data to be extracted from the RTP packet by oRTP.
 
70
         */
 
71
        void rtpDataReady();
 
72
        void rtcpDataReady(); // Maybe not used.
 
73
 
 
74
signals:
 
75
        void dataSent();
 
76
        void readyRead(const QByteArray&);
 
77
 
 
78
private:
 
79
        QUdpSocket *rtpSocket;
 
80
        QUdpSocket *rtcpSocket;
 
81
        RtpSession *m_rtpSession;
 
82
        int payloadID;
 
83
        QString payloadName;
 
84
        enum State {SendingData = 0} state;
 
85
        Direction m_direction;
 
86
        int bufSize;
 
87
        QByteArray inData;
 
88
        MediaSession *m_mediaSession;
 
89
};
 
90
 
 
91
#endif