mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 02:36:51 -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 <QMutex>
|
||||
|
||||
#include <chiaki/log.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
@ -35,7 +37,7 @@ struct AVOpenGLFrame
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
|
||||
bool Update(AVFrame *frame);
|
||||
bool Update(AVFrame *frame, ChiakiLog *log);
|
||||
};
|
||||
|
||||
class AVOpenGLWidget: public QOpenGLWidget
|
||||
|
@ -65,7 +67,6 @@ class AVOpenGLWidget: public QOpenGLWidget
|
|||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
void resizeGL(int w, int h) override;
|
||||
void paintGL() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "exception.h"
|
||||
|
||||
#include <chiaki/log.h>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
|
@ -41,16 +43,19 @@ class VideoDecoder: public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
VideoDecoder();
|
||||
VideoDecoder(ChiakiLog *log);
|
||||
~VideoDecoder();
|
||||
|
||||
void PushFrame(uint8_t *buf, size_t buf_size);
|
||||
AVFrame *PullFrame();
|
||||
|
||||
ChiakiLog *GetChiakiLog() { return log; }
|
||||
|
||||
signals:
|
||||
void FramesAvailable();
|
||||
|
||||
private:
|
||||
ChiakiLog *log;
|
||||
QMutex mutex;
|
||||
|
||||
AVCodec *codec;
|
||||
|
|
|
@ -41,7 +41,7 @@ void AVOpenGLFrameUploader::UpdateFrame()
|
|||
if(!next_frame)
|
||||
return;
|
||||
|
||||
bool success = widget->GetBackgroundFrame()->Update(next_frame);
|
||||
bool success = widget->GetBackgroundFrame()->Update(next_frame, decoder->GetChiakiLog());
|
||||
av_frame_free(&next_frame);
|
||||
|
||||
if(success)
|
||||
|
|
|
@ -107,14 +107,13 @@ void AVOpenGLWidget::SwapFrames()
|
|||
QMetaObject::invokeMethod(this, "update");
|
||||
}
|
||||
|
||||
bool AVOpenGLFrame::Update(AVFrame *frame)
|
||||
bool AVOpenGLFrame::Update(AVFrame *frame, ChiakiLog *log)
|
||||
{
|
||||
auto f = QOpenGLContext::currentContext()->functions();
|
||||
|
||||
if(frame->format != AV_PIX_FMT_YUV420P)
|
||||
{
|
||||
// TODO: log to somewhere else
|
||||
printf("Invalid Format\n");
|
||||
CHIAKI_LOGE(log, "AVOpenGLFrame got AVFrame with invalid format");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -175,8 +174,7 @@ void AVOpenGLWidget::initializeGL()
|
|||
std::vector<GLchar> info_log(info_log_size);
|
||||
f->glGetProgramInfoLog(program, info_log_size, &info_log_size, info_log.data());
|
||||
f->glDeleteProgram(program);
|
||||
// TODO: log to somewhere else
|
||||
printf("Failed to Link Shader Program:\n%s\n", info_log.data());
|
||||
CHIAKI_LOGE(decoder->GetChiakiLog(), "Failed to Link Shader Program:\n%s", info_log.data());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -222,7 +220,7 @@ void AVOpenGLWidget::initializeGL()
|
|||
frame_uploader_context->setShareContext(context());
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -236,10 +234,6 @@ void AVOpenGLWidget::initializeGL()
|
|||
frame_uploader_thread->start();
|
||||
}
|
||||
|
||||
void AVOpenGLWidget::resizeGL(int w, int h)
|
||||
{
|
||||
}
|
||||
|
||||
void AVOpenGLWidget::paintGL()
|
||||
{
|
||||
auto f = QOpenGLContext::currentContext()->extraFunctions();
|
||||
|
|
|
@ -36,10 +36,11 @@ static void EventCb(ChiakiEvent *event, void *user);
|
|||
|
||||
StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, 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
|
||||
,gamepad(nullptr)
|
||||
gamepad(nullptr),
|
||||
#endif
|
||||
video_decoder(log.GetChiakiLog())
|
||||
{
|
||||
QByteArray host_str = connect_info.host.toUtf8();
|
||||
QByteArray registkey_str = connect_info.registkey.toUtf8();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <QImage>
|
||||
|
||||
VideoDecoder::VideoDecoder()
|
||||
VideoDecoder::VideoDecoder(ChiakiLog *log) : log(log)
|
||||
{
|
||||
codec = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||
if(!codec)
|
||||
|
@ -60,25 +60,27 @@ send_packet:
|
|||
{
|
||||
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();
|
||||
if(!frame)
|
||||
{
|
||||
printf("failed to alloc frame\n");
|
||||
CHIAKI_LOGE(log, "Failed to alloc AVFrame");
|
||||
return;
|
||||
}
|
||||
r = avcodec_receive_frame(codec_context, frame);
|
||||
av_frame_free(&frame);
|
||||
if(r != 0)
|
||||
{
|
||||
printf("failed to pull packet\n");
|
||||
CHIAKI_LOGE(log, "Failed to pull frame");
|
||||
return;
|
||||
}
|
||||
goto send_packet;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ AVFrame *VideoDecoder::PullFrame()
|
|||
if(r != 0)
|
||||
{
|
||||
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);
|
||||
return frame_last;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue