mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-07-15 01:23:37 -07:00
Very dirty Video Display
This commit is contained in:
parent
6846d61fa2
commit
76a3d67f5e
8 changed files with 391 additions and 179 deletions
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <streamwindow.h>
|
||||
#include <videodecoder.h>
|
||||
|
||||
#include <chiaki/session.h>
|
||||
#include <chiaki/base64.h>
|
||||
|
@ -15,8 +16,7 @@
|
|||
QAudioOutput *audio_out;
|
||||
QIODevice *audio_io;
|
||||
|
||||
QFile *video_out_file;
|
||||
size_t file_size = 0;
|
||||
VideoDecoder video_decoder;
|
||||
|
||||
|
||||
void audio_frame_cb(int16_t *buf, size_t samples_count, void *user)
|
||||
|
@ -26,12 +26,13 @@ void audio_frame_cb(int16_t *buf, size_t samples_count, void *user)
|
|||
|
||||
void video_sample_cb(uint8_t *buf, size_t buf_size, void *user)
|
||||
{
|
||||
if(!video_out_file)
|
||||
video_decoder.PutFrame(buf, buf_size);
|
||||
/*if(!video_out_file)
|
||||
return;
|
||||
printf("writing %#zx to file, start: %#zx\n", buf_size, file_size);
|
||||
chiaki_log_hexdump(nullptr, CHIAKI_LOG_DEBUG, buf, buf_size);
|
||||
file_size += buf_size;
|
||||
video_out_file->write((const char *)buf, buf_size);
|
||||
video_out_file->write((const char *)buf, buf_size);*/
|
||||
//StreamRelayIODevice *io_device = reinterpret_cast<StreamRelayIODevice *>(user);
|
||||
//io_device->PushSample(buf, buf_size);
|
||||
}
|
||||
|
@ -98,13 +99,28 @@ int main(int argc, char *argv[])
|
|||
audio_io = audio_out->start();
|
||||
|
||||
|
||||
video_out_file = nullptr;
|
||||
//video_out_file = nullptr;
|
||||
//video_out_file->open(QFile::ReadWrite);
|
||||
|
||||
QObject::connect(&video_decoder, &VideoDecoder::FramesAvailable, &window, [&window]() {
|
||||
QImage prev;
|
||||
QImage image;
|
||||
do
|
||||
{
|
||||
prev = image;
|
||||
image = video_decoder.PullFrame();
|
||||
} while(!image.isNull());
|
||||
|
||||
if(!prev.isNull())
|
||||
{
|
||||
window.SetImage(prev);
|
||||
}
|
||||
});
|
||||
|
||||
ChiakiSession session;
|
||||
chiaki_session_init(&session, &connect_info);
|
||||
chiaki_session_set_audio_frame_cb(&session, audio_frame_cb, NULL);
|
||||
chiaki_session_set_video_sample_cb(&session, video_sample_cb, window.GetIODevice());
|
||||
chiaki_session_set_audio_frame_cb(&session, audio_frame_cb, nullptr);
|
||||
chiaki_session_set_video_sample_cb(&session, video_sample_cb, nullptr);
|
||||
chiaki_session_start(&session);
|
||||
|
||||
app.setQuitOnLastWindowClosed(true);
|
||||
|
@ -113,7 +129,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
//video_out_file->close();
|
||||
|
||||
printf("CLOSED!!! filesize: %zu\n", file_size);
|
||||
//printf("CLOSED!!! filesize: %zu\n", file_size);
|
||||
|
||||
chiaki_session_join(&session);
|
||||
chiaki_session_fini(&session);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue