From 500fc0aeb152c0b6c14580843f98fa977dbef264 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 27 Sep 2023 10:10:57 +0200 Subject: [PATCH] video_rxtx: make API functions noexcept --- src/video_rxtx.h | 4 ++-- src/video_rxtx/h264_rtp.cpp | 3 ++- src/video_rxtx/h264_rtp.h | 6 +++--- src/video_rxtx/h264_sdp.cpp | 3 ++- src/video_rxtx/h264_sdp.hpp | 4 ++-- src/video_rxtx/ihdtv.cpp | 5 +++-- src/video_rxtx/ihdtv.h | 6 +++--- src/video_rxtx/loopback.cpp | 10 +++++----- src/video_rxtx/{loopback.h => loopback.hpp} | 14 +++++++------- src/video_rxtx/sage.cpp | 9 +++++---- src/video_rxtx/sage.h | 6 +++--- src/video_rxtx/ultragrid_rtp.cpp | 6 ++++-- src/video_rxtx/ultragrid_rtp.h | 6 +++--- 13 files changed, 44 insertions(+), 38 deletions(-) rename src/video_rxtx/{loopback.h => loopback.hpp} (86%) diff --git a/src/video_rxtx.h b/src/video_rxtx.h index e8b9ad5ec..848a037d8 100644 --- a/src/video_rxtx.h +++ b/src/video_rxtx.h @@ -101,8 +101,8 @@ protected: unsigned long long int m_frames_sent; private: void start(); - virtual void send_frame(std::shared_ptr) = 0; - virtual void *(*get_receiver_thread())(void *arg) = 0; + virtual void send_frame(std::shared_ptr) noexcept = 0; + virtual void *(*get_receiver_thread() noexcept)(void *arg) = 0; static void *sender_thread(void *args); void *sender_loop(); virtual struct response *process_sender_message(struct msg_sender *) { diff --git a/src/video_rxtx/h264_rtp.cpp b/src/video_rxtx/h264_rtp.cpp index 7e3d19675..ec8321bef 100644 --- a/src/video_rxtx/h264_rtp.cpp +++ b/src/video_rxtx/h264_rtp.cpp @@ -81,7 +81,8 @@ h264_rtp_video_rxtx::h264_rtp_video_rxtx(std::map const &p #endif } -void h264_rtp_video_rxtx::send_frame(shared_ptr tx_frame) +void +h264_rtp_video_rxtx::send_frame(shared_ptr tx_frame) noexcept { tx_send_h264(m_tx, tx_frame.get(), m_network_device); if ((m_rxtx_mode & MODE_RECEIVER) == 0) { // send RTCP (receiver thread would otherwise do this diff --git a/src/video_rxtx/h264_rtp.h b/src/video_rxtx/h264_rtp.h index 199f0d957..43196fa04 100644 --- a/src/video_rxtx/h264_rtp.h +++ b/src/video_rxtx/h264_rtp.h @@ -7,7 +7,7 @@ */ /* * Copyright (c) 2013-2014 Fundació i2CAT, Internet I Innovació Digital a Catalunya - * Copyright (c) 2013-2014 CESNET, z. s. p. o. + * Copyright (c) 2013-2023 CESNET, z. s. p. o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,8 +51,8 @@ public: h264_rtp_video_rxtx(std::map const &, int); virtual ~h264_rtp_video_rxtx(); private: - virtual void send_frame(std::shared_ptr); - virtual void *(*get_receiver_thread())(void *arg) { + virtual void send_frame(std::shared_ptr) noexcept override; + virtual void *(*get_receiver_thread() noexcept)(void *arg) override { return NULL; } rtsp_serv_t *m_rtsp_server; diff --git a/src/video_rxtx/h264_sdp.cpp b/src/video_rxtx/h264_sdp.cpp index 6331f7d52..c509c8632 100644 --- a/src/video_rxtx/h264_sdp.cpp +++ b/src/video_rxtx/h264_sdp.cpp @@ -114,7 +114,8 @@ void h264_sdp_video_rxtx::sdp_add_video(codec_t codec) * producing H.264/JPEG natively (eg. v4l2) to be passed untouched to transport. Fallback H.264 is applied when uncompressed * stream is detected. */ -void h264_sdp_video_rxtx::send_frame(shared_ptr tx_frame) +void +h264_sdp_video_rxtx::send_frame(shared_ptr tx_frame) noexcept { if (!is_codec_opaque(tx_frame->color_spec)) { if (m_sent_compress_change) { diff --git a/src/video_rxtx/h264_sdp.hpp b/src/video_rxtx/h264_sdp.hpp index a9785f63d..eb7b22671 100644 --- a/src/video_rxtx/h264_sdp.hpp +++ b/src/video_rxtx/h264_sdp.hpp @@ -54,8 +54,8 @@ public: virtual ~h264_sdp_video_rxtx(); private: static void change_address_callback(void *udata, const char *address); - virtual void send_frame(std::shared_ptr); - virtual void *(*get_receiver_thread())(void *arg) { + virtual void send_frame(std::shared_ptr) noexcept override; + virtual void *(*get_receiver_thread() noexcept)(void *arg) override { return NULL; } void sdp_add_video(codec_t codec); diff --git a/src/video_rxtx/ihdtv.cpp b/src/video_rxtx/ihdtv.cpp index 6d4fc04a2..221bab867 100644 --- a/src/video_rxtx/ihdtv.cpp +++ b/src/video_rxtx/ihdtv.cpp @@ -10,7 +10,7 @@ * Dalibor Matura <255899@mail.muni.cz> * Ian Wesley-Smith * - * Copyright (c) 2005-2010 CESNET z.s.p.o. + * Copyright (c) 2005-2023 CESNET z.s.p.o. * Copyright (c) 2001-2004 University of Southern California * Copyright (c) 2003-2004 University of Glasgow * @@ -71,7 +71,8 @@ using namespace std; -void ihdtv_video_rxtx::send_frame(shared_ptr tx_frame) +void +ihdtv_video_rxtx::send_frame(shared_ptr tx_frame) noexcept { #ifdef HAVE_IHDTV ihdtv_send(&m_tx_connection, tx_frame.get(), 9000000); // FIXME: fix the use of frame size!! diff --git a/src/video_rxtx/ihdtv.h b/src/video_rxtx/ihdtv.h index a1adda8bd..95a7c009d 100644 --- a/src/video_rxtx/ihdtv.h +++ b/src/video_rxtx/ihdtv.h @@ -11,7 +11,7 @@ * Ian Wesley-Smith * Martin Pulec * - * Copyright (c) 2005-2010 CESNET z.s.p.o. + * Copyright (c) 2005-2023 CESNET z.s.p.o. * Copyright (c) 2001-2004 University of Southern California * Copyright (c) 2003-2004 University of Glasgow * @@ -70,12 +70,12 @@ public: ihdtv_video_rxtx(std::map const &); ~ihdtv_video_rxtx(); private: - void send_frame(std::shared_ptr); + void send_frame(std::shared_ptr) noexcept override; static void *receiver_thread(void *arg) { ihdtv_video_rxtx *s = static_cast(arg); return s->receiver_loop(); } - void *(*get_receiver_thread())(void *arg) { + void *(*get_receiver_thread() noexcept)(void *arg) override { return receiver_thread; } void *receiver_loop(); diff --git a/src/video_rxtx/loopback.cpp b/src/video_rxtx/loopback.cpp index fbdef44ce..5a6788824 100644 --- a/src/video_rxtx/loopback.cpp +++ b/src/video_rxtx/loopback.cpp @@ -3,7 +3,7 @@ * @author Martin Pulec */ /* - * Copyright (c) 2018 CESNET, z. s. p. o. + * Copyright (c) 2018-2023 CESNET, z. s. p. o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,7 +46,7 @@ #include "config_win32.h" #endif // HAVE_CONFIG_H -#include "video_rxtx/loopback.h" +#include "video_rxtx/loopback.hpp" #include @@ -81,7 +81,8 @@ void *loopback_video_rxtx::receiver_thread(void *arg) return s->receiver_loop(); } -void loopback_video_rxtx::send_frame(std::shared_ptr f) +void +loopback_video_rxtx::send_frame(std::shared_ptr f) noexcept { unique_lock lk(m_lock); if (m_frames.size() >= BUFF_MAX_LEN) { @@ -91,7 +92,6 @@ void loopback_video_rxtx::send_frame(std::shared_ptr f) m_frames.push(f); lk.unlock(); m_frame_ready.notify_one(); - } void *loopback_video_rxtx::receiver_loop() @@ -123,7 +123,7 @@ void *loopback_video_rxtx::receiver_loop() return nullptr; } -void *(*loopback_video_rxtx::get_receiver_thread())(void *arg) +void *(*loopback_video_rxtx::get_receiver_thread() noexcept)(void *arg) { return receiver_thread; } diff --git a/src/video_rxtx/loopback.h b/src/video_rxtx/loopback.hpp similarity index 86% rename from src/video_rxtx/loopback.h rename to src/video_rxtx/loopback.hpp index 7b36e8af1..5fa9cb1f8 100644 --- a/src/video_rxtx/loopback.h +++ b/src/video_rxtx/loopback.hpp @@ -1,9 +1,9 @@ /** - * @file video_rxtx/ultragrid_rtp.h + * @file video_rxtx/loopback.hpp * @author Martin Pulec */ /* - * Copyright (c) 2018 CESNET, z. s. p. o. + * Copyright (c) 2018-2023 CESNET, z. s. p. o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,8 +35,8 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef VIDEO_RXTX_LOOPBACK_H -#define VIDEO_RXTX_LOOPBACK_H +#ifndef VIDEO_RXTX_LOOPBACK_HPP +#define VIDEO_RXTX_LOOPBACK_HPP #include #include @@ -55,9 +55,9 @@ public: private: static void *receiver_thread(void *arg); - virtual void send_frame(std::shared_ptr) override; + virtual void send_frame(std::shared_ptr) noexcept override; void *receiver_loop(); - virtual void *(*get_receiver_thread())(void *arg) override; + virtual void *(*get_receiver_thread() noexcept)(void *arg) override; struct display *m_display_device; struct video_desc m_configure_desc{}; @@ -66,5 +66,5 @@ private: std::mutex m_lock; }; -#endif // VIDEO_RXTX_LOOPBACK_H +#endif // !defined VIDEO_RXTX_LOOPBACK_HPP diff --git a/src/video_rxtx/sage.cpp b/src/video_rxtx/sage.cpp index fd0af6d4b..7a83a2329 100644 --- a/src/video_rxtx/sage.cpp +++ b/src/video_rxtx/sage.cpp @@ -3,7 +3,7 @@ * @author Martin Pulec */ /* - * Copyright (c) 2013-2014 CESNET z.s.p.o. + * Copyright (c) 2013-2023 CESNET z.s.p.o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -74,10 +74,11 @@ sage_video_rxtx::sage_video_rxtx(map const ¶ms) : memset(&m_saved_video_desc, 0, sizeof(m_saved_video_desc)); } -void sage_video_rxtx::send_frame(shared_ptr tx_frame) +void +sage_video_rxtx::send_frame(shared_ptr tx_frame) noexcept { - if(!video_desc_eq(m_saved_video_desc, - video_desc_from_frame(tx_frame.get()))) { + if (!video_desc_eq(m_saved_video_desc, + video_desc_from_frame(tx_frame.get()))) { display_reconfigure(m_sage_tx_device, video_desc_from_frame(tx_frame.get()), VIDEO_NORMAL); m_saved_video_desc = video_desc_from_frame(tx_frame.get()); diff --git a/src/video_rxtx/sage.h b/src/video_rxtx/sage.h index f4e5e7f25..15e4ba07a 100644 --- a/src/video_rxtx/sage.h +++ b/src/video_rxtx/sage.h @@ -3,7 +3,7 @@ * @author Martin Pulec */ /* - * Copyright (c) 2014 CESNET, z. s. p. o. + * Copyright (c) 2014-2023 CESNET, z. s. p. o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,8 +51,8 @@ public: sage_video_rxtx(std::map const &); ~sage_video_rxtx(); private: - void send_frame(std::shared_ptr); - void *(*get_receiver_thread())(void *arg) { + void send_frame(std::shared_ptr) noexcept override; + void *(*get_receiver_thread() noexcept)(void *arg) override { return NULL; } struct video_desc m_saved_video_desc; diff --git a/src/video_rxtx/ultragrid_rtp.cpp b/src/video_rxtx/ultragrid_rtp.cpp index 4dff8188a..a05209b87 100644 --- a/src/video_rxtx/ultragrid_rtp.cpp +++ b/src/video_rxtx/ultragrid_rtp.cpp @@ -115,11 +115,13 @@ void *ultragrid_rtp_video_rxtx::receiver_thread(void *arg) { return s->receiver_loop(); } -void *(*ultragrid_rtp_video_rxtx::get_receiver_thread())(void *arg) { +void *(*ultragrid_rtp_video_rxtx::get_receiver_thread() noexcept)(void *arg) +{ return receiver_thread; } -void ultragrid_rtp_video_rxtx::send_frame(shared_ptr tx_frame) +void +ultragrid_rtp_video_rxtx::send_frame(shared_ptr tx_frame) noexcept { m_video_desc = video_desc_from_frame(tx_frame.get()); if (m_fec_state) { diff --git a/src/video_rxtx/ultragrid_rtp.h b/src/video_rxtx/ultragrid_rtp.h index 362cf73a6..f02bd5502 100644 --- a/src/video_rxtx/ultragrid_rtp.h +++ b/src/video_rxtx/ultragrid_rtp.h @@ -3,7 +3,7 @@ * @author Martin Pulec */ /* - * Copyright (c) 2013-2014 CESNET z.s.p.o. + * Copyright (c) 2013-2023 CESNET z.s.p.o. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -60,11 +60,11 @@ public: friend ssize_t hd_rum_decompress_write(void *state, void *buf, size_t count); private: static void *receiver_thread(void *arg); - virtual void send_frame(std::shared_ptr); + virtual void send_frame(std::shared_ptr) noexcept override; void *receiver_loop(); static void *send_frame_async_callback(void *arg); virtual void send_frame_async(std::shared_ptr); - virtual void *(*get_receiver_thread())(void *arg); + virtual void *(*get_receiver_thread() noexcept)(void *arg) override; void receiver_process_messages(); void remove_display_from_decoders();