common: Reduce include dependencies in header files

I removed as many dependencies as I could. I tried to preserve the API
by including the necessary headers for library usage in lib.hh file.
This commit is contained in:
Joni Räsänen 2021-06-02 10:25:40 +03:00
parent ba8b0cba80
commit cb99edb203
63 changed files with 329 additions and 82 deletions

View File

@ -1,13 +1,13 @@
#pragma once
#include "queue.hh"
#include "socket.hh"
#include "runner.hh"
#include "util.hh"
#include <condition_variable>
#include <queue>
#include <thread>
#include <mutex>
namespace uvgrtp {
@ -31,6 +31,9 @@ namespace uvgrtp {
* experiences to very small (<50 us even for large frames [>170 kB]) */
typedef struct transaction transaction_t;
class socket;
class dispatcher;
class dispatcher : public runner {
public:
dispatcher(uvgrtp::socket *socket);

View File

@ -1,13 +1,17 @@
#pragma once
#include "formats/h26x.hh"
#include "clock.hh"
#include "util.hh"
#include "frame.hh"
#include "queue.hh"
#include "socket.hh"
#include <deque>
namespace uvgrtp {
class rtp;
namespace formats {
enum H264_NAL_TYPES {

View File

@ -1,8 +1,10 @@
#pragma once
#include "formats/h26x.hh"
#include "clock.hh"
#include "util.hh"
#include "frame.hh"
#include "queue.hh"
#include "socket.hh"
#include <deque>
#include <map>

View File

@ -1,12 +1,19 @@
#pragma once
#include "formats/h26x.hh"
#include "frame.hh"
#include "queue.hh"
#include "util.hh"
#include "socket.hh"
#include "clock.hh"
#include "frame.hh"
#include <deque>
namespace uvgrtp {
class rtp;
namespace formats {
enum H266_NAL_TYPES {

View File

@ -1,11 +1,15 @@
#pragma once
#include "frame.hh"
#include "media.hh"
#include "queue.hh"
#include "util.hh"
namespace uvgrtp {
// forward definitions
class socket;
class rtp;
namespace formats {
class h26x : public media {

View File

@ -1,8 +1,5 @@
#pragma once
#include "../rtp.hh"
#include "../socket.hh"
#include "../queue.hh"
#include "../util.hh"
#include <map>
@ -12,6 +9,14 @@
namespace uvgrtp {
class socket;
class rtp;
class frame_queue;
namespace frame {
struct rtp_frame;
};
namespace formats {
typedef struct media_info {

View File

@ -1,13 +1,14 @@
#pragma once
#include "runner.hh"
#include "socket.hh"
#include "util.hh"
#include <atomic>
namespace uvgrtp {
class socket;
class holepuncher : public runner {
public:
holepuncher(uvgrtp::socket *socket);

View File

@ -1,7 +1,51 @@
#pragma once
// these includes are here for easier usage of this library
// At this point I don't know which ones are required so I'll include them all
#include "formats/h26x.hh"
#include "formats/h264.hh"
#include "formats/h265.hh"
#include "formats/h266.hh"
#include "formats/media.hh"
#include "srtp/base.hh"
#include "srtp/srtcp.hh"
#include "srtp/srtp.hh"
#include "zrtp/commit.hh"
#include "zrtp/confack.hh"
#include "zrtp/confirm.hh"
#include "zrtp/defines.hh"
#include "zrtp/dh_kxchng.hh"
#include "zrtp/error.hh"
#include "zrtp/hello.hh"
#include "zrtp/hello_ack.hh"
#include "zrtp/zrtp_receiver.hh"
#include "clock.hh"
#include "crypto.hh"
#include "debug.hh"
#include "dispatch.hh"
#include "frame.hh"
#include "holepuncher.hh"
#include "hostname.hh"
#include "media_stream.hh"
#include "mingw_inet.hh"
#include "multicast.hh"
#include "pkt_dispatch.hh"
#include "poll.hh"
#include "queue.hh"
#include "random.hh"
#include "rtcp.hh"
#include "rtp.hh"
#include "runner.hh"
#include "session.hh"
#include "socket.hh"
#include "util.hh"
#include "zrtp.hh"
#include <map>
#include <string>
namespace uvgrtp {

View File

@ -1,22 +1,32 @@
#pragma once
#include "holepuncher.hh"
#include "pkt_dispatch.hh"
#include "rtcp.hh"
#include "socket.hh"
#include "srtp/srtcp.hh"
#include "srtp/srtp.hh"
#include "util.hh"
#include "formats/media.hh"
#include <unordered_map>
#include <memory>
#include <string>
namespace uvgrtp {
// forward declarations
class rtp;
class zrtp;
class rtcp;
class srtp;
class srtcp;
class pkt_dispatcher;
class holepuncher;
class socket;
namespace frame {
struct rtp_frame;
};
namespace formats {
class media;
};
class media_stream {
public:
/// \cond DO_NOT_DOCUMENT

View File

@ -1,11 +1,14 @@
#pragma once
#include "util.hh"
#include "frame.hh"
namespace uvgrtp {
class connection;
namespace frame {
struct rtp_frame;
};
const int MULTICAST_MAX_PEERS = 64;
class multicast {

View File

@ -1,8 +1,7 @@
#pragma once
#include "frame.hh"
#include "runner.hh"
#include "socket.hh"
#include "util.hh"
#include <mutex>
@ -10,6 +9,12 @@
namespace uvgrtp {
namespace frame {
struct rtp_frame;
};
class socket;
typedef rtp_error_t (*packet_handler)(ssize_t, void *, int, uvgrtp::frame::rtp_frame **);
typedef rtp_error_t (*packet_handler_aux)(void *, int, uvgrtp::frame::rtp_frame **);
typedef rtp_error_t (*frame_getter)(void *, uvgrtp::frame::rtp_frame **);

View File

@ -1,10 +1,12 @@
#pragma once
#include "socket.hh"
#include "util.hh"
#include <vector>
namespace uvgrtp {
class socket;
namespace poll {
/* Cross-platform poll implementation for listening to a socket for a period of time
*

View File

@ -1,16 +1,15 @@
#pragma once
#include "dispatch.hh"
#include "frame.hh"
#include "rtp.hh"
#include "socket.hh"
#include "srtp/base.hh"
#include "util.hh"
#include <atomic>
#include <memory>
#include <unordered_map>
#include <vector>
#include <mutex>
#if defined(_MSC_VER)
typedef SSIZE_T ssize_t;
@ -24,6 +23,8 @@ namespace uvgrtp {
class dispatcher;
class frame_queue;
class rtp;
typedef struct active_range {
size_t h_start; size_t h_end;

View File

@ -1,11 +1,11 @@
#pragma once
#include "clock.hh"
#include "util.hh"
#include "socket.hh"
#include "frame.hh"
#include "runner.hh"
#include "socket.hh"
#include "srtp/srtcp.hh"
#include "util.hh"
#include <bitset>
#include <map>
@ -14,6 +14,9 @@
namespace uvgrtp {
class rtp;
class srtcp;
/// \cond DO_NOT_DOCUMENT
enum RTCP_ROLE {
RECEIVER,

View File

@ -1,11 +1,15 @@
#pragma once
#include "clock.hh"
#include "frame.hh"
#include "util.hh"
namespace uvgrtp {
namespace frame
{
struct rtp_frame;
};
class rtp {
public:
rtp(rtp_format_t fmt);

View File

@ -1,14 +1,17 @@
#pragma once
#include "media_stream.hh"
#include "zrtp.hh"
#include "util.hh"
#include <mutex>
#include <string>
#include <vector>
#include <unordered_map>
namespace uvgrtp {
class media_stream;
class zrtp;
class session {
public:
/// \cond DO_NOT_DOCUMENT

View File

@ -1,10 +1,6 @@
#pragma once
#include "../debug.hh"
#include "../frame.hh"
#include "../rtp.hh"
#include "../util.hh"
#include "../zrtp.hh"
#ifdef _WIN32
#include <winsock2.h>
@ -37,6 +33,9 @@ enum {
namespace uvgrtp {
class zrtp;
class rtp;
/* Vector of buffers that contain a full RTP frame */
typedef std::vector<std::pair<size_t, uint8_t *>> buf_vec;

View File

@ -4,6 +4,10 @@
namespace uvgrtp {
namespace frame {
struct rtp_frame;
};
class srtp : public base_srtp {
public:
srtp();

View File

@ -1,11 +1,8 @@
#pragma once
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#ifdef _WIN32
#include <winsock2.h>
#include <mswsock.h>
@ -22,6 +19,27 @@
namespace uvgrtp {
namespace frame {
struct rtp_frame;
};
namespace crypto
{
namespace hmac {
class sha256;
};
class sha256;
class dh;
};
namespace zrtp_msg {
struct zrtp_hello_ack;
struct zrtp_commit;
struct zrtp_hello;
struct zrtp_dh;
};
enum ZRTP_ROLE {
INITIATOR,
RESPONDER

View File

@ -1,19 +1,25 @@
#pragma once
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "frame.hh"
#include "socket.hh"
#include "zrtp/defines.hh"
#include "util.hh"
namespace uvgrtp {
namespace frame {
struct zrtp_frame;
}
class socket;
typedef struct zrtp_session zrtp_session_t;
namespace zrtp_msg {
class receiver;
/* DH Commit Message */
PACK(struct zrtp_commit {
zrtp_msg msg_start;

View File

@ -2,15 +2,17 @@
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
namespace frame {
struct zrtp_frame;
};
typedef struct zrtp_session zrtp_session_t;
namespace zrtp_msg {
PACK(struct zrtp_confack {

View File

@ -1,19 +1,24 @@
#pragma once
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "zrtp/defines.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
typedef struct zrtp_session zrtp_session_t;
class socket;
namespace frame {
struct zrtp_frame;
};
namespace zrtp_msg {
class receiver;
PACK(struct zrtp_confirm {
zrtp_msg msg_start;

View File

@ -1,20 +1,23 @@
#pragma once
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
typedef struct zrtp_session zrtp_session_t;
class socket;
namespace frame {
struct zrtp_frame;
};
namespace zrtp_msg {
class receiver;
PACK(struct zrtp_dh {
zrtp_msg msg_start;
uint32_t hash[8];

View File

@ -1,16 +1,20 @@
#pragma once
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
class socket;
namespace frame {
struct zrtp_frame;
};
namespace zrtp_msg {
class receiver;
PACK(struct zrtp_error {
zrtp_msg msg_start;

View File

@ -1,10 +1,7 @@
#pragma once
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
@ -12,7 +9,15 @@ namespace uvgrtp {
typedef struct capabilities zrtp_capab_t;
typedef struct zrtp_session zrtp_session_t;
class socket;
namespace frame {
struct zrtp_frame;
};
namespace zrtp_msg {
class receiver;
PACK(struct zrtp_hello {
zrtp_msg msg_start;

View File

@ -1,16 +1,21 @@
#pragma once
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "frame.hh"
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
class socket;
namespace frame {
struct zrtp_frame;
};
namespace zrtp_msg {
class receiver;
PACK(struct zrtp_hello_ack {
zrtp_msg msg_start;
uint32_t crc;

View File

@ -1,8 +1,11 @@
#pragma once
#include "socket.hh"
#include "util.hh"
namespace uvgrtp {
class socket;
namespace zrtp_msg {
class receiver {

View File

@ -1,5 +1,6 @@
#include "dispatch.hh"
#include "queue.hh"
#include "socket.hh"
#include "debug.hh"

View File

@ -1,6 +1,7 @@
#include "formats/h264.hh"
#include "queue.hh"
#include "rtp.hh"
#include "debug.hh"
#include <cstdint>

View File

@ -1,7 +1,9 @@
#include "formats/h265.hh"
#include "debug.hh"
#include "srtp/srtcp.hh"
#include "rtp.hh"
#include "queue.hh"
#include "debug.hh"
#include <cstdint>
#include <cstring>

View File

@ -1,7 +1,8 @@
#include "formats/h265.hh"
#include "debug.hh"
#include "rtp.hh"
#include "queue.hh"
#include "debug.hh"
#include <cstdint>
#include <cstring>

View File

@ -1,6 +1,8 @@
#include "formats/h266.hh"
#include "rtp.hh"
#include "queue.hh"
#include "frame.hh"
#include "debug.hh"
#include <cstdint>

View File

@ -1,7 +1,8 @@
#include "formats/h266.hh"
#include "debug.hh"
#include "rtp.hh"
#include "queue.hh"
#include "debug.hh"
#include <cstdint>
#include <cstring>

View File

@ -1,8 +1,11 @@
#include "formats/h26x.hh"
#include "rtp.hh"
#include "queue.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstdint>
#include <cstring>
#include <iostream>

View File

@ -1,9 +1,14 @@
#include "formats/media.hh"
#include "../rtp.hh"
#include "../socket.hh"
#include "../queue.hh"
#include "debug.hh"
#include <map>
#include <unordered_map>
#include "debug.hh"
#define INVALID_SEQ 0xffffffff

View File

@ -1,6 +1,7 @@
#include "holepuncher.hh"
#include "clock.hh"
#include "socket.hh"
#include "debug.hh"

View File

@ -3,6 +3,7 @@
#include "debug.hh"
#include "hostname.hh"
#include "random.hh"
#include "session.hh"
#include <cstdlib>
#include <cstring>

View File

@ -5,6 +5,16 @@
#include "formats/h266.hh"
#include "debug.hh"
#include "random.hh"
#include "rtp.hh"
#include "zrtp.hh"
#include "holepuncher.hh"
#include "pkt_dispatch.hh"
#include "rtcp.hh"
#include "socket.hh"
#include "srtp/srtcp.hh"
#include "srtp/srtp.hh"
#include "formats/media.hh"
#include <cstring>
#include <errno.h>

View File

@ -1,5 +1,7 @@
#include "multicast.hh"
#include "frame.hh"
uvgrtp::multicast::multicast()
{
}

View File

@ -1,5 +1,7 @@
#include "pkt_dispatch.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include "random.hh"
#include "util.hh"

View File

@ -1,6 +1,7 @@
#include "poll.hh"
#include "multicast.hh"
#include "socket.hh"
#include "debug.hh"
#ifdef _WIN32

View File

@ -4,6 +4,8 @@
#include "formats/h265.hh"
#include "formats/h266.hh"
#include "rtp.hh"
#include "srtp/base.hh"
#include "debug.hh"
#include "random.hh"

View File

@ -4,6 +4,7 @@
#include "poll.hh"
#include "debug.hh"
#include "util.hh"
#include "rtp.hh"
#ifndef _WIN32
#include <sys/time.h>

View File

@ -1,5 +1,8 @@
#include "rtcp.hh"
#include "srtp/srtcp.hh"
#include "debug.hh"
uvgrtp::frame::rtcp_app_packet *uvgrtp::rtcp::get_app_packet(uint32_t ssrc)
{
if (participants_.find(ssrc) == participants_.end())

View File

@ -1,5 +1,7 @@
#include "rtcp.hh"
#include "debug.hh"
rtp_error_t uvgrtp::rtcp::handle_bye_packet(uint8_t *packet, size_t size)
{
if (!packet || !size)

View File

@ -1,5 +1,8 @@
#include "rtcp.hh"
#include "srtp/srtcp.hh"
#include "debug.hh"
uvgrtp::frame::rtcp_receiver_report *uvgrtp::rtcp::get_receiver_packet(uint32_t ssrc)
{
if (participants_.find(ssrc) == participants_.end())

View File

@ -1,6 +1,8 @@
#include "rtcp.hh"
#include "poll.hh"
#include "debug.hh"
std::vector<uvgrtp::socket>& uvgrtp::rtcp::get_sockets()
{
return sockets_;

View File

@ -1,5 +1,8 @@
#include "rtcp.hh"
#include "srtp/srtcp.hh"
#include "debug.hh"
uvgrtp::frame::rtcp_sdes_packet *uvgrtp::rtcp::get_sdes_packet(uint32_t ssrc)
{
if (participants_.find(ssrc) == participants_.end())

View File

@ -1,5 +1,8 @@
#include "rtcp.hh"
#include "srtp/srtcp.hh"
#include "debug.hh"
uvgrtp::frame::rtcp_sender_report *uvgrtp::rtcp::get_sender_packet(uint32_t ssrc)
{
if (participants_.find(ssrc) == participants_.end())

View File

@ -1,6 +1,6 @@
#include "rtp.hh"
#include "clock.hh"
#include "frame.hh"
#include "debug.hh"
#include "random.hh"

View File

@ -1,4 +1,8 @@
#include "session.hh"
#include "media_stream.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "debug.hh"

View File

@ -1,6 +1,8 @@
#include "srtp/base.hh"
#include "crypto.hh"
#include "zrtp.hh"
#include "debug.hh"
#include <cstring>
#include <iostream>

View File

@ -1,6 +1,7 @@
#include "srtp/srtcp.hh"
#include "crypto.hh"
#include "debug.hh"
#include <cstring>
#include <iostream>

View File

@ -1,6 +1,9 @@
#include "srtp/srtp.hh"
#include "srtp/base.hh"
#include "crypto.hh"
#include "debug.hh"
#include "frame.hh"
#include <cstring>
#include <iostream>

View File

@ -6,7 +6,7 @@
#include "zrtp/dh_kxchng.hh"
#include "zrtp/hello.hh"
#include "zrtp/hello_ack.hh"
#include "zrtp/zrtp_receiver.hh"
#include "socket.hh"
#include "debug.hh"
#include "crypto.hh"

View File

@ -1,7 +1,10 @@
#include "zrtp/commit.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "debug.hh"
#include "frame.hh"
#include "socket.hh"
#include <cassert>
#include <cstring>

View File

@ -1,5 +1,9 @@
#include "zrtp/confack.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstring>

View File

@ -1,5 +1,9 @@
#include "zrtp/confirm.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstring>

View File

@ -1,7 +1,11 @@
#include "zrtp/dh_kxchng.hh"
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "zrtp/defines.hh"
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstring>

View File

@ -1,7 +1,11 @@
#include "zrtp/error.hh"
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "socket.hh"
#include "frame.hh"
#include "debug.hh"

View File

@ -1,9 +1,15 @@
#include "zrtp/hello.hh"
#include "zrtp/defines.hh"
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstring>
#define ZRTP_VERSION "1.10"

View File

@ -1,7 +1,11 @@
#include "zrtp/hello_ack.hh"
#include "zrtp/zrtp_receiver.hh"
#include "zrtp.hh"
#include "zrtp/defines.hh"
#include "crypto.hh"
#include "frame.hh"
#include "socket.hh"
#include "debug.hh"
#include <cstring>

View File

@ -8,6 +8,7 @@
#include "zrtp/hello.hh"
#include "zrtp/hello_ack.hh"
#include "socket.hh"
#include "crypto.hh"
#include "poll.hh"
#include "debug.hh"