summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authordknn <yoann.blein@free.fr>2012-08-16 21:52:56 (GMT)
committerdknn <yoann.blein@free.fr>2012-09-22 09:32:38 (GMT)
commitdce09fe24d55d67f60d7bc691e285897f1d64fc2 (patch)
treef064c11c7c25a647a73c42d01e2cb836ea601bb3 /Swift
parent867a950d5b3eb1422051a57c2533509188014b1a (diff)
downloadswift-contrib-dce09fe24d55d67f60d7bc691e285897f1d64fc2.zip
swift-contrib-dce09fe24d55d67f60d7bc691e285897f1d64fc2.tar.bz2
Add error resilience on decoder side
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/ScreenSharing/ScreenSharingController.cpp3
-rw-r--r--Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp41
2 files changed, 35 insertions, 9 deletions
diff --git a/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp b/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
index b932765..2e9a75d 100644
--- a/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
+++ b/Swift/Controllers/ScreenSharing/ScreenSharingController.cpp
@@ -123,7 +123,8 @@ void ScreenSharingController::handleStateChange(ScreenSharing::SCState state)
void ScreenSharingController::handleWindowStopRequest()
{
remoteScreenWindow->onStopRequest.disconnect(boost::bind(&ScreenSharingController::handleWindowStopRequest, this));
- screenSharing->stop();
+ if (screenSharing)
+ screenSharing->stop();
}
}
diff --git a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
index a5eeafd..aae2ff1 100644
--- a/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
+++ b/Swift/QtUI/ScreenSharing/QtDesktopScreenGrabber.cpp
@@ -11,20 +11,17 @@
#include <QApplication>
#include <QDesktopWidget>
+#include <QPainter>
+#include <QColor>
+
#include <Swiften/ScreenSharing/Image.h>
-/*#include <QImage>
-#include <QLabel>*/
+#include <Swiften/Base/Log.h>
namespace Swift {
QtDesktopScreenGrabber::QtDesktopScreenGrabber()
{
- /*Image img = grab();
- QImage qImg(img.data.data(), img.width, img.height, QImage::Format_RGB888);
- QLabel *label = new QLabel;
- label->setPixmap(QPixmap::fromImage(qImg));
- label->show();*/
}
QtDesktopScreenGrabber::~QtDesktopScreenGrabber()
@@ -33,7 +30,35 @@ QtDesktopScreenGrabber::~QtDesktopScreenGrabber()
Image QtDesktopScreenGrabber::grab() const
{
- QImage qImg = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage().convertToFormat(QImage::Format_RGB888);
+ QImage qImg = QPixmap::grabWindow(QApplication::desktop()->winId()).toImage();//.convertToFormat(QImage::Format_RGB888);
+// QImage qImg("/home/yb/Images/wallpaper-1681250.jpg");
+ qImg = qImg.scaled(qImg.width() * 0.7, qImg.height() * 0.7, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+// SWIFT_LOG(debug) << "Format RGB32: " << (qImg.format() == QImage::Format_RGB32) << std::endl;
+
+// QImage qImg(1920, 1080, QImage::Format_RGB32);
+// qImg.fill(QColor(qrand() % 255, qrand()%255, qrand()%255));
+// QPainter p(&qImg);
+// p.translate(qImg.width() / 2, qImg.height() / 2);
+// p.setBrush(Qt::black);
+// static int x = 0;
+// static int y = 0;
+// x = (x+50)%qImg.width();
+// y = (y+50)%qImg.height();
+// p.drawEllipse(x, y, 100, 100);
+
+// for (int i = 0; i < 40; ++i) {
+// p.setBrush(QColor(qrand() % 255, qrand()%255, qrand()%255));
+// p.drawEllipse(qrand()%qImg.width(), qrand()%qImg.height(), qrand()%(qImg.width()/4), qrand()%(qImg.height()/4));
+// }
+// p.end();
+
+ qImg = qImg.convertToFormat(QImage::Format_RGB888);
+
+// uchar* bits = qImg.bits();
+// for (int i = 0; i < qImg.byteCount(); ++i) {
+// bits[i] = qrand();
+// }
+
return Image(qImg.width(), qImg.height(), qImg.constBits());
}