Skip to content
Snippets Groups Projects
Commit 60706c02 authored by Alexandre Lision's avatar Alexandre Lision
Browse files

video: resynchronize start and stop render signals

make sure start and stop decoding are always fired to the client in the same
than the daemon as fired them.

Refs #70681
parent 19027630
Branches
Tags
No related merge requests found
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <video/resolution.h> #include <video/resolution.h>
#include "private/videorate_p.h" #include "private/videorate_p.h"
#include "private/call_p.h" #include "private/call_p.h"
#include "private/videorenderer_p.h"
#ifdef ENABLE_LIBWRAP #ifdef ENABLE_LIBWRAP
#include "private/directrenderer.h" #include "private/directrenderer.h"
...@@ -205,6 +204,7 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -205,6 +204,7 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
r = new Video::DirectRenderer(rid, res); r = new Video::DirectRenderer(rid, res);
qWarning() << "Calling registerFrameListener"; qWarning() << "Calling registerFrameListener";
m_hRenderers[rid] = r;
DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const unsigned char* frame) { DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const unsigned char* frame) {
static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame( static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame(
...@@ -215,10 +215,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -215,10 +215,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
#else //ENABLE_LIBWRAP #else //ENABLE_LIBWRAP
r = new Video::ShmRenderer(rid,shmPath,res); r = new Video::ShmRenderer(rid,shmPath,res);
m_hRenderers[rid] = r;
#endif #endif
m_hRenderers[rid] = r;
QThread* t = new QThread(this); QThread* t = new QThread(this);
m_hThreads[r] = t; m_hThreads[r] = t;
...@@ -280,7 +280,7 @@ void VideoRendererManagerPrivate::stoppedDecoding(const QString& id, const QStri ...@@ -280,7 +280,7 @@ void VideoRendererManagerPrivate::stoppedDecoding(const QString& id, const QStri
//Quit if for some reasons the renderer is not found //Quit if for some reasons the renderer is not found
if ( !r ) { if ( !r ) {
qWarning() << "Cannot stop renrering, renderer" << id << "not found"; qWarning() << "Cannot stop rendering, renderer" << id << "not found";
return; return;
} }
......
/******************************************************************************
* Copyright (C) 2014 by Savoir-Faire Linux *
* Author : Philippe Groarke <philippe.groarke@savoirfairelinux.com> *
* Author : Alexandre Lision <alexandre.lision@savoirfairelinux.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#include "videomanager_wrap.h" #include "videomanager_wrap.h"
VideoManagerInterface::VideoManagerInterface() VideoManagerInterface::VideoManagerInterface()
...@@ -36,7 +54,8 @@ VideoManagerInterface::~VideoManagerInterface() ...@@ -36,7 +54,8 @@ VideoManagerInterface::~VideoManagerInterface()
} }
VideoManagerSignalProxy::VideoManagerSignalProxy(VideoManagerInterface* parent) : QObject(parent), m_pParent(parent) VideoManagerSignalProxy::VideoManagerSignalProxy(VideoManagerInterface* parent) : QObject(parent),
m_pParent(parent), m_pSem(new QSemaphore(3))
{} {}
void VideoManagerSignalProxy::slotDeviceEvent() void VideoManagerSignalProxy::slotDeviceEvent()
...@@ -49,13 +68,21 @@ void VideoManagerSignalProxy::slotDeviceEvent() ...@@ -49,13 +68,21 @@ void VideoManagerSignalProxy::slotDeviceEvent()
void VideoManagerSignalProxy::slotStartedDecoding(const QString &id, const QString &shmPath, int width, int height, bool isMixer) void VideoManagerSignalProxy::slotStartedDecoding(const QString &id, const QString &shmPath, int width, int height, bool isMixer)
{ {
QTimer::singleShot(0, [=] { QTimer::singleShot(0, [=] {
if(m_pSem->available() == 3)
emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer); emit m_pParent->startedDecoding(id,shmPath,width,height,isMixer);
else {
QTimer::singleShot(0, [=] {
slotStartedDecoding(id,shmPath,width,height,isMixer);
});
}
}); });
} }
void VideoManagerSignalProxy::slotStoppedDecoding(const QString &id, const QString &shmPath, bool isMixer) void VideoManagerSignalProxy::slotStoppedDecoding(const QString &id, const QString &shmPath, bool isMixer)
{ {
m_pSem->acquire(1);
QTimer::singleShot(0, [=] { QTimer::singleShot(0, [=] {
emit m_pParent->stoppedDecoding(id,shmPath,isMixer); emit m_pParent->stoppedDecoding(id,shmPath,isMixer);
m_pSem->release(1);
}); });
} }
...@@ -29,17 +29,20 @@ ...@@ -29,17 +29,20 @@
#include <QtCore/QThread> #include <QtCore/QThread>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QMap> #include <QtCore/QMap>
#include <QtCore/QSemaphore>
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QVariant> #include <QtCore/QVariant>
#include <QtCore/QTimer> #include <QtCore/QTimer>
// Ring
#include <videomanager_interface.h> #include <videomanager_interface.h>
#include "typedefs.h" #include "typedefs.h"
#include "conversions_wrap.hpp" #include "conversions_wrap.hpp"
class VideoManagerInterface; class VideoManagerInterface;
class QSemaphore;
class VideoManagerSignalProxy : public QObject class VideoManagerSignalProxy : public QObject
{ {
...@@ -54,6 +57,7 @@ public Q_SLOTS: ...@@ -54,6 +57,7 @@ public Q_SLOTS:
private: private:
VideoManagerInterface* m_pParent; VideoManagerInterface* m_pParent;
QSemaphore* m_pSem;
}; };
class VideoManagerProxySender : public QObject class VideoManagerProxySender : public QObject
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment