[Telepathy-commits] [telepathy-qt4/master] StreamedMediaChannel: Make sure all streams are added to the channel even if StreamAdded is not emitted.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue Mar 17 01:56:24 PDT 2009


---
 TelepathyQt4/Client/streamed-media-channel.cpp |   17 ++++++++++++++++-
 TelepathyQt4/Client/streamed-media-channel.h   |    2 ++
 2 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/TelepathyQt4/Client/streamed-media-channel.cpp b/TelepathyQt4/Client/streamed-media-channel.cpp
index 78d06da..4074441 100644
--- a/TelepathyQt4/Client/streamed-media-channel.cpp
+++ b/TelepathyQt4/Client/streamed-media-channel.cpp
@@ -158,7 +158,6 @@ void PendingMediaStreams::gotContacts(PendingOperation *op)
     if (pc->isError()) {
         warning().nospace() << "Gathering contacts failed: "
             << pc->errorName() << ": " << pc->errorMessage();
-        // TODO should we setFinishedWithError here?
     }
 
     QHash<uint, QSharedPointer<Contact> > contactsForHandles;
@@ -172,6 +171,9 @@ void PendingMediaStreams::gotContacts(PendingOperation *op)
 
     foreach (const QSharedPointer<MediaStream> &stream, mPriv->streams) {
         stream->setContact(contactsForHandles[stream->contactHandle()]);
+        // make sure the channel has all streams even if StreamAdded was not
+        // emitted
+        mPriv->channel->addStream(stream);
     }
 
     setFinished();
@@ -731,5 +733,18 @@ void StreamedMediaChannel::onStreamError(uint streamId,
     }
 }
 
+void StreamedMediaChannel::addStream(const QSharedPointer<MediaStream> &stream)
+{
+    if (mPriv->streams.contains(stream->id())) {
+        return;
+    }
+
+    mPriv->streams.insert(stream->id(), stream);
+
+    if (mPriv->initialStreamsReceived) {
+        emit streamAdded(stream);
+    }
+}
+
 } // Telepathy::Client
 } // Telepathy
diff --git a/TelepathyQt4/Client/streamed-media-channel.h b/TelepathyQt4/Client/streamed-media-channel.h
index 01e71d7..feb4970 100644
--- a/TelepathyQt4/Client/streamed-media-channel.h
+++ b/TelepathyQt4/Client/streamed-media-channel.h
@@ -173,6 +173,8 @@ private Q_SLOTS:
 private:
     friend class PendingMediaStreams;
 
+    void addStream(const QSharedPointer<MediaStream> &stream);
+
     struct Private;
     friend struct Private;
     Private *mPriv;
-- 
1.5.6.5




More information about the telepathy-commits mailing list