mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-19 13:09:39 -07:00
Log into SessionLog
This commit is contained in:
parent
c4921ad682
commit
5403cbb389
6 changed files with 25 additions and 22 deletions
|
@ -21,6 +21,8 @@
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
|
#include <chiaki/log.h>
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
@ -35,7 +37,7 @@ struct AVOpenGLFrame
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
|
|
||||||
bool Update(AVFrame *frame);
|
bool Update(AVFrame *frame, ChiakiLog *log);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AVOpenGLWidget: public QOpenGLWidget
|
class AVOpenGLWidget: public QOpenGLWidget
|
||||||
|
@ -65,7 +67,6 @@ class AVOpenGLWidget: public QOpenGLWidget
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initializeGL() override;
|
void initializeGL() override;
|
||||||
void resizeGL(int w, int h) override;
|
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
|
||||||
|
#include <chiaki/log.h>
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
@ -41,16 +43,19 @@ class VideoDecoder: public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VideoDecoder();
|
VideoDecoder(ChiakiLog *log);
|
||||||
~VideoDecoder();
|
~VideoDecoder();
|
||||||
|
|
||||||
void PushFrame(uint8_t *buf, size_t buf_size);
|
void PushFrame(uint8_t *buf, size_t buf_size);
|
||||||
AVFrame *PullFrame();
|
AVFrame *PullFrame();
|
||||||
|
|
||||||
|
ChiakiLog *GetChiakiLog() { return log; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void FramesAvailable();
|
void FramesAvailable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
ChiakiLog *log;
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|
|
||||||
AVCodec *codec;
|
AVCodec *codec;
|
||||||
|
|
|
@ -41,7 +41,7 @@ void AVOpenGLFrameUploader::UpdateFrame()
|
||||||
if(!next_frame)
|
if(!next_frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool success = widget->GetBackgroundFrame()->Update(next_frame);
|
bool success = widget->GetBackgroundFrame()->Update(next_frame, decoder->GetChiakiLog());
|
||||||
av_frame_free(&next_frame);
|
av_frame_free(&next_frame);
|
||||||
|
|
||||||
if(success)
|
if(success)
|
||||||
|
|
|
@ -107,14 +107,13 @@ void AVOpenGLWidget::SwapFrames()
|
||||||
QMetaObject::invokeMethod(this, "update");
|
QMetaObject::invokeMethod(this, "update");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AVOpenGLFrame::Update(AVFrame *frame)
|
bool AVOpenGLFrame::Update(AVFrame *frame, ChiakiLog *log)
|
||||||
{
|
{
|
||||||
auto f = QOpenGLContext::currentContext()->functions();
|
auto f = QOpenGLContext::currentContext()->functions();
|
||||||
|
|
||||||
if(frame->format != AV_PIX_FMT_YUV420P)
|
if(frame->format != AV_PIX_FMT_YUV420P)
|
||||||
{
|
{
|
||||||
// TODO: log to somewhere else
|
CHIAKI_LOGE(log, "AVOpenGLFrame got AVFrame with invalid format");
|
||||||
printf("Invalid Format\n");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +174,7 @@ void AVOpenGLWidget::initializeGL()
|
||||||
std::vector<GLchar> info_log(info_log_size);
|
std::vector<GLchar> info_log(info_log_size);
|
||||||
f->glGetProgramInfoLog(program, info_log_size, &info_log_size, info_log.data());
|
f->glGetProgramInfoLog(program, info_log_size, &info_log_size, info_log.data());
|
||||||
f->glDeleteProgram(program);
|
f->glDeleteProgram(program);
|
||||||
// TODO: log to somewhere else
|
CHIAKI_LOGE(decoder->GetChiakiLog(), "Failed to Link Shader Program:\n%s", info_log.data());
|
||||||
printf("Failed to Link Shader Program:\n%s\n", info_log.data());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +220,7 @@ void AVOpenGLWidget::initializeGL()
|
||||||
frame_uploader_context->setShareContext(context());
|
frame_uploader_context->setShareContext(context());
|
||||||
if(!frame_uploader_context->create())
|
if(!frame_uploader_context->create())
|
||||||
{
|
{
|
||||||
printf("Failed to create upload context!\n"); // TODO: log to somewhere else
|
CHIAKI_LOGE(decoder->GetChiakiLog(), "Failed to create upload OpenGL context");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,10 +234,6 @@ void AVOpenGLWidget::initializeGL()
|
||||||
frame_uploader_thread->start();
|
frame_uploader_thread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AVOpenGLWidget::resizeGL(int w, int h)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void AVOpenGLWidget::paintGL()
|
void AVOpenGLWidget::paintGL()
|
||||||
{
|
{
|
||||||
auto f = QOpenGLContext::currentContext()->extraFunctions();
|
auto f = QOpenGLContext::currentContext()->extraFunctions();
|
||||||
|
|
|
@ -36,10 +36,11 @@ static void EventCb(ChiakiEvent *event, void *user);
|
||||||
|
|
||||||
StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObject *parent)
|
StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
log(this, connect_info.log_level_mask, connect_info.log_file)
|
log(this, connect_info.log_level_mask, connect_info.log_file),
|
||||||
#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
|
#if CHIAKI_GUI_ENABLE_QT_GAMEPAD
|
||||||
,gamepad(nullptr)
|
gamepad(nullptr),
|
||||||
#endif
|
#endif
|
||||||
|
video_decoder(log.GetChiakiLog())
|
||||||
{
|
{
|
||||||
QByteArray host_str = connect_info.host.toUtf8();
|
QByteArray host_str = connect_info.host.toUtf8();
|
||||||
QByteArray registkey_str = connect_info.registkey.toUtf8();
|
QByteArray registkey_str = connect_info.registkey.toUtf8();
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
|
||||||
VideoDecoder::VideoDecoder()
|
VideoDecoder::VideoDecoder(ChiakiLog *log) : log(log)
|
||||||
{
|
{
|
||||||
codec = avcodec_find_decoder(AV_CODEC_ID_H264);
|
codec = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||||
if(!codec)
|
if(!codec)
|
||||||
|
@ -60,25 +60,27 @@ send_packet:
|
||||||
{
|
{
|
||||||
if(r == AVERROR(EAGAIN))
|
if(r == AVERROR(EAGAIN))
|
||||||
{
|
{
|
||||||
printf("avcodec internal buffer is full, removing frames\n"); // TODO: log to somewhere else
|
CHIAKI_LOGE(log, "AVCodec internal buffer is full removing frames before pushing");
|
||||||
AVFrame *frame = av_frame_alloc();
|
AVFrame *frame = av_frame_alloc();
|
||||||
if(!frame)
|
if(!frame)
|
||||||
{
|
{
|
||||||
printf("failed to alloc frame\n");
|
CHIAKI_LOGE(log, "Failed to alloc AVFrame");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r = avcodec_receive_frame(codec_context, frame);
|
r = avcodec_receive_frame(codec_context, frame);
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
if(r != 0)
|
if(r != 0)
|
||||||
{
|
{
|
||||||
printf("failed to pull packet\n");
|
CHIAKI_LOGE(log, "Failed to pull frame");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
goto send_packet;
|
goto send_packet;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("failed to push frame\n");
|
char errbuf[128];
|
||||||
|
av_make_error_string(errbuf, sizeof(errbuf), r);
|
||||||
|
CHIAKI_LOGE(log, "Failed to push frame: %s", errbuf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +118,7 @@ AVFrame *VideoDecoder::PullFrame()
|
||||||
if(r != 0)
|
if(r != 0)
|
||||||
{
|
{
|
||||||
if(r != AVERROR(EAGAIN))
|
if(r != AVERROR(EAGAIN))
|
||||||
printf("decoding with ffmpeg failed!!\n"); // TODO: log somewhere else
|
CHIAKI_LOGE(log, "Decoding with FFMPEG failed");
|
||||||
av_frame_free(&frame);
|
av_frame_free(&frame);
|
||||||
return frame_last;
|
return frame_last;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue