zenomt / rtmfp-cpp Goto Github PK
View Code? Open in Web Editor NEWSecure Real-Time Media Flow Protocol (RTMFP) Library in C++
Home Page: https://www.rfc-editor.org/rfc/rfc7016.html
License: MIT License
Secure Real-Time Media Flow Protocol (RTMFP) Library in C++
Home Page: https://www.rfc-editor.org/rfc/rfc7016.html
License: MIT License
Hi I was wondering why don't you use something like https://github.com/ithewei/libhv.
You said you don't have any windows networking programming XP. With this framework you write your code once and it works on all platform. With one rock you hit all birds.
It seems that it has something similar to what you did with Event Loop.
Best Regards
Greetings !
I started a Windows port but came to a roadblock because I have no experience with Socket porting from Unix to Windows but somehow I found the bits an pieces from around the web and added new files and modified CMakeLists.txt file to take into consideration WIN32 with vcpkg for Visual Studio 2019 project generation.
I hope that it is going to lead somewhere.
https://github.com/al-sabr/rtmfp-cpp/tree/win32-port
Best Regards
Greetings again!
Since OpenSSL is an old library and not as performant as WolfSSL I thought to suggest to add an Adapter for it which will reduce the size and increase the performances of this library. I hope that this is a good idea that might inspire you.
Best regards
Line 34 in d0ee847
Hi Thornburgh,
I've tested your redirector code in your example on CentOS7 and met a crash as many redirector's client disconnect (close) at the same time with the stack trace below. to specific, This is my test:
E20240911 14:01:58.894667 45021 ServerApp.cpp:248] *** SIGABRT (@0x3e90000afd5) received by PID 45013 (TID 0x7fe515295700) from PID 45013; stack trace: ***
E20240911 14:01:58.894979 45021 ServerApp.cpp:248] @ 0x7fe518019630 (unknown)
E20240911 14:01:58.895383 45021 ServerApp.cpp:248] @ 0x7fe516e30387 __GI_raise
E20240911 14:01:58.895720 45021 ServerApp.cpp:248] @ 0x7fe516e31a78 __GI_abort
E20240911 14:01:58.896059 45021 ServerApp.cpp:248] @ 0x7fe516e72ed7 __libc_message
E20240911 14:01:58.896251 45021 ServerApp.cpp:248] @ 0x7fe516e7b299 _int_free
E20240911 14:01:58.899547 45021 ServerApp.cpp:248] @ 0x6ee63a com::zenomt::List<>::~List()
E20240911 14:01:58.902670 45021 ServerApp.cpp:248] @ 0x6eb4a2 com::zenomt::rtmfp::RecvFlow::~RecvFlow()
E20240911 14:01:58.906158 45021 ServerApp.cpp:248] @ 0x6eb629 com::zenomt::rtmfp::RecvFlow::~RecvFlow()
E20240911 14:01:58.908824 45021 ServerApp.cpp:248] @ 0x6ef4ba _ZNSt19_Sp_counted_deleterIPN3com6zenomt5rtmfp8RecvFlowEZNS1_9share_refIS3_EESt10shared_ptrIT_EPS7_bEUlPNS1_6ObjectEE_SaIvELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
E20240911 14:01:58.911636 45021 ServerApp.cpp:248] @ 0x702fd7 com::zenomt::rtmfp::Session::abortFlowsAndTimers()
E20240911 14:01:58.914172 45021 ServerApp.cpp:248] @ 0x7022b0 com::zenomt::rtmfp::Session::abort()
E20240911 14:01:58.917240 45021 ServerApp.cpp:248] @ 0x70bbb3 com::zenomt::rtmfp::Session::onCloseAckChunk()
E20240911 14:01:58.920346 45021 ServerApp.cpp:248] @ 0x70b155 com::zenomt::rtmfp::Session::onChunk()
E20240911 14:01:58.923573 45021 ServerApp.cpp:248] @ 0x6fde94 com::zenomt::rtmfp::ISession::onReceivePacket()
E20240911 14:01:58.926578 45021 ServerApp.cpp:248] @ 0x70a4d6 com::zenomt::rtmfp::Session::onReceivePacket()
E20240911 14:01:58.929595 45021 ServerApp.cpp:248] @ 0x6dfbcd com::zenomt::rtmfp::RTMFP::onReceivePacket()
E20240911 14:01:58.932370 45021 ServerApp.cpp:248] @ 0x6db518 com::zenomt::rtmfp::PosixPlatformAdapter::receiveOnePacket()
E20240911 14:01:58.932555 45021 ServerApp.cpp:248] @ 0x6db5cc std::_Function_handler<>::_M_invoke()
E20240911 14:01:58.935199 45021 ServerApp.cpp:248] @ 0x6c764d com::zenomt::EPollRunLoop::processActivatedItems()
E20240911 14:01:58.938537 45021 ServerApp.cpp:248] @ 0x6c72f0 com::zenomt::EPollRunLoop::run()
Do you have any insight for this crash ?
Thanks.
Hi zenomt, Your example is using CBC to encrypt data between sessions. Can I replace it with GCM? is there any problem with GCM as in my research GCM has a better performance than CBC. Does GCM cause rtmfp overhead in some cases that I don't realize ?
Sometimes, RTMP player stops playing, I try to use ffplay to play an RTMP url from server and it dumps the error message:
RTMP packet size mismatch 52249 != 10815/1
At the first time, I think that maybe there is some wrong from the network, internet. But when I make a overload test, using many tccon to connect to server at the same time this error often occurs , the ffplay rtmp player hangs up and shows the message: "RTMP packet size mismatch xxxx != yyyyy1"
Run tcserver -B 0.0.0.0:1935 -b 0.0.0.0:1936 and make a stress test for server.
The tcserver run with RTMFP which disables openssl by call EVP_enc_null() in
if( (not EVP_CipherInit_ex(m_ctx, EVP_enc_null(), NULL, (const unsigned char *)key, NULL, encrypt ? 1 : 0))
or (not EVP_CIPHER_CTX_set_padding(m_ctx, 0))
)
return false;
and:
m_ciphertextBuf = (uint8_t *)malloc(ENCRYPT_BUF_LENGTH + ENCRYPT_BUF_MARGIN);
m_plaintextBuf = m_ciphertextBuf + ENCRYPT_BUF_MARGIN;
I've tested, and it were ok for both client tcconn & tcserver to make sure that the crypto didnt costs any cpu.
I had 3 days to review to fix this problem but I havent found any solution yet. Please help me to fix this!
I think there is some this wrong on RTMFP, so it costs so much CPU.
P2: 1000 - RTMP clients
Run tcserver -B 0.0.0.0:1935 -b 0.0.0.0:1936 now that tcserver use 1.2MB of memory
Using 100 rtmfp clients or more connect to a tcserver to play a stream, after that closing all these streams from each client. The memory of tcserver process increases to 3.9MB ...
After thousand of rtmfp connections & disconnect and now tcserver increases to 2GB memory.
Edit: I've found that when the client is killed or crashed (shutdown function is not called from client) to server, so server leaked memory though the function onException is called by RTMFPClient.
Please fix!! Thanks!!
Hi I was only proposing this idea to communicate with the folks at https://github.com/MonaSolutions/librtmfp
They did most of the major work maybe this could save you some time.
Best Regards
here is the error log:
g++ -Os -Wall -pedantic -std=c++11 -c -o src/URIParse.o src/URIParse.cpp
In file included from src/URIParse.cpp:9:
src/../include/rtmfp/Hex.hpp:15:62: error: ‘uint8_t’ was not declared in this scope
15 | static void print(const char *msg, const std::vector<uint8_t> &bytes);
| ^~~~~~~
src/../include/rtmfp/Hex.hpp:8:1: note: ‘uint8_t’ is defined in header ‘’; this is probably fixable by adding ‘#include ’
7 | #include
+++ |+#include
8 |
src/../include/rtmfp/Hex.hpp:15:69: error: template argument 1 is invalid
15 | static void print(const char *msg, const std::vector<uint8_t> &bytes);
| ^
src/../include/rtmfp/Hex.hpp:15:69: error: template argument 2 is invalid
src/../include/rtmfp/Hex.hpp:22:53: error: ‘uint8_t’ was not declared in this scope
22 | static std::string encode(const std::vector<uint8_t> &bytes);
| ^~~~~~~
src/../include/rtmfp/Hex.hpp:22:53: note: ‘uint8_t’ is defined in header ‘’; this is probably fixable by adding ‘#include ’
src/../include/rtmfp/Hex.hpp:22:60: error: template argument 1 is invalid
22 | static std::string encode(const std::vector<uint8_t> &bytes);
| ^
src/../include/rtmfp/Hex.hpp:22:60: error: template argument 2 is invalid
src/../include/rtmfp/Hex.hpp:24:57: error: ‘uint8_t’ was not declared in this scope
24 | static bool decode(const char *hex, std::vector<uint8_t> &dst);
| ^~~~~~~
src/../include/rtmfp/Hex.hpp:24:57: note: ‘uint8_t’ is defined in header ‘’; this is probably fixable by adding ‘#include ’
src/../include/rtmfp/Hex.hpp:24:64: error: template argument 1 is invalid
24 | static bool decode(const char *hex, std::vector<uint8_t> &dst);
| ^
src/../include/rtmfp/Hex.hpp:24:64: error: template argument 2 is invalid
src/URIParse.cpp: In static member function ‘static std::string com::zenomt::URIParse::percentDecode(const std::string&)’:
src/URIParse.cpp:226:38: error: ‘uint8_t’ was not declared in this scope
226 | rv.push_back(uint8_t(b));
| ^~~~~~~
src/URIParse.cpp:11:1: note: ‘uint8_t’ is defined in header ‘’; this is probably fixable by adding ‘#include ’
10 | #include "../include/rtmfp/URIParse.hpp"
+++ |+#include
11 |
make: *** [: src/URIParse.o] Error
gcc 14.1.1
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.