[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle
From:       Detlev Casanova <detlev.casanova () gmail ! com>
Date:       2008-08-18 18:59:18
Message-ID: 1219085958.727814.22463.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 848944 by casanova:

 * Sending and receiving ok, but data seems to be wrong, no time to test more, I only \
                have 2 minutes left :-)
 * A workaround has been made to receive data, something is wrong with QUdpSocket...


 M  +20 -21    alsaio.cpp  
 M  +1 -1      jabberjinglecontent.cpp  
 M  +25 -12    jinglertpsession.cpp  


--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/alsaio.cpp \
#848943:848944 @@ -1,3 +1,19 @@
+ /*
+  * alsaio.cpp - An alsa I/O manager (works in Capture or in Playback mode but not \
both at a time.) +  *
+  * Copyright (c) 2008 by Detlev Casanova <detlev.casanova@gmail.com>
+  *
+  * Kopete    (c) by the Kopete developers  <kopete-devel@kde.org>
+  *
+  * *************************************************************************
+  * *                                                                       *
+  * * This program is free software; you can redistribute it and/or modify  *
+  * * it under the terms of the GNU General Public License as published by  *
+  * * the Free Software Foundation; either version 2 of the License, or     *
+  * * (at your option) any later version.                                   *
+  * *                                                                       *
+  * *************************************************************************
+  */
 #include <alsa/asoundlib.h>
 
 #include <QObject>
@@ -190,25 +206,8 @@
 		return; // Must delete the data before ?
 	}
 
-	kDebug() << "Appending received data";
+	kDebug() << "Appending received data (" << data.size() << "bytes)";
 	buf.append(data);
-
-	/*int ret;
-	if ((ret = ::write(ufds[0].fd, (const void*)data.data(), data.size())) < 0)
-	{
-		kDebug() << "fd =" << ufds[0].fd;
-		kDebug() << "There was an error writing on the audio device." << ret;
-		kDebug() << "errno =" << errno;
-		kDebug() << "Trying writei()";
-		ret = snd_pcm_writei(handle, data.data(), data.size());
-		if (ret < 0)
-			kDebug() << "You are not lucky :-( writei did not work either... :" << \
                snd_strerror(ret);
-		else
-			kDebug() << "Written" << ret << "bytes on the audio device. You hear anything ? \
                don't forget to unmute !!!!";
-		return;
-	}
-	kDebug() << "Written" << ret << "bytes on the audio device. You hear anything ? \
                don't forget to unmute !!!!";
-	*/
 }
 
 bool AlsaIO::isReady()
@@ -249,7 +248,7 @@
 	return ts;
 }
 
