qrtplib: Windows build

This commit is contained in:
f4exb 2018-03-05 16:40:53 +01:00
parent e86e2f25a2
commit 3c4d40ac73
5 changed files with 194 additions and 142 deletions

View File

@ -10,6 +10,8 @@ TEMPLATE = lib
TARGET = httpserver TARGET = httpserver
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
INCLUDEPATH += ../sdrbase
QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11
CONFIG(Release):build_subdir = release CONFIG(Release):build_subdir = release

View File

@ -1,100 +1,100 @@
project(qrtplib) project(qrtplib)
set (qrtplib_HEADERS set (qrtplib_HEADERS
rtcpapppacket.h rtcpapppacket.h
rtcpbyepacket.h rtcpbyepacket.h
rtcpcompoundpacket.h rtcpcompoundpacket.h
rtcpcompoundpacketbuilder.h rtcpcompoundpacketbuilder.h
rtcppacket.h rtcppacket.h
rtcppacketbuilder.h rtcppacketbuilder.h
rtcprrpacket.h rtcprrpacket.h
rtcpscheduler.h rtcpscheduler.h
rtcpsdesinfo.h rtcpsdesinfo.h
rtcpsdespacket.h rtcpsdespacket.h
rtcpsrpacket.h rtcpsrpacket.h
rtcpunknownpacket.h rtcpunknownpacket.h
rtpaddress.h rtpaddress.h
rtpcollisionlist.h rtpcollisionlist.h
rtpconfig.h rtpconfig.h
rtpdefines.h rtpdefines.h
rtpendian.h rtpendian.h
rtperrors.h rtperrors.h
rtphashtable.h rtphashtable.h
rtpinternalsourcedata.h rtpinternalsourcedata.h
# rtpipv4address.h # rtpipv4address.h
# rtpipv4destination.h # rtpipv4destination.h
rtpkeyhashtable.h rtpkeyhashtable.h
rtplibraryversion.h rtplibraryversion.h
rtppacket.h rtppacket.h
rtppacketbuilder.h rtppacketbuilder.h
rtprandom.h rtprandom.h
rtprandomrand48.h rtprandomrand48.h
rtprandomrands.h rtprandomrands.h
rtprandomurandom.h rtprandomurandom.h
rtprawpacket.h rtprawpacket.h
rtpsession.h rtpsession.h
rtpsessionparams.h rtpsessionparams.h
rtpsessionsources.h rtpsessionsources.h
rtpsourcedata.h rtpsourcedata.h
rtpsources.h rtpsources.h
rtpstructs.h rtpstructs.h
rtptimeutilities.h rtptimeutilities.h
rtptransmitter.h rtptransmitter.h
rtptypes_win.h rtptypes_win.h
rtptypes.h rtptypes.h
rtpudpransmitter.h rtpudptransmitter.h
# rtpudpv4transmitter.h # rtpudpv4transmitter.h
# rtpudpv4transmitternobind.h # rtpudpv4transmitternobind.h
# rtpexternaltransmitter.h # rtpexternaltransmitter.h
rtpsocketutil.h rtpsocketutil.h
rtpabortdescriptors.h rtpabortdescriptors.h
rtpselect.h rtpselect.h
# rtptcpaddress.h # rtptcpaddress.h
# rtptcptransmitter.h # rtptcptransmitter.h
) )
set(qrtplib_SOURCES set(qrtplib_SOURCES
rtcpapppacket.cpp rtcpapppacket.cpp
rtcpbyepacket.cpp rtcpbyepacket.cpp
rtcpcompoundpacket.cpp rtcpcompoundpacket.cpp
rtcpcompoundpacketbuilder.cpp rtcpcompoundpacketbuilder.cpp
rtcppacketbuilder.cpp rtcppacketbuilder.cpp
rtcprrpacket.cpp rtcprrpacket.cpp
rtcpscheduler.cpp rtcpscheduler.cpp
rtcpsdesinfo.cpp rtcpsdesinfo.cpp
rtcpsdespacket.cpp rtcpsdespacket.cpp
rtcpsrpacket.cpp rtcpsrpacket.cpp
rtpaddress.cpp rtpaddress.cpp
rtpcollisionlist.cpp rtpcollisionlist.cpp
rtperrors.cpp rtperrors.cpp
rtpinternalsourcedata.cpp rtpinternalsourcedata.cpp
# rtpipv4address.cpp # rtpipv4address.cpp
# rtpipv4destination.cpp # rtpipv4destination.cpp
rtplibraryversion.cpp rtplibraryversion.cpp
rtppacket.cpp rtppacket.cpp
rtppacketbuilder.cpp rtppacketbuilder.cpp
rtprandom.cpp rtprandom.cpp
rtprandomrand48.cpp rtprandomrand48.cpp
rtprandomrands.cpp rtprandomrands.cpp
rtprandomurandom.cpp rtprandomurandom.cpp
rtpsession.cpp rtpsession.cpp
rtpsessionparams.cpp rtpsessionparams.cpp
rtpsessionsources.cpp rtpsessionsources.cpp
rtpsourcedata.cpp rtpsourcedata.cpp
rtpsources.cpp rtpsources.cpp
rtptimeutilities.cpp rtptimeutilities.cpp
rtpudptransmitter.cpp rtpudptransmitter.cpp
# rtpudpv4transmitter.cpp # rtpudpv4transmitter.cpp
# rtpudpv4transmitternobind.cpp # rtpudpv4transmitternobind.cpp
# rtpexternaltransmitter.cpp # rtpexternaltransmitter.cpp
rtpabortdescriptors.cpp rtpabortdescriptors.cpp
# rtptcpaddress.cpp # rtptcpaddress.cpp
# rtptcptransmitter.cpp # rtptcptransmitter.cpp
) )
include_directories( include_directories(
. .
${CMAKE_SOURCE_DIR}/sdrbase ${CMAKE_SOURCE_DIR}/sdrbase
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )

96
qrtplib/qrtplib.pro Normal file
View File

@ -0,0 +1,96 @@
#--------------------------------------------------------
#
# Pro file for Windows builds with Qt Creator
#
#--------------------------------------------------------
QT += core network
TEMPLATE = lib
TARGET = qrtplib
INCLUDEPATH += $$PWD
INCLUDEPATH += ../sdrbase
QMAKE_CXXFLAGS += -std=c++11
CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug
# Enable very detailed debug messages when compiling the debug version
CONFIG(debug, debug|release) {
DEFINES += SUPERVERBOSE
}
HEADERS += $$PWD/rtcpapppacket.h \
$$PWD/rtcpbyepacket.h \
$$PWD/rtcpcompoundpacket.h \
$$PWD/rtcpcompoundpacketbuilder.h \
$$PWD/rtcppacket.h \
$$PWD/rtcppacketbuilder.h \
$$PWD/rtcprrpacket.h \
$$PWD/rtcpscheduler.h \
$$PWD/rtcpsdesinfo.h \
$$PWD/rtcpsdespacket.h \
$$PWD/rtcpsrpacket.h \
$$PWD/rtcpunknownpacket.h \
$$PWD/rtpaddress.h \
$$PWD/rtpcollisionlist.h \
$$PWD/rtpconfig.h \
$$PWD/rtpdefines.h \
$$PWD/rtpendian.h \
$$PWD/rtperrors.h \
$$PWD/rtphashtable.h \
$$PWD/rtpinternalsourcedata.h \
$$PWD/rtpkeyhashtable.h \
$$PWD/rtplibraryversion.h \
$$PWD/rtppacket.h \
$$PWD/rtppacketbuilder.h \
$$PWD/rtprandom.h \
$$PWD/rtprandomrand48.h \
$$PWD/rtprandomrands.h \
$$PWD/rtprandomurandom.h \
$$PWD/rtprawpacket.h \
$$PWD/rtpsession.h \
$$PWD/rtpsessionparams.h \
$$PWD/rtpsessionsources.h \
$$PWD/rtpsourcedata.h \
$$PWD/rtpsources.h \
$$PWD/rtpstructs.h \
$$PWD/rtptimeutilities.h \
$$PWD/rtptransmitter.h \
$$PWD/rtptypes_win.h \
$$PWD/rtptypes.h \
$$PWD/rtpudptransmitter.h \
$$PWD/rtpsocketutil.h \
$$PWD/rtpselect.h
SOURCES += $$PWD/rtcpapppacket.cpp \
$$PWD/rtcpbyepacket.cpp \
$$PWD/rtcpcompoundpacket.cpp \
$$PWD/rtcpcompoundpacketbuilder.cpp \
$$PWD/rtcppacketbuilder.cpp \
$$PWD/rtcprrpacket.cpp \
$$PWD/rtcpscheduler.cpp \
$$PWD/rtcpsdesinfo.cpp \
$$PWD/rtcpsdespacket.cpp \
$$PWD/rtcpsrpacket.cpp \
$$PWD/rtpaddress.cpp \
$$PWD/rtpcollisionlist.cpp \
$$PWD/rtperrors.cpp \
$$PWD/rtpinternalsourcedata.cpp \
$$PWD/rtplibraryversion.cpp \
$$PWD/rtppacket.cpp \
$$PWD/rtppacketbuilder.cpp \
$$PWD/rtprandom.cpp \
$$PWD/rtprandomrand48.cpp \
$$PWD/rtprandomrands.cpp \
$$PWD/rtprandomurandom.cpp \
$$PWD/rtpsession.cpp \
$$PWD/rtpsessionparams.cpp \
$$PWD/rtpsessionsources.cpp \
$$PWD/rtpsourcedata.cpp \
$$PWD/rtpsources.cpp \
$$PWD/rtptimeutilities.cpp \
$$PWD/rtpudptransmitter.cpp

View File

@ -48,12 +48,11 @@
#include "rtcpcompoundpacket.h" #include "rtcpcompoundpacket.h"
#endif // RTP_SUPPORT_SENDAPP #endif // RTP_SUPPORT_SENDAPP
#include "rtpinternalutils.h" #include "rtpinternalutils.h"
#ifndef WIN32
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#else
#include <winbase.h> #include <QHostInfo>
#endif // WIN32
namespace qrtplib namespace qrtplib
@ -1145,51 +1144,6 @@ int RTPSession::ProcessPolledData()
int RTPSession::CreateCNAME(uint8_t *buffer, std::size_t *bufferlength, bool resolve __attribute__((unused))) int RTPSession::CreateCNAME(uint8_t *buffer, std::size_t *bufferlength, bool resolve __attribute__((unused)))
{ {
#ifndef WIN32
bool gotlogin = true;
#ifdef RTP_SUPPORT_GETLOGINR
buffer[0] = 0;
if (getlogin_r((char *) buffer, *bufferlength) != 0)
gotlogin = false;
else
{
if (buffer[0] == 0)
gotlogin = false;
}
if (!gotlogin) // try regular getlogin
{
char *loginname = getlogin();
if (loginname == 0)
gotlogin = false;
else
strncpy((char *) buffer, loginname, *bufferlength);
}
#else
char *loginname = getlogin();
if (loginname == 0)
gotlogin = false;
else
strncpy((char *)buffer,loginname,*bufferlength);
#endif // RTP_SUPPORT_GETLOGINR
if (!gotlogin)
{
char *logname = getenv("LOGNAME");
if (logname == 0)
return ERR_RTP_SESSION_CANTGETLOGINNAME;
strncpy((char *) buffer, logname, *bufferlength);
}
#else // Win32 version
#ifndef _WIN32_WCE
DWORD len = *bufferlength;
if (!GetUserName((LPTSTR)buffer,&len))
strncpy((char *)buffer,"unknown",*bufferlength);
#else
strncpy((char *)buffer,"unknown",*bufferlength);
#endif // _WIN32_WCE
#endif // WIN32
buffer[*bufferlength - 1] = 0; buffer[*bufferlength - 1] = 0;
std::size_t offset = strlen((const char *) buffer); std::size_t offset = strlen((const char *) buffer);
@ -1199,16 +1153,15 @@ int RTPSession::CreateCNAME(uint8_t *buffer, std::size_t *bufferlength, bool res
std::size_t buflen2 = *bufferlength - offset; std::size_t buflen2 = *bufferlength - offset;
char hostname[1024]; QString hostnameStr = QHostInfo::localHostName();
int hostnameSize = hostnameStr.size();
strncpy(hostname, "localhost", 1024); // just in case gethostname fails strncpy((char * )(buffer + offset), hostnameStr.toStdString().c_str(), buflen2);
*bufferlength = offset + hostnameSize;
gethostname(hostname, 1024);
strncpy((char * )(buffer + offset), hostname, buflen2);
*bufferlength = offset + strlen(hostname);
if (*bufferlength > RTCP_SDES_MAXITEMLENGTH) if (*bufferlength > RTCP_SDES_MAXITEMLENGTH)
*bufferlength = RTCP_SDES_MAXITEMLENGTH; *bufferlength = RTCP_SDES_MAXITEMLENGTH;
return 0; return 0;
} }

View File

@ -11,6 +11,7 @@ CONFIG += ordered
SUBDIRS = serialdv SUBDIRS = serialdv
SUBDIRS += httpserver SUBDIRS += httpserver
SUBDIRS += logging SUBDIRS += logging
SUBDIRS += qrtplib
SUBDIRS += swagger SUBDIRS += swagger
SUBDIRS += sdrbase SUBDIRS += sdrbase
SUBDIRS += sdrgui SUBDIRS += sdrgui