mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-19 19:15:26 +00:00
Qt/overlays: expose qt_video_source_wrapper as emu callback
This commit is contained in:
parent
fac1cc57d7
commit
8e83fd7d50
6 changed files with 57 additions and 20 deletions
|
@ -111,6 +111,7 @@ struct EmuCallbacks
|
|||
std::function<bool()> display_sleep_control_supported;
|
||||
std::function<void(bool)> enable_display_sleep;
|
||||
std::function<void()> check_microphone_permissions;
|
||||
std::function<std::unique_ptr<class video_source>()> make_video_source;
|
||||
};
|
||||
|
||||
namespace utils
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "Emu/Cell/Modules/sceNpTrophy.h"
|
||||
#include "Emu/Io/Null/null_camera_handler.h"
|
||||
#include "Emu/Io/Null/null_music_handler.h"
|
||||
#include "util/video_source.h"
|
||||
|
||||
#include <clocale>
|
||||
|
||||
|
@ -173,6 +174,8 @@ void headless_application::InitializeCallbacks()
|
|||
|
||||
callbacks.check_microphone_permissions = [](){};
|
||||
|
||||
callbacks.make_video_source = [](){ return nullptr; };
|
||||
|
||||
Emu.SetCallbacks(std::move(callbacks));
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "Emu/vfs_config.h"
|
||||
#include "util/init_mutex.hpp"
|
||||
#include "util/console.h"
|
||||
#include "qt_video_source.h"
|
||||
#include "trophy_notification_helper.h"
|
||||
#include "save_data_dialog.h"
|
||||
#include "msg_dialog_frame.h"
|
||||
|
@ -955,6 +956,8 @@ void gui_application::InitializeCallbacks()
|
|||
});
|
||||
};
|
||||
|
||||
callbacks.make_video_source = [](){ return std::make_unique<qt_video_source_wrapper>(); };
|
||||
|
||||
Emu.SetCallbacks(std::move(callbacks));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ qt_video_source::~qt_video_source()
|
|||
stop_movie();
|
||||
}
|
||||
|
||||
void qt_video_source::set_video_path(const std::string& path)
|
||||
void qt_video_source::set_video_path(const std::string& video_path)
|
||||
{
|
||||
m_video_path = QString::fromStdString(path);
|
||||
m_video_path = QString::fromStdString(video_path);
|
||||
}
|
||||
|
||||
void qt_video_source::set_active(bool active)
|
||||
|
@ -209,14 +209,14 @@ qt_video_source_wrapper::~qt_video_source_wrapper()
|
|||
});
|
||||
}
|
||||
|
||||
void qt_video_source_wrapper::set_video_path(const std::string& path)
|
||||
void qt_video_source_wrapper::set_video_path(const std::string& video_path)
|
||||
{
|
||||
Emu.BlockingCallFromMainThread([this, &path]()
|
||||
Emu.CallFromMainThread([this, path = video_path]()
|
||||
{
|
||||
m_qt_video_source = std::make_unique<qt_video_source>();
|
||||
m_qt_video_source->m_image_change_callback = [this](const QVideoFrame& frame)
|
||||
{
|
||||
std::lock_guard lock(m_qt_video_source->m_image_mutex);
|
||||
std::unique_lock lock(m_qt_video_source->m_image_mutex);
|
||||
|
||||
if (m_qt_video_source->m_movie)
|
||||
{
|
||||
|
@ -236,12 +236,30 @@ void qt_video_source_wrapper::set_video_path(const std::string& path)
|
|||
{
|
||||
m_qt_video_source->m_image.convertTo(QImage::Format_RGBA8888);
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
notify_update();
|
||||
};
|
||||
m_qt_video_source->set_video_path(path);
|
||||
});
|
||||
}
|
||||
|
||||
void qt_video_source_wrapper::set_active(bool active)
|
||||
{
|
||||
Emu.CallFromMainThread([this, active]()
|
||||
{
|
||||
m_qt_video_source->set_active(true);
|
||||
});
|
||||
}
|
||||
|
||||
bool qt_video_source_wrapper::get_active() const
|
||||
{
|
||||
ensure(m_qt_video_source);
|
||||
|
||||
return m_qt_video_source->get_active();
|
||||
}
|
||||
|
||||
void qt_video_source_wrapper::get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp)
|
||||
{
|
||||
ensure(m_qt_video_source);
|
||||
|
|
|
@ -17,17 +17,14 @@ public:
|
|||
qt_video_source();
|
||||
virtual ~qt_video_source();
|
||||
|
||||
void set_video_path(const std::string& path) override;
|
||||
void set_video_path(const std::string& video_path) override;
|
||||
const QString& video_path() const { return m_video_path; }
|
||||
|
||||
void get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp) override;
|
||||
bool has_new() const override { return m_has_new; }
|
||||
|
||||
virtual void set_active(bool active);
|
||||
[[nodiscard]] bool get_active() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
bool get_active() const override { return m_active; }
|
||||
|
||||
void start_movie();
|
||||
void stop_movie();
|
||||
|
@ -67,9 +64,11 @@ public:
|
|||
qt_video_source_wrapper() : video_source() {}
|
||||
virtual ~qt_video_source_wrapper();
|
||||
|
||||
void set_video_path(const std::string& path) override;
|
||||
void get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp) override;
|
||||
void set_video_path(const std::string& video_path) override;
|
||||
void set_active(bool active) override;
|
||||
bool get_active() const override;
|
||||
bool has_new() const override { return m_qt_video_source && m_qt_video_source->has_new(); }
|
||||
void get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<qt_video_source> m_qt_video_source;
|
||||
|
|
|
@ -1,20 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hpp"
|
||||
#include <functional>
|
||||
|
||||
class video_source
|
||||
{
|
||||
public:
|
||||
video_source() {};
|
||||
virtual ~video_source() {};
|
||||
virtual void set_video_path(const std::string& path) { static_cast<void>(path); }
|
||||
virtual bool has_new() const { return false; };
|
||||
virtual void get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp)
|
||||
virtual void set_video_path(const std::string& video_path) = 0;
|
||||
virtual void set_active(bool active) = 0;
|
||||
virtual bool get_active() const = 0;
|
||||
virtual bool has_new() const = 0;
|
||||
virtual void get_image(std::vector<u8>& data, int& w, int& h, int& ch, int& bpp) = 0;
|
||||
|
||||
void set_update_callback(std::function<void()> callback)
|
||||
{
|
||||
static_cast<void>(data);
|
||||
static_cast<void>(w);
|
||||
static_cast<void>(h);
|
||||
static_cast<void>(ch);
|
||||
static_cast<void>(bpp);
|
||||
m_update_callback = callback;
|
||||
}
|
||||
|
||||
protected:
|
||||
void notify_update()
|
||||
{
|
||||
if (m_update_callback)
|
||||
{
|
||||
m_update_callback();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void()> m_update_callback;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue