mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Move FFMPEG Decoder to lib
This commit is contained in:
parent
aba17d48a3
commit
673a2de9c1
24 changed files with 566 additions and 350 deletions
|
@ -6,8 +6,10 @@
|
|||
#include <QObject>
|
||||
#include <QOpenGLWidget>
|
||||
|
||||
#include <chiaki/ffmpegdecoder.h>
|
||||
|
||||
class StreamSession;
|
||||
class AVOpenGLWidget;
|
||||
class VideoDecoder;
|
||||
class QSurface;
|
||||
|
||||
class AVOpenGLFrameUploader: public QObject
|
||||
|
@ -15,16 +17,16 @@ class AVOpenGLFrameUploader: public QObject
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
VideoDecoder *decoder;
|
||||
StreamSession *session;
|
||||
AVOpenGLWidget *widget;
|
||||
QOpenGLContext *context;
|
||||
QSurface *surface;
|
||||
|
||||
private slots:
|
||||
void UpdateFrame();
|
||||
void UpdateFrameFromDecoder();
|
||||
|
||||
public:
|
||||
AVOpenGLFrameUploader(VideoDecoder *decoder, AVOpenGLWidget *widget, QOpenGLContext *context, QSurface *surface);
|
||||
AVOpenGLFrameUploader(StreamSession *session, AVOpenGLWidget *widget, QOpenGLContext *context, QSurface *surface);
|
||||
};
|
||||
|
||||
#endif // CHIAKI_AVOPENGLFRAMEUPLOADER_H
|
||||
|
|
|
@ -15,7 +15,7 @@ extern "C"
|
|||
|
||||
#define MAX_PANES 3
|
||||
|
||||
class VideoDecoder;
|
||||
class StreamSession;
|
||||
class AVOpenGLFrameUploader;
|
||||
class QOffscreenSurface;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class AVOpenGLWidget: public QOpenGLWidget
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
VideoDecoder *decoder;
|
||||
StreamSession *session;
|
||||
|
||||
GLuint program;
|
||||
GLuint vbo;
|
||||
|
@ -74,7 +74,7 @@ class AVOpenGLWidget: public QOpenGLWidget
|
|||
public:
|
||||
static QSurfaceFormat CreateSurfaceFormat();
|
||||
|
||||
explicit AVOpenGLWidget(VideoDecoder *decoder, QWidget *parent = nullptr);
|
||||
explicit AVOpenGLWidget(StreamSession *session, QWidget *parent = nullptr);
|
||||
~AVOpenGLWidget() override;
|
||||
|
||||
void SwapFrames();
|
||||
|
|
81
gui/include/logsniffer.h
Normal file
81
gui/include/logsniffer.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
// SPDX-License-Identifier: LicenseRef-GPL-3.0-or-later-OpenSSL
|
||||
|
||||
#ifndef CHIAKI_LOG_SNIFFER_H
|
||||
#define CHIAKI_LOG_SNIFFER_H
|
||||
|
||||
#include <chiaki/controller.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
class Controller;
|
||||
|
||||
class ControllerManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class Controller;
|
||||
|
||||
private:
|
||||
#ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
|
||||
QSet<SDL_JoystickID> available_controllers;
|
||||
#endif
|
||||
QMap<int, Controller *> open_controllers;
|
||||
|
||||
void ControllerClosed(Controller *controller);
|
||||
|
||||
private slots:
|
||||
void UpdateAvailableControllers();
|
||||
void HandleEvents();
|
||||
void ControllerEvent(int device_id);
|
||||
|
||||
public:
|
||||
static ControllerManager *GetInstance();
|
||||
|
||||
ControllerManager(QObject *parent = nullptr);
|
||||
~ControllerManager();
|
||||
|
||||
QSet<int> GetAvailableControllers();
|
||||
Controller *OpenController(int device_id);
|
||||
|
||||
signals:
|
||||
void AvailableControllersUpdated();
|
||||
};
|
||||
|
||||
class Controller : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class ControllerManager;
|
||||
|
||||
private:
|
||||
Controller(int device_id, ControllerManager *manager);
|
||||
|
||||
void UpdateState();
|
||||
|
||||
ControllerManager *manager;
|
||||
int id;
|
||||
|
||||
#ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER
|
||||
SDL_GameController *controller;
|
||||
#endif
|
||||
|
||||
public:
|
||||
~Controller();
|
||||
|
||||
bool IsConnected();
|
||||
int GetDeviceID();
|
||||
QString GetName();
|
||||
ChiakiControllerState GetState();
|
||||
|
||||
signals:
|
||||
void StateChanged();
|
||||
};
|
||||
|
||||
#endif // CHIAKI_CONTROLLERMANAGER_H
|
|
@ -6,7 +6,6 @@
|
|||
#include <chiaki/session.h>
|
||||
|
||||
#include "host.h"
|
||||
#include "videodecoder.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QAudioDeviceInfo>
|
||||
|
@ -79,8 +78,8 @@ class Settings : public QObject
|
|||
Decoder GetDecoder() const;
|
||||
void SetDecoder(Decoder decoder);
|
||||
|
||||
HardwareDecodeEngine GetHardwareDecodeEngine() const;
|
||||
void SetHardwareDecodeEngine(HardwareDecodeEngine enabled);
|
||||
QString GetHardwareDecoder() const;
|
||||
void SetHardwareDecoder(const QString &hw_decoder);
|
||||
|
||||
unsigned int GetAudioBufferSizeDefault() const;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class SettingsDialog : public QDialog
|
|||
QLineEdit *audio_buffer_size_edit;
|
||||
QComboBox *audio_device_combo_box;
|
||||
QCheckBox *pi_decoder_check_box;
|
||||
QComboBox *hardware_decode_combo_box;
|
||||
QComboBox *hw_decoder_combo_box;
|
||||
|
||||
QListWidget *registered_hosts_list_widget;
|
||||
QPushButton *delete_registered_host_button;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include <chiaki/session.h>
|
||||
#include <chiaki/opusdecoder.h>
|
||||
#include <chiaki/ffmpegdecoder.h>
|
||||
|
||||
#if CHIAKI_LIB_ENABLE_PI_DECODER
|
||||
#include <chiaki/pidecoder.h>
|
||||
|
@ -14,7 +15,6 @@
|
|||
#include <setsu.h>
|
||||
#endif
|
||||
|
||||
#include "videodecoder.h"
|
||||
#include "exception.h"
|
||||
#include "sessionlog.h"
|
||||
#include "controllermanager.h"
|
||||
|
@ -41,7 +41,7 @@ struct StreamSessionConnectInfo
|
|||
Settings *settings;
|
||||
QMap<Qt::Key, int> key_map;
|
||||
Decoder decoder;
|
||||
HardwareDecodeEngine hw_decode_engine;
|
||||
QString hw_decoder;
|
||||
QString audio_out_device;
|
||||
uint32_t log_level_mask;
|
||||
QString log_file;
|
||||
|
@ -78,7 +78,8 @@ class StreamSession : public QObject
|
|||
|
||||
ChiakiControllerState keyboard_state;
|
||||
|
||||
VideoDecoder *video_decoder;
|
||||
ChiakiFfmpegDecoder *ffmpeg_decoder;
|
||||
void TriggerFfmpegFrameAvailable();
|
||||
#if CHIAKI_LIB_ENABLE_PI_DECODER
|
||||
ChiakiPiDecoder *pi_decoder;
|
||||
#endif
|
||||
|
@ -91,7 +92,6 @@ class StreamSession : public QObject
|
|||
QMap<Qt::Key, int> key_map;
|
||||
|
||||
void PushAudioFrame(int16_t *buf, size_t samples_count);
|
||||
void PushVideoSample(uint8_t *buf, size_t buf_size);
|
||||
void Event(ChiakiEvent *event);
|
||||
#if CHIAKI_GUI_ENABLE_SETSU
|
||||
void HandleSetsuEvent(SetsuEvent *event);
|
||||
|
@ -112,8 +112,9 @@ class StreamSession : public QObject
|
|||
|
||||
void SetLoginPIN(const QString &pin);
|
||||
|
||||
ChiakiLog *GetChiakiLog() { return log.GetChiakiLog(); }
|
||||
QList<Controller *> GetControllers() { return controllers.values(); }
|
||||
VideoDecoder *GetVideoDecoder() { return video_decoder; }
|
||||
ChiakiFfmpegDecoder *GetFfmpegDecoder() { return ffmpeg_decoder; }
|
||||
#if CHIAKI_LIB_ENABLE_PI_DECODER
|
||||
ChiakiPiDecoder *GetPiDecoder() { return pi_decoder; }
|
||||
#endif
|
||||
|
@ -122,7 +123,7 @@ class StreamSession : public QObject
|
|||
void HandleMouseEvent(QMouseEvent *event);
|
||||
|
||||
signals:
|
||||
void CurrentImageUpdated();
|
||||
void FfmpegFrameAvailable();
|
||||
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
|
||||
void LoginPINRequested(bool incorrect);
|
||||
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||
|
||||
#ifndef CHIAKI_VIDEODECODER_H
|
||||
#define CHIAKI_VIDEODECODER_H
|
||||
|
||||
#include <chiaki/log.h>
|
||||
|
||||
#include "exception.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
typedef enum {
|
||||
HW_DECODE_NONE = 0,
|
||||
HW_DECODE_VAAPI = 1,
|
||||
HW_DECODE_VDPAU = 2,
|
||||
HW_DECODE_VIDEOTOOLBOX = 3,
|
||||
HW_DECODE_CUDA = 4,
|
||||
} HardwareDecodeEngine;
|
||||
|
||||
|
||||
static const QMap<HardwareDecodeEngine, const char *> hardware_decode_engine_names = {
|
||||
{ HW_DECODE_NONE, "none"},
|
||||
{ HW_DECODE_VAAPI, "vaapi"},
|
||||
{ HW_DECODE_VDPAU, "vdpau"},
|
||||
{ HW_DECODE_VIDEOTOOLBOX, "videotoolbox"},
|
||||
{ HW_DECODE_CUDA, "cuda"},
|
||||
};
|
||||
|
||||
class VideoDecoderException: public Exception
|
||||
{
|
||||
public:
|
||||
explicit VideoDecoderException(const QString &msg) : Exception(msg) {};
|
||||
};
|
||||
|
||||
class VideoDecoder: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoDecoder(HardwareDecodeEngine hw_decode_engine, ChiakiLog *log);
|
||||
~VideoDecoder();
|
||||
|
||||
void PushFrame(uint8_t *buf, size_t buf_size);
|
||||
AVFrame *PullFrame();
|
||||
AVFrame *GetFromHardware(AVFrame *hw_frame);
|
||||
|
||||
ChiakiLog *GetChiakiLog() { return log; }
|
||||
|
||||
enum AVPixelFormat PixelFormat() { return hw_decode_engine?AV_PIX_FMT_NV12:AV_PIX_FMT_YUV420P; }
|
||||
|
||||
signals:
|
||||
void FramesAvailable();
|
||||
|
||||
private:
|
||||
HardwareDecodeEngine hw_decode_engine;
|
||||
|
||||
ChiakiLog *log;
|
||||
QMutex mutex;
|
||||
|
||||
AVCodec *codec;
|
||||
AVCodecContext *codec_context;
|
||||
|
||||
enum AVPixelFormat hw_pix_fmt;
|
||||
AVBufferRef *hw_device_ctx;
|
||||
};
|
||||
|
||||
#endif // CHIAKI_VIDEODECODER_H
|
Loading…
Add table
Add a link
Reference in a new issue