-void AlsaIO::slotActivated(int)
+void AlsaIO::slotActivated(int) //Rename this slot
 {
 	//kDebug() << "Data arrived. (Alsa told me !)";
 	size_t size;
@@ -270,7 +269,7 @@
 	snd_pcm_poll_descriptors_revents(handle, ufds, fdCount, &revents);
 
 	if (revents & POLLOUT)
-		writeData();//This should write data which have been bufed when the application \
called "write". +		writeData();
 	else
 		kDebug() << "poll returned no event (" << revents << ", " << ufds[0].revents << ") \
?";	  }
@@ -281,7 +280,7 @@
 	//kDebug() << "Buffer size =" << buf.size();
 	if (buf.size() <= 0)
 	{
-	//	kDebug() << "No Data in the buffer.";
+		kDebug() << "No Data in the buffer.";
 		return;
 	}
 
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/jabberjinglecontent.cpp \
#848943:848944 @@ -95,7 +95,7 @@
 
 void JabberJingleContent::slotIncomingData(const QByteArray& data)
 {
-	kDebug() << "Receiving ! (" << data.size() << "bytes)";
+	//kDebug() << "Receiving ! (" << data.size() << "bytes)";
 	m_mediaSession->playData(data);
 }
 
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/jinglertpsession.cpp \
#848943:848944 @@ -70,19 +70,37 @@
 void JingleRtpSession::setRtpSocket(QAbstractSocket* socket, int rtcpPort)
 {
 	kDebug() << (socket->isValid() ? "Socket ready" : "Socket not ready");
-	//delete rtpSocket;
-	rtpSocket = (QUdpSocket*) socket;
+	
+	//rtpSocket = (QUdpSocket*) socket;
+	
+	// WARNING, this is a workaround, that's not clean code.
+	// What I do here is that I create a new socket for RTP with information which are \
in the old one. +	// that means we have to re-bind or re-connect it.
+	// As long as we are here, the connection is possible with that socket and
+	// UDP policy does not prevent me to do that.
+	
+	rtpSocket = new QUdpSocket(this); //Part of the workaround
 	rtcpSocket = new QUdpSocket(this);
 	
 	if (m_direction == In)
 	{
+		int localPort = socket->localPort();
+		delete socket;
+		rtpSocket->bind(localPort); // ^ Part of the workaround
+
 		kDebug() << "Given socket is bound to :" << rtpSocket->localPort();
 		kDebug() << "RTCP socket will be bound to :" << (rtcpPort == 0 ? \
rtpSocket->localPort() + 1 : rtcpPort);  connect(rtpSocket, SIGNAL(readyRead()), \
this, SLOT(rtpDataReady())); +		connect(rtcpSocket, SIGNAL(readyRead()), this, \
SLOT(rtcpDataReady()));  rtcpSocket->bind(/*rtpSocket->localAddress(), */rtcpPort == \
0 ? rtpSocket->localPort() + 1 : rtcpPort);  }
 	else if (m_direction == Out)
 	{
+		int peerPort = socket->peerPort();
+		QHostAddress peerAddress = socket->peerAddress();
+		delete socket;
+		rtpSocket->connectToHost(peerAddress, peerPort); //Part of the workaround
+
 		kDebug() << "Given socket is connected to" << rtpSocket->peerAddress() << ":" << \
rtpSocket->peerPort();  kDebug() << "RTCP socket will be connected to" << \
rtpSocket->peerAddress() << ":" << (rtcpPort == 0 ? rtpSocket->peerPort() + 1 : \
rtcpPort);  connect(rtpSocket, SIGNAL(bytesWritten(qint64)), this, \
SLOT(slotBytesWritten(qint64))); @@ -127,35 +145,30 @@
 
 void JingleRtpSession::rtpDataReady()
 {
-	kDebug() << "JingleRtpSession::rtpDataReady";
+	mblk_t *packet;
 	
-	//kDebug() << "receivingTS =" << receivingTS;
-	mblk_t *packet;
-	/*if ((packet = rtp_session_recvm_with_ts(m_rtpSession, receivingTS)) == NULL)
-	{
-		//We skip this time, packet is NULL, that's not interresting....
-		kDebug() << "Packet is Null, Skip !";
-		return;
-	}*/
 	//This is the only way I found to get data once in a while, sometimes, it just \
hangs...  while ((packet = rtp_session_recvm_with_ts(m_rtpSession, receivingTS)) == \
NULL)  {
 		//kDebug() << "Packet is Null, retrying.";
 		receivingTS += payloadTS;
 	}
+	
 	QByteArray data((char*) packet->b_cont->b_rptr, packet->b_cont->b_wptr - \
packet->b_cont->b_rptr);  
 	// Seems we should empty the socket...
 	QByteArray buf;
 	buf.resize(rtpSocket->pendingDatagramSize());
 	rtpSocket->readDatagram(buf.data(), rtpSocket->pendingDatagramSize());
+
+	kDebug() << "Data size =" << data.size();
 	
 	emit readyRead(data);
 }
 
 void JingleRtpSession::rtcpDataReady()
 {
-
+	//kDebug() << "Received :" << rtcpSocket->readAll();
 }
 
 void JingleRtpSession::setPayload(const QDomElement& payload)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic