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