From 8ab83b415cd4865a84a1e6c215efd3220620d249 Mon Sep 17 00:00:00 2001 From: RLamm Date: Fri, 14 Feb 2020 14:24:42 +0200 Subject: [PATCH] First version, which compiles with VS --- src/debug.hh | 2 +- src/formats/hevc.cc | 2 +- src/frame.hh | 14 +++++++------- src/poll.cc | 2 +- src/queue.hh | 4 ++++ src/rtcp.cc | 7 +++---- src/socket.cc | 4 +++- src/util.hh | 6 +++++- 8 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/debug.hh b/src/debug.hh index 990275f..fe06b21 100644 --- a/src/debug.hh +++ b/src/debug.hh @@ -50,7 +50,7 @@ static inline void win_get_last_error(void) #define debug(level, fmt, ...) \ fprintf(stderr, "[RTPLIB][%s][%s::%s] " fmt "\n", level, \ - className(__PRETTY_FUNCTION__), __func__, ##__VA_ARGS__) + "", __func__, ##__VA_ARGS__) #ifndef NDEBUG #define LOG_DEBUG(fmt, ...) debug(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__) diff --git a/src/formats/hevc.cc b/src/formats/hevc.cc index 50e9949..560cbd1 100644 --- a/src/formats/hevc.cc +++ b/src/formats/hevc.cc @@ -29,7 +29,7 @@ #endif #ifndef __BYTE_ORDER -#warning "setting byte order to little endian" +//#warning "setting byte order to little endian" #define __BYTE_ORDER __LITTLE_ENDIAN #endif diff --git a/src/frame.hh b/src/frame.hh index 79160a0..b240aee 100644 --- a/src/frame.hh +++ b/src/frame.hh @@ -110,30 +110,30 @@ namespace kvz_rtp { struct rtcp_header header; uint32_t sender_ssrc; struct rtcp_sender_info s_info; - struct rtcp_report_block blocks[0]; + struct rtcp_report_block blocks[1]; }; PACKED_STRUCT(rtcp_receiver_frame) { struct rtcp_header header; uint32_t sender_ssrc; - struct rtcp_report_block blocks[0]; + struct rtcp_report_block blocks[1]; }; PACKED_STRUCT(rtcp_sdes_item) { uint8_t type; uint8_t length; - uint8_t data[0]; + uint8_t data[1]; }; PACKED_STRUCT(rtcp_sdes_frame) { struct rtcp_header header; uint32_t sender_ssrc; - struct rtcp_sdes_item items[0]; + struct rtcp_sdes_item items[1]; }; PACKED_STRUCT(rtcp_bye_frame) { struct rtcp_header header; - uint32_t ssrc[0]; + uint32_t ssrc[1]; }; PACKED_STRUCT(rtcp_app_frame) { @@ -145,7 +145,7 @@ namespace kvz_rtp { uint32_t ssrc; uint8_t name[4]; - uint8_t payload[0]; + uint8_t payload[1]; }; PACKED_STRUCT(zrtp_frame) { @@ -154,7 +154,7 @@ namespace kvz_rtp { uint16_t seq; uint32_t magic; uint32_t ssrc; - uint8_t payload[0]; + uint8_t payload[1]; }; /* Allocate an RTP frame diff --git a/src/poll.cc b/src/poll.cc index d8c68a6..4a3f91b 100644 --- a/src/poll.cc +++ b/src/poll.cc @@ -84,7 +84,7 @@ rtp_error_t kvz_rtp::poll::poll(std::vector& sockets, uint8_t * } for (size_t i = 0; i < sockets.size(); ++i) { - auto rtp_ret = sockets.at(i).recv((char *)buf, (int)buf_len, 0); + auto rtp_ret = sockets.at(i).recv(buf, (int)buf_len, 0); if (rtp_ret != RTP_OK) { if (WSAGetLastError() == WSAEWOULDBLOCK) diff --git a/src/queue.hh b/src/queue.hh index 225de43..8d9f47c 100644 --- a/src/queue.hh +++ b/src/queue.hh @@ -10,6 +10,10 @@ #include "sender.hh" #include "util.hh" +#if defined(_MSC_VER) +typedef SSIZE_T ssize_t; +#endif + const int MAX_MSG_COUNT = 5000; const int MAX_QUEUED_MSGS = 10; const int MAX_CHUNK_COUNT = 4; diff --git a/src/rtcp.cc b/src/rtcp.cc index 36f4a77..e8a95c3 100644 --- a/src/rtcp.cc +++ b/src/rtcp.cc @@ -77,10 +77,9 @@ rtp_error_t kvz_rtp::rtcp::add_participant(std::string dst_addr, int dst_port, i * * This means that the socket is listened for 5s at a time and after the timeout, * Send Report is sent to all participants */ - struct timeval tv = { - .tv_sec = 3, - .tv_usec = 0 - }; + struct timeval tv; + tv.tv_sec = 3; + tv.tv_usec = 0; if ((ret = p->socket->setsockopt(SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv))) != RTP_OK) return ret; diff --git a/src/socket.cc b/src/socket.cc index e249f66..622ea85 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -1,5 +1,6 @@ #ifdef _WIN32 #include +#include #include #else #include @@ -125,7 +126,7 @@ socket_t& kvz_rtp::socket::get_raw_socket() rtp_error_t kvz_rtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags, int *bytes_sent) { - int nsend; + int nsend = 0; #ifdef __linux__ if ((nsend = ::sendto(socket_, buf, buf_len, flags, (const struct sockaddr *)&addr, sizeof(addr_))) == -1) { @@ -149,6 +150,7 @@ rtp_error_t kvz_rtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t bu *bytes_sent = -1; return RTP_SEND_ERROR; } + nsend = sent_bytes; #endif if (bytes_sent) diff --git a/src/util.hh b/src/util.hh index 0b6f91c..fe9fd17 100644 --- a/src/util.hh +++ b/src/util.hh @@ -13,12 +13,16 @@ #include #include +#if defined(_MSC_VER) +typedef SSIZE_T ssize_t; +#endif + #if defined(__MINGW32__) || defined(__MINGW64__) || defined(__linux__) #define PACKED_STRUCT(name) \ struct __attribute__((packed)) name #else -#warning "structures are not packed!" +//#warning "structures are not packed!" #define PACKED_STRUCT(name) struct name #endif