Fix Cygwin compilation:

- Fix various incompatibilities and differences between Linux and Cygwin builds
- Make usrsctp an optional dependency
- Fix building without SSL
- Add new secure random bytes function, use it for websockets
- Switch to libsrtp2 v2.6.0 (currently latest release)
- Add patch that makes latest libsrtp2 build in latest Cygwin
- Add patch that makes srt build in latest Cygwin
- Correctly allow linking libsrtp2 and srt to local mbedtls version
This commit is contained in:
Thulinma 2024-03-26 12:04:53 +01:00
parent db30be38c5
commit dbafa808b8
23 changed files with 131 additions and 23 deletions

View file

@ -91,7 +91,9 @@ foreach output : outputs
endif
if extra.contains('srtp')
sources += files('output_webrtc_srtp.cpp', 'output_webrtc_srtp.h')
deps += usrsctp_dep
if have_usrsctp
deps += usrsctp_dep
endif
endif
if extra.contains('embed')
sources += embed_tgts

View file

@ -36,6 +36,7 @@ namespace Mist{
static void onRTPPacketizerHasDataCallback(void *socket, const char *data, size_t len, uint8_t channel);
static void onRTPPacketizerHasRTCPDataCallback(void *socket, const char *data, size_t nbytes, uint8_t channel);
#ifdef WITH_DATACHANNELS
static int sctp_recv_cb(struct socket *s, union sctp_sockstore addr, void *data, size_t datalen, struct sctp_rcvinfo rcv, int flags, void *ulp_info){
if (data) {
if (!(flags & MSG_NOTIFICATION)){
@ -61,6 +62,7 @@ namespace Mist{
va_end(args);
INFO_MSG("sctp: %s", msg);
}
#endif
WebRTCSocket::WebRTCSocket(){
udpSock = 0;
@ -132,8 +134,10 @@ namespace Mist{
/* ------------------------------------------------ */
OutWebRTC::OutWebRTC(Socket::Connection &myConn) : HTTPOutput(myConn){
#ifdef WITH_DATACHANNELS
sctpInited = false;
sctpConnected = false;
#endif
noSignalling = false;
totalPkts = 0;
totalLoss = 0;
@ -1170,6 +1174,7 @@ namespace Mist{
if (wSock.udpSock->data.size() && wSock.udpSock->wasEncrypted){
lastRecv = Util::bootMS();
#ifdef WITH_DATACHANNELS
if (packetLog.is_open()){
packetLog << "[" << Util::bootMS() << "]" << "SCTP packet (" << wSock.udpSock->data.size() << "b): " << std::endl;
char * buffer = usrsctp_dumppacket(wSock.udpSock->data, wSock.udpSock->data.size(), SCTP_DUMP_INBOUND);
@ -1200,6 +1205,7 @@ namespace Mist{
}
usrsctp_conninput(this, wSock.udpSock->data, wSock.udpSock->data.size(), 0);
//usrsctp_accept(sctp_sock, 0, 0);
#endif
continue;
}
@ -1636,6 +1642,7 @@ namespace Mist{
}
void OutWebRTC::onSCTP(const char * data, size_t len, uint16_t stream, uint32_t ppid){
#ifdef WITH_DATACHANNELS
if (!sctpConnected){
// We have to call accept (at least) once, otherwise the SCTP library considers our socket not connected
// Accept blocks if there is no peer, so we do this as soon as the first message is received, which means we have a peer.
@ -1723,6 +1730,7 @@ namespace Mist{
packetLog << std::dec << std::endl;
}
}
#endif
}
void OutWebRTC::onDTSCConverterHasPacket(const DTSC::Packet &pkt){
@ -1894,6 +1902,7 @@ namespace Mist{
if (M.getType(thisIdx) == "meta"){
#ifdef WITH_DATACHANNELS
JSON::Value jPack;
if (M.getCodec(thisIdx) == "JSON"){
if (dataLen == 0 || (dataLen == 1 && dataPointer[0] == ' ')){return;}
@ -1938,6 +1947,7 @@ namespace Mist{
WARN_MSG("I don't have a data channel for %s data!", M.getCodec(thisIdx).c_str());
}
}
#endif
return;
}

View file

@ -12,7 +12,10 @@
#include <mist/websocket.h>
#include <fstream>
#include "output_webrtc_srtp.h"
#include <usrsctp.h>
#ifdef WITH_DATACHANNELS
#include <usrsctp.h>
#endif
#define NACK_BUFFER_SIZE 1024
@ -206,11 +209,13 @@ namespace Mist{
int64_t ntpClockDifference;
bool syncedNTPClock;
#ifdef WITH_DATACHANNELS
bool sctpInited;
bool sctpConnected;
struct socket * sctp_sock;
std::map<std::string, uint16_t> dataChannels;
std::deque<std::string> queuedJSON;
#endif
};
}// namespace Mist