Skip to content
Snippets Groups Projects
Commit aee03b95 authored by Edric Milaret's avatar Edric Milaret
Browse files

directrenderer: Use smart ptr for frame

-Also set the size for every frame
-This patch also fix the API break of IncomingTrustRequest

Refs #75280

-Warning : This break frame retrieval for OS X

Change-Id: I6f488b7f11d884ab21a2edf10a4f211d541fb9ef
parent 59001eb2
Branches
Tags
No related merge requests found
...@@ -72,13 +72,15 @@ void Video::DirectRenderer::stopRendering () ...@@ -72,13 +72,15 @@ void Video::DirectRenderer::stopRendering ()
emit stopped(); emit stopped();
} }
void Video::DirectRenderer::onNewFrame(const QByteArray& frame) void Video::DirectRenderer::onNewFrame(const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h)
{ {
if (!isRendering()) { if (!isRendering()) {
return; return;
} }
Video::Renderer::d_ptr->m_pFrame = const_cast<char*>(frame.data()); Video::Renderer::d_ptr->m_pSize.setWidth(w);
Video::Renderer::d_ptr->m_pSize.setHeight(h);
Video::Renderer::d_ptr->m_pSFrame = frame;
emit frameUpdated(); emit frameUpdated();
} }
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#ifndef VIDEO_DIRECT_RENDERER_H #ifndef VIDEO_DIRECT_RENDERER_H
#define VIDEO_DIRECT_RENDERER_H #define VIDEO_DIRECT_RENDERER_H
#include <memory>
//Base //Base
#include <QtCore/QObject> #include <QtCore/QObject>
#include "typedefs.h" #include "typedefs.h"
...@@ -51,7 +53,7 @@ public: ...@@ -51,7 +53,7 @@ public:
//Getter //Getter
virtual ColorSpace colorSpace() const override; virtual ColorSpace colorSpace() const override;
void onNewFrame(const QByteArray& frame); void onNewFrame(const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h);
public Q_SLOTS: public Q_SLOTS:
virtual void startRendering() override; virtual void startRendering() override;
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#ifndef RENDERERPRIVATE_H #ifndef RENDERERPRIVATE_H
#define RENDERERPRIVATE_H #define RENDERERPRIVATE_H
#include <memory>
//Qt //Qt
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QSize> #include <QtCore/QSize>
...@@ -42,6 +44,7 @@ public: ...@@ -42,6 +44,7 @@ public:
QString m_Id ; QString m_Id ;
QSize m_pSize ; QSize m_pSize ;
char* m_pFrame ; char* m_pFrame ;
std::shared_ptr<std::vector<unsigned char> > m_pSFrame;
QByteArray m_Content ; QByteArray m_Content ;
unsigned int m_FrameSize ; unsigned int m_FrameSize ;
......
...@@ -213,9 +213,9 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -213,9 +213,9 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
m_hRenderers[rid] = r; m_hRenderers[rid] = r;
m_hRendererIds[r]=rid; m_hRendererIds[r]=rid;
DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const unsigned char* frame) { DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h) {
static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame( static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame(
QByteArray::fromRawData(reinterpret_cast<const char *>(frame), width*height) frame, w, h
); );
}); });
...@@ -243,10 +243,9 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -243,10 +243,9 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
r->setSize(res); r->setSize(res);
#ifdef ENABLE_LIBWRAP #ifdef ENABLE_LIBWRAP
DBus::VideoManager::instance().registerSinkTarget(id, [this, id, width, height] (const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h) {
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(
QByteArray::fromRawData(reinterpret_cast<const char *>(frame), width*height) frame, w, h
); );
}); });
......
...@@ -119,7 +119,7 @@ public: ...@@ -119,7 +119,7 @@ public:
}), }),
exportable_callback<ConfigurationSignal::IncomingTrustRequest>( exportable_callback<ConfigurationSignal::IncomingTrustRequest>(
[this] (const std::string &accountId, const std::string &certId, time_t timestamp) { [this] (const std::string &accountId, const std::string &certId, const std::vector<uint8_t> &payload, time_t timestamp) {
QTimer::singleShot(0, [this, certId,accountId,timestamp] { QTimer::singleShot(0, [this, certId,accountId,timestamp] {
Q_EMIT this->incomingTrustRequest(QString(accountId.c_str()), QString(certId.c_str()), timestamp); Q_EMIT this->incomingTrustRequest(QString(accountId.c_str()), QString(certId.c_str()), timestamp);
}); });
......
...@@ -196,14 +196,14 @@ public Q_SLOTS: // METHODS ...@@ -196,14 +196,14 @@ public Q_SLOTS: // METHODS
#endif #endif
} }
void registerSinkTarget(const QString &sinkID, std::function<void(uint8_t*)>&& cb) void registerSinkTarget(const QString &sinkID, std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>&& cb)
{ {
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb)); DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb));
#endif #endif
} }
void registerSinkTarget(const QString &sinkID, std::function<void(uint8_t*)>& cb) void registerSinkTarget(const QString &sinkID, std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>& cb)
{ {
#ifdef ENABLE_VIDEO #ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb)); DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb));
......
...@@ -73,6 +73,21 @@ const QByteArray& Video::Renderer::currentFrame() const ...@@ -73,6 +73,21 @@ const QByteArray& Video::Renderer::currentFrame() const
return d_ptr->m_Content; return d_ptr->m_Content;
} }
const std::shared_ptr<std::vector<unsigned char> >& Video::Renderer::currentSmartFrame() const
{
return d_ptr->m_pSFrame;
}
bool Video::Renderer::isFrameSmart() const
{
#ifdef ENABLE_LIBWRAP
return true;
#else
return false;
#endif
}
/***************************************************************************** /*****************************************************************************
* * * *
* Setters * * Setters *
......
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#ifndef VIDEO_ABSTRACT_RENDERER_H #ifndef VIDEO_ABSTRACT_RENDERER_H
#define VIDEO_ABSTRACT_RENDERER_H #define VIDEO_ABSTRACT_RENDERER_H
#include <memory>
//Base //Base
#include <QtCore/QObject> #include <QtCore/QObject>
#include <typedefs.h> #include <typedefs.h>
...@@ -75,6 +77,8 @@ public: ...@@ -75,6 +77,8 @@ public:
//Getters //Getters
virtual bool isRendering () const; virtual bool isRendering () const;
virtual const QByteArray& currentFrame () const; virtual const QByteArray& currentFrame () const;
virtual const std::shared_ptr<std::vector<unsigned char> >& currentSmartFrame() const;
virtual bool isFrameSmart() const;
virtual QSize size () const; virtual QSize size () const;
virtual QMutex* mutex () const; virtual QMutex* mutex () const;
virtual ColorSpace colorSpace () const = 0; virtual ColorSpace colorSpace () const = 0;
......
...@@ -936,6 +936,8 @@ ...@@ -936,6 +936,8 @@
</arg> </arg>
<arg type="s" name="from"> <arg type="s" name="from">
</arg> </arg>
<arg type="ay" name="payload">
</arg>
<arg type="t" name="receiveTime"> <arg type="t" name="receiveTime">
</arg> </arg>
</signal> </signal>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment