[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-10-14 13:53:40
Message-ID: 1223992420.900067.1635.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 871312 by casanova:
* As GStreamer was not a good idea, back with the mediamanager;
* Fixed oRTP blocking functions;
* Fixed AlsaIO notifier issue.
M +19 -5 alsaio.cpp
M +1 -0 alsaio.h
M +22 -16 jinglertpsession.cpp
M +1 -0 jinglertpsession.h
M +2 -1 mediamanager.cpp
M +4 -1 mediasession.cpp
M +5 -1 speexio.cpp
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/alsaio.cpp \
#871311:871312 @@ -19,17 +19,19 @@
#include <QObject>
#include <QSocketNotifier>
-#include <QDebug>
+#include <KDebug>
#include "alsaio.h"
AlsaIO::AlsaIO(StreamType t, Format f)
: m_type(t)
{
+ times = 0;
ready = false;
written = 0;
notifier = 0;
int err;
+ const char *device = (m_type == Capture ? "hw:0,0" : "default");
if ((err = snd_pcm_open(&handle, "default", m_type == Capture ? \
SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) {
@@ -223,8 +225,8 @@
return false;
}
- notifier = new QSocketNotifier(ufds[0].fd, type); //FIXME:Taking 100% of CPU \
time...
- notifier->setEnabled(true);
+ notifier = new QSocketNotifier(ufds[0].fd, type);
+ notifier->setEnabled(false); //Will be activated as soon as data comes in
connect(notifier, SIGNAL(activated(int)), this, SLOT(checkAlsaPoll(int)));
qDebug() << "Time stamp =" << timeStamp();
}
@@ -234,12 +236,20 @@
void AlsaIO::write(const QByteArray& data)
{
+ //kDebug() << "Buffered ! (" << data.size() << "bytes )";
if (!ready || m_type != Playback)
{
qDebug() << "Packet dropped";
return; // Must delete the data before ?
}
- buf = data;
+
+ buf.append(data);
+ if (!notifier->isEnabled())
+ {
+ //kDebug() << "Reactivating notifier.";
+ notifier->setEnabled(true);
+ }
+ //kDebug() << "Buffer size is now" << buf.size() << "bytes )";
}
bool AlsaIO::isReady()
@@ -310,9 +320,11 @@
void AlsaIO::writeData()
{
+ //kDebug() << "Preparing writing ! " << times++;
if (buf.size() < pSizeBytes)
{
- //qDebug() << "No enough Data in the buffer.";
+ //kDebug() << "No enough Data in the buffer. Waiting for more...";
+ notifier->setEnabled(false);
//We don't write data now as it's an empty buffer and it would make weird noises \
only. return;
}
@@ -320,6 +332,8 @@
int size = snd_pcm_writei(handle, buf.data(), buf.size());
emit bytesWritten();
+
+ //kDebug() << "Written on alsa device !";
buf.clear();
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/alsaio.h \
#871311:871312 @@ -99,6 +99,7 @@
snd_pcm_hw_params_t *hwParams;
int pSizeBytes;
QByteArray tmpBuf;
+ int times;
};
#endif //ALSA_IO
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/jinglertpsession.cpp \
#871311:871312 @@ -29,17 +29,18 @@
//connect(rtcpSocket, SIGNAL(readyRead()), this, SLOT(rtcpDataReady())); // \
FIXME:Not sure I must do this, oRTP will manage that, I don't care \
about this signal.
*/
m_rtpSession = rtp_session_new(m_direction == In ? RTP_SESSION_RECVONLY : \
RTP_SESSION_SENDONLY);
- rtp_session_set_connected_mode(m_rtpSession, true);
+ //rtp_session_set_connected_mode(m_rtpSession, true);
payloadID = -1;
payloadName = "";
+ bufSize = 0;
receivingTS = 0;
sendingTS = 0;
rtpSocket = 0;
rtcpSocket = 0;
- rtp_session_set_scheduling_mode(m_rtpSession, 1);
- rtp_session_set_blocking_mode(m_rtpSession, 1);
+ rtp_session_set_scheduling_mode(m_rtpSession, 0);
+ rtp_session_set_blocking_mode(m_rtpSession, 0);
kDebug() << "Created";
}
@@ -143,33 +144,36 @@
return;
}
- kDebug() << "Bytes sent :" << size;
+// kDebug() << "Bytes sent :" << size;
sendingTS += payloadTS;
}
void JingleRtpSession::rtpDataReady()
{
- kDebug() << "Incoming data ready to be read !";
- mblk_t *packet;
+ //kDebug() << "Incoming data ready to be read !";
+ void *buf = new uint8_t[bufSize];
+ int more;
- //This waits until the media data has been extracted from the received packet.
- //It would work the same way if ortp was used in Blocking mode.
- while ((packet = rtp_session_recvm_with_ts(m_rtpSession, receivingTS)) == NULL)
+ while (rtp_session_recv_with_ts(m_rtpSession, static_cast<uint8_t*>(buf), bufSize, \
receivingTS, &more) == 0) {
- //kDebug() << "Packet is Null, retrying.";
- receivingTS += payloadTS; //Must be increased fo unknown reason.
+ // kDebug() << "No packet received.";
+ receivingTS += payloadTS; //Must be increased for unknown reason.
+ //return;
}
+
+ //if (more != 0)
+ // kDebug() << "Still some data to read";
- QByteArray data((char*) packet->b_cont->b_rptr, packet->b_cont->b_wptr - \
packet->b_cont->b_rptr); + QByteArray data(static_cast<char*>(buf), bufSize);
// Seems we should empty the socket...
- QByteArray buf;
- buf.resize(rtpSocket->pendingDatagramSize());
- rtpSocket->readDatagram(buf.data(), rtpSocket->pendingDatagramSize());
+ QByteArray b;
+ b.resize(rtpSocket->pendingDatagramSize());
+ rtpSocket->readDatagram(b.data(), rtpSocket->pendingDatagramSize());
- //kDebug() << "Data size =" << data.size();
+ //kDebug() << "Data :" << data.toBase64() << "(" << data.size() << "bytes)";
emit readyRead(data);
}
@@ -185,6 +189,7 @@
// Parse QDomElement here and store data.
//payloadTS must be set here.
payloadName = "speex";
+ bufSize = 38;
payloadID = 96;
payloadTS = 160;
RtpProfile *profile = rtp_profile_new(payloadName.toAscii());
@@ -195,6 +200,7 @@
void JingleRtpSession::slotBytesWritten(qint64 size)
{
+ Q_UNUSED(size)
//kDebug() << size << "bytes written";
//if (state != SendingData)
// return;
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/jinglertpsession.h \
#871311:871312 @@ -84,6 +84,7 @@
QString payloadName;
enum State {SendingData = 0} state;
Direction m_direction;
+ int bufSize;
};
#endif
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/mediamanager.cpp \
#871311:871312 @@ -1,4 +1,4 @@
-#include <QDebug>
+#include <KDebug>
#include "mediamanager.h"
#include "alsaio.h"
@@ -55,6 +55,7 @@
void MediaManager::write(const QByteArray& data)
{
+ //kDebug() << "Writin on alsa device !";
alsaOut()->write(data);
}
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/mediasession.cpp \
#871311:871312 @@ -1,4 +1,4 @@
-#include <QDebug>
+#include <KDebug>
#include "mediasession.h"
#include "mediamanager.h"
@@ -59,6 +59,7 @@
void MediaSession::write(const QByteArray& sData)
{
//decoding speex data.
+ //kDebug() << "Receiving ! (" << sData.size() << "bytes)";
d->plugin->decode(sData);
}
@@ -86,6 +87,8 @@
void MediaSession::slotDecoded()
{
+ //kDebug() << "Decoded !";
+
QByteArray rawData = d->plugin->decodedData(); //FIXME:what about this QByteArray \
lifetime ? if (rawData.isNull())
{
--- branches/work/soc-kopete-jingle/kopete/protocols/jabber/jingle/speexio.cpp \
#871311:871312 @@ -1,6 +1,6 @@
#include "speexio.h"
-#include <QDebug>
+#include <KDebug>
class SpeexIO::Private
{
@@ -38,6 +38,7 @@
speex_bits_destroy(&d->decBits);
speex_decoder_destroy(d->decoder);
+ kDebug() << "Destroyed SpeexIO";
}
void SpeexIO::setSamplingRate(int sr)
@@ -146,6 +147,7 @@
void SpeexIO::decode(const QByteArray& speexData)
{
+ //kDebug() << "Decode ! (" << speexData.size() << "bytes)";
d->rawData.clear();
if (d->samplingRate == -1 || speexData.size() == 0)
@@ -163,6 +165,8 @@
qDebug() << "Error decoding speex data :" << (ret == -1 ? "end of stream" : \
"corrupt stream"); return;
}
+
+ //kDebug() << "Decoded !";
emit decoded();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic