Skip to content
Snippets Groups Projects
Commit 6ccd9726 authored by Eloi Bail's avatar Eloi Bail Committed by Edric Milaret
Browse files

directrenderer: remove shared ptr

remove sharedptr for direct rendering. Instead provide a buffer
to the daemon in which it will write the frame and thus unsure
that it will not be destroyed by the daemon while being used

Issue: #80643
Change-Id: Id92768fd098ea93d9fcca8c5570a192633eba432
parent 216b27cf
No related branches found
No related tags found
No related merge requests found
......@@ -72,7 +72,8 @@ void Video::DirectRenderer::stopRendering ()
emit stopped();
}
void Video::DirectRenderer::onNewFrame(const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h)
void Video::DirectRenderer::onNewFrame(int w, int h)
{
if (!isRendering()) {
return;
......@@ -80,7 +81,7 @@ void Video::DirectRenderer::onNewFrame(const std::shared_ptr<std::vector<unsigne
Video::Renderer::d_ptr->m_pSize.setWidth(w);
Video::Renderer::d_ptr->m_pSize.setHeight(h);
Video::Renderer::d_ptr->m_pSFrame = frame;
Video::Renderer::d_ptr->m_pFrame = reinterpret_cast<char*>(frameBuffer_.data());
emit frameUpdated();
}
......
......@@ -17,8 +17,6 @@
***************************************************************************/
#pragma once
#include <memory>
//Base
#include <QtCore/QObject>
#include "typedefs.h"
......@@ -52,7 +50,9 @@ public:
//Getter
virtual ColorSpace colorSpace() const override;
void onNewFrame(const std::shared_ptr<std::vector<unsigned char> >& frame, int w, int h);
void onNewFrame(int w, int h);
std::vector<unsigned char> frameBuffer_;
public Q_SLOTS:
virtual void startRendering() override;
......@@ -61,7 +61,6 @@ public Q_SLOTS:
private:
QScopedPointer<DirectRendererPrivate> d_ptr;
Q_DECLARE_PRIVATE(DirectRenderer)
};
}
......
......@@ -17,7 +17,6 @@
***************************************************************************/
#pragma once
#include <memory>
//Qt
#include <QtCore/QObject>
......@@ -43,7 +42,6 @@ public:
QString m_Id ;
QSize m_pSize ;
char* m_pFrame ;
std::shared_ptr<std::vector<unsigned char> > m_pSFrame;
QByteArray m_Content ;
unsigned int m_FrameSize ;
......
......@@ -213,9 +213,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
m_hRenderers[rid] = r;
m_hRendererIds[r]=rid;
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, static_cast<Video::DirectRenderer*>(r)->frameBuffer_,
[this, id, width, height] (int w, int h) {
static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame(
frame, w, h
w, h
);
});
......@@ -243,9 +244,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
r->setSize(res);
#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, static_cast<Video::DirectRenderer*>(r)->frameBuffer_,
[this, id, width, height] (int w, int h) {
static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame(
frame, w, h
w, h
);
});
......
......@@ -195,17 +195,21 @@ public Q_SLOTS: // METHODS
#endif
}
void registerSinkTarget(const QString &sinkID, std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>&& cb)
void registerSinkTarget(const QString &sinkID,
std::vector<unsigned char>& frameBuffer,
std::function<void(int, int)>&& cb)
{
#ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb));
DRing::registerSinkTarget(sinkID.toStdString(), frameBuffer, std::move(cb));
#endif
}
void registerSinkTarget(const QString &sinkID, std::function<void(std::shared_ptr<std::vector<unsigned char> >&, int, int)>& cb)
void registerSinkTarget(const QString &sinkID,
std::vector<unsigned char>& frameBuffer,
std::function<void(int, int)>& cb)
{
#ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb));
DRing::registerSinkTarget(sinkID.toStdString(), frameBuffer, std::move(cb));
#endif
}
......
......@@ -73,21 +73,6 @@ const QByteArray& Video::Renderer::currentFrame() const
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 *
......
......@@ -17,7 +17,6 @@
***************************************************************************/
#pragma once
#include <memory>
//Base
#include <QtCore/QObject>
......@@ -76,8 +75,6 @@ public:
//Getters
virtual bool isRendering () 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 QMutex* mutex () const;
virtual ColorSpace colorSpace () const = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment