From b2541d54300700fe851f9a80295fda984054a8bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Fri, 31 May 2019 22:22:56 +0200 Subject: [PATCH] Add stub Video Receiver --- lib/CMakeLists.txt | 9 ++++- lib/include/chiaki/session.h | 2 + lib/include/chiaki/videoreceiver.h | 59 ++++++++++++++++++++++++++++++ lib/src/session.c | 13 ++++++- lib/src/videoreceiver.c | 30 +++++++++++++++ 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 lib/include/chiaki/videoreceiver.h create mode 100644 lib/src/videoreceiver.c diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ab62cef..668268c 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -16,7 +16,9 @@ set(HEADER_FILES include/chiaki/launchspec.h include/chiaki/random.h include/chiaki/gkcrypt.h - include/chiaki/audio.h) + include/chiaki/audio.h + include/chiaki/audioreceiver.h + include/chiaki/videoreceiver.h) set(SOURCE_FILES src/common.c @@ -36,7 +38,10 @@ set(SOURCE_FILES src/ecdh.c src/launchspec.c src/random.c - src/gkcrypt.c src/audio.c include/chiaki/audioreceiver.h src/audioreceiver.c) + src/gkcrypt.c + src/audio.c + src/audioreceiver.c + src/videoreceiver.c) add_subdirectory(protobuf) include_directories("${NANOPB_SOURCE_DIR}") diff --git a/lib/include/chiaki/session.h b/lib/include/chiaki/session.h index 43b8f25..44c0e81 100644 --- a/lib/include/chiaki/session.h +++ b/lib/include/chiaki/session.h @@ -28,6 +28,7 @@ #include "ecdh.h" #include "audio.h" #include "audioreceiver.h" +#include "videoreceiver.h" #include #include @@ -133,6 +134,7 @@ typedef struct chiaki_session_t ChiakiNagare nagare; ChiakiAudioReceiver *audio_receiver; + ChiakiVideoReceiver *video_receiver; } ChiakiSession; CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, ChiakiConnectInfo *connect_info); diff --git a/lib/include/chiaki/videoreceiver.h b/lib/include/chiaki/videoreceiver.h new file mode 100644 index 0000000..3b2c23a --- /dev/null +++ b/lib/include/chiaki/videoreceiver.h @@ -0,0 +1,59 @@ +/* + * This file is part of Chiaki. + * + * Chiaki is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Chiaki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chiaki. If not, see . + */ + +#ifndef CHIAKI_VIDEORECEIVER_H +#define CHIAKI_VIDEORECEIVER_H + +#include "common.h" +#include "log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct chiaki_video_receiver_t +{ + struct chiaki_session_t *session; + ChiakiLog *log; + +} ChiakiVideoReceiver; + +CHIAKI_EXPORT void chiaki_video_receiver_init(ChiakiVideoReceiver *video_receiver, struct chiaki_session_t *session); +CHIAKI_EXPORT void chiaki_video_receiver_fini(ChiakiVideoReceiver *video_receiver); + +static inline ChiakiVideoReceiver *chiaki_video_receiver_new(struct chiaki_session_t *session) +{ + ChiakiVideoReceiver *video_receiver = CHIAKI_NEW(ChiakiVideoReceiver); + if(!video_receiver) + return NULL; + chiaki_video_receiver_init(video_receiver, session); + return video_receiver; +} + +static inline void chiaki_video_receiver_free(ChiakiVideoReceiver *video_receiver) +{ + if(!video_receiver) + return; + chiaki_video_receiver_fini(video_receiver); + free(video_receiver); +} + +#ifdef __cplusplus +} +#endif + +#endif // CHIAKI_VIDEORECEIVER_H diff --git a/lib/src/session.c b/lib/src/session.c index ae05cb7..d0b5793 100644 --- a/lib/src/session.c +++ b/lib/src/session.c @@ -192,15 +192,26 @@ static void *session_thread_func(void *arg) goto quit_ctrl; } + session->video_receiver = chiaki_video_receiver_new(session); + if(!session->video_receiver) + { + CHIAKI_LOGE(&session->log, "Session failed to initialize Video Receiver\n"); + goto quit_audio_receiver; + } + err = chiaki_nagare_run(session); if(err != CHIAKI_ERR_SUCCESS) { CHIAKI_LOGE(&session->log, "Nagare failed\n"); - goto quit_audio_receiver; + goto quit_video_receiver; } CHIAKI_LOGI(&session->log, "Nagare completed successfully\n"); +quit_video_receiver: + chiaki_video_receiver_free(session->video_receiver); + session->video_receiver = NULL; + quit_audio_receiver: chiaki_audio_receiver_free(session->audio_receiver); session->audio_receiver = NULL; diff --git a/lib/src/videoreceiver.c b/lib/src/videoreceiver.c new file mode 100644 index 0000000..eb2f4af --- /dev/null +++ b/lib/src/videoreceiver.c @@ -0,0 +1,30 @@ +/* + * This file is part of Chiaki. + * + * Chiaki is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Chiaki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Chiaki. If not, see . + */ + +#include +#include + + +CHIAKI_EXPORT void chiaki_video_receiver_init(ChiakiVideoReceiver *video_receiver, struct chiaki_session_t *session) +{ + video_receiver->session = session; + video_receiver->log = &session->log; +} + +CHIAKI_EXPORT void chiaki_video_receiver_fini(ChiakiVideoReceiver *video_receiver) +{ +} \ No newline at end of file