Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A bunch of refactoring before changes in the API #110

Merged
merged 3 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions common/socketoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ extern const set<string> false_names = { "0", "no", "off", "false" };

extern const std::map<std::string, int> enummap_transtype = {
{ "live", SRTT_LIVE },
{ "vod", SRTT_VOD },
{ "file", SRTT_VOD }
{ "file", SRTT_FILE }
};

SocketOption::Mode SrtConfigurePre(SRTSOCKET socket, string host, map<string, string> options, vector<string>* failures)
Expand Down
12 changes: 12 additions & 0 deletions common/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ struct ref_t: public std::reference_wrapper<T>
{
this->get() = i;
}

T operator->() const
{ return this->get(); }
};

// This alias was created so that 'Ref' (not 'ref') is used everywhere.
Expand Down Expand Up @@ -370,6 +373,9 @@ class ref_t

Type& get() const
{ return *m_data; }

Type operator->() const
{ return *m_data; }
};

template <class Type>
Expand Down Expand Up @@ -609,4 +615,10 @@ inline size_t safe_advance(It& it, size_t num, It end)
template <class V, size_t N> inline
ATR_CONSTEXPR size_t Size(const V (&)[N]) ATR_NOEXCEPT { return N; }

template <size_t DEPRLEN, typename ValueType>
inline ValueType avg_iir(ValueType old_value, ValueType new_value)
{
return (old_value*(DEPRLEN-1) + new_value)/DEPRLEN;
}

#endif
6 changes: 3 additions & 3 deletions haicrypt/hc_openssl_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ static int hcOpenSSL_AES_SetKey(hcrypt_CipherData *cipher_data, hcrypt_Ctx *ctx,
}

static int hcOpenSSL_AES_Encrypt(
hcrypt_CipherData *cipher_data,
hcrypt_CipherData *cipher_data,
hcrypt_Ctx *ctx,
hcrypt_DataDesc *in_data, int nbin,
hcrypt_DataDesc *in_data, int nbin ATR_UNUSED,
void *out_p[], size_t out_len_p[], int *nbout_p)
{
hcOpenSSL_AES_data *aes_data = (hcOpenSSL_AES_data *)cipher_data;
Expand Down Expand Up @@ -356,7 +356,7 @@ static int hcOpenSSL_AES_Encrypt(


static int hcOpenSSL_AES_Decrypt(hcrypt_CipherData *cipher_data, hcrypt_Ctx *ctx,
hcrypt_DataDesc *in_data, int nbin, void *out_p[], size_t out_len_p[], int *nbout_p)
hcrypt_DataDesc *in_data, int nbin ATR_UNUSED, void *out_p[], size_t out_len_p[], int *nbout_p)
{
hcOpenSSL_AES_data *aes_data = (hcOpenSSL_AES_data *)cipher_data;
unsigned char *out_txt;
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/hc_openssl_evp_ctr.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static int hcOpenSSL_EVP_CTR_SetKey(hcrypt_CipherData *cipher_data, hcrypt_Ctx *
}

static int hcOpenSSL_EVP_CTR_Crypt(hcrypt_CipherData *cipher_data, hcrypt_Ctx *ctx,
hcrypt_DataDesc *in_data, int nbin, void *out_p[], size_t out_len_p[], int *nbout_p)
hcrypt_DataDesc *in_data, int nbin ATR_UNUSED, void *out_p[], size_t out_len_p[], int *nbout_p)
{
hcOpenSSL_EVP_CTR_data *evp_data = (hcOpenSSL_EVP_CTR_data *)cipher_data;
unsigned char iv[HCRYPT_EVP_CTR_BLK_SZ];
Expand Down
6 changes: 6 additions & 0 deletions haicrypt/hcrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ written by
#include <sys/time.h>
#endif

#ifdef __GNUC__
#define ATR_UNUSED __attribute__((unused))
#else
#define ATR_UNUSED
#endif

#include "haicrypt.h"
#include "hcrypt_msg.h"
#include "hcrypt_ctx.h"
Expand Down
2 changes: 1 addition & 1 deletion haicrypt/hcrypt_ctx_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ int hcryptCtx_Tx_ManageKM(hcrypt_Session *crypto)
}

int hcryptCtx_Tx_InjectKM(hcrypt_Session *crypto,
void *out_p[], size_t out_len_p[], int maxout)
void *out_p[], size_t out_len_p[], int maxout ATR_UNUSED)
{
int i, nbout = 0;

Expand Down
26 changes: 0 additions & 26 deletions srtcore/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,6 @@ int CUDT::recv(SRTSOCKET u, char* buf, int len, int)
}
}

#ifdef SRT_ENABLE_SRCTIMESTAMP
int CUDT::sendmsg(
SRTSOCKET u, const char* buf, int len, int ttl, bool inorder,
uint64_t srctime)
Expand All @@ -2170,15 +2169,6 @@ int CUDT::sendmsg(
{
CUDT* udt = s_UDTUnited.lookup(u);
return udt->sendmsg(buf, len, ttl, inorder, srctime);
#else
int CUDT::sendmsg(
SRTSOCKET u, const char* buf, int len, int ttl, bool inorder)
{
try
{
CUDT* udt = s_UDTUnited.lookup(u);
return udt->sendmsg(buf, len, ttl, inorder);
#endif
}
catch (CUDTException e)
{
Expand Down Expand Up @@ -2222,7 +2212,6 @@ int CUDT::recvmsg(SRTSOCKET u, char* buf, int len)
}
}

#ifdef SRT_ENABLE_SRCTIMESTAMP
int CUDT::recvmsg(SRTSOCKET u, char* buf, int len, uint64_t& srctime)
{
try
Expand All @@ -2244,7 +2233,6 @@ int CUDT::recvmsg(SRTSOCKET u, char* buf, int len, uint64_t& srctime)
return ERROR;
}
}
#endif

int64_t CUDT::sendfile(
SRTSOCKET u, fstream& ifs, int64_t& offset, int64_t size, int block)
Expand Down Expand Up @@ -2766,7 +2754,6 @@ int recv(SRTSOCKET u, char* buf, int len, int flags)
return CUDT::recv(u, buf, len, flags);
}

#ifdef SRT_ENABLE_SRCTIMESTAMP

int sendmsg(
SRTSOCKET u, const char* buf, int len, int ttl, bool inorder,
Expand All @@ -2781,19 +2768,6 @@ int recvmsg(SRTSOCKET u, char* buf, int len, uint64_t& srctime)
return CUDT::recvmsg(u, buf, len, srctime);
}

#else
int sendmsg(
SRTSOCKET u,
const char* buf,
int len,
int ttl,
bool inorder,
uint64_t /*ignored*/)
{
return CUDT::sendmsg(u, buf, len, ttl, inorder);
}

#endif

int recvmsg(SRTSOCKET u, char* buf, int len)
{
Expand Down
Loading