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 () ...@@ -72,7 +72,8 @@ void Video::DirectRenderer::stopRendering ()
emit stopped(); 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()) { if (!isRendering()) {
return; return;
...@@ -80,7 +81,7 @@ void Video::DirectRenderer::onNewFrame(const std::shared_ptr<std::vector<unsigne ...@@ -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.setWidth(w);
Video::Renderer::d_ptr->m_pSize.setHeight(h); 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(); emit frameUpdated();
} }
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
***************************************************************************/ ***************************************************************************/
#pragma once #pragma once
#include <memory>
//Base //Base
#include <QtCore/QObject> #include <QtCore/QObject>
#include "typedefs.h" #include "typedefs.h"
...@@ -52,7 +50,9 @@ public: ...@@ -52,7 +50,9 @@ public:
//Getter //Getter
virtual ColorSpace colorSpace() const override; 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: public Q_SLOTS:
virtual void startRendering() override; virtual void startRendering() override;
...@@ -61,7 +61,6 @@ public Q_SLOTS: ...@@ -61,7 +61,6 @@ public Q_SLOTS:
private: private:
QScopedPointer<DirectRendererPrivate> d_ptr; QScopedPointer<DirectRendererPrivate> d_ptr;
Q_DECLARE_PRIVATE(DirectRenderer) Q_DECLARE_PRIVATE(DirectRenderer)
}; };
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
***************************************************************************/ ***************************************************************************/
#pragma once #pragma once
#include <memory>
//Qt //Qt
#include <QtCore/QObject> #include <QtCore/QObject>
...@@ -43,7 +42,6 @@ public: ...@@ -43,7 +42,6 @@ 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,10 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -213,9 +213,10 @@ 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 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( 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 ...@@ -243,9 +244,10 @@ 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, static_cast<Video::DirectRenderer*>(r)->frameBuffer_,
[this, id, width, height] (int w, int h) {
static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame( static_cast<Video::DirectRenderer*>(m_hRenderers[id.toLatin1()])->onNewFrame(
frame, w, h w, h
); );
}); });
......
...@@ -195,17 +195,21 @@ public Q_SLOTS: // METHODS ...@@ -195,17 +195,21 @@ public Q_SLOTS: // METHODS
#endif #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 #ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb)); DRing::registerSinkTarget(sinkID.toStdString(), frameBuffer, std::move(cb));
#endif #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 #ifdef ENABLE_VIDEO
DRing::registerSinkTarget(sinkID.toStdString(), std::move(cb)); DRing::registerSinkTarget(sinkID.toStdString(), frameBuffer, std::move(cb));
#endif #endif
} }
......
...@@ -73,21 +73,6 @@ const QByteArray& Video::Renderer::currentFrame() const ...@@ -73,21 +73,6 @@ 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 *
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
***************************************************************************/ ***************************************************************************/
#pragma once #pragma once
#include <memory>
//Base //Base
#include <QtCore/QObject> #include <QtCore/QObject>
...@@ -76,8 +75,6 @@ public: ...@@ -76,8 +75,6 @@ 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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment