diff --git a/npm-scripts.mjs b/npm-scripts.mjs index a526283aaa..a390672051 100644 --- a/npm-scripts.mjs +++ b/npm-scripts.mjs @@ -391,7 +391,7 @@ function flatcNode(clean = false) logInfo('flatcNode()'); // Build flatc if needed. - executeCmd(`${MAKE} -C worker flatc-all`); + executeCmd(`${MAKE} -C worker flatc`); const buildType = process.env.MEDIASOUP_BUILDTYPE || 'Release'; const extension = IS_WINDOWS ? '.exe' : ''; diff --git a/rust/crypto_suite_fbs.patch b/rust/crypto_suite_fbs.patch deleted file mode 100644 index 0fe4a70870..0000000000 --- a/rust/crypto_suite_fbs.patch +++ /dev/null @@ -1,53 +0,0 @@ -diff --git a/worker/src/RTC/SrtpSession.cpp b/worker/src/RTC/SrtpSession.cpp -index 97051e0cf..d87f03ae4 100644 ---- a/worker/src/RTC/SrtpSession.cpp -+++ b/worker/src/RTC/SrtpSession.cpp -@@ -1,3 +1,4 @@ -+#include "FBS/srtpParameters_generated.h" - #define MS_CLASS "RTC::SrtpSession" - // #define MS_LOG_DEV_LEVEL 3 - -@@ -28,6 +29,43 @@ namespace RTC - } - } - -+ FBS::SrtpParameters::SrtpCryptoSuite SrtpSession::CryptoSuiteToFbs(CryptoSuite cryptoSuite) -+ { -+ switch (cryptoSuite) -+ { -+ case SrtpSession::CryptoSuite::AEAD_AES_256_GCM: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM; -+ -+ case SrtpSession::CryptoSuite::AEAD_AES_128_GCM: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM; -+ -+ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80; -+ -+ case SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32: -+ return FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32; -+ } -+ } -+ -+ SrtpSession::CryptoSuite SrtpSession::CryptoSuiteFromFbs(FBS::SrtpParameters::SrtpCryptoSuite cryptoSuite) -+ { -+ switch (cryptoSuite) -+ { -+ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_256_GCM: -+ return SrtpSession::CryptoSuite::AEAD_AES_256_GCM; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AEAD_AES_128_GCM: -+ return SrtpSession::CryptoSuite::AEAD_AES_128_GCM; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_80: -+ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_80; -+ -+ case FBS::SrtpParameters::SrtpCryptoSuite::AES_CM_128_HMAC_SHA1_32: -+ return SrtpSession::CryptoSuite::AES_CM_128_HMAC_SHA1_32; -+ } -+ -+ } -+ - void SrtpSession::OnSrtpEvent(srtp_event_data_t* data) - { - MS_TRACE(); diff --git a/worker/Makefile b/worker/Makefile index 90cb17f565..be41dd515f 100644 --- a/worker/Makefile +++ b/worker/Makefile @@ -21,8 +21,6 @@ INSTALL_DIR ?= $(MEDIASOUP_OUT_DIR)/$(MEDIASOUP_BUILDTYPE) BUILD_DIR ?= $(INSTALL_DIR)/build MESON ?= $(PIP_DIR)/bin/meson MESON_VERSION ?= 1.2.1 -FLATC ?= $(BUILD_DIR)/subprojects/flatbuffers-23.3.3/flatc -FLATC_OUT_DIR ?= ./include/FBS # `MESON_ARGS` can be used to provide extra configuration parameters to Meson, # such as adding defines or changing optimization options. For instance, use # `MESON_ARGS="-Dms_log_trace=true -Dms_log_file_line=true" npm i` to compile @@ -209,17 +207,7 @@ libmediasoup-worker: setup flatc $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags libmediasoup-worker flatc: setup - $(MESON) compile -C $(BUILD_DIR) flatc - [ -d $(FLATC_OUT_DIR) ] || \ - $(FLATC) --cpp --cpp-field-case-style lower --reflect-names --scoped-enums \ - -o $(FLATC_OUT_DIR) ./fbs/* - -flatc-clean: - $(RM) -rf $(FLATC_OUT_DIR) - -flatc-force: flatc-clean flatc - -flatc-all: setup flatc + $(MESON) compile -C $(BUILD_DIR) flatbuffers-generator xcode: setup $(MESON) setup --buildtype debug --backend xcode $(MEDIASOUP_OUT_DIR)/xcode @@ -230,7 +218,7 @@ lint: format: $(GULP) --gulpfile ./scripts/gulpfile.mjs format:worker -test: setup +test: setup flatc $(MESON) compile -C $(BUILD_DIR) -j $(CORES) mediasoup-worker-test $(MESON) install -C $(BUILD_DIR) --no-rebuild --tags mediasoup-worker-test ifeq ($(OS),Windows_NT) diff --git a/worker/fbs/meson.build b/worker/fbs/meson.build new file mode 100644 index 0000000000..5394c8bddf --- /dev/null +++ b/worker/fbs/meson.build @@ -0,0 +1,53 @@ +flatbuffers_schemas = [ + 'activeSpeakerObserver.fbs', + 'audioLevelObserver.fbs', + 'common.fbs', + 'consumer.fbs', + 'dataConsumer.fbs', + 'dataProducer.fbs', + 'directTransport.fbs', + 'log.fbs', + 'message.fbs', + 'notification.fbs', + 'pipeTransport.fbs', + 'plainTransport.fbs', + 'producer.fbs', + 'request.fbs', + 'response.fbs', + 'router.fbs', + 'rtpObserver.fbs', + 'rtpParameters.fbs', + 'rtpStream.fbs', + 'rtxStream.fbs', + 'sctpAssociation.fbs', + 'sctpParameters.fbs', + 'srtpParameters.fbs', + 'transport.fbs', + 'webRtcServer.fbs', + 'webRtcTransport.fbs', + 'worker.fbs', +] + +# Directory from which worker code will include the header files. +flatbuffers_cpp_out_dir = 'FBS' + +flatc = find_program('flatc') +flatbuffers_generator = custom_target('flatbuffers-generator', + output: flatbuffers_cpp_out_dir, + input: flatbuffers_schemas, + command : [ + flatc, + '--cpp', + '--cpp-field-case-style', 'lower', + '--reflect-names', + '--scoped-enums', + '--filename-suffix', '', + '-o', '@OUTPUT@', + '@INPUT@' + ], + build_by_default: true, +) + +flatbuffers_generator_dep = declare_dependency( + include_directories: '.', +) diff --git a/worker/include/Channel/ChannelNotification.hpp b/worker/include/Channel/ChannelNotification.hpp index 05fdf7d290..2aa940656d 100644 --- a/worker/include/Channel/ChannelNotification.hpp +++ b/worker/include/Channel/ChannelNotification.hpp @@ -2,7 +2,7 @@ #define MS_CHANNEL_NOTIFICATION_HPP #include "common.hpp" -#include "FBS/notification_generated.h" +#include "FBS/notification.h" #include #include diff --git a/worker/include/Channel/ChannelRequest.hpp b/worker/include/Channel/ChannelRequest.hpp index d718d9aaa2..0351204362 100644 --- a/worker/include/Channel/ChannelRequest.hpp +++ b/worker/include/Channel/ChannelRequest.hpp @@ -2,9 +2,9 @@ #define MS_CHANNEL_REQUEST_HPP #include "common.hpp" -#include "FBS/message_generated.h" -#include "FBS/request_generated.h" -#include "FBS/response_generated.h" +#include "FBS/message.h" +#include "FBS/request.h" +#include "FBS/response.h" #include #include #include diff --git a/worker/include/RTC/Consumer.hpp b/worker/include/RTC/Consumer.hpp index ecb41bc839..8d3a25c95e 100644 --- a/worker/include/RTC/Consumer.hpp +++ b/worker/include/RTC/Consumer.hpp @@ -4,7 +4,7 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #include "RTC/RTCP/CompoundPacket.hpp" #include "RTC/RTCP/FeedbackPs.hpp" #include "RTC/RTCP/FeedbackPsFir.hpp" diff --git a/worker/include/RTC/DtlsTransport.hpp b/worker/include/RTC/DtlsTransport.hpp index 93b81bbd7c..bb635ea42f 100644 --- a/worker/include/RTC/DtlsTransport.hpp +++ b/worker/include/RTC/DtlsTransport.hpp @@ -2,7 +2,7 @@ #define MS_RTC_DTLS_TRANSPORT_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/SrtpSession.hpp" #include "handles/TimerHandle.hpp" #include diff --git a/worker/include/RTC/IceCandidate.hpp b/worker/include/RTC/IceCandidate.hpp index db1a9e047b..3993b9bef1 100644 --- a/worker/include/RTC/IceCandidate.hpp +++ b/worker/include/RTC/IceCandidate.hpp @@ -2,7 +2,7 @@ #define MS_RTC_ICE_CANDIDATE_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/TcpServer.hpp" #include "RTC/TransportTuple.hpp" #include "RTC/UdpSocket.hpp" diff --git a/worker/include/RTC/IceServer.hpp b/worker/include/RTC/IceServer.hpp index acbdea2909..35aa636d99 100644 --- a/worker/include/RTC/IceServer.hpp +++ b/worker/include/RTC/IceServer.hpp @@ -2,7 +2,7 @@ #define MS_RTC_ICE_SERVER_HPP #include "common.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include "RTC/StunPacket.hpp" #include "RTC/TransportTuple.hpp" #include diff --git a/worker/include/RTC/Parameters.hpp b/worker/include/RTC/Parameters.hpp index c0ac24b049..0bbd89cde6 100644 --- a/worker/include/RTC/Parameters.hpp +++ b/worker/include/RTC/Parameters.hpp @@ -2,7 +2,7 @@ #define MS_RTC_PARAMETERS_HPP #include "common.hpp" -#include "FBS/rtpParameters_generated.h" +#include "FBS/rtpParameters.h" #include #include #include diff --git a/worker/include/RTC/PipeTransport.hpp b/worker/include/RTC/PipeTransport.hpp index 6a2d803648..1c08492a42 100644 --- a/worker/include/RTC/PipeTransport.hpp +++ b/worker/include/RTC/PipeTransport.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_PIPE_TRANSPORT_HPP #define MS_RTC_PIPE_TRANSPORT_HPP -#include "FBS/pipeTransport_generated.h" +#include "FBS/pipeTransport.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" diff --git a/worker/include/RTC/PlainTransport.hpp b/worker/include/RTC/PlainTransport.hpp index 5b728a406a..ad9783618f 100644 --- a/worker/include/RTC/PlainTransport.hpp +++ b/worker/include/RTC/PlainTransport.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_PLAIN_TRANSPORT_HPP #define MS_RTC_PLAIN_TRANSPORT_HPP -#include "FBS/plainTransport_generated.h" +#include "FBS/plainTransport.h" #include "RTC/Shared.hpp" #include "RTC/SrtpSession.hpp" #include "RTC/Transport.hpp" diff --git a/worker/include/RTC/RtpDictionaries.hpp b/worker/include/RTC/RtpDictionaries.hpp index fc60435758..caf3211f1a 100644 --- a/worker/include/RTC/RtpDictionaries.hpp +++ b/worker/include/RTC/RtpDictionaries.hpp @@ -2,7 +2,7 @@ #define MS_RTC_RTP_DICTIONARIES_HPP #include "common.hpp" -#include "FBS/rtpParameters_generated.h" +#include "FBS/rtpParameters.h" #include "RTC/Parameters.hpp" #include #include diff --git a/worker/include/RTC/RtpStream.hpp b/worker/include/RTC/RtpStream.hpp index 5a3224fdcd..80e86a0dd5 100644 --- a/worker/include/RTC/RtpStream.hpp +++ b/worker/include/RTC/RtpStream.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "DepLibUV.hpp" -#include "FBS/rtpStream_generated.h" +#include "FBS/rtpStream.h" #include "RTC/RTCP/FeedbackPsFir.hpp" #include "RTC/RTCP/FeedbackPsPli.hpp" #include "RTC/RTCP/FeedbackRtpNack.hpp" diff --git a/worker/include/RTC/RtxStream.hpp b/worker/include/RTC/RtxStream.hpp index c0d862b063..e8c312ab92 100644 --- a/worker/include/RTC/RtxStream.hpp +++ b/worker/include/RTC/RtxStream.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "DepLibUV.hpp" -#include "FBS/rtxStream_generated.h" +#include "FBS/rtxStream.h" #include "RTC/RTCP/Packet.hpp" #include "RTC/RTCP/ReceiverReport.hpp" #include "RTC/RTCP/SenderReport.hpp" diff --git a/worker/include/RTC/SctpDictionaries.hpp b/worker/include/RTC/SctpDictionaries.hpp index 162d26b830..25862a70a1 100644 --- a/worker/include/RTC/SctpDictionaries.hpp +++ b/worker/include/RTC/SctpDictionaries.hpp @@ -2,7 +2,7 @@ #define MS_RTC_SCTP_DICTIONARIES_HPP #include "common.hpp" -#include +#include namespace RTC { diff --git a/worker/include/RTC/SimpleConsumer.hpp b/worker/include/RTC/SimpleConsumer.hpp index 7421256eef..d502801e9b 100644 --- a/worker/include/RTC/SimpleConsumer.hpp +++ b/worker/include/RTC/SimpleConsumer.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_SIMPLE_CONSUMER_HPP #define MS_RTC_SIMPLE_CONSUMER_HPP -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/Consumer.hpp" #include "RTC/SeqManager.hpp" #include "RTC/Shared.hpp" diff --git a/worker/include/RTC/SimulcastConsumer.hpp b/worker/include/RTC/SimulcastConsumer.hpp index 981a304418..fcce57adb4 100644 --- a/worker/include/RTC/SimulcastConsumer.hpp +++ b/worker/include/RTC/SimulcastConsumer.hpp @@ -1,7 +1,7 @@ #ifndef MS_RTC_SIMULCAST_CONSUMER_HPP #define MS_RTC_SIMULCAST_CONSUMER_HPP -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #include "RTC/Codecs/PayloadDescriptorHandler.hpp" #include "RTC/Consumer.hpp" #include "RTC/SeqManager.hpp" diff --git a/worker/include/RTC/SrtpSession.hpp b/worker/include/RTC/SrtpSession.hpp index 61108b6cee..fa14a14760 100644 --- a/worker/include/RTC/SrtpSession.hpp +++ b/worker/include/RTC/SrtpSession.hpp @@ -2,7 +2,7 @@ #define MS_RTC_SRTP_SESSION_HPP #include "common.hpp" -#include "FBS/srtpParameters_generated.h" +#include "FBS/srtpParameters.h" #include namespace RTC diff --git a/worker/include/RTC/Transport.hpp b/worker/include/RTC/Transport.hpp index eb0013677b..61bdd3ec65 100644 --- a/worker/include/RTC/Transport.hpp +++ b/worker/include/RTC/Transport.hpp @@ -7,7 +7,7 @@ #include "Channel/ChannelNotification.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/Consumer.hpp" #include "RTC/DataConsumer.hpp" #include "RTC/DataProducer.hpp" diff --git a/worker/include/RTC/TransportTuple.hpp b/worker/include/RTC/TransportTuple.hpp index efc37ad2bf..75c124ecd4 100644 --- a/worker/include/RTC/TransportTuple.hpp +++ b/worker/include/RTC/TransportTuple.hpp @@ -3,7 +3,7 @@ #include "common.hpp" #include "Utils.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/TcpConnection.hpp" #include "RTC/UdpSocket.hpp" #include diff --git a/worker/include/Worker.hpp b/worker/include/Worker.hpp index 90f75bf600..b5d5b79024 100644 --- a/worker/include/Worker.hpp +++ b/worker/include/Worker.hpp @@ -4,7 +4,7 @@ #include "common.hpp" #include "Channel/ChannelRequest.hpp" #include "Channel/ChannelSocket.hpp" -#include "FBS/worker_generated.h" +#include "FBS/worker.h" #include "RTC/Router.hpp" #include "RTC/Shared.hpp" #include "RTC/WebRtcServer.hpp" diff --git a/worker/meson.build b/worker/meson.build index 9da9775242..52c2244af4 100644 --- a/worker/meson.build +++ b/worker/meson.build @@ -213,7 +213,10 @@ flatbuffers_proj = subproject( 'warning_level=0', ], ) -libwebrtc_include_directories = include_directories('include') +# flatbuffers schemas subdirectory. +subdir('fbs') +# Add current build directory so libwebrtc has access to FBS folder. +libwebrtc_include_directories = include_directories('include', 'fbs') subdir('deps/libwebrtc') dependencies = [ @@ -223,6 +226,7 @@ dependencies = [ libsrtp2_proj.get_variable('libsrtp2_dep'), usrsctp_proj.get_variable('usrsctp_dep'), flatbuffers_proj.get_variable('flatbuffers_dep'), + flatbuffers_generator_dep, libwebrtc_dep, ] diff --git a/worker/src/RTC/PipeConsumer.cpp b/worker/src/RTC/PipeConsumer.cpp index d5e96f6a74..3af878f6db 100644 --- a/worker/src/RTC/PipeConsumer.cpp +++ b/worker/src/RTC/PipeConsumer.cpp @@ -1,4 +1,4 @@ -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #define MS_CLASS "RTC::PipeConsumer" // #define MS_LOG_DEV_LEVEL 3 diff --git a/worker/src/RTC/SimpleConsumer.cpp b/worker/src/RTC/SimpleConsumer.cpp index 96889142f8..9f05f36dfe 100644 --- a/worker/src/RTC/SimpleConsumer.cpp +++ b/worker/src/RTC/SimpleConsumer.cpp @@ -1,4 +1,4 @@ -#include "FBS/consumer_generated.h" +#include "FBS/consumer.h" #define MS_CLASS "RTC::SimpleConsumer" // #define MS_LOG_DEV_LEVEL 3 diff --git a/worker/src/RTC/Transport.cpp b/worker/src/RTC/Transport.cpp index 38e8f35f01..e4c39263ff 100644 --- a/worker/src/RTC/Transport.cpp +++ b/worker/src/RTC/Transport.cpp @@ -5,7 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include "FBS/transport_generated.h" +#include "FBS/transport.h" #include "RTC/BweType.hpp" #include "RTC/PipeConsumer.hpp" #include "RTC/RTCP/FeedbackPs.hpp" diff --git a/worker/src/RTC/WebRtcTransport.cpp b/worker/src/RTC/WebRtcTransport.cpp index 9aabf97ab7..b28effdb0d 100644 --- a/worker/src/RTC/WebRtcTransport.cpp +++ b/worker/src/RTC/WebRtcTransport.cpp @@ -5,7 +5,7 @@ #include "Logger.hpp" #include "MediaSoupErrors.hpp" #include "Utils.hpp" -#include "FBS/webRtcTransport_generated.h" +#include "FBS/webRtcTransport.h" #include // std::pow() namespace RTC diff --git a/worker/src/Worker.cpp b/worker/src/Worker.cpp index 5a0b42e372..46c63d4215 100644 --- a/worker/src/Worker.cpp +++ b/worker/src/Worker.cpp @@ -9,8 +9,8 @@ #include "MediaSoupErrors.hpp" #include "Settings.hpp" #include "Channel/ChannelNotifier.hpp" -#include "FBS/response_generated.h" -#include "FBS/worker_generated.h" +#include "FBS/response.h" +#include "FBS/worker.h" /* Instance methods. */